source: tags/2.10/UOptionsWindow.pas

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

Verze 2.9 a 2.10.

  • Property svn:executable set to *
File size: 32.7 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 UMainWindow, cWindows, ShellAPI, Buttons, ExtDlgs, ImgList, GIFImage, UTextFileStream,
9 ActnList, XPStyleActnCtrls, ActnMan;
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 USunriseChatCore, ULocalization, DateUtils, UWaitingDialog;
235
236{$R *.dfm}
237
238// Closing dialog and saving options
239procedure TOptionsWindow.Button1Click(Sender: TObject);
240var
241 I: Integer;
242 DiffrentAppUserEvents: Boolean;
243begin
244 with SunriseChatCore, MainWindow, OptionsWindow do begin
245 if LocalUser.Nick <> Edit1.Text then ChangeNick(Edit1.Text);
246 if NetworkInterface <> NetworkInterfaces[ComboBox1.ItemIndex].GUID then begin
247 SelectNetworkInterface(NetworkInterfaces[ComboBox1.ItemIndex].GUID);
248 NetworkInterface:= NetworkInterfaces[ComboBox1.ItemIndex].GUID;
249 end;
250
251 NetworkPort:= SpinEdit2.Value;
252 if SunriseChatCore.UDPPort <> NetworkPort then begin
253 SunriseChatCore.UDPPort:= NetworkPort;
254 ShowMessage('Změna se projeví až po restartu aplikace!');
255 //SunriseChatCore.StartNetwork;
256 end;
257 LocalUser.Color:= Shape1.Brush.Color;
258 ShowMainMenu:= CheckBox1.Checked;
259 MainMenu1.Items.Visible:= ShowMainMenu;
260 RunOnLogon:= CheckBox2.Checked;
261 ChangeRunOnLogon;
262 MinimizeToTray:= CheckBox3.Checked;
263 MainWindow.InitTrayIcon;
264 StartInTray:= CheckBox4.Checked;
265 OnTop:= CheckBox5.Checked;
266 ToolButton5.Marked:= OnTop;
267 ShowOnMessage:= CheckBox6.Checked;
268 ShowMessageTime:= CheckBox7.Checked;
269 TabControl1Change(Self);
270 ShowBallonHint:= CheckBox8.Checked;
271 ServiceFunction:= CheckBox9.Checked;
272 MinimalizeOnCloseWindow:= CheckBox10.Checked;
273 ShowRightToolBar:= CheckBox11.Checked;
274 AutoAwayIdleTime:= SpinEdit1.Value;
275 OneAppInstance:= CheckBox13.Checked;
276 SoundDisable:= CheckBox14.Checked;
277 SnapWindow:= CheckBox15.Checked;
278 MainWindow.ScreenSnap:= SnapWindow;
279 ToolButton4.Marked:= SoundDisable;
280 SunriseChatCore.LocalUser.DetailInfo:= Edit6.Text;
281 if MinimumVisibleUsersCount <> SpinEdit4.Value then begin
282 MinimumVisibleUsersCount := SpinEdit4.Value;
283 ListView1.Items.Clear;
284 MainWindow.ShowUserList;
285 end;
286 SoundVolume := 1000-TrackBar2.Position;
287 InvisibledOnStart := CheckBox31.Checked;
288 AutoChangeWindowHeight := CheckBox12.Checked;
289 AutoChangeWindowHeightDirectionDown := ComboBox4.ItemIndex = 1;
290 MinimumVisibleUsersCount := SpinEdit4.Value;
291 if MaxNumberOfRoomLines <> SpinEdit3.Value then begin
292 MaxNumberOfRoomLines := SpinEdit3.Value;
293 MaxRoomLines := MaxNumberOfRoomLines;
294 TabControl1Change(Self);
295 end;
296
297 Panel5.Visible := ShowRightToolBar;
298 //Panel2.Visible := False;
299 //Panel2.Visible := True;
300 AlphaBlendWindow := TrackBar1.Position;
301 MainWindow.AlphaBlendValue := AlphaBlendWindow;
302 AlphaBlend := AlphaBlendValue < 255;
303
304// ChangeMenuVisibility(ShowMainMenu);
305 DefaultReason:= Edit2.Text;
306 InitTrayIcon;
307
308 SunriseChatCore.BroadcastType := TBroadCastType(RadioGroup1.ItemIndex);
309 BroadcastTypeI := RadioGroup1.ItemIndex;
310
311 SetLength(MainWindow.AppEvents,Length(AppEvents));
312 for I:= 0 to High(AppEvents) do
313 MainWindow.AppEvents[I]:= AppEvents[I];
314 MainWindow.SaveAppEventsToRegistry;
315
316 // Save user events
317 DiffrentAppUserEvents := False;
318 if Length(AppUserEvents) <> Length(MainWindow.AppUserEvents) then
319 DiffrentAppUserEvents := True
320 else begin
321 for I := 0 to High(AppUserEvents) do begin
322 if (MainWindow.AppUserEvents[I].ConditionTextEnable <> AppUserEvents[I].ConditionTextEnable) or
323 (MainWindow.AppUserEvents[I].ConditionText <> AppUserEvents[I].ConditionText) or
324 (MainWindow.AppUserEvents[I].ConditionUserEnable <> AppUserEvents[I].ConditionUserEnable) or
325 (MainWindow.AppUserEvents[I].ConditionUser <> AppUserEvents[I].ConditionUser) or
326 (MainWindow.AppUserEvents[I].ConditionAppEventEnable <> AppUserEvents[I].ConditionAppEventEnable) or
327 (MainWindow.AppUserEvents[I].ConditionAppEvent <> AppUserEvents[I].ConditionAppEvent) or
328 (MainWindow.AppUserEvents[I].EventName <> AppUserEvents[I].EventName) or
329 (MainWindow.AppUserEvents[I].ShowWindow <> AppUserEvents[I].ShowWindow) or
330 (MainWindow.AppUserEvents[I].ShowBalloonHint <> AppUserEvents[I].ShowBalloonHint) or
331 (MainWindow.AppUserEvents[I].PlaySound <> AppUserEvents[I].PlaySound) or
332 (MainWindow.AppUserEvents[I].ShowAlertIcon <> AppUserEvents[I].ShowAlertIcon) or
333 (MainWindow.AppUserEvents[I].IconFile <> AppUserEvents[I].IconFile) or
334 (MainWindow.AppUserEvents[I].PlayBeep <> AppUserEvents[I].PlayBeep) or
335 (MainWindow.AppUserEvents[I].SoundFile <> AppUserEvents[I].SoundFile) or
336 (MainWindow.AppUserEvents[I].ExecuteApplication <> AppUserEvents[I].ExecuteApplication) or
337 (MainWindow.AppUserEvents[I].ApplicationFile <> AppUserEvents[I].ApplicationFile) or
338 (MainWindow.AppUserEvents[I].ShowImage <> AppUserEvents[I].ShowImage) or
339 (MainWindow.AppUserEvents[I].ImageFile <> AppUserEvents[I].ImageFile) then
340 DiffrentAppUserEvents := True;
341 end;
342 end;
343 if DiffrentAppUserEvents then begin
344 SetLength(MainWindow.AppUserEvents, Length(AppUserEvents));
345 for I := 0 to High(AppUserEvents) do
346 MainWindow.AppUserEvents[I] := AppUserEvents[I];
347 SetLength(MainWindow.AppUserEventsOptions, Length(AppUserEvents));
348 MainWindow.AppUserEventsCount := Length(AppUserEvents);
349
350 WaitingDialog.PridejUlohu('Načtení z registrů', SaveUserEvents);
351 WaitingDialog.PridejUlohu('Uložení do registrů', MainWindow.SaveAppUserEventsToRegistry);
352 WaitingDialog.Start;
353 ReloadImages;
354 end;
355 MainWindow.LanguageIndex := ComboBox3.ItemIndex;
356 Localization.Activate(MainWindow.LanguageIndex);
357 end;
358 MainWindow.Options.SaveToRegistry;
359 Close;
360end;
361
362procedure TOptionsWindow.FormShow(Sender: TObject);
363var
364 I: Integer;
365begin
366 with SunriseChatCore do begin
367 Shape1.Brush.Color:= LocalUser.Color;
368 Edit1.Text:= LocalUser.Nick;
369 Edit2.Text:= MainWindow.DefaultReason;
370 Edit6.Text:= SunriseChatCore.LocalUser.DetailInfo;
371 CheckBox1.Checked:= MainWindow.ShowMainMenu;
372 CheckBox2.Checked:= MainWindow.RunOnLogon;
373 CheckBox3.Checked:= MainWindow.MinimizeToTray;
374 CheckBox4.Checked:= MainWindow.StartInTray;
375 CheckBox5.Checked:= MainWindow.OnTop;
376 CheckBox6.Checked:= MainWindow.ShowOnMessage;
377 CheckBox7.Checked:= MainWindow.ShowMessageTime;
378 CheckBox8.Checked:= MainWindow.ShowBallonHint;
379 CheckBox9.Checked:= MainWindow.ServiceFunction;
380 CheckBox10.Checked:= MainWindow.MinimalizeOnCloseWindow;
381 CheckBox11.Checked:= MainWindow.ShowRightToolBar;
382 CheckBox12.Checked:= MainWindow.AutoChangeWindowHeight;
383 CheckBox13.Checked:= MainWindow.OneAppInstance;
384 CheckBox14.Checked:= MainWindow.SoundDisable;
385 CheckBox15.Checked:= MainWindow.SnapWindow;
386 CheckBox31.Checked:= MainWindow.InvisibledOnStart;
387 SpinEdit1.Value:= AutoAwayIdleTime;
388 SpinEdit3.Value:= MainWindow.MaxNumberOfRoomLines;
389 SpinEdit2.Value:= MainWindow.NetworkPort;
390 SpinEdit4.Value:= MainWindow.MinimumVisibleUsersCount;
391 TrackBar1.Position := MainWindow.AlphaBlendWindow;
392 TrackBar2.Position := 1000 - MainWindow.SoundVolume;
393 if MainWindow.AutoChangeWindowHeightDirectionDown then
394 ComboBox4.ItemIndex:= 1 else ComboBox4.ItemIndex:= 0;
395 RadioGroup1.ItemIndex := MainWindow.BroadcastTypeI;
396
397
398 // Fill network interfaces list
399 ComboBox1.Items.Clear;
400 for I:= 0 to High(NetworkInterfaces) do ComboBox1.Items.Add(NetworkInterfaces[I].Name);
401 ComboBox1.ItemIndex:= NetworkInterfaceIndex;
402
403 ComboBox3.Items.Clear;
404 for I:= 0 to High(Localization.Languages) do ComboBox3.Items.Add(Localization.Languages[I].Name);
405 if MainWindow.LanguageIndex < ComboBox3.Items.Count then ComboBox3.ItemIndex:= MainWindow.LanguageIndex;
406 ComboBox1Change(Self);
407
408 // Load AppEvents
409 // ShowMessage(IntToStr(Length(MainWindow.AppEvents)));
410 SetLength(AppEvents,Length(MainWindow.AppEvents));
411 for I:= 0 to High(AppEvents) do
412 AppEvents[I]:= MainWindow.AppEvents[I];
413 ListBox1.Items.BeginUpdate;
414 ListBox1.Items.Clear;
415 for I:= 0 to High(AppEvents) do ListBox1.Items.Add(AppEvents[I].EventName);
416 ListBox1.Items.EndUpdate;
417 ListBox1.ItemIndex:= 0;
418 ListBox1Click(Self);
419
420 // Load AppUserEvents
421 SetLength(AppUserEvents,Length(MainWindow.AppUserEvents));
422 for I:= 0 to High(AppUserEvents) do
423 AppUserEvents[I]:= MainWindow.AppUserEvents[I];
424 ListBox2.Items.BeginUpdate;
425 ListBox2.Items.Clear;
426 for I:= 0 to High(AppUserEvents) do ListBox2.Items.Add(AppUserEvents[I].EventName);
427 ListBox2.Items.EndUpdate;
428 ListBox2.ItemIndex:= 0;
429 ComboBox2.Items.Clear;
430 for I:= 0 to High(AppEvents) do ComboBox2.Items.Add(AppEvents[I].EventName);
431 LoadUserEventOptions;
432 end;
433end;
434
435procedure TOptionsWindow.Shape1MouseDown(Sender: TObject;
436 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
437begin
438 if ColorDialog1.Execute then Shape1.Brush.Color := ColorDialog1.Color;
439end;
440
441procedure TOptionsWindow.TrackBar1Change(Sender: TObject);
442begin
443 MainWindow.AlphaBlendValue := TrackBar1.Position;
444end;
445
446procedure TOptionsWindow.Edit1KeyPress(Sender: TObject; var Key: Char);
447begin
448 if Key = #13 then begin
449 Key := #0;
450 Button1Click(Self);
451 end;
452end;
453
454procedure TOptionsWindow.Edit2KeyPress(Sender: TObject; var Key: Char);
455begin
456 if Key = #13 then begin
457 Key:= #0;
458 Button1Click(Self);
459 end;
460end;
461
462procedure TOptionsWindow.ListBox1Click(Sender: TObject);
463begin
464 LoadEventOptions;
465end;
466
467procedure TOptionsWindow.LoadEventOptions;
468begin
469 with AppEvents[ListBox1.ItemIndex] do begin
470 CheckBox16.Checked := ShowWindow;
471 CheckBox19.Checked := ShowAlertIcon;
472 Edit12.Text := IconFile;
473 CheckBox20.Checked := ShowBalloonHint;
474 CheckBox17.Checked := PlaySound;
475 CheckBox22.Checked := PlayBeep;
476 Edit3.Text := SoundFile;
477 CheckBox18.Checked := ExecuteApplication;
478 Edit4.Text := ApplicationFile;
479 CheckBox21.Checked := ShowMessage;
480 Edit5.Text := MessageText;
481 FontDialog1.Font := MessageFont;
482 RichEdit1.SelectAll;
483 RichEdit1.SelAttributes.Name := MessageFont.Name;
484 RichEdit1.SelAttributes.Charset := MessageFont.Charset;
485 RichEdit1.SelAttributes.Color := MessageFont.Color;
486 RichEdit1.SelAttributes.Style := MessageFont.Style;
487 RichEdit1.SelAttributes.Size := MessageFont.Size;
488 RichEdit1.SelAttributes.Pitch := MessageFont.Pitch;
489 end;
490end;
491
492procedure TOptionsWindow.CheckBox16Click(Sender: TObject);
493begin
494 AppEvents[ListBox1.ItemIndex].ShowWindow:= CheckBox16.Checked;
495end;
496
497procedure TOptionsWindow.CheckBox19Click(Sender: TObject);
498begin
499 AppEvents[ListBox1.ItemIndex].ShowAlertIcon:= CheckBox19.Checked;
500end;
501
502procedure TOptionsWindow.CheckBox20Click(Sender: TObject);
503begin
504 AppEvents[ListBox1.ItemIndex].ShowBalloonHint:= CheckBox20.Checked;
505end;
506
507procedure TOptionsWindow.CheckBox17Click(Sender: TObject);
508begin
509 AppEvents[ListBox1.ItemIndex].PlaySound:= CheckBox17.Checked;
510end;
511
512procedure TOptionsWindow.CheckBox18Click(Sender: TObject);
513begin
514 AppEvents[ListBox1.ItemIndex].ExecuteApplication:= CheckBox18.Checked;
515end;
516
517procedure TOptionsWindow.CheckBox21Click(Sender: TObject);
518begin
519 AppEvents[ListBox1.ItemIndex].ShowMessage:= CheckBox21.Checked;
520end;
521
522procedure TOptionsWindow.Button2Click(Sender: TObject);
523begin
524 OpenDialog1.Filter:= 'Soubory WAV|*.wav|Všechny soubory|*.*';
525 OpenDialog1.FileName:= Edit3.Text;
526 if OpenDialog1.Execute then begin
527 CheckBox17.Checked := True;
528 Edit3.Text:= OpenDialog1.FileName;
529 AppEvents[ListBox1.ItemIndex].SoundFile:= OpenDialog1.FileName;
530 end;
531end;
532
533procedure TOptionsWindow.Button3Click(Sender: TObject);
534begin
535 OpenDialog1.Filter:= 'Spustitelné soubory|*.exe|Všechny soubory|*.*';
536 OpenDialog1.FileName:= Edit4.Text;
537 if OpenDialog1.Execute then begin
538 CheckBox18.Checked := True;
539 Edit4.Text:= OpenDialog1.FileName;
540 AppEvents[ListBox1.ItemIndex].ApplicationFile:= OpenDialog1.FileName;
541 end;
542end;
543
544procedure TOptionsWindow.Edit3Change(Sender: TObject);
545begin
546 AppEvents[ListBox1.ItemIndex].SoundFile:= Edit3.Text;
547end;
548
549procedure TOptionsWindow.Edit4Change(Sender: TObject);
550begin
551 AppEvents[ListBox1.ItemIndex].ApplicationFile:= Edit4.Text;
552end;
553
554procedure TOptionsWindow.Edit5Change(Sender: TObject);
555begin
556 AppEvents[ListBox1.ItemIndex].MessageText:= Edit5.Text;
557end;
558
559procedure TOptionsWindow.Button4Click(Sender: TObject);
560begin
561 Close;
562end;
563
564procedure TOptionsWindow.CheckBox22Click(Sender: TObject);
565begin
566 AppEvents[ListBox1.ItemIndex].PlayBeep:= CheckBox22.Checked;
567end;
568
569procedure TOptionsWindow.Button6Click(Sender: TObject);
570var
571 I: Integer;
572begin
573// SetLength(AppEvents,0);
574 with MainWindow do begin
575 Options.Delete;
576 for I:= 0 to High(AppEventsOptions) do begin
577 AppEventsOptions[I].Delete;
578 AppEventsOptions[I].Free;
579 end;
580 SetLength(AppEventsOptions,0);
581 InitSettings;
582 end;
583 FormShow(Self);
584end;
585
586procedure TOptionsWindow.Button7Click(Sender: TObject);
587begin
588 SaveDialog1.FileName:= 'Nastavení '+ApplicationName+'u '+DateToStr(Now)+'.reg';
589 if SaveDialog1.Execute then
590 //ShowMessage(IntToStr(
591 ShellExecute(0, 'open', PChar('regedit.exe'), PChar('/e "'+SaveDialog1.FileName+'" "HKEY_CURRENT_USER'+RegistryPath+'"'), '', SW_SHOWNORMAL);
592end;
593
594procedure TOptionsWindow.FormCreate(Sender: TObject);
595begin
596 if MainWindow.OnTop then FormStyle:= fsStayOnTop else FormStyle:= fsNormal;
597 PageControl1.ActivePageIndex:= 0;
598end;
599
600procedure TOptionsWindow.SpeedButton4Click(Sender: TObject);
601begin
602 with MainWindow do try
603 MediaPlayer1.FileName:= Edit3.Text;
604 MediaPlayer1.Open;
605 MediaPlayer1.Play;
606 except
607 Dialogs.ShowMessage(Localization.Item('AudioFileNotFound'));
608 end;
609end;
610
611procedure TOptionsWindow.Button9Click(Sender: TObject);
612begin
613 with AppEvents[ListBox1.ItemIndex] do
614 if FontDialog1.Execute then begin
615 MessageFont.Name := FontDialog1.Font.Name;
616 MessageFont.Charset := FontDialog1.Font.Charset;
617 MessageFont.Color := FontDialog1.Font.Color;
618 MessageFont.Style := FontDialog1.Font.Style;
619 MessageFont.Size := FontDialog1.Font.Size;
620 MessageFont.Pitch := FontDialog1.Font.Pitch;
621
622 RichEdit1.SelectAll;
623 RichEdit1.SelAttributes.Name := MessageFont.Name;
624 RichEdit1.SelAttributes.Charset := MessageFont.Charset;
625 RichEdit1.SelAttributes.Color := MessageFont.Color;
626 RichEdit1.SelAttributes.Style := MessageFont.Style;
627 RichEdit1.SelAttributes.Size := MessageFont.Size;
628 RichEdit1.SelAttributes.Pitch := MessageFont.Pitch;
629 end;
630end;
631
632procedure TOptionsWindow.Button10Click(Sender: TObject);
633begin
634 OpenDialog1.Filter:= 'Ikony|*.ico|Všechny soubory|*.*';
635 OpenDialog1.FileName:= Edit12.Text;
636 if OpenDialog1.Execute then begin
637 CheckBox19.Checked := True;
638 Edit12.Text:= OpenDialog1.FileName;
639 AppEvents[ListBox1.ItemIndex].IconFile:= OpenDialog1.FileName;
640 end;
641end;
642
643procedure TOptionsWindow.Edit12Change(Sender: TObject);
644begin
645 AppEvents[ListBox1.ItemIndex].IconFile:= Edit12.Text;
646end;
647
648procedure TOptionsWindow.ComboBox1Change(Sender: TObject);
649begin
650 Edit13.Text:= SunriseChatCore.NetworkInterfaces[ComboBox1.ItemIndex].IPAddress;
651end;
652
653procedure TOptionsWindow.CheckBox9Click(Sender: TObject);
654begin
655 MainWindow.ServiceFunction:= CheckBox9.Checked;
656 SpinEdit2.Visible:= MainWindow.ServiceFunction;
657 Label16.Visible:= MainWindow.ServiceFunction;
658 Edit13.Visible:= MainWindow.ServiceFunction;
659 Label9.Visible:= MainWindow.ServiceFunction;
660end;
661
662procedure TOptionsWindow.Button11Click(Sender: TObject);
663begin
664 OpenPictureDialog1.FileName:= Edit9.Text;
665 if OpenPictureDialog1.Execute then begin
666 CheckBox28.Checked := True;
667 Edit9.Text:= OpenPictureDialog1.FileName;
668 AppUserEvents[ListBox2.ItemIndex].SoundFile:= OpenPictureDialog1.FileName;
669 end;
670end;
671
672procedure TOptionsWindow.LoadUserEventOptions;
673begin
674 if (ListBox2.ItemIndex>=0) and (ListBox2.ItemIndex < ListBox2.Items.Count) then
675 with AppUserEvents[ListBox2.ItemIndex] do begin
676 CheckBox29.Checked:= ConditionTextEnable;
677 Edit10.Text:= ConditionText;
678 CheckBox26.Checked:= ConditionAppEventEnable;
679 ComboBox2.ItemIndex:= Integer(ConditionAppEvent);
680 CheckBox30.Checked:= ConditionUserEnable;
681 Edit11.Text:= ConditionUser;
682
683 CheckBox23.Checked:= ShowWindow;
684 CheckBox27.Checked:= ShowBalloonHint;
685 CheckBox24.Checked:= PlaySound;
686 CheckBox33.Checked:= PlayBeep;
687 CheckBox32.Checked:= ShowAlertIcon;
688 Edit14.Text:= IconFile;
689 Edit7.Text:= SoundFile;
690 CheckBox25.Checked:= ExecuteApplication;
691 Edit8.Text:= ApplicationFile;
692 CheckBox28.Checked:= ShowImage;
693 Edit9.Text:= ImageFile;
694 end;
695end;
696
697procedure TOptionsWindow.ListBox2Click(Sender: TObject);
698begin
699 LoadUserEventOptions;
700end;
701
702procedure TOptionsWindow.CheckBox29Click(Sender: TObject);
703begin
704 AppUserEvents[ListBox2.ItemIndex].ConditionTextEnable:= CheckBox29.Checked;
705end;
706
707procedure TOptionsWindow.Edit10Change(Sender: TObject);
708begin
709 AppUserEvents[ListBox2.ItemIndex].ConditionText:= Edit10.Text;
710end;
711
712procedure TOptionsWindow.CheckBox26Click(Sender: TObject);
713begin
714 AppUserEvents[ListBox2.ItemIndex].ConditionAppEventEnable:= CheckBox26.Checked;
715end;
716
717procedure TOptionsWindow.ComboBox2Change(Sender: TObject);
718begin
719 AppUserEvents[ListBox2.ItemIndex].ConditionAppEvent:= ComboBox2.ItemIndex;
720end;
721
722procedure TOptionsWindow.CheckBox30Click(Sender: TObject);
723begin
724 AppUserEvents[ListBox2.ItemIndex].ConditionUserEnable:= CheckBox30.Checked;
725end;
726
727procedure TOptionsWindow.Edit11Change(Sender: TObject);
728begin
729 AppUserEvents[ListBox2.ItemIndex].ConditionUser:= Edit11.Text;
730end;
731
732procedure TOptionsWindow.CheckBox23Click(Sender: TObject);
733begin
734 AppUserEvents[ListBox2.ItemIndex].ShowWindow:= CheckBox23.Checked;
735end;
736
737procedure TOptionsWindow.CheckBox27Click(Sender: TObject);
738begin
739 AppUserEvents[ListBox2.ItemIndex].ShowBalloonHint:= CheckBox27.Checked;
740end;
741
742procedure TOptionsWindow.CheckBox24Click(Sender: TObject);
743begin
744 AppUserEvents[ListBox2.ItemIndex].PlaySound:= CheckBox24.Checked;
745end;
746
747procedure TOptionsWindow.CheckBox33Click(Sender: TObject);
748begin
749 AppUserEvents[ListBox2.ItemIndex].PlayBeep:= CheckBox33.Checked;
750end;
751
752procedure TOptionsWindow.Edit7Change(Sender: TObject);
753begin
754 AppUserEvents[ListBox2.ItemIndex].SoundFile:= Edit7.Text;
755end;
756
757procedure TOptionsWindow.CheckBox25Click(Sender: TObject);
758begin
759 AppUserEvents[ListBox2.ItemIndex].ExecuteApplication:= CheckBox25.Checked;
760end;
761
762procedure TOptionsWindow.Edit8Change(Sender: TObject);
763begin
764 AppUserEvents[ListBox2.ItemIndex].ApplicationFile:= Edit8.Text;
765end;
766
767procedure TOptionsWindow.CheckBox28Click(Sender: TObject);
768begin
769 AppUserEvents[ListBox2.ItemIndex].ShowImage:= CheckBox28.Checked;
770end;
771
772procedure TOptionsWindow.Edit9Change(Sender: TObject);
773begin
774 AppUserEvents[ListBox2.ItemIndex].ImageFile:= Edit9.Text;
775end;
776
777procedure TOptionsWindow.CheckBox32Click(Sender: TObject);
778begin
779 AppUserEvents[ListBox2.ItemIndex].ShowAlertIcon:= CheckBox32.Checked;
780end;
781
782procedure TOptionsWindow.Edit14Change(Sender: TObject);
783begin
784 AppUserEvents[ListBox2.ItemIndex].IconFile:= Edit14.Text;
785end;
786
787procedure TOptionsWindow.SpeedButton5Click(Sender: TObject);
788begin
789 with MainWindow do try
790 MediaPlayer1.FileName:= Edit7.Text;
791 MediaPlayer1.Open;
792 MediaPlayer1.Play;
793 except
794 Dialogs.ShowMessage(Localization.Item('AudioFileNotFound'));
795 end;
796
797end;
798
799procedure TOptionsWindow.Button5Click(Sender: TObject);
800begin
801 OpenDialog1.Filter:= 'Soubory WAV|*.wav|Všechny soubory|*.*';
802 OpenDialog1.FileName:= Edit7.Text;
803 if OpenDialog1.Execute then begin
804 CheckBox24.Checked := True;
805 Edit7.Text:= OpenDialog1.FileName;
806 AppUserEvents[ListBox2.ItemIndex].SoundFile:= OpenDialog1.FileName;
807 end;
808end;
809
810procedure TOptionsWindow.Button8Click(Sender: TObject);
811begin
812 OpenDialog1.Filter:= 'Spustitelné soubory|*.exe|Všechny soubory|*.*';
813 OpenDialog1.FileName:= Edit8.Text;
814 if OpenDialog1.Execute then begin
815 CheckBox25.Checked := True;
816 Edit8.Text:= OpenDialog1.FileName;
817 AppUserEvents[ListBox2.ItemIndex].ApplicationFile:= OpenDialog1.FileName;
818 end;
819end;
820
821procedure TOptionsWindow.Button12Click(Sender: TObject);
822begin
823 OpenDialog1.Filter:= 'Ikony|*.ico|Všechny soubory|*.*';
824 OpenDialog1.FileName:= Edit14.Text;
825 if OpenDialog1.Execute then begin
826 CheckBox32.Checked := True;
827 Edit14.Text:= OpenDialog1.FileName;
828 AppUserEvents[ListBox2.ItemIndex].IconFile:= OpenDialog1.FileName;
829 end;
830end;
831
832procedure TOptionsWindow.ListBox2Reload;
833var
834 I: Integer;
835begin
836 ListBox2.Items.BeginUpdate;
837 ListBox2.Items.Clear;
838 for I:= 0 to High(AppUserEvents) do ListBox2.Items.Add(AppUserEvents[I].EventName);
839 ListBox2.Items.EndUpdate;
840 ListBox2.ItemIndex:= 0;
841 LoadUserEventOptions;
842 ListBox2Click(Self);
843end;
844
845procedure TOptionsWindow.Button14Click(Sender: TObject);
846begin
847 OpenDialog1.Filter:= 'Definiční soubor|*.def|Všechny soubory|*.*';
848 if OpenDialog1.Execute then begin
849 end;
850end;
851
852procedure TOptionsWindow.ListBox2DblClick(Sender: TObject);
853begin
854 ActionInsertToMessageExecute(Self);
855end;
856
857procedure TOptionsWindow.ActionAddUserEventExecute(Sender: TObject);
858begin
859 SetLength(AppUserEvents,Length(AppUserEvents)+1);
860 AppUserEvents[High(AppUserEvents)].EventName:= 'Nový '+IntToStr(High(AppUserEvents)+1);
861 ListBox2Reload;
862end;
863
864procedure TOptionsWindow.ActionDeleteUserEventExecute(Sender: TObject);
865var
866 I: Integer;
867begin
868 with ListBox2 do if (ItemIndex>=0) and (ItemIndex<Count) then begin
869 for I:= ItemIndex+1 to High(AppUserEvents) do
870 AppUserEvents[I-1]:= AppUserEvents[I];
871 SetLength(AppUserEvents,High(AppUserEvents));
872 Items.Delete(ItemIndex);
873 ListBox2Reload;
874 end;
875end;
876
877procedure TOptionsWindow.ActionMoveUserEventUpExecute(Sender: TObject);
878var
879 TempItem: TAppUserEvent;
880 I: Integer;
881begin
882 with ListBox2 do if (ItemIndex>0) and (ItemIndex<Count) then begin
883 I:= ItemIndex;
884 TempItem:= AppUserEvents[ItemIndex];
885 AppUserEvents[ItemIndex]:= AppUserEvents[ItemIndex-1];
886 AppUserEvents[ItemIndex-1]:= TempItem;
887 ListBox2Reload;
888 ItemIndex:= I-1;
889 end;
890end;
891
892procedure TOptionsWindow.ActionMoveUserEventDownExecute(Sender: TObject);
893var
894 I: Integer;
895 TempItem: TAppUserEvent;
896begin
897 with ListBox2 do if (ItemIndex>=0) and (ItemIndex<(Count-1)) then begin
898 I:= ItemIndex;
899 TempItem:= AppUserEvents[ItemIndex];
900 AppUserEvents[ItemIndex]:= AppUserEvents[ItemIndex+1];
901 AppUserEvents[ItemIndex+1]:= TempItem;
902 ListBox2Reload;
903 ItemIndex:= I+1;
904 end;
905end;
906
907procedure TOptionsWindow.ActionImportUserEventListExecute(Sender: TObject);
908const
909 Separator = '|';
910var
911 Row: string;
912begin
913 OpenDialog1.Filter:= 'Definiční soubor|*.def|Všechny soubory|*.*';
914 if OpenDialog1.Execute then begin
915 with TTextFileStream.Create(OpenDialog1.FileName,fmOpenRead) do try
916 repeat
917 Row:= Trim(ReadLn);
918 if Row <> '' then begin
919 SetLength(AppUserEvents, Length(AppUserEvents)+1);
920 with AppUserEvents[High(AppUserEvents)] do begin
921 EventName:= Copy(Row, 1, Pos(Separator, Row)-1);
922 ConditionTextEnable:= True;
923 ConditionText:= EventName;
924 ShowImage:= True;
925 ImageFile:= ExtractFileDir(OpenDialog1.FileName) + '\' + Copy(Row, Pos(Separator, Row)+1, Length(Row));
926 end;
927 end;
928 until Position = Size;
929 ListBox2Reload;
930 finally
931 Free;
932 end;
933 end;
934end;
935
936procedure TOptionsWindow.ActionEditUserEventCaptionExecute(
937 Sender: TObject);
938begin
939 if ListBox2.Count>0 then
940 if not InputQuery('Změna jména události','Zadejte nové jméno uživatelské události:',AppUserEvents[ListBox2.ItemIndex].EventName) then Exit;
941 ListBox2Reload;
942end;
943
944procedure TOptionsWindow.ActionInsertToMessageExecute(Sender: TObject);
945begin
946 with MainWindow.ComboBox1 do Text:= Text + ListBox2.Items[ListBox2.ItemIndex];
947 Close;
948end;
949
950procedure TOptionsWindow.ActionDeleteAllUserEventsExecute(Sender: TObject);
951begin
952 ListBox2.Items.Clear;
953 SetLength(AppUserEvents,0);
954 ListBox2Reload;
955end;
956
957procedure TOptionsWindow.ActionSaveUserEventsListExecute(Sender: TObject);
958const
959 Separator = '|';
960var
961// Row: string;
962 I: Integer;
963 FileMode: Word;
964begin
965 SaveDialog1.Filter:= 'Definiční soubor|*.def|Všechny soubory|*.*';
966 if SaveDialog1.Execute then begin
967 if FileExists(SaveDialog1.FileName) then FileMode:= fmOpenWrite else
968 FileMode:= fmCreate;
969 with TTextFileStream.Create(SaveDialog1.FileName, FileMode) do try
970 for I:= 0 to High(AppUserEvents) do with AppUserEvents[I] do
971 WriteLn(ConditionText + Separator + ExtractFileName(ImageFile));
972 finally
973 Free;
974 end;
975 end;
976end;
977
978procedure TOptionsWindow.SaveUserEvents;
979begin
980 MainWindow.LoadAppUserEventsFromRegistry(True);
981end;
982
983procedure TOptionsWindow.TrackBar2Change(Sender: TObject);
984begin
985 with MainWindow do begin
986 MPSetVolume(MediaPlayer1, 1000 - TrackBar2.Position);
987 end;
988end;
989
990procedure TOptionsWindow.FormClose(Sender: TObject;
991 var Action: TCloseAction);
992begin
993 with MainWindow do MPSetVolume(MediaPlayer1, SoundVolume);
994end;
995
996end.
Note: See TracBrowser for help on using the repository browser.