Вчера увидел на форуме UniGUI интересное приложение, написанное одним из участников из Бразилии, выглядит оно вот так…
То есть, по сути, это рабочий стол в браузере – на мой взгляд, интересный вариант интерфейса для веб-программ. Посмотрел исходный код – ничего сложного, полностью написано на Delphi UniGUI.
Единственное, что пришлось поправить, это номер версии ExtJS, по аналогии с постом на форуме. Так как автор писал на предыдущей версии UniGUI.
Исходники
Download (Desktop3)
Код модуля Main
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
unit Main; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uniGUITypes, uniGUIAbstractClasses, uniGUIClasses, uniGUIForm, uniGUIBaseClasses, uniButton, uniLabel, uniPanel, jpeg, uniImage, uniTimer, uniSpeedButton, uniBitBtn, uniToolBar, uniImageList, uniEdit, uniMultiItem, uniListBox, uStartMenu, Vcl.Imaging.pngimage,uniGUIRegClasses; type TMainForm = class(TUniForm) pnlBackground: TUniPanel; UniImage1: TUniImage; UniTimer1: TUniTimer; imgForm1: TUniImage; lblForm1: TUniLabel; TaskPanel: TUniPanel; TimePanel: TUniPanel; UniPanel5: TUniPanel; ToolbarTasks: TUniToolBar; btnStart: TUniSpeedButton; imgForm3: TUniImage; lblForm3: TUniLabel; btnMinimizeAll: TUniBitBtn; imgForm2: TUniImage; lblForm2: TUniLabel; procedure UniTimer1Timer(Sender: TObject); function AddButtonFooter(Form: TUniForm): TUniSpeedButton; procedure ClickButtonFooter(Sender: TObject); procedure OpenWindowClassName(Sender: TObject; Name: String); procedure UniFormCloseAll(Sender: TObject; var Action: TCloseAction); function CloseWindow(Form: TUniForm): boolean; procedure UniImage1Click(Sender: TObject); procedure StartListClick(Sender: TObject); procedure btnStartClick(Sender: TObject); procedure imgForm1Click(Sender: TObject); procedure CreateWindow(Form: TUniForm; FormCaption: string; FormHint: string); procedure imgForm3Click(Sender: TObject); function IsWindowOpen(Form: TUniForm): boolean; procedure MinimizeAllWindows; procedure btnMinimizeAllClick(Sender: TObject); procedure UpAllButtons; procedure UniFormScreenResize(Sender: TObject; AWidth, AHeight: Integer); procedure UniFormShow(Sender: TObject); procedure imgForm2Click(Sender: TObject); private { Private declarations } public { Public declarations } ScreenWidth: Integer; ScreenHeight: Integer; end; function MainForm: TMainForm; var frmStart: TfrmStartMenu; implementation {$R *.dfm} uses uniGUIVars, MainModule, uniGUIApplication, uForm1, uForm2, uForm3; function MainForm: TMainForm; begin Result := TMainForm(UniMainModule.GetFormInstance(TMainForm)); end; function TMainForm.AddButtonFooter(Form: TUniForm): TUniSpeedButton; var ButtonFooter: TUniSpeedButton; Bitmap : TBitmap; begin UpAllButtons; Bitmap := TBitmap.Create; Bitmap.Width :=16; Bitmap.Height :=16; Bitmap.Canvas.Draw(0, 0, Form.Icon); ButtonFooter := TUniSpeedButton.Create(ToolbarTasks); with ButtonFooter do begin Name := 'Button_' + Form.Name; Parent := ToolbarTasks; Width:=146; Caption:=Name+' Файловый менеджер'; Caption:=Copy(Caption,1,18)+'...'; Hint := Name; ShowHint := True; Glyph:=Bitmap; OnClick := ClickButtonFooter; GroupIndex := 1; AllowAllUp := True; Down := True; end; Bitmap.Free; end; procedure TMainForm.btnMinimizeAllClick(Sender: TObject); begin MinimizeAllWindows; end; procedure TMainForm.OpenWindowClassName(Sender: TObject; Name: String); var Window: TDesktopWindow; Form: TUniForm; Button:TUniSpeedButton; begin for Window in UniMainModule.ListWindows do begin if Window.Name = Name then begin if TUniSpeedButton(ToolbarTasks.FindComponent('Button_'+Name)).Down=False then Window.Window.Hide else Window.Window.Show; Break; end; end; end; procedure TMainForm.ClickButtonFooter(Sender: TObject); var ClassName: String; begin frmStart.Hide; ClassName := (Sender as TUniSpeedButton).Name; ClassName := StringReplace(ClassName, 'Button_', '',[rfReplaceAll, rfIgnoreCase]); OpenWindowClassName(Sender, ClassName); end; function TMainForm.CloseWindow(Form: TUniForm): boolean; var window: TDesktopWindow; begin for Window in UniMainModule.ListWindows do begin if Window.Name = Form.Name then begin TUniSpeedButton(ToolbarTasks.FindComponent('Button_'+Form.Name)).Free; UniMainModule.ListWindows.Remove(window); break; end; end; end; function TMainForm.IsWindowOpen(Form: TUniForm): boolean; var window: TDesktopWindow; begin Result := False; for Window in UniMainModule.ListWindows do begin if Window.Name = Form.Name then begin Result := True; Break; end; end; end; procedure TMainForm.CreateWindow(Form: TUniForm; FormCaption: string; FormHint: string); var Window: TDesktopWindow; ButtonFooter: TUniSpeedButton; i: Integer; Bitmap : TBitmap; begin frmStart.Hide; UpAllButtons; if IsWindowOpen(Form)=False then begin Window := TDesktopWindow.Create; Window.Window := Form; Window.Name := Form.Name; Window.Window.Caption:=FormCaption; Window.Window.OnClose := UniFormCloseAll; UniMainModule.ListWindows.Add(Window); Bitmap := TBitmap.Create; Bitmap.Width :=16; Bitmap.Height :=16; Bitmap.Canvas.Draw(0, 0, Form.Icon); ButtonFooter := TUniSpeedButton.Create(ToolbarTasks); with ButtonFooter do begin Name := 'Button_' + Form.Name; Parent := ToolbarTasks; Width:=146; Caption:=Copy(FormCaption,1,18)+'...'; Hint := FormHint; ShowHint := True; Glyph:=Bitmap; OnClick := ClickButtonFooter; GroupIndex := 1; AllowAllUp := True; Down := True; end; Bitmap.Free; end; Form.Show; end; procedure TMainForm.UpAllButtons; var i: Integer; begin for i := 0 to ToolbarTasks.ComponentCount - 1 do begin if ToolbarTasks.Components[i] is TUniSpeedButton then (ToolbarTasks.Components[i] as TUniSpeedButton).Down := False; end; end; procedure TMainForm.MinimizeAllWindows; var Window: TDesktopWindow; Name: String; begin for Window in UniMainModule.ListWindows do begin Name := StringReplace(Window.Window.WebForm.JSWindow.Id, '_id', '',[rfReplaceAll] + [rfIgnoreCase]); Window.Window.WebForm.Hide; end; UpAllButtons; end; procedure TMainForm.imgForm3Click(Sender: TObject); var frm: TForm3; begin frm:=TForm3.Create(UniApplication); CreateWindow(frm, 'This is Program #3', 'This is Hint Program #3'); end; procedure TMainForm.imgForm1Click(Sender: TObject); begin CreateWindow(Form1, 'This is Program #1', 'This is Hint Program #1'); end; procedure TMainForm.imgForm2Click(Sender: TObject); begin CreateWindow(Form2, 'This is Program #2', 'This is Hint Program #2'); end; procedure TMainForm.UniFormCloseAll(Sender: TObject; var Action: TCloseAction); var Form: TUniForm; begin Form := (Sender as TUniForm); CloseWindow(Form); end; procedure TMainForm.UniFormScreenResize(Sender: TObject; AWidth, AHeight: Integer); begin ScreenWidth:=AWidth; ScreenHeight:=AHeight; frmStart.Hide; end; procedure TMainForm.UniFormShow(Sender: TObject); begin frmStart:=TfrmStartMenu.Create(UniApplication); frmStart.Left:=1; frmStart.Top:=MainForm.ScreenHeight-MainForm.TaskPanel.Height-Height-1; frmStart.Show; frmStart.Hide; end; procedure TMainForm.UniImage1Click(Sender: TObject); begin frmStart.Hide; end; procedure TMainForm.StartListClick(Sender: TObject); begin frmStart.Hide; end; procedure TMainForm.btnStartClick(Sender: TObject); begin if frmStart.Visible=False then frmStart.Show else frmStart.Hide; end; procedure SetPanelRoundBorders(const APanel: TUniPanel; APixels: Integer = 5); begin APanel.ClientEvents.ExtEvents.Add ('OnAfterrender=function OnAfterrender(sender){' + 'sender.body.applyStyles('#39'border-radius:' + IntToStr(APixels) + 'px'#39');}'); end; procedure TMainForm.UniTimer1Timer(Sender: TObject); begin TimePanel.Caption:=TimeToStr(Now); end; initialization RegisterMainFormClass(TMainForm); end. |