Ignore:
Timestamp:
Dec 25, 2010, 9:31:21 PM (14 years ago)
Author:
george
Message:
  • Activated generation of language files.
  • Added: Full screen mode.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UMainForm.pas

    r5 r6  
    2121
    2222  TMainForm = class(TForm)
     23    AToggleFullscreen: TAction;
     24    AExit: TAction;
    2325    AObjectEdit: TAction;
    2426    AObjectDelete: TAction;
     
    3840    Label2: TLabel;
    3941    ListView1: TListView;
     42    MainMenu1: TMainMenu;
    4043    MenuItem1: TMenuItem;
    4144    MenuItem10: TMenuItem;
     45    MenuItem11: TMenuItem;
     46    MenuItem12: TMenuItem;
     47    MenuItem13: TMenuItem;
     48    MenuItem14: TMenuItem;
     49    MenuItem15: TMenuItem;
    4250    MenuItem2: TMenuItem;
    4351    MenuItem3: TMenuItem;
     
    5563    Splitter1: TSplitter;
    5664    TreeView1: TTreeView;
     65    procedure AExitExecute(Sender: TObject);
    5766    procedure AItemAddExecute(Sender: TObject);
    5867    procedure AItemEditExecute(Sender: TObject);
     
    6170    procedure AObjectGroupAddGroupExecute(Sender: TObject);
    6271    procedure AObjectGroupEditExecute(Sender: TObject);
     72    procedure AToggleFullscreenExecute(Sender: TObject);
    6373    procedure ButtonAddClick(Sender: TObject);
    6474    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     
    7383    procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
    7484  private
     85    OriginalBounds: TRect;
     86    OriginalWindowState: TWindowState;
     87    ScreenBounds: TRect;
    7588    procedure LoadConfiguration;
    7689  public
     
    103116  I3: Integer;
    104117begin
    105   if FileExists(ConfigFileName) then begin
     118  if FileExists(ConfigFileName) then try
    106119    ReadXMLFile(Config, ConfigFileName);
    107120    for I1 := 0 to Config.ChildNodes.Count - 1 do
     
    124137      end;
    125138    end;
    126     Config.Destroy;
     139  finally
     140    Config.Free;
    127141  end;
    128142end;
     
    139153procedure TMainForm.FormDestroy(Sender: TObject);
    140154begin
    141   TreeState.Destroy;
    142   Database.Destroy;
    143   PersistentForm.Destroy;
     155  TreeState.Free;
     156  Database.Free;
     157  PersistentForm.Free;
    144158end;
    145159
     
    182196end;
    183197
     198procedure TMainForm.AToggleFullscreenExecute(Sender: TObject);
     199begin
     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;
     223end;
     224
    184225procedure TMainForm.AItemEditExecute(Sender: TObject);
    185226begin
     
    190231begin
    191232  ItemAddForm.Show;
     233end;
     234
     235procedure TMainForm.AExitExecute(Sender: TObject);
     236begin
     237  Close;
    192238end;
    193239
     
    259305    TopItem.ImageIndex := 0;
    260306    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;
    278330    TreeState.LoadTree(TreeView1);
    279331  end;
     
    295347    Visible := True;
    296348    Clear;
     349    try
    297350    DbRows := Database.Query('SELECT * FROM `Object` WHERE `Id`=' + IntToStr(Integer(TreeView1.Selected.Data)));
    298351    if DbRows.Count = 1 then begin
     
    300353
    301354      // 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;
    308359        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;
    310367      end;
    311368
     
    313370
    314371      // Load items
     372      try
    315373      Values := Database.Query('SELECT * FROM `' + DbRows[0].Values['Schema'] + '`.`' +
    316374        DbRows[0].Values['Table'] + '`');
     
    323381        end;
    324382      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;
    329390  end;
    330391end;
Note: See TracChangeset for help on using the changeset viewer.