Changeset 6 for trunk/Forms/UMainForm.pas
- Timestamp:
- Dec 25, 2010, 9:31:21 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UMainForm.pas
r5 r6 21 21 22 22 TMainForm = class(TForm) 23 AToggleFullscreen: TAction; 24 AExit: TAction; 23 25 AObjectEdit: TAction; 24 26 AObjectDelete: TAction; … … 38 40 Label2: TLabel; 39 41 ListView1: TListView; 42 MainMenu1: TMainMenu; 40 43 MenuItem1: TMenuItem; 41 44 MenuItem10: TMenuItem; 45 MenuItem11: TMenuItem; 46 MenuItem12: TMenuItem; 47 MenuItem13: TMenuItem; 48 MenuItem14: TMenuItem; 49 MenuItem15: TMenuItem; 42 50 MenuItem2: TMenuItem; 43 51 MenuItem3: TMenuItem; … … 55 63 Splitter1: TSplitter; 56 64 TreeView1: TTreeView; 65 procedure AExitExecute(Sender: TObject); 57 66 procedure AItemAddExecute(Sender: TObject); 58 67 procedure AItemEditExecute(Sender: TObject); … … 61 70 procedure AObjectGroupAddGroupExecute(Sender: TObject); 62 71 procedure AObjectGroupEditExecute(Sender: TObject); 72 procedure AToggleFullscreenExecute(Sender: TObject); 63 73 procedure ButtonAddClick(Sender: TObject); 64 74 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); … … 73 83 procedure TreeView1Change(Sender: TObject; Node: TTreeNode); 74 84 private 85 OriginalBounds: TRect; 86 OriginalWindowState: TWindowState; 87 ScreenBounds: TRect; 75 88 procedure LoadConfiguration; 76 89 public … … 103 116 I3: Integer; 104 117 begin 105 if FileExists(ConfigFileName) then begin118 if FileExists(ConfigFileName) then try 106 119 ReadXMLFile(Config, ConfigFileName); 107 120 for I1 := 0 to Config.ChildNodes.Count - 1 do … … 124 137 end; 125 138 end; 126 Config.Destroy; 139 finally 140 Config.Free; 127 141 end; 128 142 end; … … 139 153 procedure TMainForm.FormDestroy(Sender: TObject); 140 154 begin 141 TreeState. Destroy;142 Database. Destroy;143 PersistentForm. Destroy;155 TreeState.Free; 156 Database.Free; 157 PersistentForm.Free; 144 158 end; 145 159 … … 182 196 end; 183 197 198 procedure TMainForm.AToggleFullscreenExecute(Sender: TObject); 199 begin 200 if BorderStyle <> bsNone then begin 201 // To full screen 202 OriginalWindowState := WindowState; 203 OriginalBounds := BoundsRect; 204 205 BorderStyle := bsNone; 206 ScreenBounds := Screen.MonitorFromWindow(Handle).BoundsRect; 207 with ScreenBounds do 208 SetBounds(Left, Top, Right - Left, Bottom - Top) ; 209 end else begin 210 // From full screen 211 {$IFDEF MSWINDOWS} 212 BorderStyle := bsSizeable; 213 {$ENDIF} 214 if OriginalWindowState = wsMaximized then 215 WindowState := wsMaximized 216 else 217 with OriginalBounds do 218 SetBounds(Left, Top, Right - Left, Bottom - Top) ; 219 {$IFDEF LINUX} 220 BorderStyle := bsSizeable; 221 {$ENDIF} 222 end; 223 end; 224 184 225 procedure TMainForm.AItemEditExecute(Sender: TObject); 185 226 begin … … 190 231 begin 191 232 ItemAddForm.Show; 233 end; 234 235 procedure TMainForm.AExitExecute(Sender: TObject); 236 begin 237 Close; 192 238 end; 193 239 … … 259 305 TopItem.ImageIndex := 0; 260 306 TopItem.SelectedIndex := 0; 261 DbRows := Database.Query('SELECT * FROM `ObjectGroup`'); 262 for I := 0 to DbRows.Count - 1 do begin 263 NewNode := AddChild(TopItem, DbRows[I].Values['Name']); 264 NewNode.ImageIndex := 0; 265 NewNode.SelectedIndex := 0; 266 NewNode.Data := Pointer(StrToInt(DbRows[I].Values['Id'])); 267 ObjectDbRows := Database.Query('SELECT * FROM `Object` WHERE `Group`=' + DbRows[I].Values['Id']); 268 for O := 0 to ObjectDbRows.Count - 1 do begin 269 NewObjectNode := AddChild(NewNode, ObjectDbRows[O].Values['Name']); 270 NewObjectNode.Data := Pointer(StrToInt(ObjectDbRows[O].Values['Id'])); 271 NewObjectNode.ImageIndex := 1; 272 NewObjectNode.SelectedIndex := 1; 273 end; 274 ObjectDbRows.Destroy; 275 end; 276 TopItem.Expand(True); 277 DbRows.Destroy; 307 try 308 DbRows := Database.Query('SELECT * FROM `ObjectGroup`'); 309 for I := 0 to DbRows.Count - 1 do begin 310 NewNode := AddChild(TopItem, DbRows[I].Values['Name']); 311 NewNode.ImageIndex := 0; 312 NewNode.SelectedIndex := 0; 313 NewNode.Data := Pointer(StrToInt(DbRows[I].Values['Id'])); 314 try 315 ObjectDbRows := Database.Query('SELECT * FROM `Object` WHERE `Group`=' + DbRows[I].Values['Id']); 316 for O := 0 to ObjectDbRows.Count - 1 do begin 317 NewObjectNode := AddChild(NewNode, ObjectDbRows[O].Values['Name']); 318 NewObjectNode.Data := Pointer(StrToInt(ObjectDbRows[O].Values['Id'])); 319 NewObjectNode.ImageIndex := 1; 320 NewObjectNode.SelectedIndex := 1; 321 end; 322 finally 323 ObjectDbRows.Free; 324 end; 325 end; 326 TopItem.Expand(True); 327 finally 328 DbRows.Free; 329 end; 278 330 TreeState.LoadTree(TreeView1); 279 331 end; … … 295 347 Visible := True; 296 348 Clear; 349 try 297 350 DbRows := Database.Query('SELECT * FROM `Object` WHERE `Id`=' + IntToStr(Integer(TreeView1.Selected.Data))); 298 351 if DbRows.Count = 1 then begin … … 300 353 301 354 // Load column names 302 Properties := Database.Query('SELECT * FROM `Property` WHERE `Object`=' + 303 DbRows[0].Values['Id']); 304 Columns.Clear; 305 NewColumn := Columns.Add; 306 NewColumn.Caption := 'Id'; 307 for I := 0 to Properties.Count - 1 do begin 355 try 356 Properties := Database.Query('SELECT * FROM `Property` WHERE `Object`=' + 357 DbRows[0].Values['Id']); 358 Columns.Clear; 308 359 NewColumn := Columns.Add; 309 NewColumn.Caption := Properties[I].Values['Name']; 360 NewColumn.Caption := 'Id'; 361 for I := 0 to Properties.Count - 1 do begin 362 NewColumn := Columns.Add; 363 NewColumn.Caption := Properties[I].Values['Name']; 364 end; 365 finally 366 Properties.Free; 310 367 end; 311 368 … … 313 370 314 371 // Load items 372 try 315 373 Values := Database.Query('SELECT * FROM `' + DbRows[0].Values['Schema'] + '`.`' + 316 374 DbRows[0].Values['Table'] + '`'); … … 323 381 end; 324 382 end; 325 Values.Destroy; 326 Properties.Destroy; 327 end; 328 DbRows.Destroy; 383 finally 384 Values.Free; 385 end; 386 end; 387 finally 388 DbRows.Free; 389 end; 329 390 end; 330 391 end;
Note:
See TracChangeset
for help on using the changeset viewer.