unit U_ShieldConfig;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, RzButton, RzRadChk, siComp, siLngLnk, RzPanel, ExtCtrls, RzRadGrp,
  RzDBRGrp, StdCtrls, RzLabel;

type
  TF_ShieldConfig = class(TForm)
    cbZero: TRzCheckBox;
    cbGRound: TRzCheckBox;
    cbNoGround: TRzCheckBox;
    RzBitBtn1: TRzBitBtn;
    RzBitBtn2: TRzBitBtn;
    siLangLinked1: TsiLangLinked;
    RzDBRadioGroup1: TRzDBRadioGroup;
    RzRadioButton1: TRzRadioButton;
    RzRadioButton2: TRzRadioButton;
    pnLines: TRzGroupBox;
    RzButton1: TRzButton;
    RzButton2: TRzButton;
    cbNotice: TRzCheckBox;
    RzLabel1: TRzLabel;
    RzLabel2: TRzLabel;
    ListBox1: TListBox;
    ListBox2: TListBox;
    procedure RzRadioButton2Click(Sender: TObject);
    procedure RzRadioButton1Click(Sender: TObject);
    procedure cbNoGroundClick(Sender: TObject);
    procedure cbGRoundClick(Sender: TObject);
    procedure RzButton1Click(Sender: TObject);
    procedure RzButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    Procedure InitForm;
  end;

var
  F_ShieldConfig: TF_ShieldConfig;

implementation
uses USCS_Main, U_LNG;
{$R *.dfm}

Procedure TF_ShieldConfig.InitForm;
begin
  ListBox1.Clear;
  ListBox2.Clear;
  pnLines.Enabled := False;
  RzRadioButton1.Checked := true;
  RzRadioButton2.Checked := false;
  cbZero.Checked := false;
  cbGround.Checked := false;
  cbNoGround.Checked := false;
  cbNotice.Checked := false;
end;

procedure TF_ShieldConfig.cbGRoundClick(Sender: TObject);
begin
  if cbGround.Checked then
    cbNoGround.Enabled := False
  else
    cbNoGround.Enabled := True;
end;

procedure TF_ShieldConfig.cbNoGroundClick(Sender: TObject);
begin
  if cbNoGround.Checked then
    cbGround.Enabled := False
  else
    cbGround.Enabled := True;
end;

procedure TF_ShieldConfig.RzButton1Click(Sender: TObject);
var i: integer;
    s: string;
begin
  if ListBox1.Items.Count > 1 then
  begin
    for i := 0 to ListBox1.Items.Count - 1 do
    begin
      if ListBox1.Selected[i] then
      begin
        s := ListBox1.Items.Strings[i];
        ListBox1.Items.Delete(i);
        ListBox2.AddItem(s, nil);
        Listbox1.Selected[0] := true;
        break;
      end;
    end;
  end;
end;

procedure TF_ShieldConfig.RzButton2Click(Sender: TObject);
var i: integer;
    s: string;
begin
  if ListBox2.Items.Count > 0 then
  begin
    for i := 0 to ListBox2.Items.Count - 1 do
    begin
      if ListBox2.Selected[i] then
      begin
        s := ListBox2.Items.Strings[i];
        ListBox2.Items.Delete(i);
        ListBox1.AddItem(s, nil);
        if ListBox2.Items.Count > 0 then
          Listbox2.Selected[0] := true;
        break;
      end;
    end;
  end;
end;

procedure TF_ShieldConfig.RzRadioButton1Click(Sender: TObject);
begin
  pnLines.Enabled := False;
  if F_ShieldConfig.ListBox1.Items.Count > 0 then
    F_ShieldConfig.ListBox1.ClearSelection;
  if F_ShieldConfig.ListBox2.Items.Count > 0 then
    F_ShieldConfig.ListBox2.ClearSelection;
end;

procedure TF_ShieldConfig.RzRadioButton2Click(Sender: TObject);
begin
  pnLines.Enabled := True;
  if F_ShieldConfig.ListBox1.Items.Count > 0 then
    F_ShieldConfig.ListBox1.Selected[0] := true;
  {if F_ShieldConfig.ListBox2.Items.Count > 0 then
    F_ShieldConfig.ListBox2.Selected[0] := true;}
end;

end.
