summaryrefslogtreecommitdiff
path: root/plugins/Chess4Net/MI/TransmitGameSelectionUnit.pas
blob: a70eb65ef5b41da0815489cddcaf5dc930b1aea7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
////////////////////////////////////////////////////////////////////////////////
// All code below is exclusively owned by author of Chess4Net - Pavel Perminov
// (packpaul@mail.ru, packpaul1@gmail.com).
// Any changes, modifications, borrowing and adaptation are a subject for
// explicit permition from the owner.

unit TransmitGameSelectionUnit;

interface

uses
  Forms, Controls, StdCtrls, TntStdCtrls, Classes,
  //
  ModalForm;

type
  TTransmitGameSelectionForm = class(TModalForm)
    OkButton: TTntButton;
    CancelButton: TTntButton;
    TransmitGameListBox: TTntListBox;
    procedure FormCreate(Sender: TObject);
  private
    procedure FLocalize;
  protected
    function GetModalID: TModalFormID; override;
  public
    procedure SetGames(Games: TStrings);
    function GetSelected: TObject;
  end;

implementation

{$R *.dfm}

uses
  LocalizerUnit;

////////////////////////////////////////////////////////////////////////////////
// TTransmitGameSelectionForm

procedure TTransmitGameSelectionForm.FormCreate(Sender: TObject);
begin
  FLocalize;
end;


procedure TTransmitGameSelectionForm.FLocalize;
begin
  with TLocalizer.Instance do
  begin
    Caption := GetLabel(67);
    OkButton.Caption := GetLabel(11);
    CancelButton.Caption := GetLabel(12);
  end;
end;


function TTransmitGameSelectionForm.GetModalID: TModalFormID;
begin
  Result := mfTransmitGame;
end;


procedure TTransmitGameSelectionForm.SetGames(Games: TStrings);
begin
  TransmitGameListBox.Items.Assign(Games);
  if (TransmitGameListBox.Count > 0) then
    TransmitGameListBox.ItemIndex := 0;
end;


function TTransmitGameSelectionForm.GetSelected: TObject;
var
  iIndex: integer;
begin
  iIndex := TransmitGameListBox.ItemIndex;
  if (iIndex >= 0) then
    Result := TransmitGameListBox.Items.Objects[iIndex]
  else
    Result := nil;
end;

end.