source: trunk/Add.pas

Last change on this file was 6, checked in by george, 16 years ago
  • Přesunuto: Hlavní vývojová větev přesunuta do podsložky trunk.
File size: 4.1 KB
Line 
1unit Add;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, StdCtrls, ExtCtrls, ExtDlgs, Buttons;
8
9type
10 TForm4 = class(TForm)
11 Label1: TLabel;
12 Edit1: TEdit;
13 Label2: TLabel;
14 Edit2: TEdit;
15 Label3: TLabel;
16 Edit3: TEdit;
17 Button1: TButton;
18 Image1: TImage;
19 Memo1: TMemo;
20 Label4: TLabel;
21 Button2: TButton;
22 OpenPictureDialog1: TOpenPictureDialog;
23 OpenDialog1: TOpenDialog;
24 Button3: TButton;
25 Button4: TButton;
26 Label5: TLabel;
27 SpeedButton1: TSpeedButton;
28 SpeedButton2: TSpeedButton;
29 Label6: TLabel;
30 Edit4: TEdit;
31 procedure Button1Click(Sender: TObject);
32 procedure Button3Click(Sender: TObject);
33 procedure Button4Click(Sender: TObject);
34 procedure Button2Click(Sender: TObject);
35 procedure SpeedButton1Click(Sender: TObject);
36 procedure SpeedButton2Click(Sender: TObject);
37 procedure FormClose(Sender: TObject; var Action: TCloseAction);
38 procedure Edit1KeyPress(Sender: TObject; var Key: Char);
39 procedure FormKeyDown(Sender: TObject; var Key: Word;
40 Shift: TShiftState);
41 private
42 { Private declarations }
43 public
44 { Public declarations }
45 procedure Save;
46 end;
47
48var
49 Form4: TForm4;
50 ImageFile: string;
51 ServerIndex: integer; // TODO
52
53implementation
54
55uses Main;
56
57{$R *.dfm}
58
59procedure TForm4.Button1Click(Sender: TObject);
60begin
61 OpenDialog1.Filter:= 'Spustitelné soubory|*.exe|Všechny soubory|*.*';
62 OpenDialog1.FileName:= ExtractFileDir(Edit3.Text);
63 if OpenDialog1.Execute then begin
64 Edit3.Text:= OpenDialog1.FileName;
65 end;
66end;
67
68procedure TForm4.Save;
69begin
70 if ServerIndex <> -1 then begin
71 Form1.Servers[ServerIndex].Name := Edit1.Text;
72 Form1.Servers[ServerIndex].Address := Edit2.Text;
73 Form1.Servers[ServerIndex].ExeFile := Edit3.Text;
74 Form1.Servers[ServerIndex].Description := Memo1.Lines.Text;
75 Form1.Servers[ServerIndex].Image := ImageFile;
76 Form1.Servers[ServerIndex].OnlinePlayersAddress := Edit4.Text;
77 Form1.StatusBar1.SimpleText := 'Server byl upraven';
78 end else begin
79 SetLength(Form1.Servers, Length(Form1.Servers)+1);
80 Form1.Servers[Length(Form1.Servers)-1].Name := Edit1.Text;
81 Form1.Servers[Length(Form1.Servers)-1].Address := Edit2.Text;
82 Form1.Servers[Length(Form1.Servers)-1].ExeFile := Edit3.Text;
83 Form1.Servers[Length(Form1.Servers)-1].Description := Memo1.Lines.Text;
84 Form1.Servers[Length(Form1.Servers)-1].Image := ImageFile;
85 Form1.Servers[Length(Form1.Servers)-1].OnlinePlayersAddress := Edit4.Text;
86 Form1.StatusBar1.SimpleText := 'Server byl uložen';
87 end;
88 Form1.WriteImages;
89 Form1.WriteServers;
90 Close;
91end;
92
93procedure TForm4.Button3Click(Sender: TObject);
94begin
95 Save;
96 Form1.SaveRegServers;
97end;
98
99procedure TForm4.Button4Click(Sender: TObject);
100begin
101 close;
102end;
103
104procedure TForm4.Button2Click(Sender: TObject);
105begin
106 if OpenPictureDialog1.Execute then begin
107 Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
108 ImageFile := OpenPictureDialog1.FileName;
109 end;
110end;
111
112procedure TForm4.SpeedButton1Click(Sender: TObject);
113var
114 BitMap: TBitmap;
115begin
116 ImageFile := '';
117 BitMap := TBitmap.Create;
118 Form1.ImageList32default.GetBitmap(0,BitMap);
119 Form4.Image1.Picture.Graphic := BitMap;
120end;
121
122procedure TForm4.SpeedButton2Click(Sender: TObject);
123var
124 BitMap: TBitmap;
125begin
126 ImageFile := '1';
127 BitMap := TBitmap.Create;
128 Form1.ImageList32default.GetBitmap(1,BitMap);
129 Form4.Image1.Picture.Graphic := BitMap;
130end;
131
132procedure TForm4.FormClose(Sender: TObject; var Action: TCloseAction);
133begin
134 Edit1.Text := '';
135 Edit2.Text := '';
136 Edit3.Text := '';
137 Edit4.Text := '';
138 Memo1.Clear;
139 ImageFile := '';
140 ServerIndex := -1;
141end;
142
143procedure TForm4.Edit1KeyPress(Sender: TObject; var Key: Char);
144begin
145 if Key = #13 then begin
146 Key:= #0;
147 Button3Click(nil);
148 end;
149end;
150
151procedure TForm4.FormKeyDown(Sender: TObject; var Key: Word;
152 Shift: TShiftState);
153begin
154 // Form1.Show;
155end;
156
157end.
Note: See TracBrowser for help on using the repository browser.