source: trunk/UOptionsWindow.pas

Last change on this file was 12, checked in by george, 16 years ago

Aktualizace: Vyměněna jednotka UWaitingDialog za novější UJobProgressView.
Opraveno: Chyba při vytváření souboru Error.txt.

  • Property svn:executable set to *
File size: 33.0 KB
Line 
1unit UOptionsWindow;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, StdCtrls, ComCtrls, ExtCtrls, cUtils, cWinSock, Menus, Spin,
8 cWindows, ShellAPI, Buttons, ExtDlgs, ImgList, GIFImage, UTextFileStream,
9 ActnList, XPStyleActnCtrls, ActnMan, UMainWindow;
10
11const
12 SmileysDefFile = 'Smileys\Smileys.def';
13
14type
15 TOptionsWindow = class(TForm)
16 PageControl1: TPageControl;
17 TabSheet1: TTabSheet;
18 Label1: TLabel;
19 Button1: TButton;
20 Edit1: TEdit;
21 TabSheet3: TTabSheet;
22 Label2: TLabel;
23 TrackBar1: TTrackBar;
24 CheckBox1: TCheckBox;
25 CheckBox2: TCheckBox;
26 CheckBox3: TCheckBox;
27 CheckBox4: TCheckBox;
28 CheckBox5: TCheckBox;
29 CheckBox6: TCheckBox;
30 CheckBox7: TCheckBox;
31 CheckBox8: TCheckBox;
32 Label4: TLabel;
33 Edit2: TEdit;
34 Label5: TLabel;
35 Shape1: TShape;
36 ColorDialog1: TColorDialog;
37 CheckBox9: TCheckBox;
38 CheckBox10: TCheckBox;
39 CheckBox11: TCheckBox;
40 CheckBox13: TCheckBox;
41 CheckBox14: TCheckBox;
42 CheckBox15: TCheckBox;
43 TabSheet4: TTabSheet;
44 Label7: TLabel;
45 ListBox1: TListBox;
46 GroupBox1: TGroupBox;
47 CheckBox16: TCheckBox;
48 CheckBox17: TCheckBox;
49 Edit3: TEdit;
50 Button2: TButton;
51 CheckBox18: TCheckBox;
52 Edit4: TEdit;
53 Button3: TButton;
54 CheckBox19: TCheckBox;
55 CheckBox20: TCheckBox;
56 CheckBox21: TCheckBox;
57 Edit5: TEdit;
58 OpenDialog1: TOpenDialog;
59 Button4: TButton;
60 CheckBox22: TCheckBox;
61 Edit6: TEdit;
62 Label8: TLabel;
63 Label10: TLabel;
64 SpinEdit3: TSpinEdit;
65 Button6: TButton;
66 SpinEdit1: TSpinEdit;
67 Label6: TLabel;
68 Label11: TLabel;
69 Button7: TButton;
70 SaveDialog1: TSaveDialog;
71 Label12: TLabel;
72 CheckBox12: TCheckBox;
73 SpinEdit4: TSpinEdit;
74 GroupBox2: TGroupBox;
75 TrackBar2: TTrackBar;
76 SpeedButton4: TSpeedButton;
77 TabSheet5: TTabSheet;
78 Label13: TLabel;
79 ListBox2: TListBox;
80 GroupBox3: TGroupBox;
81 SpeedButton5: TSpeedButton;
82 CheckBox23: TCheckBox;
83 CheckBox24: TCheckBox;
84 Edit7: TEdit;
85 Button5: TButton;
86 CheckBox25: TCheckBox;
87 Edit8: TEdit;
88 Button8: TButton;
89 CheckBox27: TCheckBox;
90 CheckBox28: TCheckBox;
91 Edit9: TEdit;
92 GroupBox4: TGroupBox;
93 SpeedButton3: TSpeedButton;
94 SpeedButton2: TSpeedButton;
95 SpeedButton1: TSpeedButton;
96 Edit10: TEdit;
97 FontDialog1: TFontDialog;
98 RichEdit1: TRichEdit;
99 Label15: TLabel;
100 Button9: TButton;
101 CheckBox26: TCheckBox;
102 ComboBox2: TComboBox;
103 CheckBox29: TCheckBox;
104 CheckBox30: TCheckBox;
105 Edit11: TEdit;
106 GroupBox5: TGroupBox;
107 Label3: TLabel;
108 ComboBox1: TComboBox;
109 SpinEdit2: TSpinEdit;
110 Label9: TLabel;
111 Label14: TLabel;
112 ComboBox3: TComboBox;
113 SpeedButton7: TSpeedButton;
114 Edit12: TEdit;
115 Button10: TButton;
116 Edit13: TEdit;
117 Label16: TLabel;
118 Label17: TLabel;
119 ComboBox4: TComboBox;
120 CheckBox31: TCheckBox;
121 Button11: TButton;
122 OpenPictureDialog1: TOpenPictureDialog;
123 CheckBox32: TCheckBox;
124 Edit14: TEdit;
125 Button12: TButton;
126 CheckBox33: TCheckBox;
127 SpeedButton8: TSpeedButton;
128 PopupMenu1: TPopupMenu;
129 Pidat1: TMenuItem;
130 Zmnitjmnoudlosti1: TMenuItem;
131 S1: TMenuItem;
132 Posunoutudlostnahoru1: TMenuItem;
133 Posunoutudlostdol1: TMenuItem;
134 Nastudlostisobrzkyzesouboru1: TMenuItem;
135 ActionManager1: TActionManager;
136 ActionAddUserEvent: TAction;
137 ActionDeleteUserEvent: TAction;
138 ActionMoveUserEventUp: TAction;
139 ActionMoveUserEventDown: TAction;
140 ActionImportUserEventList: TAction;
141 ActionEditUserEventCaption: TAction;
142 ActionInsertToMessage: TAction;
143 ActionDeleteAllUserEvents: TAction;
144 SpeedButton6: TSpeedButton;
145 Smazatvechnyudlosti1: TMenuItem;
146 Vloittextdozprvy1: TMenuItem;
147 ActionSaveUserEventsList: TAction;
148 Uloitseznamudlostdosouboru1: TMenuItem;
149 RadioGroup1: TRadioGroup;
150 Label18: TLabel;
151 Label19: TLabel;
152 procedure Button1Click(Sender: TObject);
153 procedure FormShow(Sender: TObject);
154 procedure Shape1MouseDown(Sender: TObject; Button: TMouseButton;
155 Shift: TShiftState; X, Y: Integer);
156 procedure TrackBar1Change(Sender: TObject);
157 procedure Edit1KeyPress(Sender: TObject; var Key: Char);
158 procedure Edit2KeyPress(Sender: TObject; var Key: Char);
159 procedure ListBox1Click(Sender: TObject);
160 procedure CheckBox16Click(Sender: TObject);
161 procedure CheckBox19Click(Sender: TObject);
162 procedure CheckBox20Click(Sender: TObject);
163 procedure CheckBox17Click(Sender: TObject);
164 procedure CheckBox18Click(Sender: TObject);
165 procedure CheckBox21Click(Sender: TObject);
166 procedure Button2Click(Sender: TObject);
167 procedure Button3Click(Sender: TObject);
168 procedure Edit3Change(Sender: TObject);
169 procedure Edit4Change(Sender: TObject);
170 procedure Edit5Change(Sender: TObject);
171 procedure Button4Click(Sender: TObject);
172 procedure CheckBox22Click(Sender: TObject);
173 procedure Button6Click(Sender: TObject);
174 procedure Button7Click(Sender: TObject);
175 procedure FormCreate(Sender: TObject);
176 procedure SpeedButton4Click(Sender: TObject);
177 procedure Button9Click(Sender: TObject);
178 procedure Button10Click(Sender: TObject);
179 procedure Edit12Change(Sender: TObject);
180 procedure ComboBox1Change(Sender: TObject);
181 procedure CheckBox9Click(Sender: TObject);
182 procedure Button11Click(Sender: TObject);
183 procedure ListBox2Click(Sender: TObject);
184 procedure CheckBox29Click(Sender: TObject);
185 procedure Edit10Change(Sender: TObject);
186 procedure CheckBox26Click(Sender: TObject);
187 procedure ComboBox2Change(Sender: TObject);
188 procedure CheckBox30Click(Sender: TObject);
189 procedure Edit11Change(Sender: TObject);
190 procedure CheckBox23Click(Sender: TObject);
191 procedure CheckBox27Click(Sender: TObject);
192 procedure CheckBox24Click(Sender: TObject);
193 procedure CheckBox33Click(Sender: TObject);
194 procedure Edit7Change(Sender: TObject);
195 procedure CheckBox25Click(Sender: TObject);
196 procedure Edit8Change(Sender: TObject);
197 procedure CheckBox28Click(Sender: TObject);
198 procedure Edit9Change(Sender: TObject);
199 procedure CheckBox32Click(Sender: TObject);
200 procedure Edit14Change(Sender: TObject);
201 procedure SpeedButton5Click(Sender: TObject);
202 procedure Button5Click(Sender: TObject);
203 procedure Button8Click(Sender: TObject);
204 procedure Button12Click(Sender: TObject);
205 procedure Button14Click(Sender: TObject);
206 procedure ListBox2DblClick(Sender: TObject);
207 procedure ActionAddUserEventExecute(Sender: TObject);
208 procedure ActionDeleteUserEventExecute(Sender: TObject);
209 procedure ActionMoveUserEventUpExecute(Sender: TObject);
210 procedure ActionMoveUserEventDownExecute(Sender: TObject);
211 procedure ActionImportUserEventListExecute(Sender: TObject);
212 procedure ActionEditUserEventCaptionExecute(Sender: TObject);
213 procedure ActionInsertToMessageExecute(Sender: TObject);
214 procedure ActionDeleteAllUserEventsExecute(Sender: TObject);
215 procedure ActionSaveUserEventsListExecute(Sender: TObject);
216 procedure TrackBar2Change(Sender: TObject);
217 procedure FormClose(Sender: TObject; var Action: TCloseAction);
218 private
219 { Private declarations }
220 public
221 AppEvents: array of TAppEvent;
222 AppUserEvents: array of TAppUserEvent;
223 procedure LoadEventOptions;
224 procedure LoadUserEventOptions;
225 procedure ListBox2Reload;
226 procedure SaveUserEvents;
227 end;
228
229var
230 OptionsWindow: TOptionsWindow;
231
232implementation
233
234uses
235 ULocalization, DateUtils, UJobProgressView, SunriseChatNetworkCoreUnit,
236 SunriseChatCoreUnit;
237
238{$R *.dfm}
239
240// Closing dialog and saving options
241procedure TOptionsWindow.Button1Click(Sender: TObject);
242var
243 I: Integer;
244 DiffrentAppUserEvents: Boolean;
245begin
246 with MainWindow, SunriseChatNetworkCore1, OptionsWindow do begin
247 if LocalUser.Nick <> Edit1.Text then LocalUser.Nick := Edit1.Text;
248 if NetworkInterface <> TNetworkInterface(NetworkInterfaces[ComboBox1.ItemIndex]).GUID then begin
249 SelectNetworkInterfaceByGUID(TNetworkInterface(NetworkInterfaces[ComboBox1.ItemIndex]).GUID);
250 NetworkInterface := TNetworkInterface(NetworkInterfaces[ComboBox1.ItemIndex]).GUID;
251 end;
252
253 NetworkPort:= SpinEdit2.Value;
254 if UDPPort <> NetworkPort then begin
255 UDPPort := NetworkPort;
256 ShowMessage('Změna se projeví až po restartu aplikace!');
257 //SunriseChatCore.StartNetwork;
258 end;
259 LocalUser.Color := Shape1.Brush.Color;
260 ShowMainMenu := CheckBox1.Checked;
261 MainMenu1.Items.Visible := ShowMainMenu;
262 RunOnLogon := CheckBox2.Checked;
263 ChangeRunOnLogon;
264 MinimizeToTray := CheckBox3.Checked;
265 MainWindow.InitTrayIcon;
266 StartInTray := CheckBox4.Checked;
267 OnTop := CheckBox5.Checked;
268 ToolButton5.Marked := OnTop;
269 ShowOnMessage := CheckBox6.Checked;
270 ShowMessageTime := CheckBox7.Checked;
271 TabControl1Change(Self);
272 ShowBallonHint := CheckBox8.Checked;
273 ServiceFunction := CheckBox9.Checked;
274 MinimalizeOnCloseWindow := CheckBox10.Checked;
275 ShowRightToolBar := CheckBox11.Checked;
276 AutoAwayDelay := SpinEdit1.Value;
277 OneAppInstance := CheckBox13.Checked;
278 SoundDisable := CheckBox14.Checked;
279 SnapWindow := CheckBox15.Checked;
280 MainWindow.ScreenSnap := SnapWindow;
281 ToolButton4.Marked := SoundDisable;
282 LocalUser.DetailInfo := Edit6.Text;
283 if MinimumVisibleUsersCount <> SpinEdit4.Value then begin
284 MinimumVisibleUsersCount := SpinEdit4.Value;
285 ListView1.Items.Clear;
286 MainWindow.ShowUserList;
287 end;
288 SoundVolume := 1000-TrackBar2.Position;
289 InvisibledOnStart := CheckBox31.Checked;
290 AutoChangeWindowHeight := CheckBox12.Checked;
291 AutoChangeWindowHeightDirectionDown := ComboBox4.ItemIndex = 1;
292 MinimumVisibleUsersCount := SpinEdit4.Value;
293 if MaxNumberOfRoomLines <> SpinEdit3.Value then begin
294 MaxNumberOfRoomLines := SpinEdit3.Value;
295 MaxRoomLines := MaxNumberOfRoomLines;
296 TabControl1Change(Self);
297 end;
298
299 Panel5.Visible := ShowRightToolBar;
300 //Panel2.Visible := False;
301 //Panel2.Visible := True;
302 AlphaBlendWindow := TrackBar1.Position;
303 MainWindow.AlphaBlendValue := AlphaBlendWindow;
304 AlphaBlend := AlphaBlendValue < 255;
305
306// ChangeMenuVisibility(ShowMainMenu);
307 DefaultReason:= Edit2.Text;
308 InitTrayIcon;
309
310 BroadcastType := TBroadCastType(RadioGroup1.ItemIndex);
311 BroadcastTypeI := RadioGroup1.ItemIndex;
312
313 SetLength(MainWindow.AppEvents,Length(AppEvents));
314 for I:= 0 to High(AppEvents) do
315 MainWindow.AppEvents[I]:= AppEvents[I];
316 MainWindow.SaveAppEventsToRegistry;
317
318 // Save user events
319 DiffrentAppUserEvents := False;
320 if Length(AppUserEvents) <> Length(MainWindow.AppUserEvents) then
321 DiffrentAppUserEvents := True
322 else begin
323 for I := 0 to High(AppUserEvents) do begin
324 if (MainWindow.AppUserEvents[I].ConditionTextEnable <> AppUserEvents[I].ConditionTextEnable) or
325 (MainWindow.AppUserEvents[I].ConditionText <> AppUserEvents[I].ConditionText) or
326 (MainWindow.AppUserEvents[I].ConditionUserEnable <> AppUserEvents[I].ConditionUserEnable) or
327 (MainWindow.AppUserEvents[I].ConditionUser <> AppUserEvents[I].ConditionUser) or
328 (MainWindow.AppUserEvents[I].ConditionAppEventEnable <> AppUserEvents[I].ConditionAppEventEnable) or
329 (MainWindow.AppUserEvents[I].ConditionAppEvent <> AppUserEvents[I].ConditionAppEvent) or
330 (MainWindow.AppUserEvents[I].EventName <> AppUserEvents[I].EventName) or
331 (MainWindow.AppUserEvents[I].ShowWindow <> AppUserEvents[I].ShowWindow) or
332 (MainWindow.AppUserEvents[I].ShowBalloonHint <> AppUserEvents[I].ShowBalloonHint) or
333 (MainWindow.AppUserEvents[I].PlaySound <> AppUserEvents[I].PlaySound) or
334 (MainWindow.AppUserEvents[I].ShowAlertIcon <> AppUserEvents[I].ShowAlertIcon) or
335 (MainWindow.AppUserEvents[I].IconFile <> AppUserEvents[I].IconFile) or
336 (MainWindow.AppUserEvents[I].PlayBeep <> AppUserEvents[I].PlayBeep) or
337 (MainWindow.AppUserEvents[I].SoundFile <> AppUserEvents[I].SoundFile) or
338 (MainWindow.AppUserEvents[I].ExecuteApplication <> AppUserEvents[I].ExecuteApplication) or
339 (MainWindow.AppUserEvents[I].ApplicationFile <> AppUserEvents[I].ApplicationFile) or
340 (MainWindow.AppUserEvents[I].ShowImage <> AppUserEvents[I].ShowImage) or
341 (MainWindow.AppUserEvents[I].ImageFile <> AppUserEvents[I].ImageFile) then
342 DiffrentAppUserEvents := True;
343 end;
344 end;
345 if DiffrentAppUserEvents then begin
346 SetLength(MainWindow.AppUserEvents, Length(AppUserEvents));
347 for I := 0 to High(AppUserEvents) do
348 MainWindow.AppUserEvents[I] := AppUserEvents[I];
349 SetLength(MainWindow.AppUserEventsOptions, Length(AppUserEvents));
350 MainWindow.AppUserEventsCount := Length(AppUserEvents);
351
352 JobProgressView.AddJob('Načtení z registrů', SaveUserEvents);
353 JobProgressView.AddJob('Uložení do registrů', MainWindow.SaveAppUserEventsToRegistry);
354 JobProgressView.Start;
355 ReloadImages;
356 end;
357 MainWindow.LanguageIndex := ComboBox3.ItemIndex;
358 Localization.Activate(MainWindow.LanguageIndex);
359 end;
360 MainWindow.Options.SaveToRegistry;
361 Close;
362end;
363
364procedure TOptionsWindow.FormShow(Sender: TObject);
365var
366 I: Integer;
367begin
368 with MainWindow.SunriseChatNetworkCore1 do begin
369 Shape1.Brush.Color := LocalUser.Color;
370 Edit1.Text := LocalUser.Nick;
371 Edit2.Text := MainWindow.DefaultReason;
372 Edit6.Text := LocalUser.DetailInfo;
373 CheckBox1.Checked := MainWindow.ShowMainMenu;
374 CheckBox2.Checked := MainWindow.RunOnLogon;
375 CheckBox3.Checked := MainWindow.MinimizeToTray;
376 CheckBox4.Checked := MainWindow.StartInTray;
377 CheckBox5.Checked := MainWindow.OnTop;
378 CheckBox6.Checked := MainWindow.ShowOnMessage;
379 CheckBox7.Checked := MainWindow.ShowMessageTime;
380 CheckBox8.Checked := MainWindow.ShowBallonHint;
381 CheckBox9.Checked := MainWindow.ServiceFunction;
382 CheckBox10.Checked := MainWindow.MinimalizeOnCloseWindow;
383 CheckBox11.Checked := MainWindow.ShowRightToolBar;
384 CheckBox12.Checked := MainWindow.AutoChangeWindowHeight;
385 CheckBox13.Checked := MainWindow.OneAppInstance;
386 CheckBox14.Checked := MainWindow.SoundDisable;
387 CheckBox15.Checked := MainWindow.SnapWindow;
388 CheckBox31.Checked := MainWindow.InvisibledOnStart;
389 SpinEdit1.Value := AutoAwayDelay;
390 SpinEdit3.Value := MainWindow.MaxNumberOfRoomLines;
391 SpinEdit2.Value := MainWindow.NetworkPort;
392 SpinEdit4.Value := MainWindow.MinimumVisibleUsersCount;
393 TrackBar1.Position := MainWindow.AlphaBlendWindow;
394 TrackBar2.Position := 1000 - MainWindow.SoundVolume;
395 if MainWindow.AutoChangeWindowHeightDirectionDown then
396 ComboBox4.ItemIndex := 1 else ComboBox4.ItemIndex:= 0;
397 RadioGroup1.ItemIndex := MainWindow.BroadcastTypeI;
398
399
400 // Fill network interfaces list
401 ComboBox1.Items.Clear;
402 for I := 0 to NetworkInterfaces.Count-1 do ComboBox1.Items.Add(TNetworkInterface(NetworkInterfaces[I]).Name);
403 ComboBox1.ItemIndex := NetworkInterfaces.IndexOf(ActiveNetworkInterface);
404
405 ComboBox3.Items.Clear;
406 for I := 0 to High(Localization.Languages) do ComboBox3.Items.Add(Localization.Languages[I].Name);
407 if MainWindow.LanguageIndex < ComboBox3.Items.Count then ComboBox3.ItemIndex := MainWindow.LanguageIndex;
408 ComboBox1Change(Self);
409
410 // Load AppEvents
411 // ShowMessage(IntToStr(Length(MainWindow.AppEvents)));
412 SetLength(AppEvents,Length(MainWindow.AppEvents));
413 for I := 0 to High(AppEvents) do
414 AppEvents[I] := MainWindow.AppEvents[I];
415 ListBox1.Items.BeginUpdate;
416 ListBox1.Items.Clear;
417 for I := 0 to High(AppEvents) do ListBox1.Items.Add(AppEvents[I].EventName);
418 ListBox1.Items.EndUpdate;
419 ListBox1.ItemIndex := 0;
420 ListBox1Click(Self);
421
422 // Load AppUserEvents
423 SetLength(AppUserEvents,Length(MainWindow.AppUserEvents));
424 for I := 0 to High(AppUserEvents) do
425 AppUserEvents[I] := MainWindow.AppUserEvents[I];
426 ListBox2.Items.BeginUpdate;
427 ListBox2.Items.Clear;
428 for I := 0 to High(AppUserEvents) do ListBox2.Items.Add(AppUserEvents[I].EventName);
429 ListBox2.Items.EndUpdate;
430 ListBox2.ItemIndex := 0;
431 ComboBox2.Items.Clear;
432 for I := 0 to High(AppEvents) do ComboBox2.Items.Add(AppEvents[I].EventName);
433 LoadUserEventOptions;
434 SendCommand(scUserInfo);
435 end;
436end;
437
438procedure TOptionsWindow.Shape1MouseDown(Sender: TObject;
439 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
440begin
441 if ColorDialog1.Execute then Shape1.Brush.Color := ColorDialog1.Color;
442end;
443
444procedure TOptionsWindow.TrackBar1Change(Sender: TObject);
445begin
446 MainWindow.AlphaBlendValue := TrackBar1.Position;
447end;
448
449procedure TOptionsWindow.Edit1KeyPress(Sender: TObject; var Key: Char);
450begin
451 if Key = #13 then begin
452 Key := #0;
453 Button1Click(Self);
454 end;
455end;
456
457procedure TOptionsWindow.Edit2KeyPress(Sender: TObject; var Key: Char);
458begin
459 if Key = #13 then begin
460 Key:= #0;
461 Button1Click(Self);
462 end;
463end;
464
465procedure TOptionsWindow.ListBox1Click(Sender: TObject);
466begin
467 LoadEventOptions;
468end;
469
470procedure TOptionsWindow.LoadEventOptions;
471begin
472 with AppEvents[ListBox1.ItemIndex] do begin
473 CheckBox16.Checked := ShowWindow;
474 CheckBox19.Checked := ShowAlertIcon;
475 Edit12.Text := IconFile;
476 CheckBox20.Checked := ShowBalloonHint;
477 CheckBox17.Checked := PlaySound;
478 CheckBox22.Checked := PlayBeep;
479 Edit3.Text := SoundFile;
480 CheckBox18.Checked := ExecuteApplication;
481 Edit4.Text := ApplicationFile;
482 CheckBox21.Checked := ShowMessage;
483 Edit5.Text := MessageText;
484 FontDialog1.Font := MessageFont;
485 RichEdit1.SelectAll;
486 RichEdit1.SelAttributes.Name := MessageFont.Name;
487 RichEdit1.SelAttributes.Charset := MessageFont.Charset;
488 RichEdit1.SelAttributes.Color := MessageFont.Color;
489 RichEdit1.SelAttributes.Style := MessageFont.Style;
490 RichEdit1.SelAttributes.Size := MessageFont.Size;
491 RichEdit1.SelAttributes.Pitch := MessageFont.Pitch;
492 end;
493end;
494
495procedure TOptionsWindow.CheckBox16Click(Sender: TObject);
496begin
497 AppEvents[ListBox1.ItemIndex].ShowWindow:= CheckBox16.Checked;
498end;
499
500procedure TOptionsWindow.CheckBox19Click(Sender: TObject);
501begin
502 AppEvents[ListBox1.ItemIndex].ShowAlertIcon:= CheckBox19.Checked;
503end;
504
505procedure TOptionsWindow.CheckBox20Click(Sender: TObject);
506begin
507 AppEvents[ListBox1.ItemIndex].ShowBalloonHint:= CheckBox20.Checked;
508end;
509
510procedure TOptionsWindow.CheckBox17Click(Sender: TObject);
511begin
512 AppEvents[ListBox1.ItemIndex].PlaySound:= CheckBox17.Checked;
513end;
514
515procedure TOptionsWindow.CheckBox18Click(Sender: TObject);
516begin
517 AppEvents[ListBox1.ItemIndex].ExecuteApplication:= CheckBox18.Checked;
518end;
519
520procedure TOptionsWindow.CheckBox21Click(Sender: TObject);
521begin
522 AppEvents[ListBox1.ItemIndex].ShowMessage:= CheckBox21.Checked;
523end;
524
525procedure TOptionsWindow.Button2Click(Sender: TObject);
526begin
527 OpenDialog1.Filter:= 'Soubory WAV|*.wav|Všechny soubory|*.*';
528 OpenDialog1.FileName:= Edit3.Text;
529 if OpenDialog1.Execute then begin
530 CheckBox17.Checked := True;
531 Edit3.Text:= OpenDialog1.FileName;
532 AppEvents[ListBox1.ItemIndex].SoundFile:= OpenDialog1.FileName;
533 end;
534end;
535
536procedure TOptionsWindow.Button3Click(Sender: TObject);
537begin
538 OpenDialog1.Filter:= 'Spustitelné soubory|*.exe|Všechny soubory|*.*';
539 OpenDialog1.FileName:= Edit4.Text;
540 if OpenDialog1.Execute then begin
541 CheckBox18.Checked := True;
542 Edit4.Text:= OpenDialog1.FileName;
543 AppEvents[ListBox1.ItemIndex].ApplicationFile:= OpenDialog1.FileName;
544 end;
545end;
546
547procedure TOptionsWindow.Edit3Change(Sender: TObject);
548begin
549 AppEvents[ListBox1.ItemIndex].SoundFile:= Edit3.Text;
550end;
551
552procedure TOptionsWindow.Edit4Change(Sender: TObject);
553begin
554 AppEvents[ListBox1.ItemIndex].ApplicationFile:= Edit4.Text;
555end;
556
557procedure TOptionsWindow.Edit5Change(Sender: TObject);
558begin
559 AppEvents[ListBox1.ItemIndex].MessageText:= Edit5.Text;
560end;
561
562procedure TOptionsWindow.Button4Click(Sender: TObject);
563begin
564 Close;
565end;
566
567procedure TOptionsWindow.CheckBox22Click(Sender: TObject);
568begin
569 AppEvents[ListBox1.ItemIndex].PlayBeep:= CheckBox22.Checked;
570end;
571
572procedure TOptionsWindow.Button6Click(Sender: TObject);
573var
574 I: Integer;
575begin
576// SetLength(AppEvents,0);
577 with MainWindow do begin
578 Options.Delete;
579 for I:= 0 to High(AppEventsOptions) do begin
580 AppEventsOptions[I].Delete;
581 AppEventsOptions[I].Free;
582 end;
583 SetLength(AppEventsOptions,0);
584 InitSettings;
585 end;
586 FormShow(Self);
587end;
588
589procedure TOptionsWindow.Button7Click(Sender: TObject);
590begin
591 SaveDialog1.FileName:= 'Nastavení '+ApplicationName+'u '+DateToStr(Now)+'.reg';
592 if SaveDialog1.Execute then
593 //ShowMessage(IntToStr(
594 ShellExecute(0, 'open', PChar('regedit.exe'), PChar('/e "'+SaveDialog1.FileName+'" "HKEY_CURRENT_USER'+RegistryPath+'"'), '', SW_SHOWNORMAL);
595end;
596
597procedure TOptionsWindow.FormCreate(Sender: TObject);
598begin
599 if MainWindow.OnTop then FormStyle := fsStayOnTop
600 else FormStyle := fsNormal;
601 PageControl1.ActivePageIndex := 0;
602end;
603
604procedure TOptionsWindow.SpeedButton4Click(Sender: TObject);
605begin
606 with MainWindow do try
607 MediaPlayer1.FileName:= Edit3.Text;
608 MediaPlayer1.Open;
609 MediaPlayer1.Play;
610 except
611 Dialogs.ShowMessage(Localization.Item('AudioFileNotFound'));
612 end;
613end;
614
615procedure TOptionsWindow.Button9Click(Sender: TObject);
616begin
617 with AppEvents[ListBox1.ItemIndex] do
618 if FontDialog1.Execute then begin
619 MessageFont.Name := FontDialog1.Font.Name;
620 MessageFont.Charset := FontDialog1.Font.Charset;
621 MessageFont.Color := FontDialog1.Font.Color;
622 MessageFont.Style := FontDialog1.Font.Style;
623 MessageFont.Size := FontDialog1.Font.Size;
624 MessageFont.Pitch := FontDialog1.Font.Pitch;
625
626 RichEdit1.SelectAll;
627 RichEdit1.SelAttributes.Name := MessageFont.Name;
628 RichEdit1.SelAttributes.Charset := MessageFont.Charset;
629 RichEdit1.SelAttributes.Color := MessageFont.Color;
630 RichEdit1.SelAttributes.Style := MessageFont.Style;
631 RichEdit1.SelAttributes.Size := MessageFont.Size;
632 RichEdit1.SelAttributes.Pitch := MessageFont.Pitch;
633 end;
634end;
635
636procedure TOptionsWindow.Button10Click(Sender: TObject);
637begin
638 OpenDialog1.Filter:= 'Ikony|*.ico|Všechny soubory|*.*';
639 OpenDialog1.FileName:= Edit12.Text;
640 if OpenDialog1.Execute then begin
641 CheckBox19.Checked := True;
642 Edit12.Text:= OpenDialog1.FileName;
643 AppEvents[ListBox1.ItemIndex].IconFile:= OpenDialog1.FileName;
644 end;
645end;
646
647procedure TOptionsWindow.Edit12Change(Sender: TObject);
648begin
649 AppEvents[ListBox1.ItemIndex].IconFile:= Edit12.Text;
650end;
651
652procedure TOptionsWindow.ComboBox1Change(Sender: TObject);
653begin
654 Edit13.Text := TNetworkInterface(MainWindow.SunriseChatNetworkCore1.NetworkInterfaces[ComboBox1.ItemIndex]).IPAddress;
655end;
656
657procedure TOptionsWindow.CheckBox9Click(Sender: TObject);
658begin
659 MainWindow.ServiceFunction:= CheckBox9.Checked;
660 SpinEdit2.Visible:= MainWindow.ServiceFunction;
661 Label16.Visible:= MainWindow.ServiceFunction;
662 Edit13.Visible:= MainWindow.ServiceFunction;
663 Label9.Visible:= MainWindow.ServiceFunction;
664end;
665
666procedure TOptionsWindow.Button11Click(Sender: TObject);
667begin
668 OpenPictureDialog1.FileName:= Edit9.Text;
669 if OpenPictureDialog1.Execute then begin
670 CheckBox28.Checked := True;
671 Edit9.Text:= OpenPictureDialog1.FileName;
672 AppUserEvents[ListBox2.ItemIndex].SoundFile:= OpenPictureDialog1.FileName;
673 end;
674end;
675
676procedure TOptionsWindow.LoadUserEventOptions;
677begin
678 if (ListBox2.ItemIndex>=0) and (ListBox2.ItemIndex < ListBox2.Items.Count) then
679 with AppUserEvents[ListBox2.ItemIndex] do begin
680 CheckBox29.Checked:= ConditionTextEnable;
681 Edit10.Text:= ConditionText;
682 CheckBox26.Checked:= ConditionAppEventEnable;
683 ComboBox2.ItemIndex:= Integer(ConditionAppEvent);
684 CheckBox30.Checked:= ConditionUserEnable;
685 Edit11.Text:= ConditionUser;
686
687 CheckBox23.Checked:= ShowWindow;
688 CheckBox27.Checked:= ShowBalloonHint;
689 CheckBox24.Checked:= PlaySound;
690 CheckBox33.Checked:= PlayBeep;
691 CheckBox32.Checked:= ShowAlertIcon;
692 Edit14.Text:= IconFile;
693 Edit7.Text:= SoundFile;
694 CheckBox25.Checked:= ExecuteApplication;
695 Edit8.Text:= ApplicationFile;
696 CheckBox28.Checked:= ShowImage;
697 Edit9.Text:= ImageFile;
698 end;
699end;
700
701procedure TOptionsWindow.ListBox2Click(Sender: TObject);
702begin
703 LoadUserEventOptions;
704end;
705
706procedure TOptionsWindow.CheckBox29Click(Sender: TObject);
707begin
708 AppUserEvents[ListBox2.ItemIndex].ConditionTextEnable:= CheckBox29.Checked;
709end;
710
711procedure TOptionsWindow.Edit10Change(Sender: TObject);
712begin
713 AppUserEvents[ListBox2.ItemIndex].ConditionText:= Edit10.Text;
714end;
715
716procedure TOptionsWindow.CheckBox26Click(Sender: TObject);
717begin
718 AppUserEvents[ListBox2.ItemIndex].ConditionAppEventEnable:= CheckBox26.Checked;
719end;
720
721procedure TOptionsWindow.ComboBox2Change(Sender: TObject);
722begin
723 AppUserEvents[ListBox2.ItemIndex].ConditionAppEvent:= ComboBox2.ItemIndex;
724end;
725
726procedure TOptionsWindow.CheckBox30Click(Sender: TObject);
727begin
728 AppUserEvents[ListBox2.ItemIndex].ConditionUserEnable:= CheckBox30.Checked;
729end;
730
731procedure TOptionsWindow.Edit11Change(Sender: TObject);
732begin
733 AppUserEvents[ListBox2.ItemIndex].ConditionUser:= Edit11.Text;
734end;
735
736procedure TOptionsWindow.CheckBox23Click(Sender: TObject);
737begin
738 AppUserEvents[ListBox2.ItemIndex].ShowWindow:= CheckBox23.Checked;
739end;
740
741procedure TOptionsWindow.CheckBox27Click(Sender: TObject);
742begin
743 AppUserEvents[ListBox2.ItemIndex].ShowBalloonHint:= CheckBox27.Checked;
744end;
745
746procedure TOptionsWindow.CheckBox24Click(Sender: TObject);
747begin
748 AppUserEvents[ListBox2.ItemIndex].PlaySound:= CheckBox24.Checked;
749end;
750
751procedure TOptionsWindow.CheckBox33Click(Sender: TObject);
752begin
753 AppUserEvents[ListBox2.ItemIndex].PlayBeep:= CheckBox33.Checked;
754end;
755
756procedure TOptionsWindow.Edit7Change(Sender: TObject);
757begin
758 AppUserEvents[ListBox2.ItemIndex].SoundFile:= Edit7.Text;
759end;
760
761procedure TOptionsWindow.CheckBox25Click(Sender: TObject);
762begin
763 AppUserEvents[ListBox2.ItemIndex].ExecuteApplication:= CheckBox25.Checked;
764end;
765
766procedure TOptionsWindow.Edit8Change(Sender: TObject);
767begin
768 AppUserEvents[ListBox2.ItemIndex].ApplicationFile:= Edit8.Text;
769end;
770
771procedure TOptionsWindow.CheckBox28Click(Sender: TObject);
772begin
773 AppUserEvents[ListBox2.ItemIndex].ShowImage:= CheckBox28.Checked;
774end;
775
776procedure TOptionsWindow.Edit9Change(Sender: TObject);
777begin
778 AppUserEvents[ListBox2.ItemIndex].ImageFile:= Edit9.Text;
779end;
780
781procedure TOptionsWindow.CheckBox32Click(Sender: TObject);
782begin
783 AppUserEvents[ListBox2.ItemIndex].ShowAlertIcon:= CheckBox32.Checked;
784end;
785
786procedure TOptionsWindow.Edit14Change(Sender: TObject);
787begin
788 AppUserEvents[ListBox2.ItemIndex].IconFile:= Edit14.Text;
789end;
790
791procedure TOptionsWindow.SpeedButton5Click(Sender: TObject);
792begin
793 with MainWindow do try
794 MediaPlayer1.FileName:= Edit7.Text;
795 MediaPlayer1.Open;
796 MediaPlayer1.Play;
797 except
798 Dialogs.ShowMessage(Localization.Item('AudioFileNotFound'));
799 end;
800
801end;
802
803procedure TOptionsWindow.Button5Click(Sender: TObject);
804begin
805 OpenDialog1.Filter:= 'Soubory WAV|*.wav|Všechny soubory|*.*';
806 OpenDialog1.FileName:= Edit7.Text;
807 if OpenDialog1.Execute then begin
808 CheckBox24.Checked := True;
809 Edit7.Text:= OpenDialog1.FileName;
810 AppUserEvents[ListBox2.ItemIndex].SoundFile:= OpenDialog1.FileName;
811 end;
812end;
813
814procedure TOptionsWindow.Button8Click(Sender: TObject);
815begin
816 OpenDialog1.Filter:= 'Spustitelné soubory|*.exe|Všechny soubory|*.*';
817 OpenDialog1.FileName:= Edit8.Text;
818 if OpenDialog1.Execute then begin
819 CheckBox25.Checked := True;
820 Edit8.Text:= OpenDialog1.FileName;
821 AppUserEvents[ListBox2.ItemIndex].ApplicationFile:= OpenDialog1.FileName;
822 end;
823end;
824
825procedure TOptionsWindow.Button12Click(Sender: TObject);
826begin
827 OpenDialog1.Filter:= 'Ikony|*.ico|Všechny soubory|*.*';
828 OpenDialog1.FileName:= Edit14.Text;
829 if OpenDialog1.Execute then begin
830 CheckBox32.Checked := True;
831 Edit14.Text:= OpenDialog1.FileName;
832 AppUserEvents[ListBox2.ItemIndex].IconFile:= OpenDialog1.FileName;
833 end;
834end;
835
836procedure TOptionsWindow.ListBox2Reload;
837var
838 I: Integer;
839begin
840 ListBox2.Items.BeginUpdate;
841 ListBox2.Items.Clear;
842 for I:= 0 to High(AppUserEvents) do ListBox2.Items.Add(AppUserEvents[I].EventName);
843 ListBox2.Items.EndUpdate;
844 ListBox2.ItemIndex:= 0;
845 LoadUserEventOptions;
846 ListBox2Click(Self);
847end;
848
849procedure TOptionsWindow.Button14Click(Sender: TObject);
850begin
851 OpenDialog1.Filter:= 'Definiční soubor|*.def|Všechny soubory|*.*';
852 if OpenDialog1.Execute then begin
853 end;
854end;
855
856procedure TOptionsWindow.ListBox2DblClick(Sender: TObject);
857begin
858 ActionInsertToMessageExecute(Self);
859end;
860
861procedure TOptionsWindow.ActionAddUserEventExecute(Sender: TObject);
862begin
863 SetLength(AppUserEvents,Length(AppUserEvents)+1);
864 AppUserEvents[High(AppUserEvents)].EventName:= 'Nový '+IntToStr(High(AppUserEvents)+1);
865 ListBox2Reload;
866end;
867
868procedure TOptionsWindow.ActionDeleteUserEventExecute(Sender: TObject);
869var
870 I: Integer;
871begin
872 with ListBox2 do if (ItemIndex>=0) and (ItemIndex<Count) then begin
873 for I:= ItemIndex+1 to High(AppUserEvents) do
874 AppUserEvents[I-1]:= AppUserEvents[I];
875 SetLength(AppUserEvents,High(AppUserEvents));
876 Items.Delete(ItemIndex);
877 ListBox2Reload;
878 end;
879end;
880
881procedure TOptionsWindow.ActionMoveUserEventUpExecute(Sender: TObject);
882var
883 TempItem: TAppUserEvent;
884 I: Integer;
885begin
886 with ListBox2 do if (ItemIndex>0) and (ItemIndex<Count) then begin
887 I:= ItemIndex;
888 TempItem:= AppUserEvents[ItemIndex];
889 AppUserEvents[ItemIndex]:= AppUserEvents[ItemIndex-1];
890 AppUserEvents[ItemIndex-1]:= TempItem;
891 ListBox2Reload;
892 ItemIndex:= I-1;
893 end;
894end;
895
896procedure TOptionsWindow.ActionMoveUserEventDownExecute(Sender: TObject);
897var
898 I: Integer;
899 TempItem: TAppUserEvent;
900begin
901 with ListBox2 do if (ItemIndex>=0) and (ItemIndex<(Count-1)) then begin
902 I:= ItemIndex;
903 TempItem:= AppUserEvents[ItemIndex];
904 AppUserEvents[ItemIndex]:= AppUserEvents[ItemIndex+1];
905 AppUserEvents[ItemIndex+1]:= TempItem;
906 ListBox2Reload;
907 ItemIndex:= I+1;
908 end;
909end;
910
911procedure TOptionsWindow.ActionImportUserEventListExecute(Sender: TObject);
912const
913 Separator = '|';
914var
915 Row: string;
916begin
917 OpenDialog1.Filter:= 'Definiční soubor|*.def|Všechny soubory|*.*';
918 if OpenDialog1.Execute then begin
919 with TTextFileStream.Create(OpenDialog1.FileName,fmOpenRead) do try
920 repeat
921 Row:= Trim(ReadLn);
922 if Row <> '' then begin
923 SetLength(AppUserEvents, Length(AppUserEvents)+1);
924 with AppUserEvents[High(AppUserEvents)] do begin
925 EventName:= Copy(Row, 1, Pos(Separator, Row)-1);
926 ConditionTextEnable:= True;
927 ConditionText:= EventName;
928 ShowImage:= True;
929 ImageFile:= ExtractFileDir(OpenDialog1.FileName) + '\' + Copy(Row, Pos(Separator, Row)+1, Length(Row));
930 end;
931 end;
932 until Position = Size;
933 ListBox2Reload;
934 finally
935 Free;
936 end;
937 end;
938end;
939
940procedure TOptionsWindow.ActionEditUserEventCaptionExecute(
941 Sender: TObject);
942begin
943 if ListBox2.Count>0 then
944 if not InputQuery('Změna jména události','Zadejte nové jméno uživatelské události:',AppUserEvents[ListBox2.ItemIndex].EventName) then Exit;
945 ListBox2Reload;
946end;
947
948procedure TOptionsWindow.ActionInsertToMessageExecute(Sender: TObject);
949begin
950 with MainWindow.ComboBox1 do Text:= Text + ListBox2.Items[ListBox2.ItemIndex];
951 Close;
952end;
953
954procedure TOptionsWindow.ActionDeleteAllUserEventsExecute(Sender: TObject);
955begin
956 ListBox2.Items.Clear;
957 SetLength(AppUserEvents,0);
958 ListBox2Reload;
959end;
960
961procedure TOptionsWindow.ActionSaveUserEventsListExecute(Sender: TObject);
962const
963 Separator = '|';
964var
965// Row: string;
966 I: Integer;
967 FileMode: Word;
968begin
969 SaveDialog1.Filter:= 'Definiční soubor|*.def|Všechny soubory|*.*';
970 if SaveDialog1.Execute then begin
971 if FileExists(SaveDialog1.FileName) then FileMode:= fmOpenWrite else
972 FileMode:= fmCreate;
973 with TTextFileStream.Create(SaveDialog1.FileName, FileMode) do try
974 for I:= 0 to High(AppUserEvents) do with AppUserEvents[I] do
975 WriteLn(ConditionText + Separator + ExtractFileName(ImageFile));
976 finally
977 Free;
978 end;
979 end;
980end;
981
982procedure TOptionsWindow.SaveUserEvents;
983begin
984 MainWindow.LoadAppUserEventsFromRegistry(True);
985end;
986
987procedure TOptionsWindow.TrackBar2Change(Sender: TObject);
988begin
989 with MainWindow do begin
990 MPSetVolume(MediaPlayer1, 1000 - TrackBar2.Position);
991 end;
992end;
993
994procedure TOptionsWindow.FormClose(Sender: TObject;
995 var Action: TCloseAction);
996begin
997 with MainWindow do MPSetVolume(MediaPlayer1, SoundVolume);
998end;
999
1000end.
Note: See TracBrowser for help on using the repository browser.