| 1 | unit UMainWindow;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|---|
| 7 | Dialogs, StdCtrls, cTCPClient, cTCPServer, cWindows, cSockets, cUtils,
|
|---|
| 8 | cSocketsUDP, USunriseChatCore, ImgList, Menus, CoolTrayIcon, ToolWin,
|
|---|
| 9 | ActnMan, ActnCtrls, ActnMenus, ActnList, XPStyleActnCtrls, ComCtrls,
|
|---|
| 10 | ExtCtrls, cWinSock, UAutoRegistry, Registry, CustomizeDlg, MPlayer,
|
|---|
| 11 | StdActns, ULogExceptions, RVScroll, RichView, RVStyle, UTextFileStream,
|
|---|
| 12 | ShellAPI;
|
|---|
| 13 |
|
|---|
| 14 | const
|
|---|
| 15 | ApplicationName = 'SunriseChat';
|
|---|
| 16 | Author = 'Jiří Hajda';
|
|---|
| 17 | HomePage = 'http://www.zdechov.net/sunrisechat/';
|
|---|
| 18 | Email = 'robie@centrum.cz';
|
|---|
| 19 | ClientVersion = '2.10';
|
|---|
| 20 | ClientReleaseDate = '29.6.2007';
|
|---|
| 21 | OfflineTimeout = 13/24/3600; // 13 seconds
|
|---|
| 22 | Creator = 'Chronosoft';
|
|---|
| 23 | RegistryPath = '\Software\'+Creator+'\SunriseChat';
|
|---|
| 24 | ChangeLogFile = 'Novinky.txt';
|
|---|
| 25 | Licence = 'GNU/GPL';
|
|---|
| 26 | HttpHeader = 'http://';
|
|---|
| 27 | ShareHeader = '\\';
|
|---|
| 28 |
|
|---|
| 29 | type
|
|---|
| 30 | TAppEventTextColor = record
|
|---|
| 31 | Color: Integer;
|
|---|
| 32 | Charset: Integer;
|
|---|
| 33 | Style: string;
|
|---|
| 34 | Size: Integer;
|
|---|
| 35 | Name: string;
|
|---|
| 36 | end;
|
|---|
| 37 |
|
|---|
| 38 | TAppEvent = record
|
|---|
| 39 | // Actions
|
|---|
| 40 | EventName: string;
|
|---|
| 41 | ShowWindow: Boolean;
|
|---|
| 42 | ShowBalloonHint: Boolean;
|
|---|
| 43 | PlaySound: Boolean;
|
|---|
| 44 | ShowAlertIcon: Boolean;
|
|---|
| 45 | IconFile: string;
|
|---|
| 46 | PlayBeep: Boolean;
|
|---|
| 47 | SoundFile: string;
|
|---|
| 48 | ExecuteApplication: Boolean;
|
|---|
| 49 | ApplicationFile: string;
|
|---|
| 50 | ShowMessage: Boolean;
|
|---|
| 51 | MessageText: string;
|
|---|
| 52 | MessageFont: TFont;
|
|---|
| 53 | MessageFontTemp: TAppEventTextColor;
|
|---|
| 54 | end;
|
|---|
| 55 |
|
|---|
| 56 | TAppUserEvent = record
|
|---|
| 57 | // Conditions
|
|---|
| 58 | ConditionTextEnable: Boolean;
|
|---|
| 59 | ConditionText: string;
|
|---|
| 60 | ConditionUserEnable: Boolean;
|
|---|
| 61 | ConditionUser: string;
|
|---|
| 62 | ConditionAppEventEnable: Boolean;
|
|---|
| 63 | ConditionAppEvent: Integer;
|
|---|
| 64 |
|
|---|
| 65 | // Actions
|
|---|
| 66 | EventName: string;
|
|---|
| 67 | ShowWindow: Boolean;
|
|---|
| 68 | ShowBalloonHint: Boolean;
|
|---|
| 69 | PlaySound: Boolean;
|
|---|
| 70 | ShowAlertIcon: Boolean;
|
|---|
| 71 | IconFile: string;
|
|---|
| 72 | PlayBeep: Boolean;
|
|---|
| 73 | SoundFile: string;
|
|---|
| 74 | ExecuteApplication: Boolean;
|
|---|
| 75 | ApplicationFile: string;
|
|---|
| 76 | ShowImage: Boolean;
|
|---|
| 77 | ImageFile: string;
|
|---|
| 78 | Image: TImage;
|
|---|
| 79 | end;
|
|---|
| 80 |
|
|---|
| 81 | TEventOption = (eoShowWindow, eoShowBalloonHint, eoShowAlertIcon, eoPlayBeep,
|
|---|
| 82 | eoShowMessage);
|
|---|
| 83 | TEventOptions = set of TEventOption;
|
|---|
| 84 |
|
|---|
| 85 | TMainWindow = class(TForm)
|
|---|
| 86 | Panel3: TPanel;
|
|---|
| 87 | Panel4: TPanel;
|
|---|
| 88 | Button1: TButton;
|
|---|
| 89 | ActionManager1: TActionManager;
|
|---|
| 90 | ActionOptions: TAction;
|
|---|
| 91 | ActionInfo: TAction;
|
|---|
| 92 | ActionAbout: TAction;
|
|---|
| 93 | ActionStatus: TAction;
|
|---|
| 94 | ActionClose: TAction;
|
|---|
| 95 | ActionRestore: TAction;
|
|---|
| 96 | ActionOnline: TAction;
|
|---|
| 97 | ActionAway: TAction;
|
|---|
| 98 | ActionInvisible: TAction;
|
|---|
| 99 | ActionTestResponse: TAction;
|
|---|
| 100 | ActionBlockIP: TAction;
|
|---|
| 101 | ActionCallUp: TAction;
|
|---|
| 102 | CoolTrayIcon1: TCoolTrayIcon;
|
|---|
| 103 | PopupMenu2: TPopupMenu;
|
|---|
| 104 | Blokovatadresu1: TMenuItem;
|
|---|
| 105 | estodezvy1: TMenuItem;
|
|---|
| 106 | Vzva1: TMenuItem;
|
|---|
| 107 | PopupMenu1: TPopupMenu;
|
|---|
| 108 | Obnovit1: TMenuItem;
|
|---|
| 109 | Informace1: TMenuItem;
|
|---|
| 110 | Nastaven2: TMenuItem;
|
|---|
| 111 | Oprogramu2: TMenuItem;
|
|---|
| 112 | Ukonit1: TMenuItem;
|
|---|
| 113 | ImageList1: TImageList;
|
|---|
| 114 | Timer1: TTimer;
|
|---|
| 115 | ActionUserRoom: TAction;
|
|---|
| 116 | ActionLogCommand: TAction;
|
|---|
| 117 | PopupMenu3: TPopupMenu;
|
|---|
| 118 | Odejtzmstnosti1: TMenuItem;
|
|---|
| 119 | CustomizeDlg1: TCustomizeDlg;
|
|---|
| 120 | ActionCustomizeDlg: TAction;
|
|---|
| 121 | PopupMenu4: TPopupMenu;
|
|---|
| 122 | Pedchozzprva1: TMenuItem;
|
|---|
| 123 | Doplnitjmno1: TMenuItem;
|
|---|
| 124 | MainMenu1: TMainMenu;
|
|---|
| 125 | Status1: TMenuItem;
|
|---|
| 126 | Online1: TMenuItem;
|
|---|
| 127 | Pry1: TMenuItem;
|
|---|
| 128 | Neviditeln1: TMenuItem;
|
|---|
| 129 | Nastaven1: TMenuItem;
|
|---|
| 130 | Informace2: TMenuItem;
|
|---|
| 131 | Status2: TMenuItem;
|
|---|
| 132 | Online2: TMenuItem;
|
|---|
| 133 | Pry2: TMenuItem;
|
|---|
| 134 | Neviditeln2: TMenuItem;
|
|---|
| 135 | ActionNetworkTest: TAction;
|
|---|
| 136 | estst1: TMenuItem;
|
|---|
| 137 | Panel5: TPanel;
|
|---|
| 138 | ToolBar1: TToolBar;
|
|---|
| 139 | ToolButton1: TToolButton;
|
|---|
| 140 | ToolButton2: TToolButton;
|
|---|
| 141 | ToolButton3: TToolButton;
|
|---|
| 142 | ToolButton4: TToolButton;
|
|---|
| 143 | ToolButton5: TToolButton;
|
|---|
| 144 | ToolButton7: TToolButton;
|
|---|
| 145 | Panel2: TPanel;
|
|---|
| 146 | Label1: TLabel;
|
|---|
| 147 | ListView1: TListView;
|
|---|
| 148 | Splitter3: TSplitter;
|
|---|
| 149 | Panel1: TPanel;
|
|---|
| 150 | Label2: TLabel;
|
|---|
| 151 | MediaPlayer1: TMediaPlayer;
|
|---|
| 152 | Vytvoitmstnost1: TMenuItem;
|
|---|
| 153 | ActionCreateRoom: TAction;
|
|---|
| 154 | Vytvoitmstnost2: TMenuItem;
|
|---|
| 155 | SearchFind1: TSearchFind;
|
|---|
| 156 | PopupMenu5: TPopupMenu;
|
|---|
| 157 | Find1: TMenuItem;
|
|---|
| 158 | Vymazatve1: TMenuItem;
|
|---|
| 159 | ActionClearMessageList: TAction;
|
|---|
| 160 | ComboBox1: TComboBox;
|
|---|
| 161 | N1: TMenuItem;
|
|---|
| 162 | Novinky1: TMenuItem;
|
|---|
| 163 | ActionChangeLog: TAction;
|
|---|
| 164 | Oprogramu1: TMenuItem;
|
|---|
| 165 | RVStyle1: TRVStyle;
|
|---|
| 166 | Panel6: TPanel;
|
|---|
| 167 | RichView1: TRichView;
|
|---|
| 168 | PageControl1: TPageControl;
|
|---|
| 169 | TabSheet1: TTabSheet;
|
|---|
| 170 | Pozvatuivateledomstnosti1: TMenuItem;
|
|---|
| 171 | ActionUserEventsList: TAction;
|
|---|
| 172 | Nabdkauivatelskchudlost1: TMenuItem;
|
|---|
| 173 | ToolButton6: TToolButton;
|
|---|
| 174 | ListView2: TListView;
|
|---|
| 175 | Koprovar1: TMenuItem;
|
|---|
| 176 | Vloit1: TMenuItem;
|
|---|
| 177 | Vloitsovodkaz1: TMenuItem;
|
|---|
| 178 | OpenDialog1: TOpenDialog;
|
|---|
| 179 | procedure Vloitsovodkaz1Click(Sender: TObject);
|
|---|
| 180 | procedure RichView1Jump(Sender: TObject; id: Integer);
|
|---|
| 181 | procedure Vloit1Click(Sender: TObject);
|
|---|
| 182 | procedure Koprovar1Click(Sender: TObject);
|
|---|
| 183 | procedure FormCreate(Sender: TObject);
|
|---|
| 184 | procedure Button1Click(Sender: TObject);
|
|---|
| 185 | procedure FormShow(Sender: TObject);
|
|---|
| 186 | procedure Timer1Timer(Sender: TObject);
|
|---|
| 187 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|---|
| 188 | procedure ComboBox1KeyPress(Sender: TObject; var Key: Char);
|
|---|
| 189 | procedure ComboBox1KeyDown(Sender: TObject; var Key: Word;
|
|---|
| 190 | Shift: TShiftState);
|
|---|
| 191 | procedure ActionInfoExecute(Sender: TObject);
|
|---|
| 192 | procedure ActionAwayExecute(Sender: TObject);
|
|---|
| 193 | procedure ActionOnlineExecute(Sender: TObject);
|
|---|
| 194 | procedure ActionCloseExecute(Sender: TObject);
|
|---|
| 195 | procedure ListView1Click(Sender: TObject);
|
|---|
| 196 | procedure ActionTestResponseExecute(Sender: TObject);
|
|---|
| 197 | procedure ActionRestoreExecute(Sender: TObject);
|
|---|
| 198 | procedure ActionInvisibleExecute(Sender: TObject);
|
|---|
| 199 | procedure ActionAboutExecute(Sender: TObject);
|
|---|
| 200 | procedure ActionOptionsExecute(Sender: TObject);
|
|---|
| 201 | procedure ActionCallUpExecute(Sender: TObject);
|
|---|
| 202 | procedure TabControl1Change(Sender: TObject);
|
|---|
| 203 | procedure ActionBlockIPExecute(Sender: TObject);
|
|---|
| 204 | procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
|---|
| 205 | procedure ActionUserRoomExecute(Sender: TObject);
|
|---|
| 206 | procedure Odejtzmstnosti1Click(Sender: TObject);
|
|---|
| 207 | procedure ActionCustomizeDlgExecute(Sender: TObject);
|
|---|
| 208 | procedure PopupMenu2Popup(Sender: TObject);
|
|---|
| 209 | procedure Pedchozzprva1Click(Sender: TObject);
|
|---|
| 210 | // procedure Doplnitjmno1Click(Sender: TObject);
|
|---|
| 211 | procedure ActionNetworkTestExecute(Sender: TObject);
|
|---|
| 212 | procedure ToolButton7Click(Sender: TObject);
|
|---|
| 213 | procedure CoolTrayIcon1Click(Sender: TObject);
|
|---|
| 214 | procedure ToolButton1Click(Sender: TObject);
|
|---|
| 215 | procedure ToolButton3Click(Sender: TObject);
|
|---|
| 216 | procedure ToolButton2Click(Sender: TObject);
|
|---|
| 217 | procedure ToolButton5Click(Sender: TObject);
|
|---|
| 218 | procedure ToolButton4Click(Sender: TObject);
|
|---|
| 219 | procedure RichEdit1MouseDown(Sender: TObject; Button: TMouseButton;
|
|---|
| 220 | Shift: TShiftState; X, Y: Integer);
|
|---|
| 221 | procedure ListView1InfoTip(Sender: TObject; Item: TListItem;
|
|---|
| 222 | var InfoTip: String);
|
|---|
| 223 | procedure ActionCreateRoomExecute(Sender: TObject);
|
|---|
| 224 | procedure Doplnitjmno1Click(Sender: TObject);
|
|---|
| 225 | procedure SearchFind1FindDialogFind(Sender: TObject);
|
|---|
| 226 | procedure SearchFind1BeforeExecute(Sender: TObject);
|
|---|
| 227 | procedure ActionClearMessageListExecute(Sender: TObject);
|
|---|
| 228 | procedure ComboBox1Change(Sender: TObject);
|
|---|
| 229 | procedure ActionChangeLogExecute(Sender: TObject);
|
|---|
| 230 | procedure ComboBox1DropDown(Sender: TObject);
|
|---|
| 231 | procedure ComboBox1CloseUp(Sender: TObject);
|
|---|
| 232 | procedure FormResize(Sender: TObject);
|
|---|
| 233 | procedure ActionUserEventsListExecute(Sender: TObject);
|
|---|
| 234 | procedure ToolButton6Click(Sender: TObject);
|
|---|
| 235 | procedure Panel6Resize(Sender: TObject);
|
|---|
| 236 | private
|
|---|
| 237 | CloseEnabled: Boolean;
|
|---|
| 238 | UserLastText: string;
|
|---|
| 239 | procedure WMQueryEndSession(var Message: TMessage); message WM_QUERYENDSESSION;
|
|---|
| 240 | procedure AppMessage(var Msg: TMsg; var Handled: Boolean);
|
|---|
| 241 | procedure ChangeNetworkState;
|
|---|
| 242 | procedure CallUp;
|
|---|
| 243 | procedure lComboBox1Change(Sender: TObject);
|
|---|
| 244 | { Private declarations }
|
|---|
| 245 | public
|
|---|
| 246 | UserEventsImagesEnabled: Boolean;
|
|---|
| 247 | FirstStart: Boolean;
|
|---|
| 248 | LastRichViewStyle: Integer;
|
|---|
| 249 | MaxNumberOfRoomLines: Integer;
|
|---|
| 250 | AppEvents: array of TAppEvent;
|
|---|
| 251 | AppUserEvents: array of TAppUserEvent;
|
|---|
| 252 | AppEventsInit: array of TAppEvent;
|
|---|
| 253 | Options: TAutoRegistry;
|
|---|
| 254 | AppEventsOptions: array of TAutoRegistry;
|
|---|
| 255 | AppUserEventsOptions: array of TAutoRegistry;
|
|---|
| 256 | NetworkPort: Integer;
|
|---|
| 257 | NetworkInterface: string;
|
|---|
| 258 | PingTimeout: Integer;
|
|---|
| 259 | MinimizeToTray: Boolean;
|
|---|
| 260 | StartInTray: Boolean;
|
|---|
| 261 | RunOnLogon: Boolean;
|
|---|
| 262 | LastText: string;
|
|---|
| 263 | OnTop: Boolean;
|
|---|
| 264 | ShowOnMessage: Boolean;
|
|---|
| 265 | PositionX, PositionY, SizeX, SizeY: Integer;
|
|---|
| 266 | LastWindowState: Integer;
|
|---|
| 267 | AlphaBlendWindow: Integer;
|
|---|
| 268 | UserListWidth: Integer;
|
|---|
| 269 | ShowMessageTime: Boolean;
|
|---|
| 270 | ShowMainMenu: Boolean;
|
|---|
| 271 | InstanceIndex: Integer;
|
|---|
| 272 | ShowBallonHint: Boolean;
|
|---|
| 273 | NoResloveHostName: Boolean;
|
|---|
| 274 | MinimalizeOnCloseWindow: Boolean;
|
|---|
| 275 | DefaultReason: string;
|
|---|
| 276 | ServiceFunction: Boolean;
|
|---|
| 277 | ShowRightToolBar: Boolean;
|
|---|
| 278 | PauseScrollText: Boolean;
|
|---|
| 279 | OneAppInstance: Boolean;
|
|---|
| 280 | WM_SunriseChatStart: Cardinal;
|
|---|
| 281 | WM_SunriseChatClose: Cardinal;
|
|---|
| 282 | NoSaveToRegistry: Boolean;
|
|---|
| 283 | SoundDisable: Boolean;
|
|---|
| 284 | StopProgram: Boolean;
|
|---|
| 285 | SnapWindow: Boolean;
|
|---|
| 286 | InvisibledOnStart: Boolean;
|
|---|
| 287 | AutoChangeWindowHeight: Boolean;
|
|---|
| 288 | AutoChangeWindowHeightDirectionDown: Boolean;
|
|---|
| 289 | MinimumVisibleUsersCount: Integer;
|
|---|
| 290 | SoundVolume: Integer;
|
|---|
| 291 | LanguageIndex: Integer;
|
|---|
| 292 | SettingsName: string;
|
|---|
| 293 | AutoChangeInfoWindowHeight: Boolean;
|
|---|
| 294 | AppUserEventsCount: Integer;
|
|---|
| 295 | HyperLinks: array of string;
|
|---|
| 296 | BroadcastTypeI: Integer;
|
|---|
| 297 | procedure RoomListChanged;
|
|---|
| 298 | procedure InitTrayIcon;
|
|---|
| 299 | procedure ChangeRunOnLogon;
|
|---|
| 300 | procedure AddMessage(RoomIndex: Integer; const Args: array of const; EventType: TAppEventType; TextColor: TColor = clSysMessage; UserNick: string = '');
|
|---|
| 301 | procedure ScrollDownRichEdit1;
|
|---|
| 302 | procedure DoplnitJmeno;
|
|---|
| 303 | procedure AddEvent(Name, Text: string; Options: TEventOptions);
|
|---|
| 304 | procedure SaveAppEventsToRegistry;
|
|---|
| 305 | procedure LoadAppEventsFromRegistry;
|
|---|
| 306 | procedure SaveAppUserEventsToRegistry;
|
|---|
| 307 | procedure LoadAppUserEventsFromRegistry(UpdateOnly: Boolean = False);
|
|---|
| 308 | procedure RefreshAppTitle;
|
|---|
| 309 | procedure InitSettings;
|
|---|
| 310 | procedure FillComboBox;
|
|---|
| 311 | procedure ShowUserList;
|
|---|
| 312 | procedure ReloadImages;
|
|---|
| 313 | end;
|
|---|
| 314 |
|
|---|
| 315 | procedure MPSetVolume(MP: TMediaPlayer; Volume: Integer) ;
|
|---|
| 316 | function MPGetVolume(MP: TMediaPlayer): Integer;
|
|---|
| 317 |
|
|---|
| 318 | var
|
|---|
| 319 | MainWindow: TMainWindow;
|
|---|
| 320 |
|
|---|
| 321 | implementation
|
|---|
| 322 |
|
|---|
| 323 | uses UInfoWindow, UAboutWindow, UOptionsWindow, UNetworkTest, UNewRoom,
|
|---|
| 324 | DateUtils, ULocalization, UWaitingDialog, MMSystem;
|
|---|
| 325 |
|
|---|
| 326 | {$R *.dfm}
|
|---|
| 327 |
|
|---|
| 328 | const
|
|---|
| 329 | MCI_SETAUDIO = $0873;
|
|---|
| 330 | MCI_DGV_SETAUDIO_VOLUME = $4002;
|
|---|
| 331 | MCI_DGV_SETAUDIO_ITEM = $00800000;
|
|---|
| 332 | MCI_DGV_SETAUDIO_VALUE = $01000000;
|
|---|
| 333 | MCI_DGV_STATUS_VOLUME = $4019;
|
|---|
| 334 | type
|
|---|
| 335 | MCI_DGV_SETAUDIO_PARMS = record
|
|---|
| 336 | dwCallback: DWORD;
|
|---|
| 337 | dwItem: DWORD;
|
|---|
| 338 | dwValue: DWORD;
|
|---|
| 339 | dwOver: DWORD;
|
|---|
| 340 | lpstrAlgorithm: PChar;
|
|---|
| 341 | lpstrQuality: PChar;
|
|---|
| 342 | end;
|
|---|
| 343 | type
|
|---|
| 344 | MCI_STATUS_PARMS = record
|
|---|
| 345 | dwCallback: DWORD;
|
|---|
| 346 | dwReturn: DWORD;
|
|---|
| 347 | dwItem: DWORD;
|
|---|
| 348 | dwTrack: DWORD;
|
|---|
| 349 | end;
|
|---|
| 350 |
|
|---|
| 351 | {Set Volume, range 0 - 1000}
|
|---|
| 352 | procedure MPSetVolume(MP: TMediaPlayer; Volume: Integer) ;
|
|---|
| 353 | var
|
|---|
| 354 | p: MCI_DGV_SETAUDIO_PARMS;
|
|---|
| 355 | begin
|
|---|
| 356 | p.dwCallback := 0;
|
|---|
| 357 | p.dwItem := MCI_DGV_SETAUDIO_VOLUME;
|
|---|
| 358 | p.dwValue := Volume;
|
|---|
| 359 | p.dwOver := 0;
|
|---|
| 360 | p.lpstrAlgorithm := nil;
|
|---|
| 361 | p.lpstrQuality := nil;
|
|---|
| 362 | mciSendCommand(MP.DeviceID, MCI_SETAUDIO, MCI_DGV_SETAUDIO_VALUE or MCI_DGV_SETAUDIO_ITEM, Cardinal(@p)) ;
|
|---|
| 363 | end;
|
|---|
| 364 |
|
|---|
| 365 | {Get Volume, range 0 - 1000}
|
|---|
| 366 | function MPGetVolume(MP: TMediaPlayer): Integer;
|
|---|
| 367 | var
|
|---|
| 368 | p: MCI_STATUS_PARMS;
|
|---|
| 369 | begin
|
|---|
| 370 | p.dwCallback := 0;
|
|---|
| 371 | p.dwItem := MCI_DGV_STATUS_VOLUME;
|
|---|
| 372 | mciSendCommand(MP.DeviceID, MCI_STATUS, MCI_STATUS_ITEM, Cardinal(@p)) ;
|
|---|
| 373 | Result := p.dwReturn;
|
|---|
| 374 | end;
|
|---|
| 375 |
|
|---|
| 376 | procedure SwitchToThisWindow(h1: hWnd; x: bool); stdcall; external user32 Name 'SwitchToThisWindow';
|
|---|
| 377 |
|
|---|
| 378 | procedure TMainWindow.FormCreate(Sender: TObject);
|
|---|
| 379 | const
|
|---|
| 380 | Separator = '|';
|
|---|
| 381 | var
|
|---|
| 382 | Row: string;
|
|---|
| 383 | FileName: string;
|
|---|
| 384 | I: Integer;
|
|---|
| 385 | begin
|
|---|
| 386 | SettingsName:= '';
|
|---|
| 387 | // Process application parameters
|
|---|
| 388 | for I:= 0 to ParamCount do begin
|
|---|
| 389 | //ShowMessage(ParamStr(I));
|
|---|
| 390 | if Copy(ParamStr(I),1,3) = '/s:' then SettingsName:= Copy(ParamStr(I),4,255);
|
|---|
| 391 | end;
|
|---|
| 392 | if SettingsName = '' then SettingsName:= 'Default';
|
|---|
| 393 |
|
|---|
| 394 | SunriseChatCore.OnChangeNetworkState:= ChangeNetworkState;
|
|---|
| 395 | SunriseChatCore.OnAddMessage:= AddMessage;
|
|---|
| 396 | SunriseChatCore.OnUserListChange:= ShowUserList;
|
|---|
| 397 | SunriseChatCore.OnRoomListChanged:= RoomListChanged;
|
|---|
| 398 |
|
|---|
| 399 | Options:= TAutoRegistry.Create(RegistryPath+'\'+SettingsName);
|
|---|
| 400 | with Options, SunriseChatCore do begin
|
|---|
| 401 | InitSettings;
|
|---|
| 402 | if FirstStart then begin
|
|---|
| 403 | FileName:= ExtractFileDir(Application.ExeName) + '\' + SmileysDefFile;
|
|---|
| 404 | if FileExists(FileName) then begin
|
|---|
| 405 | with TTextFileStream.Create(FileName,fmOpenRead) do try
|
|---|
| 406 | repeat
|
|---|
| 407 | Row:= Trim(ReadLn);
|
|---|
| 408 | if Row <> '' then begin
|
|---|
| 409 | SetLength(AppUserEvents, Length(AppUserEvents)+1);
|
|---|
| 410 | with AppUserEvents[High(AppUserEvents)] do begin
|
|---|
| 411 | EventName:= Copy(Row, 1, Pos(Separator, Row)-1);
|
|---|
| 412 | ConditionTextEnable:= True;
|
|---|
| 413 | ConditionText:= EventName;
|
|---|
| 414 | ShowImage:= True;
|
|---|
| 415 | ImageFile:= ExtractFileDir(FileName) + '\' + Copy(Row, Pos(Separator, Row)+1, Length(Row));
|
|---|
| 416 | end;
|
|---|
| 417 | end;
|
|---|
| 418 | until Position = Size;
|
|---|
| 419 | finally
|
|---|
| 420 | Free;
|
|---|
| 421 | end;
|
|---|
| 422 | SetLength(AppUserEventsOptions,Length(AppUserEvents));
|
|---|
| 423 | AppUserEventsCount:= Length(AppUserEvents);
|
|---|
| 424 | LoadAppUserEventsFromRegistry(True);
|
|---|
| 425 | SaveAppUserEventsToRegistry;
|
|---|
| 426 | ReloadImages;
|
|---|
| 427 | end;
|
|---|
| 428 | end;
|
|---|
| 429 |
|
|---|
| 430 | // Check multiple application instance
|
|---|
| 431 | WM_SunriseChatStart := RegisterWindowMessage('SunriseChatStart');
|
|---|
| 432 | WM_SunriseChatClose := RegisterWindowMessage('SunriseChatClose');
|
|---|
| 433 | Application.OnMessage := AppMessage;
|
|---|
| 434 | PostMessage(HWND_BROADCAST,WM_SunriseChatStart,Application.Handle,0);
|
|---|
| 435 | for I:= 0 to 10 do begin
|
|---|
| 436 | Sleep(1);
|
|---|
| 437 | Application.ProcessMessages;
|
|---|
| 438 | if StopProgram then Break;
|
|---|
| 439 | end;
|
|---|
| 440 | if StopProgram then begin
|
|---|
| 441 | Application.Terminate;
|
|---|
| 442 | Exit;
|
|---|
| 443 | end;
|
|---|
| 444 | end;
|
|---|
| 445 |
|
|---|
| 446 | // Local user initialization
|
|---|
| 447 | with SunriseChatCore.LocalUser do begin
|
|---|
| 448 | Client:= ApplicationName;
|
|---|
| 449 | Application.Title:= ApplicationName;
|
|---|
| 450 | end;
|
|---|
| 451 | SunriseChatCore.LocalUser.ClientVersion:= ClientVersion;
|
|---|
| 452 | SunriseChatCore.UDPPort:= NetworkPort;
|
|---|
| 453 | SunriseChatCore.SelectNetworkInterface(NetworkInterface);
|
|---|
| 454 | // SunriseChatCore.Init;
|
|---|
| 455 | RoomListChanged;
|
|---|
| 456 | // if FileExists(CustomizeFile) then ActionManager1.LoadFromFile(CustomizeFile);
|
|---|
| 457 | RefreshAppTitle;
|
|---|
| 458 | AddMessage(riAll,[],aeStart);
|
|---|
| 459 | end;
|
|---|
| 460 |
|
|---|
| 461 | procedure TMainWindow.InitTrayIcon;
|
|---|
| 462 | begin
|
|---|
| 463 | CoolTrayIcon1.MinimizeToTray:= MinimizeToTray;
|
|---|
| 464 | CoolTrayIcon1.IconIndex:= 5;
|
|---|
| 465 | CoolTrayIcon1.IconVisible:= True; //MinimizeToTray;
|
|---|
| 466 | if OnTop then FormStyle:= fsStayOnTop else FormStyle:= fsNormal;
|
|---|
| 467 |
|
|---|
| 468 | if MinimizeToTray then CoolTrayIcon1.HideTaskbarIcon
|
|---|
| 469 | else CoolTrayIcon1.ShowTaskbarIcon;
|
|---|
| 470 |
|
|---|
| 471 | // Hide MainForm at startup.
|
|---|
| 472 | if StartInTray then Application.ShowMainForm:= False;
|
|---|
| 473 | end;
|
|---|
| 474 |
|
|---|
| 475 | procedure TMainWindow.Koprovar1Click(Sender: TObject);
|
|---|
| 476 | begin
|
|---|
| 477 | RichView1.CopyText;
|
|---|
| 478 | //SendMessage(RichView1.Handle, WM_COPY, 0, 0);
|
|---|
| 479 | end;
|
|---|
| 480 |
|
|---|
| 481 | procedure TMainWindow.AddMessage(RoomIndex: Integer; const Args: array of const; EventType: TAppEventType; TextColor: TColor = clSysMessage; UserNick: string = '');
|
|---|
| 482 | var
|
|---|
| 483 | ForUser, ForUser2, MessageTime: string;
|
|---|
| 484 | Icon: TIcon;
|
|---|
| 485 | RichViewStyle: Integer;
|
|---|
| 486 | I, II: Integer;
|
|---|
| 487 | MessageTextTemp: string;
|
|---|
| 488 | TextStart, TextEnd: Integer;
|
|---|
| 489 | TemporaryText: string;
|
|---|
| 490 | begin
|
|---|
| 491 | case EventType of
|
|---|
| 492 | aeUserChangeNick: RefreshAppTitle;
|
|---|
| 493 | end;
|
|---|
| 494 |
|
|---|
| 495 | // One user message checking
|
|---|
| 496 | if EventType = aeCommonMessage then begin
|
|---|
| 497 | ForUser:= SunriseChatCore.LocalUser.Nick+': ';
|
|---|
| 498 | ForUser2:= Copy(Format('%1:s',Args),1,Length(ForUser));
|
|---|
| 499 | if ForUser2 = ForUser then EventType:= aeOneUserMessage;
|
|---|
| 500 | end;
|
|---|
| 501 |
|
|---|
| 502 | // if SunriseChatCore.ActiveRoomIndex <> RoomIndex then EventType:=
|
|---|
| 503 | try
|
|---|
| 504 | SunriseChatCore.LastMessage:= Format(AppEvents[Integer(EventType)].MessageText,Args);
|
|---|
| 505 | except
|
|---|
| 506 | ShowMessage('Chyba ve zprávě pro událost '+AppEvents[Integer(EventType)].EventName+'!');
|
|---|
| 507 | end;
|
|---|
| 508 |
|
|---|
| 509 | with AppEvents[Integer(EventType)] do begin
|
|---|
| 510 | if ShowWindow then CallUp; //CoolTrayIcon1.ShowMainForm;
|
|---|
| 511 | if not SoundDisable then begin
|
|---|
| 512 | if PlayBeep then Beep;
|
|---|
| 513 | if PlaySound then
|
|---|
| 514 | try
|
|---|
| 515 | MediaPlayer1.FileName := SoundFile;
|
|---|
| 516 | MediaPlayer1.Open;
|
|---|
| 517 | MediaPlayer1.Play;
|
|---|
| 518 | MPSetVolume(MediaPlayer1, SoundVolume);
|
|---|
| 519 | except
|
|---|
| 520 | Dialogs.ShowMessage('Zadaný zvukový soubor pro událost '+AppEvents[Integer(EventType)].EventName+' není audio soubor nebo nebyl nalezen!');
|
|---|
| 521 | end;
|
|---|
| 522 | end;
|
|---|
| 523 | try
|
|---|
| 524 | if ExecuteApplication then ShellLaunch(ApplicationFile);
|
|---|
| 525 | except
|
|---|
| 526 | Dialogs.ShowMessage('Zadaný program ke spuštění pro událost '+AppEvents[Integer(EventType)].EventName+' nebyl nalezen!');
|
|---|
| 527 | end;
|
|---|
| 528 |
|
|---|
| 529 | with SunriseChatCore do
|
|---|
| 530 | if (not Visible) and ShowBalloonHint then with SunriseChatCore do
|
|---|
| 531 | CoolTrayIcon1.ShowBalloonHint(ApplicationName+' - Zpráva',LastMessage,bitInfo,10);
|
|---|
| 532 |
|
|---|
| 533 | // Change tray icon
|
|---|
| 534 | if ShowAlertIcon and MinimizeToTray and (not Visible) and FileExists(IconFile) then begin
|
|---|
| 535 | Icon:= TIcon.Create;
|
|---|
| 536 | try
|
|---|
| 537 | Icon.LoadFromFile(IconFile);
|
|---|
| 538 | CoolTrayIcon1.IconList.ReplaceIcon(6,Icon);
|
|---|
| 539 | CoolTrayIcon1.IconIndex:= 6;
|
|---|
| 540 | finally
|
|---|
| 541 | Icon.Free;
|
|---|
| 542 | end;
|
|---|
| 543 | end;
|
|---|
| 544 |
|
|---|
| 545 | if ShowMessage then with SunriseChatCore do begin
|
|---|
| 546 | // Set text font
|
|---|
| 547 | LastFont := TFont.Create;
|
|---|
| 548 | LastFont.Charset := MessageFont.Charset;
|
|---|
| 549 | LastFont.Name := MessageFont.Name;
|
|---|
| 550 | LastFont.Size := MessageFont.Size;
|
|---|
| 551 | LastFont.Style := MessageFont.Style;
|
|---|
| 552 | if TextColor = clSysMessage then LastFont.Color := MessageFont.Color
|
|---|
| 553 | else LastFont.Color := TextColor;
|
|---|
| 554 | if EventType = aeOneUserMessage then begin
|
|---|
| 555 | LastFont.Style := LastFont.Style + [fsBold];
|
|---|
| 556 | end;
|
|---|
| 557 |
|
|---|
| 558 | //Dialogs.ShowMessage(UserList[LastUserIndex].Nick + ' ' +IntToStr(Length(SunriseChatCore.UserList)));
|
|---|
| 559 | if (RoomIndex = riAll) or (SunriseChatCore.ActiveRoomIndex = RoomIndex) then begin
|
|---|
| 560 | with SunriseChatCore, RVStyle1.TextStyles do begin
|
|---|
| 561 | AddFontEx(LastFont.Name, LastFont.Size, LastFont.Color, LastFont.Style, LastFont.Charset);
|
|---|
| 562 |
|
|---|
| 563 | if ShowMessageTime then MessageTime := '['+TimeToStr(Now)+'] ' else MessageTime:= '';
|
|---|
| 564 | RichView1.AddNamedCheckPoint('a');
|
|---|
| 565 | RichView1.AddFromNewLine(MessageTime, Count-1);
|
|---|
| 566 |
|
|---|
| 567 | // Process user defined events
|
|---|
| 568 | MessageTextTemp := SunriseChatCore.LastMessage;
|
|---|
| 569 | TextStart := 1;
|
|---|
| 570 | TextEnd := 1;
|
|---|
| 571 | while TextEnd <= Length(MessageTextTemp) do begin
|
|---|
| 572 | if (HttpHeader = Copy(MessageTextTemp, TextEnd, Length(HttpHeader))) or
|
|---|
| 573 | (ShareHeader = Copy(MessageTextTemp, TextEnd, Length(ShareHeader))) or
|
|---|
| 574 | (('"' + ShareHeader) = Copy(MessageTextTemp, TextEnd, Length(ShareHeader)+1)) then begin
|
|---|
| 575 | if (MessageTime = '') and (TextStart = 1) then RichView1.AddTextFromNewLine(Copy(MessageTextTemp,TextStart,TextEnd-TextStart),Count-1)
|
|---|
| 576 | else RichView1.AddText(Copy(MessageTextTemp,TextStart,TextEnd-TextStart),Count-1);
|
|---|
| 577 | TemporaryText := Copy(MessageTextTemp, TextEnd, High(Integer));
|
|---|
| 578 | if TemporaryText[1] = '"' then begin
|
|---|
| 579 | if Pos('"', Copy(TemporaryText, 2, High(Integer))) > 0 then
|
|---|
| 580 | TemporaryText := Copy(TemporaryText, 1, Pos('"', Copy(TemporaryText, 2, High(Integer)))+1)
|
|---|
| 581 | end else if(Pos(' ', TemporaryText)>0) then TemporaryText := Copy(TemporaryText, 1, Pos(' ', TemporaryText)-1);
|
|---|
| 582 | RichView1.Add(TemporaryText, rvsJump1);
|
|---|
| 583 | TextStart := TextEnd + Length(TemporaryText);
|
|---|
| 584 | TextEnd := TextStart-1;
|
|---|
| 585 | SetLength(HyperLinks, Length(HyperLinks) + 1);
|
|---|
| 586 | HyperLinks[High(HyperLinks)] := TemporaryText;
|
|---|
| 587 | end else
|
|---|
| 588 | for I := 0 to High(AppUserEvents) do
|
|---|
| 589 | with AppUserEvents[I] do begin
|
|---|
| 590 | if (((not ConditionUserEnable) or (ConditionUserEnable and (ConditionUser = UserNick))) and
|
|---|
| 591 | ((not ConditionTextEnable) or (ConditionTextEnable and (Length(ConditionText)>0)and (ConditionText = Copy(MessageTextTemp,TextEnd,Length(ConditionText))))) and
|
|---|
| 592 | ((not ConditionAppEventEnable) or (ConditionAppEventEnable and (ConditionAppEvent = Integer(EventType))))) and
|
|---|
| 593 | (ConditionAppEventEnable or ConditionTextEnable or ConditionUserEnable) then begin
|
|---|
| 594 | // Show image instead text
|
|---|
| 595 | if ShowImage and UserEventsImagesEnabled then begin
|
|---|
| 596 | if (MessageTime = '') and (TextStart = 1) then RichView1.AddTextFromNewLine(Copy(MessageTextTemp,TextStart,TextEnd-TextStart),Count-1)
|
|---|
| 597 | else RichView1.AddText(Copy(MessageTextTemp,TextStart,TextEnd-TextStart),Count-1);
|
|---|
| 598 |
|
|---|
| 599 | if not Assigned(Image) then begin
|
|---|
| 600 | Image:= TImage.Create(Self);
|
|---|
| 601 | if FileExists(ImageFile) then
|
|---|
| 602 | Image.Picture.LoadFromFile(ImageFile);
|
|---|
| 603 | end;
|
|---|
| 604 | if Assigned(Image.Picture.Graphic) then RichView1.AddImage(Image, False)
|
|---|
| 605 | else RichView1.AddText(ConditionText+'"Obrázek nenalezen!"',Count-1);
|
|---|
| 606 |
|
|---|
| 607 | TextStart:= TextEnd + Length(ConditionText);
|
|---|
| 608 | TextEnd:= TextStart-1;
|
|---|
| 609 | end;
|
|---|
| 610 |
|
|---|
| 611 | // Show call up
|
|---|
| 612 | if ShowWindow then CallUp; //CoolTrayIcon1.ShowMainForm;
|
|---|
| 613 |
|
|---|
| 614 | // Play sound
|
|---|
| 615 | if not SoundDisable then begin
|
|---|
| 616 | if PlayBeep then Beep;
|
|---|
| 617 | if PlaySound then
|
|---|
| 618 | try
|
|---|
| 619 | MediaPlayer1.FileName:= SoundFile;
|
|---|
| 620 | MediaPlayer1.Open;
|
|---|
| 621 | MediaPlayer1.Play;
|
|---|
| 622 | except
|
|---|
| 623 | Dialogs.ShowMessage('Zadaný zvukový soubor pro uživatelskou událost '+EventName+' není audio soubor nebo nebyl nalezen!');
|
|---|
| 624 | end;
|
|---|
| 625 | end;
|
|---|
| 626 | // Execute application
|
|---|
| 627 | try
|
|---|
| 628 | if ExecuteApplication then ShellLaunch(ApplicationFile);
|
|---|
| 629 | except
|
|---|
| 630 | Dialogs.ShowMessage('Zadaný program ke spuštění pro událost '+AppEvents[Integer(EventType)].EventName+' nebyl nalezen!');
|
|---|
| 631 | end;
|
|---|
| 632 |
|
|---|
| 633 | // Show balloon hint
|
|---|
| 634 | with SunriseChatCore do
|
|---|
| 635 | if (not Visible) and ShowBalloonHint then with SunriseChatCore do
|
|---|
| 636 | CoolTrayIcon1.ShowBalloonHint(ApplicationName+' - Zpráva',LastMessage,bitInfo,10);
|
|---|
| 637 |
|
|---|
| 638 | // Change tray icon
|
|---|
| 639 | if ShowAlertIcon and MinimizeToTray and (not Visible) and FileExists(IconFile) then begin
|
|---|
| 640 | Icon:= TIcon.Create;
|
|---|
| 641 | try
|
|---|
| 642 | Icon.LoadFromFile(IconFile);
|
|---|
| 643 | CoolTrayIcon1.IconList.ReplaceIcon(6,Icon);
|
|---|
| 644 | CoolTrayIcon1.IconIndex:= 6;
|
|---|
| 645 | finally
|
|---|
| 646 | Icon.Free;
|
|---|
| 647 | end;
|
|---|
| 648 | end;
|
|---|
| 649 | Break;
|
|---|
| 650 | end;
|
|---|
| 651 | end;
|
|---|
| 652 | TextEnd:= TextEnd + 1;
|
|---|
| 653 | end;
|
|---|
| 654 | if (MessageTime = '') and (TextStart = 1) then RichView1.AddTextFromNewLine(Copy(MessageTextTemp,TextStart,TextEnd-TextStart),Count-1)
|
|---|
| 655 | else RichView1.AddText(Copy(MessageTextTemp,TextStart,TextEnd-TextStart),Count-1);
|
|---|
| 656 | //Dialogs.ShowMessage(IntToStr(RichView1.CheckPointsCount));
|
|---|
| 657 | if RichView1.CheckPointsCount > SunriseChatCore.MaxRoomLines then
|
|---|
| 658 | RichView1.DeleteSection('a');
|
|---|
| 659 | RichView1.Format;
|
|---|
| 660 | ScrollDownRichEdit1;
|
|---|
| 661 | RichView1.Paint;
|
|---|
| 662 | end;
|
|---|
| 663 | end else begin
|
|---|
| 664 | if RoomIndex < PageControl1.PageCount then
|
|---|
| 665 | with PageControl1.Pages[RoomIndex] do begin
|
|---|
| 666 | if ImageIndex = 25 then ImageIndex := 27;
|
|---|
| 667 | if ImageIndex = 26 then ImageIndex := 28;
|
|---|
| 668 | end;
|
|---|
| 669 | end;
|
|---|
| 670 | end else SunriseChatCore.LastMessage:= '';;
|
|---|
| 671 | end;
|
|---|
| 672 | end;
|
|---|
| 673 |
|
|---|
| 674 | procedure TMainWindow.Button1Click(Sender: TObject);
|
|---|
| 675 | begin
|
|---|
| 676 | //raise Exception.Create('Test');
|
|---|
| 677 | if ComboBox1.Text<>'' then
|
|---|
| 678 | with SunriseChatCore do begin
|
|---|
| 679 | LocalUser.Status:= usOnline;
|
|---|
| 680 | LocalUser.RoomName:= RoomList[PageControl1.TabIndex].Name;
|
|---|
| 681 | LocalUser.RoomType:= RoomList[PageControl1.TabIndex].Typ;
|
|---|
| 682 | UserLastText:= ComboBox1.Text;
|
|---|
| 683 | SunriseChatCore.SendCommand('Message', ComboBox1.Text);
|
|---|
| 684 | end;
|
|---|
| 685 | ComboBox1.Text:= '';
|
|---|
| 686 | ComboBox1.SetFocus;
|
|---|
| 687 | lComboBox1Change(Self);
|
|---|
| 688 | // MediaPlayer1.Play;
|
|---|
| 689 | end;
|
|---|
| 690 |
|
|---|
| 691 | procedure TMainWindow.FormShow(Sender: TObject);
|
|---|
| 692 | begin
|
|---|
| 693 | FirstStart:= False;
|
|---|
| 694 | Options.SaveToRegistry;
|
|---|
| 695 |
|
|---|
| 696 | LogExceptions.NazevAplikace:= ApplicationName + ' ' +ClientVersion;
|
|---|
| 697 | if MinimizeToTray then CoolTrayIcon1.HideTaskbarIcon
|
|---|
| 698 | else CoolTrayIcon1.ShowTaskbarIcon;
|
|---|
| 699 | CoolTrayIcon1.IconIndex:= 5;
|
|---|
| 700 | // Localization section
|
|---|
| 701 | with Localization do begin
|
|---|
| 702 | ActionAbout.Caption:= Item('AboutProgram');
|
|---|
| 703 | ActionAway.Caption:= Item('AwayMode');
|
|---|
| 704 | ActionBlockIP.Caption:= Item('BlockUser');
|
|---|
| 705 | ActionCallUp.Caption:= Item('CallUp');
|
|---|
| 706 | ActionClearMessageList.Caption:= Item('ClearMessageList');
|
|---|
| 707 | ActionClose.Caption:= Item('Close');
|
|---|
| 708 | ActionCreateRoom.Caption:= Item('CreateRoom');
|
|---|
| 709 | ActionInfo.Caption:= Item('Information');
|
|---|
| 710 | ActionInvisible.Caption:= Item('Invisible');
|
|---|
| 711 | ActionNetworkTest.Caption:= Item('NetworkTest');
|
|---|
| 712 | ActionOnline.Caption:= Item('Online');
|
|---|
| 713 | ActionOptions.Caption:= Item('Options');
|
|---|
| 714 | ActionRestore.Caption:= Item('Restore');
|
|---|
| 715 | ActionStatus.Caption:= Item('Status');
|
|---|
| 716 | ActionTestResponse.Caption:= Item('ResponseTest');
|
|---|
| 717 | ActionUserRoom.Caption:= Item('InviteUserToRoom');
|
|---|
| 718 | ActionChangeLog.Caption:= Item('ChangeLog');
|
|---|
| 719 |
|
|---|
| 720 | SearchFind1.Caption:= Item('SearchText');
|
|---|
| 721 | Label1.Caption:= Item('UserList')+':';
|
|---|
| 722 | Label2.Caption:= Item('MessageList')+':';
|
|---|
| 723 | Pedchozzprva1.Caption:= Item('PreviousMessage');
|
|---|
| 724 | Doplnitjmno1.Caption:= Item('CompleteUserName');
|
|---|
| 725 | Odejtzmstnosti1.Caption:= Item('LeaveRoom');
|
|---|
| 726 | Button1.Caption:= Item('Send');
|
|---|
| 727 | end;
|
|---|
| 728 | end;
|
|---|
| 729 |
|
|---|
| 730 | procedure TMainWindow.CallUp;
|
|---|
| 731 | begin
|
|---|
| 732 | CoolTrayIcon1.ShowMainForm;
|
|---|
| 733 | FormStyle := fsStayOnTop;
|
|---|
| 734 | // ShowMessage('Výzva');
|
|---|
| 735 | // CallUpWindow.Show;
|
|---|
| 736 | BringWindowToTop(Handle);
|
|---|
| 737 | //Timer1.Tag := 0;
|
|---|
| 738 | //Timer1.Enabled := True;
|
|---|
| 739 |
|
|---|
| 740 | //Windows.SetForegroundWindow(Handle);
|
|---|
| 741 | //BringToFront;
|
|---|
| 742 | //windows.SetFocus(Handle);
|
|---|
| 743 | //FormStyle := fsStayOnTop;
|
|---|
| 744 | // ShellLaunch('calc.exe');
|
|---|
| 745 | if not OnTop then FormStyle := fsNormal;
|
|---|
| 746 | //SwitchToThisWindow(Handle,True);
|
|---|
| 747 | //TabControl1Change(Self);
|
|---|
| 748 | // RichEdit1.Repaint;
|
|---|
| 749 | end;
|
|---|
| 750 |
|
|---|
| 751 | procedure TMainWindow.Timer1Timer(Sender: TObject);
|
|---|
| 752 | begin
|
|---|
| 753 | with SunriseChatCore, LocalUser do begin
|
|---|
| 754 | Repaint;
|
|---|
| 755 | Beep;
|
|---|
| 756 | Timer1.Tag := Timer1.Tag + 1;
|
|---|
| 757 | if Timer1.Tag > 50 then Timer1.Enabled := False;
|
|---|
| 758 | // if SunriseChatCore.Connected then NewCaption:= '' else NewCaption:= '(offline)';
|
|---|
| 759 | // Caption:= 'SunriseChat'+NewCaption+' - '+SunriseChatCore.LocalUser.Nick;
|
|---|
| 760 | // Label1.Caption:= BoolToStr(CoolTrayIcon1.MinimizeToTray);
|
|---|
| 761 | // Label3.Caption:= BoolToStr(SunriseChatCore.fndTCPServer1.Active);
|
|---|
| 762 | // Label4.Caption:= IntToStr(SunriseChatCore.fndTCPServer1.ClientCount);
|
|---|
| 763 | end;
|
|---|
| 764 | end;
|
|---|
| 765 |
|
|---|
| 766 | procedure TMainWindow.ChangeRunOnLogon;
|
|---|
| 767 | begin
|
|---|
| 768 | // Check run on startup
|
|---|
| 769 | with TRegistry.Create do
|
|---|
| 770 | try
|
|---|
| 771 | RootKey := HKEY_CURRENT_USER;
|
|---|
| 772 | OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run', True);
|
|---|
| 773 | if RunOnLogon then WriteString(ApplicationName+'-'+SettingsName,'"'+Application.ExeName+'" "/s:'+SettingsName+'"')
|
|---|
| 774 | else DeleteValue(ApplicationName+'-'+SettingsName);
|
|---|
| 775 | finally
|
|---|
| 776 | Free;
|
|---|
| 777 | end;
|
|---|
| 778 | end;
|
|---|
| 779 |
|
|---|
| 780 | procedure TMainWindow.FormClose(Sender: TObject; var Action: TCloseAction);
|
|---|
| 781 | begin
|
|---|
| 782 | // IdleTrackerTerm;
|
|---|
| 783 | //Timer1.Enabled:= False;
|
|---|
| 784 | BroadcastTypeI := Integer(SunriseChatCore.BroadcastType);
|
|---|
| 785 | PositionX:= Left;
|
|---|
| 786 | PositionY:= Top;
|
|---|
| 787 | SizeX:= Width;
|
|---|
| 788 | SizeY:= Height;
|
|---|
| 789 | LastWindowState:= Integer(WindowState);
|
|---|
| 790 | UserListWidth:= Panel2.Width;
|
|---|
| 791 | SaveAppEventsToRegistry;
|
|---|
| 792 | SaveAppUserEventsToRegistry;
|
|---|
| 793 | if not NoSaveToRegistry then Options.SaveToRegistry;
|
|---|
| 794 | ShowBallonHint:= False;
|
|---|
| 795 | SoundDisable:= True;
|
|---|
| 796 | SunriseChatCore.SendCommand('Disconnect','');
|
|---|
| 797 | Options.Free;
|
|---|
| 798 | end;
|
|---|
| 799 |
|
|---|
| 800 | procedure TMainWindow.ChangeNetworkState;
|
|---|
| 801 | begin
|
|---|
| 802 | RefreshAppTitle;
|
|---|
| 803 | end;
|
|---|
| 804 |
|
|---|
| 805 | procedure TMainWindow.ShowUserList;
|
|---|
| 806 | var
|
|---|
| 807 | I: Integer;
|
|---|
| 808 | Node: TListItem;
|
|---|
| 809 | Index: Integer;
|
|---|
| 810 | LastCount: Integer;
|
|---|
| 811 | NewImageIndex: Integer;
|
|---|
| 812 |
|
|---|
| 813 | function StatusToImageIndex(Status: string): Integer;
|
|---|
| 814 | begin
|
|---|
| 815 | if Status = usAway then Result:= 2
|
|---|
| 816 | else if Status = usWritting then Result:= 4
|
|---|
| 817 | else if Status = usInvisible then Result:= 7
|
|---|
| 818 | else if Status = usOffline then Result:= 7
|
|---|
| 819 | else Result:= 0;
|
|---|
| 820 | end;
|
|---|
| 821 |
|
|---|
| 822 | begin
|
|---|
| 823 | with SunriseChatCore, ListView1 do begin
|
|---|
| 824 | if Assigned(ListView1.Selected) then Index:= ListView1.Selected.Index
|
|---|
| 825 | else Index:= 0;
|
|---|
| 826 | LastCount:= ListView1.Items.Count;
|
|---|
| 827 | //ListView1.Items.BeginUpdate;
|
|---|
| 828 | //ListView1.Items.Clear;
|
|---|
| 829 |
|
|---|
| 830 | // Add missing items to list
|
|---|
| 831 | for I:= 1 to Length(UserList) - Items.Count do begin
|
|---|
| 832 | Node:= ListView1.Items.Add;
|
|---|
| 833 | with Node do begin
|
|---|
| 834 | Node.Caption:= '';
|
|---|
| 835 | ImageIndex:= 0;
|
|---|
| 836 | end;
|
|---|
| 837 | end;
|
|---|
| 838 |
|
|---|
| 839 | // Delete excessive items from list
|
|---|
| 840 | for I:= 1 to Items.Count - Length(UserList) do Items.Delete(Items.Count-1);
|
|---|
| 841 |
|
|---|
| 842 | // Update all items
|
|---|
| 843 | for I:= 0 to High(UserList) do with UserList[I], Items.Item[I] do begin
|
|---|
| 844 | if Caption <> Nick then Caption:= Nick;
|
|---|
| 845 | if (Now - LastTime)>OfflineTimeout then NewImageIndex:= 7 else begin
|
|---|
| 846 | if (IdleTime>(AutoAwayIdleTime*60)) and (Status <> usAway) then NewImageIndex:= 1 else
|
|---|
| 847 | NewImageIndex:= StatusToImageIndex(Status);
|
|---|
| 848 | if BlockMessages then NewImageIndex:= 17;
|
|---|
| 849 | end;
|
|---|
| 850 | if NewImageIndex <> ImageIndex then ImageIndex:= NewImageIndex;
|
|---|
| 851 | end;
|
|---|
| 852 |
|
|---|
| 853 | //ListView1.Items.EndUpdate;
|
|---|
| 854 |
|
|---|
| 855 | // Select previous selected item
|
|---|
| 856 | try
|
|---|
| 857 | with ListView1 do
|
|---|
| 858 | if Items.Count>0 then
|
|---|
| 859 | if Index < Items.Count then Selected:= Items.Item[Index] else
|
|---|
| 860 | Selected:= Items.Item[Items.Count-1];
|
|---|
| 861 | except
|
|---|
| 862 | end;
|
|---|
| 863 |
|
|---|
| 864 | // Automatically change window height according to user list count
|
|---|
| 865 | if AutoChangeWindowHeight then
|
|---|
| 866 | if LastCount <> ListView1.Items.Count then begin
|
|---|
| 867 | LastCount:= ListView1.Items.Count;
|
|---|
| 868 | if LastCount < MinimumVisibleUsersCount then LastCount:= MinimumVisibleUsersCount;
|
|---|
| 869 | with MainWindow do begin
|
|---|
| 870 | if not AutoChangeWindowHeightDirectionDown then
|
|---|
| 871 | Top := Top - (LastCount * 17 - ListView1.Height + 10);
|
|---|
| 872 | Height := Height + (LastCount * 17 - ListView1.Height + 10);
|
|---|
| 873 | ListView1.Update;
|
|---|
| 874 | end;
|
|---|
| 875 | end;
|
|---|
| 876 | end;
|
|---|
| 877 | end;
|
|---|
| 878 |
|
|---|
| 879 | procedure TMainWindow.ComboBox1KeyPress(Sender: TObject; var Key: Char);
|
|---|
| 880 | begin
|
|---|
| 881 | if Key = #13 then begin
|
|---|
| 882 | with ComboBox1 do
|
|---|
| 883 | if DroppedDown and (Style <> csSimple) then begin
|
|---|
| 884 | DroppedDown:= False;
|
|---|
| 885 | Items.Clear;
|
|---|
| 886 | SelStart:= Length(ComboBox1.Text);
|
|---|
| 887 | ComboBox1.Style:= csSimple;
|
|---|
| 888 | end else Button1Click(Self);
|
|---|
| 889 | Key:= #0;
|
|---|
| 890 | end;
|
|---|
| 891 | end;
|
|---|
| 892 |
|
|---|
| 893 | procedure TMainWindow.ComboBox1KeyDown(Sender: TObject; var Key: Word;
|
|---|
| 894 | Shift: TShiftState);
|
|---|
| 895 | begin
|
|---|
| 896 | // ShowMessage(IntToStr(Key));
|
|---|
| 897 | if Key = 38 then ComboBox1.Text:= UserLastText;
|
|---|
| 898 | if Key = 39 then with SunriseChatCore do DoplnitJmeno;
|
|---|
| 899 | end;
|
|---|
| 900 |
|
|---|
| 901 | procedure TMainWindow.ActionInfoExecute(Sender: TObject);
|
|---|
| 902 | begin
|
|---|
| 903 | InfoWindow.ShowModal;
|
|---|
| 904 | end;
|
|---|
| 905 |
|
|---|
| 906 | procedure TMainWindow.ActionAwayExecute(Sender: TObject);
|
|---|
| 907 | begin
|
|---|
| 908 | with SunriseChatCore, LocalUser do
|
|---|
| 909 | if Status <> usAway then begin
|
|---|
| 910 | Reason:= DefaultReason;
|
|---|
| 911 | if ComboBox1.Text <> '' then begin
|
|---|
| 912 | Reason:= ComboBox1.Text;
|
|---|
| 913 | ComboBox1.Text:= '';
|
|---|
| 914 | end else
|
|---|
| 915 | if not InputQuery('Odchod pryč','Zadejte důvod nepřítomnosti',Reason) then Exit;
|
|---|
| 916 | ActionAway.Checked:= True;
|
|---|
| 917 | SendCommand('GoAway','');
|
|---|
| 918 | Status:= usAway;
|
|---|
| 919 | ShowUserList;
|
|---|
| 920 | ComboBox1.Enabled:= False;
|
|---|
| 921 | Button1.Enabled:= False;
|
|---|
| 922 | end;
|
|---|
| 923 | //ShowUserList;
|
|---|
| 924 | end;
|
|---|
| 925 |
|
|---|
| 926 | procedure TMainWindow.ActionOnlineExecute(Sender: TObject);
|
|---|
| 927 | begin
|
|---|
| 928 | ActionOnline.Checked:= True;
|
|---|
| 929 | with SunriseChatCore do begin
|
|---|
| 930 | if LocalUser.Status = usAway then begin
|
|---|
| 931 | SendCommand('GoOnline','');
|
|---|
| 932 | end;
|
|---|
| 933 | LocalUser.Status:= usOnline;
|
|---|
| 934 | ShowUserList;
|
|---|
| 935 | end;
|
|---|
| 936 | ComboBox1.Enabled:= True;
|
|---|
| 937 | Button1.Enabled:= True;
|
|---|
| 938 | ShowUserList;
|
|---|
| 939 | end;
|
|---|
| 940 |
|
|---|
| 941 | procedure TMainWindow.ActionCloseExecute(Sender: TObject);
|
|---|
| 942 | begin
|
|---|
| 943 | CloseEnabled:= True;
|
|---|
| 944 | Close;
|
|---|
| 945 | end;
|
|---|
| 946 |
|
|---|
| 947 | procedure TMainWindow.ListView1Click(Sender: TObject);
|
|---|
| 948 | begin
|
|---|
| 949 | with SunriseChatCore do
|
|---|
| 950 | if Assigned(ListView1.Selected) then with ListView1.Selected do begin
|
|---|
| 951 | if UserList[Index].Status = usAway then
|
|---|
| 952 | AddMessage(riAll,[UserList[Index].Nick, UserList[Index].Reason],aeUserGoAway);
|
|---|
| 953 | end;
|
|---|
| 954 | end;
|
|---|
| 955 |
|
|---|
| 956 | procedure TMainWindow.ActionTestResponseExecute(Sender: TObject);
|
|---|
| 957 | begin
|
|---|
| 958 | with SunriseChatCore do
|
|---|
| 959 | if Assigned(ListView1.Selected) then with ListView1.Selected do begin
|
|---|
| 960 | SunriseChatCore.SendCommand('Ping',TimeToStr(Now),UserList[Index].IP,UserList[Index].ID);
|
|---|
| 961 | SunriseChatCore.AddMessage(riAll,[UserList[Index].Nick],aeSendPing);
|
|---|
| 962 | end;
|
|---|
| 963 | end;
|
|---|
| 964 |
|
|---|
| 965 | procedure TMainWindow.ActionRestoreExecute(Sender: TObject);
|
|---|
| 966 | begin
|
|---|
| 967 | CoolTrayIcon1.ShowMainForm;
|
|---|
| 968 | end;
|
|---|
| 969 |
|
|---|
| 970 | procedure TMainWindow.ActionInvisibleExecute(Sender: TObject);
|
|---|
| 971 | begin
|
|---|
| 972 | ActionInvisible.Checked:= True;
|
|---|
| 973 | SunriseChatCore.LocalUser.Status:= usInvisible;
|
|---|
| 974 | ComboBox1.Enabled:= False;
|
|---|
| 975 | Button1.Enabled:= False;
|
|---|
| 976 | ShowUserList;
|
|---|
| 977 | end;
|
|---|
| 978 |
|
|---|
| 979 | procedure TMainWindow.ActionAboutExecute(Sender: TObject);
|
|---|
| 980 | begin
|
|---|
| 981 | AboutWindow.ShowModal;
|
|---|
| 982 | end;
|
|---|
| 983 |
|
|---|
| 984 | procedure TMainWindow.ActionOptionsExecute(Sender: TObject);
|
|---|
| 985 | begin
|
|---|
| 986 | OptionsWindow.ShowModal;
|
|---|
| 987 | end;
|
|---|
| 988 |
|
|---|
| 989 | procedure TMainWindow.ActionCallUpExecute(Sender: TObject);
|
|---|
| 990 | begin
|
|---|
| 991 | with SunriseChatCore do
|
|---|
| 992 | if Assigned(ListView1.Selected) then with ListView1.Selected do begin
|
|---|
| 993 | SunriseChatCore.SendCommand('CallUp','',UserList[Index].IP,UserList[Index].ID);
|
|---|
| 994 | AddMessage(riAll,[UserList[Index].Nick],aeSendCallUp);
|
|---|
| 995 | end;
|
|---|
| 996 | end;
|
|---|
| 997 |
|
|---|
| 998 |
|
|---|
| 999 | procedure TMainWindow.TabControl1Change(Sender: TObject);
|
|---|
| 1000 | var
|
|---|
| 1001 | I, II: Integer;
|
|---|
| 1002 | ForUser: string;
|
|---|
| 1003 | MessageTime: string;
|
|---|
| 1004 | MessageTextTemp: string;
|
|---|
| 1005 | TextStart, TextEnd: Integer;
|
|---|
| 1006 | TemporaryText: string;
|
|---|
| 1007 | begin
|
|---|
| 1008 | SetLength(HyperLinks, 0);
|
|---|
| 1009 | SunriseChatCore.ActiveRoomIndex:= PageControl1.TabIndex;
|
|---|
| 1010 | with SunriseChatCore, RoomList[PageControl1.TabIndex] do begin
|
|---|
| 1011 | with PageControl1 do
|
|---|
| 1012 | if RoomList[ActiveRoomIndex].Typ = rtPublic then Pages[TabIndex].ImageIndex:= 25
|
|---|
| 1013 | else Pages[TabIndex].ImageIndex:= 26;
|
|---|
| 1014 | RichView1.Clear;
|
|---|
| 1015 | ForUser:= SunriseChatCore.LocalUser.Nick+': ';
|
|---|
| 1016 | for II:= 0 to Count-1 do
|
|---|
| 1017 | with SunriseChatCore, RVStyle1.TextStyles, Lines[(StartLine+II) mod MaxRoomLines] do begin
|
|---|
| 1018 |
|
|---|
| 1019 | AddFontEx(Font.Name, Font.Size, Font.Color, Font.Style, Font.Charset);
|
|---|
| 1020 | if ShowMessageTime then MessageTime := '['+TimeToStr(Time)+'] ' else MessageTime:= '';
|
|---|
| 1021 | RichView1.AddNamedCheckPoint('a');
|
|---|
| 1022 | RichView1.AddFromNewLine(MessageTime, Count-1);
|
|---|
| 1023 |
|
|---|
| 1024 | // Process user defined events
|
|---|
| 1025 | MessageTextTemp:= Text;
|
|---|
| 1026 | TextStart:= 1;
|
|---|
| 1027 | TextEnd:= 1;
|
|---|
| 1028 | while TextEnd <= Length(MessageTextTemp) do begin
|
|---|
| 1029 | if (HttpHeader = Copy(MessageTextTemp, TextEnd, Length(HttpHeader))) or
|
|---|
| 1030 | (ShareHeader = Copy(MessageTextTemp, TextEnd, Length(ShareHeader))) or
|
|---|
| 1031 | (('"' + ShareHeader) = Copy(MessageTextTemp, TextEnd, Length(ShareHeader)+1)) then begin
|
|---|
| 1032 | if (MessageTime = '') and (TextStart = 1) then RichView1.AddTextFromNewLine(Copy(MessageTextTemp,TextStart,TextEnd-TextStart),Count-1)
|
|---|
| 1033 | else RichView1.AddText(Copy(MessageTextTemp,TextStart,TextEnd-TextStart),Count-1);
|
|---|
| 1034 | TemporaryText := Copy(MessageTextTemp, TextEnd, High(Integer));
|
|---|
| 1035 | if TemporaryText[1] = '"' then begin
|
|---|
| 1036 | if Pos('"', Copy(TemporaryText, 2, High(Integer))) > 0 then
|
|---|
| 1037 | TemporaryText := Copy(TemporaryText, 1, Pos('"', Copy(TemporaryText, 2, High(Integer)))+1)
|
|---|
| 1038 | end else if(Pos(' ', TemporaryText)>0) then TemporaryText := Copy(TemporaryText, 1, Pos(' ', TemporaryText)-1);
|
|---|
| 1039 | RichView1.Add(TemporaryText, rvsJump1);
|
|---|
| 1040 | TextStart := TextEnd + Length(TemporaryText);
|
|---|
| 1041 | TextEnd := TextStart-1;
|
|---|
| 1042 | SetLength(HyperLinks, Length(HyperLinks)+1);
|
|---|
| 1043 | HyperLinks[High(HyperLinks)] := TemporaryText;
|
|---|
| 1044 | end else
|
|---|
| 1045 | for I:= 0 to High(AppUserEvents) do
|
|---|
| 1046 | with AppUserEvents[I] do begin
|
|---|
| 1047 | if (((not ConditionUserEnable) or (ConditionUserEnable and (ConditionUser = Nick))) and
|
|---|
| 1048 | ((not ConditionTextEnable) or (ConditionTextEnable and (ConditionText = Copy(MessageTextTemp,TextEnd,Length(ConditionText))))) and
|
|---|
| 1049 | (ConditionText <> '') and
|
|---|
| 1050 | ((not ConditionAppEventEnable) or (ConditionAppEventEnable and (ConditionAppEvent = Integer(EventType))))) and
|
|---|
| 1051 | (ConditionAppEventEnable or ConditionTextEnable or ConditionUserEnable) then begin
|
|---|
| 1052 | // Show image instead text
|
|---|
| 1053 | if ShowImage and UserEventsImagesEnabled then begin
|
|---|
| 1054 | if (MessageTime = '') and (TextStart = 1) then RichView1.AddTextFromNewLine(Copy(MessageTextTemp,TextStart,TextEnd-TextStart),Count-1)
|
|---|
| 1055 | else RichView1.AddText(Copy(MessageTextTemp,TextStart,TextEnd-TextStart),Count-1);
|
|---|
| 1056 | if not Assigned(Image) then begin
|
|---|
| 1057 | Image:= TImage.Create(Self);
|
|---|
| 1058 | if FileExists(ImageFile) then
|
|---|
| 1059 | Image.Picture.LoadFromFile(ImageFile);
|
|---|
| 1060 | end;
|
|---|
| 1061 | if Assigned(Image.Picture.Graphic) then RichView1.AddImage(Image, False)
|
|---|
| 1062 | else RichView1.AddText(ConditionText+'"Obrázek nenalezen!"',Count-1);
|
|---|
| 1063 | TextStart:= TextEnd + Length(ConditionText);
|
|---|
| 1064 | TextEnd:= TextStart-1;
|
|---|
| 1065 | Break;
|
|---|
| 1066 | end;
|
|---|
| 1067 | end;
|
|---|
| 1068 | end;
|
|---|
| 1069 | TextEnd:= TextEnd + 1;
|
|---|
| 1070 | end;
|
|---|
| 1071 | if (MessageTime = '') and (TextStart = 1) then RichView1.AddTextFromNewLine(Copy(MessageTextTemp,TextStart,TextEnd-TextStart),Count-1)
|
|---|
| 1072 | else RichView1.AddText(Copy(MessageTextTemp,TextStart,TextEnd-TextStart),Count-1);
|
|---|
| 1073 | end;
|
|---|
| 1074 | RichView1.Format;
|
|---|
| 1075 | ScrollDownRichEdit1;
|
|---|
| 1076 | RichView1.Paint;
|
|---|
| 1077 | end;
|
|---|
| 1078 | end;
|
|---|
| 1079 |
|
|---|
| 1080 | procedure TMainWindow.ActionBlockIPExecute(Sender: TObject);
|
|---|
| 1081 | begin
|
|---|
| 1082 | with SunriseChatCore do
|
|---|
| 1083 | if Assigned(ListView1.Selected) then
|
|---|
| 1084 | with ListView1.Selected, SunriseChatCore.UserList[Index] do begin
|
|---|
| 1085 | BlockMessages:= not BlockMessages;
|
|---|
| 1086 | ShowUserList;
|
|---|
| 1087 | end;
|
|---|
| 1088 | end;
|
|---|
| 1089 |
|
|---|
| 1090 | procedure TMainWindow.FormCloseQuery(Sender: TObject;
|
|---|
| 1091 | var CanClose: Boolean);
|
|---|
| 1092 | begin
|
|---|
| 1093 | CanClose:= CloseEnabled;
|
|---|
| 1094 | if MinimalizeOnCloseWindow then begin
|
|---|
| 1095 | CoolTrayIcon1.HideMainForm;
|
|---|
| 1096 | end else CanClose:= True;
|
|---|
| 1097 | end;
|
|---|
| 1098 |
|
|---|
| 1099 | procedure TMainWindow.ActionUserRoomExecute(Sender: TObject);
|
|---|
| 1100 | begin
|
|---|
| 1101 | if Assigned(ListView1.Selected) then
|
|---|
| 1102 | with ListView1.Selected, SunriseChatCore, SunriseChatCore.UserList[Index] do begin
|
|---|
| 1103 | if RoomList[ActiveRoomIndex].Typ = rtPublic then ShowMessage('Nelze pozvat uživatele do veřejné místnosti!')
|
|---|
| 1104 | else begin
|
|---|
| 1105 | LocalUser.RoomName:= RoomList[ActiveRoomIndex].Name;
|
|---|
| 1106 | LocalUser.RoomType:= rtPrivate;
|
|---|
| 1107 | SendCommand('CreateRoom','',IP,ID);
|
|---|
| 1108 | //if (IP<>LocalUser.IP) or (ID<>LocalUser.ID) then SendCommand('CreateRoom','',LocalUser.IP,LocalUser.ID);
|
|---|
| 1109 | end;
|
|---|
| 1110 | end;
|
|---|
| 1111 | end;
|
|---|
| 1112 |
|
|---|
| 1113 | procedure TMainWindow.RoomListChanged;
|
|---|
| 1114 | var
|
|---|
| 1115 | I: Integer;
|
|---|
| 1116 | NewTabSheet: TTabSheet;
|
|---|
| 1117 | begin
|
|---|
| 1118 | with SunriseChatCore do with PageControl1 do begin
|
|---|
| 1119 | while PageCount>0 do Pages[0].Free;
|
|---|
| 1120 | for I:= 0 to High(RoomList) do begin
|
|---|
| 1121 | NewTabSheet := TTabSheet.Create(PageControl1);
|
|---|
| 1122 | NewTabSheet.PageControl := PageControl1;
|
|---|
| 1123 | NewTabSheet.Caption:= RoomList[I].Name;
|
|---|
| 1124 | if RoomList[I].Typ = rtPublic then NewTabSheet.ImageIndex:= 25
|
|---|
| 1125 | else NewTabSheet.ImageIndex:= 26;
|
|---|
| 1126 | end;
|
|---|
| 1127 | Visible:= PageCount > 1;
|
|---|
| 1128 | if ActiveRoomIndex >= PageControl1.PageCount then ActiveRoomIndex:= 0;
|
|---|
| 1129 | ActivePageIndex:= ActiveRoomIndex;
|
|---|
| 1130 | PageControl1.TabIndex := ActiveRoomIndex;
|
|---|
| 1131 | TabControl1Change(Self);
|
|---|
| 1132 | end;
|
|---|
| 1133 | end;
|
|---|
| 1134 |
|
|---|
| 1135 | procedure TMainWindow.Odejtzmstnosti1Click(Sender: TObject);
|
|---|
| 1136 | begin
|
|---|
| 1137 | if PageControl1.ActivePageIndex = 0 then ShowMessage('Tuto místnost nelze zrušit')
|
|---|
| 1138 | else begin
|
|---|
| 1139 | SunriseChatCore.SendCommand('LeaveRoom','');
|
|---|
| 1140 | SunriseChatCore.DeleteRoom(PageControl1.ActivePageIndex);
|
|---|
| 1141 | TabControl1Change(Self);
|
|---|
| 1142 | end;
|
|---|
| 1143 | end;
|
|---|
| 1144 |
|
|---|
| 1145 | procedure TMainWindow.ActionCustomizeDlgExecute(Sender: TObject);
|
|---|
| 1146 | begin
|
|---|
| 1147 | FormStyle:= fsNormal;
|
|---|
| 1148 | CustomizeDlg1.Show;
|
|---|
| 1149 | // if OnTop then FormStyle:= fsStayOnTop;
|
|---|
| 1150 | end;
|
|---|
| 1151 |
|
|---|
| 1152 | procedure TMainWindow.PopupMenu2Popup(Sender: TObject);
|
|---|
| 1153 | begin
|
|---|
| 1154 | with SunriseChatCore do
|
|---|
| 1155 | if Assigned(ListView1.Selected) then
|
|---|
| 1156 | with ListView1.Selected, SunriseChatCore.UserList[Index] do
|
|---|
| 1157 | BlokovatAdresu1.Checked:= BlockMessages;
|
|---|
| 1158 | end;
|
|---|
| 1159 |
|
|---|
| 1160 | procedure TMainWindow.WMQueryEndSession(var Message: TMessage);
|
|---|
| 1161 | { This method is a hack. It intercepts the WM_QUERYENDSESSION message.
|
|---|
| 1162 | This way we can decide if we want to ignore the "Close to tray" option.
|
|---|
| 1163 | Otherwise, when selected, the option would make Windows unable to shut down. }
|
|---|
| 1164 | begin
|
|---|
| 1165 | CloseEnabled:= True;
|
|---|
| 1166 | Message.Result:= 1;
|
|---|
| 1167 | end;
|
|---|
| 1168 |
|
|---|
| 1169 | procedure TMainWindow.Pedchozzprva1Click(Sender: TObject);
|
|---|
| 1170 | var
|
|---|
| 1171 | I: Integer;
|
|---|
| 1172 | begin
|
|---|
| 1173 | ComboBox1.Style:= csDropDown;
|
|---|
| 1174 | with SunriseChatCore, ComboBox1.Items do begin
|
|---|
| 1175 | BeginUpdate;
|
|---|
| 1176 | Clear;
|
|---|
| 1177 | for I:= RoomList[ActiveRoomIndex].Count-1 downto 0 do with RoomList[ActiveRoomIndex], Lines[(I + StartLine) mod MaxRoomLines] do begin
|
|---|
| 1178 | Add(Text);
|
|---|
| 1179 | end;
|
|---|
| 1180 | Update;
|
|---|
| 1181 | EndUpdate;
|
|---|
| 1182 | if ComboBox1.Items.Count>0 then ComboBox1.DroppedDown:= True;
|
|---|
| 1183 | end;
|
|---|
| 1184 | end;
|
|---|
| 1185 |
|
|---|
| 1186 |
|
|---|
| 1187 | procedure TMainWindow.DoplnitJmeno;
|
|---|
| 1188 | var
|
|---|
| 1189 | I: Integer;
|
|---|
| 1190 | UserIndex: Integer;
|
|---|
| 1191 | NickCount: Integer;
|
|---|
| 1192 | begin
|
|---|
| 1193 | UserIndex:= -1;
|
|---|
| 1194 | NickCOunt:= 0;
|
|---|
| 1195 | with SunriseChatCore do begin
|
|---|
| 1196 | for I:= 0 to High(UserList) do begin
|
|---|
| 1197 | if Length(ComboBox1.Text) <= Length(UserList[I].Nick) then
|
|---|
| 1198 | if ComboBox1.Text = Copy(UserList[I].Nick,1,Length(ComboBox1.Text)) then begin
|
|---|
| 1199 | UserIndex:= I;
|
|---|
| 1200 | NickCount:= NickCount + 1;
|
|---|
| 1201 | end;
|
|---|
| 1202 | end;
|
|---|
| 1203 | if NickCount = 1 then begin
|
|---|
| 1204 | ComboBox1.Text:= UserList[UserIndex].Nick + ': ';
|
|---|
| 1205 | ComboBox1.SelStart:= Length(ComboBox1.Text);
|
|---|
| 1206 | end else
|
|---|
| 1207 | if NickCount > 1 then FillComboBox;
|
|---|
| 1208 | end;
|
|---|
| 1209 | end;
|
|---|
| 1210 |
|
|---|
| 1211 | procedure TMainWindow.ActionNetworkTestExecute(Sender: TObject);
|
|---|
| 1212 | begin
|
|---|
| 1213 | NetworkTest.ShowModal;
|
|---|
| 1214 | end;
|
|---|
| 1215 |
|
|---|
| 1216 | procedure TMainWindow.ToolButton7Click(Sender: TObject);
|
|---|
| 1217 | begin
|
|---|
| 1218 | Application.Minimize;
|
|---|
| 1219 | end;
|
|---|
| 1220 |
|
|---|
| 1221 | procedure TMainWindow.Vloit1Click(Sender: TObject);
|
|---|
| 1222 | begin
|
|---|
| 1223 | SendMessage(ComboBox1.Handle, WM_PASTE, 0, 0);
|
|---|
| 1224 | end;
|
|---|
| 1225 |
|
|---|
| 1226 | procedure TMainWindow.Vloitsovodkaz1Click(Sender: TObject);
|
|---|
| 1227 | begin
|
|---|
| 1228 | if OpenDialog1.Execute then begin
|
|---|
| 1229 | if Pos(' ', OpenDialog1.FileName) > 0 then
|
|---|
| 1230 | ComboBox1.Text := ComboBox1.Text + '"' + OpenDialog1.FileName + '"'
|
|---|
| 1231 | else
|
|---|
| 1232 | ComboBox1.Text := ComboBox1.Text + OpenDialog1.FileName;
|
|---|
| 1233 | end;
|
|---|
| 1234 | end;
|
|---|
| 1235 |
|
|---|
| 1236 | procedure TMainWindow.CoolTrayIcon1Click(Sender: TObject);
|
|---|
| 1237 | begin
|
|---|
| 1238 | // RichEdit1.Lines.Add(IntToStr(GetForegroundWindow)+' '+IntToStr(MainWindow.Handle)+' '+IntToStr(Application.Handle));
|
|---|
| 1239 | // if GetForegroundWindow = Application.Handle then CoolTrayIcon1.HideMainForm else
|
|---|
| 1240 | if MainWindow.Visible then CoolTrayIcon1.HideMainForm else
|
|---|
| 1241 | CoolTrayIcon1.ShowMainForm;
|
|---|
| 1242 | end;
|
|---|
| 1243 |
|
|---|
| 1244 | procedure TMainWindow.ToolButton1Click(Sender: TObject);
|
|---|
| 1245 | begin
|
|---|
| 1246 | // ToolButton1.Marked := not ToolButton1.Marked;
|
|---|
| 1247 | PauseScrollText := ToolButton1.Down;
|
|---|
| 1248 | end;
|
|---|
| 1249 |
|
|---|
| 1250 | procedure TMainWindow.ToolButton3Click(Sender: TObject);
|
|---|
| 1251 | begin
|
|---|
| 1252 | ActionOptionsExecute(Self);
|
|---|
| 1253 | end;
|
|---|
| 1254 |
|
|---|
| 1255 | procedure TMainWindow.ToolButton2Click(Sender: TObject);
|
|---|
| 1256 | begin
|
|---|
| 1257 | ActionInfoExecute(Self);
|
|---|
| 1258 | end;
|
|---|
| 1259 |
|
|---|
| 1260 | procedure TMainWindow.ToolButton5Click(Sender: TObject);
|
|---|
| 1261 | begin
|
|---|
| 1262 | // ToolButton5.Marked:= not ToolButton5.Marked;
|
|---|
| 1263 | OnTop:= ToolButton5.Down;
|
|---|
| 1264 | InitTrayIcon;
|
|---|
| 1265 | end;
|
|---|
| 1266 |
|
|---|
| 1267 | procedure TMainWindow.ToolButton4Click(Sender: TObject);
|
|---|
| 1268 | begin
|
|---|
| 1269 | // ToolButton4.Marked:= not ToolButton4.Marked;
|
|---|
| 1270 | SoundDisable:= ToolButton4.Down;
|
|---|
| 1271 | end;
|
|---|
| 1272 |
|
|---|
| 1273 | procedure TMainWindow.ScrollDownRichEdit1;
|
|---|
| 1274 | begin
|
|---|
| 1275 | if not PauseScrollText then begin
|
|---|
| 1276 | RichView1.ScrollTo(High(Integer));
|
|---|
| 1277 | RichView1.Paint;
|
|---|
| 1278 | (*
|
|---|
| 1279 | // Scroll down Richedit
|
|---|
| 1280 | ScrollMessage.Msg:= WM_VScroll;
|
|---|
| 1281 |
|
|---|
| 1282 | ScrollMessage.ScrollCode:= sb_Bottom;
|
|---|
| 1283 | ScrollMessage.Pos:= 0;
|
|---|
| 1284 | RichEdit1.Dispatch(ScrollMessage);
|
|---|
| 1285 | if Win32Platform = 1 then begin
|
|---|
| 1286 | ScrollMessage.Msg:= WM_VScroll;
|
|---|
| 1287 | begin
|
|---|
| 1288 | ScrollMessage.ScrollCode:= SB_PAGEUP;
|
|---|
| 1289 | ScrollMessage.Pos:= 0;
|
|---|
| 1290 | RichEdit1.Dispatch(ScrollMessage);
|
|---|
| 1291 | end;
|
|---|
| 1292 | end;
|
|---|
| 1293 | *)
|
|---|
| 1294 | end;
|
|---|
| 1295 | end;
|
|---|
| 1296 |
|
|---|
| 1297 |
|
|---|
| 1298 | procedure TMainWindow.AppMessage(var Msg: TMsg; var Handled: Boolean);
|
|---|
| 1299 | begin
|
|---|
| 1300 | if Msg.Message = WM_SunriseChatStart then begin
|
|---|
| 1301 | if HWND(Msg.wParam) <> Application.Handle then begin
|
|---|
| 1302 | if OneAppInstance then begin
|
|---|
| 1303 | Application.Restore;
|
|---|
| 1304 | CoolTrayIcon1.ShowMainForm;
|
|---|
| 1305 | SetForeGroundWindow(Application.MainForm.Handle);
|
|---|
| 1306 | PostMessage(HWND_BROADCAST, WM_SunriseChatClose, Application.Handle, 0);
|
|---|
| 1307 | end;
|
|---|
| 1308 | end;
|
|---|
| 1309 | Handled := true;
|
|---|
| 1310 | end;
|
|---|
| 1311 | if Msg.Message = WM_SunriseChatClose then begin
|
|---|
| 1312 | if HWND(Msg.wParam) <> Application.Handle then begin
|
|---|
| 1313 | if OneAppInstance then begin
|
|---|
| 1314 | NoSaveToRegistry:= True;
|
|---|
| 1315 | StopProgram:= True;
|
|---|
| 1316 | end;
|
|---|
| 1317 | end;
|
|---|
| 1318 | Handled := true;
|
|---|
| 1319 | end;
|
|---|
| 1320 | end;
|
|---|
| 1321 |
|
|---|
| 1322 | procedure TMainWindow.RichEdit1MouseDown(Sender: TObject;
|
|---|
| 1323 | Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
|---|
| 1324 | begin
|
|---|
| 1325 | SendMessage(HWND_BROADCAST,WM_SunriseChatStart,0,0);
|
|---|
| 1326 | end;
|
|---|
| 1327 |
|
|---|
| 1328 | procedure TMainWindow.RichView1Jump(Sender: TObject; id: Integer);
|
|---|
| 1329 | var
|
|---|
| 1330 | Url: string;
|
|---|
| 1331 | begin
|
|---|
| 1332 | Url := HyperLinks[id];
|
|---|
| 1333 | if Url[1] = '"' then Delete(Url, 1, 1);
|
|---|
| 1334 | if Pos('"', Url) > 0 then Delete(Url, Length(Url), 1);
|
|---|
| 1335 | ShellExecute(Handle, 'open', PChar(Url), nil, nil, SW_SHOWNORMAL);
|
|---|
| 1336 | end;
|
|---|
| 1337 |
|
|---|
| 1338 | procedure TMainWindow.lComboBox1Change(Sender: TObject);
|
|---|
| 1339 | begin
|
|---|
| 1340 | if (ComboBox1.Text = '') and (Length(LastText)>0) then begin
|
|---|
| 1341 | SunriseChatCore.LocalUser.Status:= usOnline;
|
|---|
| 1342 | SunriseChatCore.SendCommand('UserInfo','');
|
|---|
| 1343 | end;
|
|---|
| 1344 | if (Length(ComboBox1.Text)>0) and (Length(LastText)=0) then begin
|
|---|
| 1345 | SunriseChatCore.LocalUser.Status := usWritting;
|
|---|
| 1346 | SunriseChatCore.SendCommand('UserInfo','');
|
|---|
| 1347 | end;
|
|---|
| 1348 | LastText:= ComboBox1.Text;
|
|---|
| 1349 | // if Edit1.Text='' then SunriseChatCore.LocalUser.Status:= usOnline;
|
|---|
| 1350 | end;
|
|---|
| 1351 |
|
|---|
| 1352 | procedure TMainWindow.AddEvent(Name, Text: string; Options: TEventOptions);
|
|---|
| 1353 | begin
|
|---|
| 1354 | SetLength(AppEventsInit,Length(AppEventsInit)+1);
|
|---|
| 1355 | with AppEventsInit[High(AppEventsInit)] do begin
|
|---|
| 1356 | EventName:= Name;
|
|---|
| 1357 | ShowMessage:= eoShowMessage in Options;
|
|---|
| 1358 | MessageText:= Text;
|
|---|
| 1359 | MessageFont:= TFont.Create;
|
|---|
| 1360 | ShowBalloonHint:= eoShowBalloonHint in Options;
|
|---|
| 1361 | ShowAlertIcon:= eoShowAlertIcon in Options;
|
|---|
| 1362 | ShowWindow:= eoShowWindow in Options;
|
|---|
| 1363 | PlayBeep:= eoPlayBeep in Options;
|
|---|
| 1364 | end;
|
|---|
| 1365 | end;
|
|---|
| 1366 |
|
|---|
| 1367 | procedure TMainWindow.SaveAppEventsToRegistry;
|
|---|
| 1368 | var
|
|---|
| 1369 | I: Integer;
|
|---|
| 1370 | begin
|
|---|
| 1371 | for I:= 0 to High(AppEventsOptions) do with AppEvents[I] do begin
|
|---|
| 1372 | MessageFontTemp.Color := MessageFont.Color;
|
|---|
| 1373 | MessageFontTemp.Style:= '';
|
|---|
| 1374 | if fsBold in MessageFont.Style then MessageFontTemp.Style := MessageFontTemp.Style + 'Bold,';
|
|---|
| 1375 | if fsItalic in MessageFont.Style then MessageFontTemp.Style := MessageFontTemp.Style + 'Italic,';
|
|---|
| 1376 | if fsUnderline in MessageFont.Style then MessageFontTemp.Style := MessageFontTemp.Style + 'Underline,';
|
|---|
| 1377 | if fsStrikeOut in MessageFont.Style then MessageFontTemp.Style := MessageFontTemp.Style + 'StrikeOut,';
|
|---|
| 1378 | MessageFontTemp.Charset := MessageFont.Charset;
|
|---|
| 1379 | MessageFontTemp.Size := MessageFont.Size;
|
|---|
| 1380 | MessageFontTemp.Name := MessageFont.Name;
|
|---|
| 1381 |
|
|---|
| 1382 | AppEventsOptions[I].SaveToRegistry;
|
|---|
| 1383 | AppEventsOptions[I].Free;
|
|---|
| 1384 | end;
|
|---|
| 1385 | SetLength(AppEventsOptions,0);
|
|---|
| 1386 | LoadAppEventsFromRegistry;
|
|---|
| 1387 | end;
|
|---|
| 1388 |
|
|---|
| 1389 | procedure TMainWindow.SaveAppUserEventsToRegistry;
|
|---|
| 1390 | var
|
|---|
| 1391 | I: Integer;
|
|---|
| 1392 | Max: Integer;
|
|---|
| 1393 | begin
|
|---|
| 1394 | AppUserEventsCount := Length(AppUserEvents);
|
|---|
| 1395 | Max := High(AppUserEventsOptions);
|
|---|
| 1396 | for I := 0 to Max do begin
|
|---|
| 1397 | if I<Length(AppUserEvents) then AppUserEventsOptions[I].SaveToRegistry;
|
|---|
| 1398 | //AppUserEventsOptions[I].Free;
|
|---|
| 1399 | if Assigned(WaitingDialog) then WaitingDialog.Pozice := I/Max*100;
|
|---|
| 1400 | end;
|
|---|
| 1401 | //SetLength(AppUserEventsOptions,0);
|
|---|
| 1402 | //LoadAppUserEventsFromRegistry;
|
|---|
| 1403 | end;
|
|---|
| 1404 |
|
|---|
| 1405 | procedure TMainWindow.LoadAppEventsFromRegistry;
|
|---|
| 1406 | var
|
|---|
| 1407 | I: Integer;
|
|---|
| 1408 | Text: string;
|
|---|
| 1409 | begin
|
|---|
| 1410 | SetLength(AppEventsOptions,Length(AppEvents));
|
|---|
| 1411 | for I:= 0 to High(AppEventsOptions) do begin
|
|---|
| 1412 | //if not Assigned(AppEventsOptions[I]) then
|
|---|
| 1413 | AppEventsOptions[I]:= TAutoRegistry.Create(RegistryPath+'\'+SettingsName+'\AppEvents\'+IntToStr(I));
|
|---|
| 1414 | with AppEventsOptions[I], AppEvents[I] do begin
|
|---|
| 1415 | Include('ShowWindow',ShowWindow,ShowWindow);
|
|---|
| 1416 | Include('ShowAlertIcon',ShowAlertIcon,ShowAlertIcon);
|
|---|
| 1417 | Include('ShowBaloonHint',ShowBalloonHint,ShowBalloonHint);
|
|---|
| 1418 | Include('PlayBeep',PlayBeep,PlayBeep);
|
|---|
| 1419 | Include('PlaySound',PlaySound,PlaySound);
|
|---|
| 1420 | Include('SoundFile',SoundFile,'');
|
|---|
| 1421 | Include('ExecuteApplication',ExecuteApplication,False);
|
|---|
| 1422 | Include('ApplicationFile',ApplicationFile,'');
|
|---|
| 1423 | Include('ShowMessage',ShowMessage,ShowMessage);
|
|---|
| 1424 | Include('MessageText',MessageText,MessageText);
|
|---|
| 1425 | Include('IconFile',IconFile,'Envelope.ico');
|
|---|
| 1426 | // Font
|
|---|
| 1427 | Include('FontColor',MessageFontTemp.Color,Integer(clBlack));
|
|---|
| 1428 | Include('FontStyle',MessageFontTemp.Style,'');
|
|---|
| 1429 | Include('FontCharset',MessageFontTemp.Charset,1);
|
|---|
| 1430 | Include('FontSize', MessageFontTemp.Size, 8);
|
|---|
| 1431 | Include('FontName', MessageFontTemp.Name, 'MS Sans Serif');
|
|---|
| 1432 | LoadFromRegistry;
|
|---|
| 1433 | MessageFont.Color := MessageFontTemp.Color;
|
|---|
| 1434 | while Pos(',', MessageFontTemp.Style)>0 do begin
|
|---|
| 1435 | Text:= Copy(MessageFontTemp.Style, 1, Pos(',', MessageFontTemp.Style)-1);
|
|---|
| 1436 | System.Delete(MessageFontTemp.Style, 1, Length(Text)+1);
|
|---|
| 1437 | if Text = 'Bold' then MessageFont.Style := MessageFont.Style + [fsBold];
|
|---|
| 1438 | if Text = 'Italic' then MessageFont.Style := MessageFont.Style + [fsItalic];
|
|---|
| 1439 | if Text = 'Underline' then MessageFont.Style := MessageFont.Style + [fsUnderline];
|
|---|
| 1440 | if Text = 'StrikeOut' then MessageFont.Style := MessageFont.Style + [fsStrikeOut];
|
|---|
| 1441 | end;
|
|---|
| 1442 | MessageFont.Charset := MessageFontTemp.Charset;
|
|---|
| 1443 | MessageFont.Size := MessageFontTemp.Size;
|
|---|
| 1444 | MessageFont.Name := MessageFontTemp.Name;
|
|---|
| 1445 | end;
|
|---|
| 1446 | end;
|
|---|
| 1447 | end;
|
|---|
| 1448 |
|
|---|
| 1449 | procedure TMainWindow.LoadAppUserEventsFromRegistry(UpdateOnly: Boolean = False);
|
|---|
| 1450 | var
|
|---|
| 1451 | I: Integer;
|
|---|
| 1452 | begin
|
|---|
| 1453 | SetLength(AppUserEventsOptions, AppUserEventsCount);
|
|---|
| 1454 | SetLength(AppUserEvents, AppUserEventsCount);
|
|---|
| 1455 | for I := 0 to AppUserEventsCount-1 do begin
|
|---|
| 1456 | //if not Assigned(AppEventsOptions[I]) then
|
|---|
| 1457 | AppUserEventsOptions[I] := TAutoRegistry.Create(RegistryPath+'\'+SettingsName+'\AppUserEvents\'+IntToStr(I));
|
|---|
| 1458 | with AppUserEventsOptions[I], AppUserEvents[I] do begin
|
|---|
| 1459 | Update := UpdateOnly;
|
|---|
| 1460 | Include('ConditionTextEnable', ConditionTextEnable, ConditionTextEnable);
|
|---|
| 1461 | Include('ConditionText', ConditionText, ConditionText);
|
|---|
| 1462 | Include('ConditionUserEnable', ConditionUserEnable, ConditionUserEnable);
|
|---|
| 1463 | Include('ConditionUser', ConditionUser, ConditionUser);
|
|---|
| 1464 | Include('ConditionAppEventEnable', ConditionAppEventEnable,ConditionAppEventEnable);
|
|---|
| 1465 | Include('ConditionAppEvent',ConditionAppEvent,ConditionAppEvent);
|
|---|
| 1466 | Include('ShowWindow',ShowWindow,ShowWindow);
|
|---|
| 1467 | Include('ShowAlertIcon',ShowAlertIcon,ShowAlertIcon);
|
|---|
| 1468 | Include('IconFile',IconFile,'Envelope.ico');
|
|---|
| 1469 | Include('ShowBaloonHint',ShowBalloonHint,ShowBalloonHint);
|
|---|
| 1470 | Include('PlayBeep',PlayBeep,PlayBeep);
|
|---|
| 1471 | Include('PlaySound',PlaySound,PlaySound);
|
|---|
| 1472 | Include('SoundFile',SoundFile,'');
|
|---|
| 1473 | Include('ExecuteApplication',ExecuteApplication,False);
|
|---|
| 1474 | Include('ApplicationFile',ApplicationFile,'');
|
|---|
| 1475 | Include('ShowImage',ShowImage,ShowImage);
|
|---|
| 1476 | Include('ImageFile',ImageFile,ImageFile);
|
|---|
| 1477 | Include('EventName',EventName,EventName);
|
|---|
| 1478 | LoadFromRegistry;
|
|---|
| 1479 | end;
|
|---|
| 1480 | if Assigned(WaitingDialog) then WaitingDialog.Pozice := I/AppUserEventsCount*100;
|
|---|
| 1481 | end;
|
|---|
| 1482 | end;
|
|---|
| 1483 |
|
|---|
| 1484 | procedure TMainWindow.RefreshAppTitle;
|
|---|
| 1485 | var
|
|---|
| 1486 | NewCaption: string;
|
|---|
| 1487 | Settings: string;
|
|---|
| 1488 | begin
|
|---|
| 1489 | if SettingsName = 'Default' then Settings:= '' else Settings:= '('+SettingsName+')';
|
|---|
| 1490 | if SunriseChatCore.Connected then NewCaption:= '' else NewCaption:= ' (Offline)';
|
|---|
| 1491 | Caption:= ApplicationName+Settings+' - '+SunriseChatCore.LocalUser.Nick+NewCaption;
|
|---|
| 1492 | end;
|
|---|
| 1493 |
|
|---|
| 1494 | procedure TMainWindow.ListView1InfoTip(Sender: TObject; Item: TListItem;
|
|---|
| 1495 | var InfoTip: String);
|
|---|
| 1496 | begin
|
|---|
| 1497 | InfoTip:= SunriseChatCore.UserList[Item.Index].DetailInfo;
|
|---|
| 1498 | end;
|
|---|
| 1499 |
|
|---|
| 1500 | procedure TMainWindow.ActionCreateRoomExecute(Sender: TObject);
|
|---|
| 1501 | begin
|
|---|
| 1502 | NewRoom.ShowModal;
|
|---|
| 1503 | end;
|
|---|
| 1504 |
|
|---|
| 1505 | procedure TMainWindow.Doplnitjmno1Click(Sender: TObject);
|
|---|
| 1506 | begin
|
|---|
| 1507 | //if Pos(':',ComboBox1.Text) = 0 then
|
|---|
| 1508 | DoplnitJmeno;
|
|---|
| 1509 | ComboBox1.SelStart:= ComboBox1.SelStart + 1;
|
|---|
| 1510 | end;
|
|---|
| 1511 |
|
|---|
| 1512 | procedure TMainWindow.SearchFind1FindDialogFind(Sender: TObject);
|
|---|
| 1513 | //var
|
|---|
| 1514 | // FoundAt: LongInt;
|
|---|
| 1515 | // StartPos, ToEnd: Integer;
|
|---|
| 1516 | // STypes: TSearchTypes;
|
|---|
| 1517 | begin
|
|---|
| 1518 | (*
|
|---|
| 1519 | with SearchFind1, RichEdit1 do begin
|
|---|
| 1520 | if frWholeWord in Dialog.Options then STypes := STypes + [stWholeWord];
|
|---|
| 1521 | if frMatchCase in Dialog.Options then STypes := STypes + [stMatchCase];
|
|---|
| 1522 | if SelLength <> 0 then StartPos := SelStart + SelLength
|
|---|
| 1523 | else StartPos := 0;
|
|---|
| 1524 | ToEnd := Length(Text) - StartPos;
|
|---|
| 1525 | FoundAt := FindText(Dialog.FindText, StartPos, ToEnd, Stypes);
|
|---|
| 1526 | if FoundAt <> -1 then begin
|
|---|
| 1527 | SetFocus;
|
|---|
| 1528 | SelStart := FoundAt;
|
|---|
| 1529 | SelLength := Length(Dialog.FindText);
|
|---|
| 1530 | end else ShowMessage(Dialog.FindText+' nelze najít');
|
|---|
| 1531 | end;
|
|---|
| 1532 | *)
|
|---|
| 1533 | end;
|
|---|
| 1534 |
|
|---|
| 1535 | procedure TMainWindow.SearchFind1BeforeExecute(Sender: TObject);
|
|---|
| 1536 | begin
|
|---|
| 1537 | SearchFind1.Dialog.Options:= [frHideUpDown];
|
|---|
| 1538 | end;
|
|---|
| 1539 |
|
|---|
| 1540 | procedure TMainWindow.ActionClearMessageListExecute(Sender: TObject);
|
|---|
| 1541 | var
|
|---|
| 1542 | I: Integer;
|
|---|
| 1543 | begin
|
|---|
| 1544 | with SunriseChatCore do begin
|
|---|
| 1545 | for I:= 0 to RoomList[ActiveRoomIndex].Count-1 do
|
|---|
| 1546 | RoomList[ActiveRoomIndex].Lines[I].Font.Free;
|
|---|
| 1547 | RoomList[ActiveRoomIndex].Count:= 0;
|
|---|
| 1548 | TabControl1Change(Self);
|
|---|
| 1549 | end;
|
|---|
| 1550 | end;
|
|---|
| 1551 |
|
|---|
| 1552 | procedure TMainWindow.InitSettings;
|
|---|
| 1553 | var
|
|---|
| 1554 | I: Integer;
|
|---|
| 1555 | begin
|
|---|
| 1556 | with Options, SunriseChatCore do begin
|
|---|
| 1557 | Include('UserEventsImagesEnabled', UserEventsImagesEnabled, True);
|
|---|
| 1558 | Include('ShowRightToolBar', ShowRightToolBar, True);
|
|---|
| 1559 | Include('MinimalizeOnCloseWindow', MinimalizeOnCloseWindow, False);
|
|---|
| 1560 | Include('DefaultReason', DefaultReason, 'Jsem pryč');
|
|---|
| 1561 | Include('NoResloveHostName', NoResloveHostName, False);
|
|---|
| 1562 | Include('ShowMainMenu', ShowMainMenu, True);
|
|---|
| 1563 | MainMenu1.Items.Visible:= ShowMainMenu;
|
|---|
| 1564 | Include('ShowMessageTime', ShowMessageTime, False);
|
|---|
| 1565 | Include('AlphaBlend', AlphaBlendWindow, 255);
|
|---|
| 1566 | Include('UserListWidth', UserListWidth, 100);
|
|---|
| 1567 | Include('ShowOnMessage', ShowOnMessage, False);
|
|---|
| 1568 | Include('ShowBallonHint', ShowBallonHint, False);
|
|---|
| 1569 | Include('OnTop', OnTop, False);
|
|---|
| 1570 | Include('RunOnLogon', RunOnLogon, True);
|
|---|
| 1571 | Include('StartInTray', StartInTray, False);
|
|---|
| 1572 | Include('MinimizeToTray', MinimizeToTray, True);
|
|---|
| 1573 | Include('ServiceFunction',ServiceFunction,False);
|
|---|
| 1574 | Include('Nick',LocalUser.Nick,'Host');
|
|---|
| 1575 | Include('DetailInfo',LocalUser.DetailInfo,'');
|
|---|
| 1576 | LocalUser.NickTime:= Now;
|
|---|
| 1577 | Include('Color',LocalUser.Color,0);
|
|---|
| 1578 | Include('SnapWindow',SnapWindow,True);
|
|---|
| 1579 | Include('Port',NetworkPort,55556);
|
|---|
| 1580 | Include('NetworkInterfaceGUID',NetworkInterface,'');
|
|---|
| 1581 | Include('PositionX',PositionX,Left);
|
|---|
| 1582 | if (PositionX < 0) or (PositionX > Screen.Width) then PositionX := 0;
|
|---|
| 1583 | Include('PositionY',PositionY,Top);
|
|---|
| 1584 | if (PositionY < 0) or (PositionY > Screen.Height) then PositionY := 0;
|
|---|
| 1585 | Include('SizeX',SizeX,Width);
|
|---|
| 1586 | Include('SizeY',SizeY,Height);
|
|---|
| 1587 | Include('WindowState',LastWindowState,Integer(fsNormal));
|
|---|
| 1588 | Include('AutoAwayIdleTime',AutoAwayIdleTime,5);
|
|---|
| 1589 | Include('PauseScrollText',PauseScrollText,False);
|
|---|
| 1590 | Include('SoundDisable',SoundDisable,False);
|
|---|
| 1591 | Include('OneAppInstance',OneAppInstance,True);
|
|---|
| 1592 | Include('MaxNumberOfRoomLines',MaxNumberOfRoomLines,100);
|
|---|
| 1593 | Include('AutoChangeWindowHeight',AutoChangeWindowHeight,False);
|
|---|
| 1594 | Include('AutoChangeWindowHeightDirectionDown',AutoChangeWindowHeightDirectionDown,False);
|
|---|
| 1595 | Include('MinimumVisibleUsersCount',MinimumVisibleUsersCount,8);
|
|---|
| 1596 | Include('PingTimeout',PingTimeout, 200);
|
|---|
| 1597 | Include('LanguageIndex', LanguageIndex, 0);
|
|---|
| 1598 | Include('InvisibledOnStart', InvisibledOnStart, False);
|
|---|
| 1599 | Include('AutoChangeInfoWindowHeight', AutoChangeInfoWindowHeight, True);
|
|---|
| 1600 | Include('AppUserEventsCount', AppUserEventsCount, 0);
|
|---|
| 1601 | Include('FirstStart', FirstStart, True);
|
|---|
| 1602 | Include('BroadcastType', BroadcastTypeI, 0);
|
|---|
| 1603 | Include('SoundVolume', SoundVolume, 1000);
|
|---|
| 1604 | LoadFromRegistry;
|
|---|
| 1605 | MPSetVolume(MediaPlayer1, SoundVolume);
|
|---|
| 1606 | SunriseChatCore.BroadcastType := TBroadcastType(BroadcastTypeI);
|
|---|
| 1607 | if InvisibledOnStart then ActionInvisibleExecute(Self) else ActionOnlineExecute(Self);
|
|---|
| 1608 | Localization.Activate(LanguageIndex);
|
|---|
| 1609 | SunriseChatCore.MaxRoomLines := MaxNumberOfRoomLines;
|
|---|
| 1610 | MainWindow.ScreenSnap := SnapWindow;
|
|---|
| 1611 | ToolButton1.Down := PauseScrollText;
|
|---|
| 1612 | ToolButton4.Down := SoundDisable;
|
|---|
| 1613 | ToolButton5.Down := OnTop;
|
|---|
| 1614 | Left := PositionX;
|
|---|
| 1615 | Top := PositionY;
|
|---|
| 1616 | Width := SizeX;
|
|---|
| 1617 | Height := SizeY;
|
|---|
| 1618 | WindowState := TWindowState(LastWindowState);
|
|---|
| 1619 | Panel2.Width := UserListWidth;
|
|---|
| 1620 | AlphaBlendValue := AlphaBlendWindow;
|
|---|
| 1621 | AlphaBlend := AlphaBlendValue < 255;
|
|---|
| 1622 |
|
|---|
| 1623 | // Initialisation of Events
|
|---|
| 1624 | AddEvent('Běžná zpráva', '<%0:s> %1:s', [eoShowMessage, eoPlayBeep, eoShowAlertIcon]);
|
|---|
| 1625 | AddEvent('Osobní zpráva', '<%0:s> %1:s', [eoShowMessage, eoPlayBeep, eoShowAlertIcon, eoShowBalloonHint]);
|
|---|
| 1626 | AddEvent('Uživatel se připojil', 'Uživatel %0:s se připojil z počítače %1:s', [eoShowMessage]);
|
|---|
| 1627 | AddEvent('Uživatel se odpojil', 'Uživatel %s se odpojil', [eoShowMessage]);
|
|---|
| 1628 | AddEvent('Uživatel obnoven', 'Uživatel %s obnoven', []);
|
|---|
| 1629 | AddEvent('Uživatel zmizel', 'Uživatel %s zmizel', []);
|
|---|
| 1630 | AddEvent('Uživatel odešel', 'Uživatel %0:s odešel: %1:s', [eoShowMessage]);
|
|---|
| 1631 | AddEvent('Uživatel se vrátil', 'Uživatel %s se vrátil', []);
|
|---|
| 1632 | AddEvent('Odeslání výzvy', 'Výzva uživateli %s byla odeslána', [eoShowMessage]);
|
|---|
| 1633 | AddEvent('Přijetí výzvy', 'Uživatel %s vás vyzval', [eoShowMessage, eoShowWindow, eoPlayBeep]);
|
|---|
| 1634 | AddEvent('Test odezvy', 'Odezva uživateli %s byla odeslána', [eoShowMessage]);
|
|---|
| 1635 | AddEvent('Přijetí odezvy', 'Odezva od uživatele %0:s přijata za %1:s sekund', [eoShowMessage]);
|
|---|
| 1636 | AddEvent('Změna jména uživatele', 'Uživatel %0:s se přejmenoval na %1:s', [eoShowMessage]);
|
|---|
| 1637 | AddEvent('Změna jména při konfliktu', 'Došlo ke konfliktu jmen. Měním vaše jméno na %s', [eoShowMessage]);
|
|---|
| 1638 | AddEvent('Vytvoření místnosti', 'Uživatel %0:s vytvořil místnost %1:s', [eoShowMessage]);
|
|---|
| 1639 | AddEvent('Opuštění místnosti', 'Uživatel %0:s opustil místnosti %1:s', [eoShowMessage]);
|
|---|
| 1640 | AddEvent('Uživatel automaticky odešel', 'Uživatel %0:s automaticky odešel po %1:s minutách nečinnosti', []);
|
|---|
| 1641 | AddEvent('Uživatel se automaticky vrátil', 'Uživatel %0:s se automaticky vrátil po %1:s minutách', []);
|
|---|
| 1642 | AddEvent('Celé hodiny', 'Je %0:d hodin', []);
|
|---|
| 1643 | AddEvent('Start aplikace', 'Vítá tě '+ApplicationName+'!', [eoShowMessage]);
|
|---|
| 1644 | SetLength(AppEvents,Length(AppEventsInit));
|
|---|
| 1645 | for I:= 0 to High(AppEventsInit) do
|
|---|
| 1646 | AppEvents[I]:= AppEventsInit[I];
|
|---|
| 1647 | SetLength(AppEventsInit,0);
|
|---|
| 1648 | LoadAppEventsFromRegistry;
|
|---|
| 1649 |
|
|---|
| 1650 | LoadAppUserEventsFromRegistry;
|
|---|
| 1651 | ReloadImages;
|
|---|
| 1652 |
|
|---|
| 1653 | CoolTrayIcon1.Hint:= ApplicationName;
|
|---|
| 1654 | if OnTop then FormStyle:= fsStayOnTop else FormStyle:= fsNormal;
|
|---|
| 1655 | InitTrayIcon;
|
|---|
| 1656 | ChangeRunOnLogon;
|
|---|
| 1657 | Panel5.Visible:= ShowRightToolBar;
|
|---|
| 1658 | Panel2.Visible:= False;
|
|---|
| 1659 | Panel2.Visible:= True;
|
|---|
| 1660 | end;
|
|---|
| 1661 | end;
|
|---|
| 1662 |
|
|---|
| 1663 | procedure TMainWindow.ComboBox1Change(Sender: TObject);
|
|---|
| 1664 | begin
|
|---|
| 1665 | lComboBox1Change(Self);
|
|---|
| 1666 | end;
|
|---|
| 1667 |
|
|---|
| 1668 | procedure TMainWindow.FillComboBox;
|
|---|
| 1669 | var
|
|---|
| 1670 | I: Integer;
|
|---|
| 1671 | begin
|
|---|
| 1672 | ComboBox1.Style:= csDropDown;
|
|---|
| 1673 | with SunriseChatCore, ComboBox1.Items do begin
|
|---|
| 1674 | BeginUpdate;
|
|---|
| 1675 | Clear;
|
|---|
| 1676 | for I:= 0 to High(UserList) do with UserList[I] do begin
|
|---|
| 1677 | if Copy(Nick,1,Length(ComboBox1.Text)) = ComboBox1.Text then Add(Nick+': ');
|
|---|
| 1678 | end;
|
|---|
| 1679 | Update;
|
|---|
| 1680 | EndUpdate;
|
|---|
| 1681 | if ComboBox1.Items.Count>0 then ComboBox1.DroppedDown:= True;
|
|---|
| 1682 | end;
|
|---|
| 1683 | end;
|
|---|
| 1684 |
|
|---|
| 1685 | procedure TMainWindow.ActionChangeLogExecute(Sender: TObject);
|
|---|
| 1686 | begin
|
|---|
| 1687 | ShellLaunch(ChangeLogFile);
|
|---|
| 1688 | end;
|
|---|
| 1689 |
|
|---|
| 1690 | procedure TMainWindow.ComboBox1DropDown(Sender: TObject);
|
|---|
| 1691 | begin
|
|---|
| 1692 | ComboBox1.Style:= csSimple;
|
|---|
| 1693 | end;
|
|---|
| 1694 |
|
|---|
| 1695 | procedure TMainWindow.ComboBox1CloseUp(Sender: TObject);
|
|---|
| 1696 | begin
|
|---|
| 1697 | ComboBox1.Style:= csSimple;
|
|---|
| 1698 | ComboBox1.SelStart:= -1;
|
|---|
| 1699 | end;
|
|---|
| 1700 |
|
|---|
| 1701 | procedure TMainWindow.FormResize(Sender: TObject);
|
|---|
| 1702 | begin
|
|---|
| 1703 | ScrollDownRichEdit1;
|
|---|
| 1704 | end;
|
|---|
| 1705 |
|
|---|
| 1706 | procedure TMainWindow.ReloadImages;
|
|---|
| 1707 | var
|
|---|
| 1708 | I: Integer;
|
|---|
| 1709 | begin
|
|---|
| 1710 | RichView1.Clear;
|
|---|
| 1711 | for I:= 0 to High(AppUserEvents) do
|
|---|
| 1712 | if Assigned(AppUserEvents[I].Image) then FreeAndNil(AppUserEvents[I].Image);
|
|---|
| 1713 | TabControl1Change(Self);
|
|---|
| 1714 | (*
|
|---|
| 1715 | for I:= 0 to High(AppUserEvents) do
|
|---|
| 1716 | with AppUserEvents[I] do begin
|
|---|
| 1717 | if not Assigned(Image) then Image:= TImage.Create(Self);
|
|---|
| 1718 | if FileExists(ImageFile) then
|
|---|
| 1719 | Image.Picture.LoadFromFile(ImageFile);
|
|---|
| 1720 | end;
|
|---|
| 1721 | RichView1.Paint;
|
|---|
| 1722 | *)
|
|---|
| 1723 | end;
|
|---|
| 1724 |
|
|---|
| 1725 | procedure TMainWindow.ActionUserEventsListExecute(Sender: TObject);
|
|---|
| 1726 | var
|
|---|
| 1727 | I: Integer;
|
|---|
| 1728 | StringList: TStringList;
|
|---|
| 1729 | begin
|
|---|
| 1730 | ComboBox1.Style := csDropDown;
|
|---|
| 1731 | StringList := TStringList.Create;
|
|---|
| 1732 | try
|
|---|
| 1733 | with SunriseChatCore, StringList do begin
|
|---|
| 1734 | BeginUpdate;
|
|---|
| 1735 | for I := 0 to High(AppUserEvents) do with AppUserEvents[I] do begin
|
|---|
| 1736 | Add(ComboBox1.Text+EventName);
|
|---|
| 1737 | end;
|
|---|
| 1738 | Sort;
|
|---|
| 1739 | EndUpdate;
|
|---|
| 1740 | end;
|
|---|
| 1741 | with SunriseChatCore, ComboBox1, Items do begin
|
|---|
| 1742 | BeginUpdate;
|
|---|
| 1743 | Clear;
|
|---|
| 1744 | AddStrings(StringList);
|
|---|
| 1745 | if Count>0 then DroppedDown:= True;
|
|---|
| 1746 | Update;
|
|---|
| 1747 | EndUpdate;
|
|---|
| 1748 | end;
|
|---|
| 1749 | finally
|
|---|
| 1750 | StringList.Free;
|
|---|
| 1751 | end;
|
|---|
| 1752 | end;
|
|---|
| 1753 |
|
|---|
| 1754 | procedure TMainWindow.ToolButton6Click(Sender: TObject);
|
|---|
| 1755 | begin
|
|---|
| 1756 | // ToolButton6.Marked := not ToolButton6.Marked;
|
|---|
| 1757 | ToolButton6.Repaint;
|
|---|
| 1758 | UserEventsImagesEnabled := not ToolButton6.Down;
|
|---|
| 1759 | TabControl1Change(Self);
|
|---|
| 1760 | end;
|
|---|
| 1761 |
|
|---|
| 1762 | procedure TMainWindow.Panel6Resize(Sender: TObject);
|
|---|
| 1763 | begin
|
|---|
| 1764 | RichView1.Width := Panel6.Width - 2;
|
|---|
| 1765 | RichView1.Height := Panel6.Height - 2;
|
|---|
| 1766 | end;
|
|---|
| 1767 |
|
|---|
| 1768 | end.
|
|---|
| 1769 |
|
|---|