Ignore:
Timestamp:
Jun 9, 2011, 9:33:21 AM (13 years ago)
Author:
george
Message:
  • Added: Application meta information.
  • Added: Empty settings form.
  • Modified: Server connect configuration is now stored in system registry.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        33chronis
        44heaptrclog.trc
         5chronis.exe
  • trunk/Forms/UMainForm.pas

    r9 r10  
    1717
    1818  TMainForm = class(TForm)
     19    AConnect: TAction;
     20    ASettings: TAction;
    1921    AToggleFullscreen: TAction;
    2022    AExit: TAction;
     
    4446    MenuItem14: TMenuItem;
    4547    MenuItem15: TMenuItem;
     48    MenuItem16: TMenuItem;
     49    MenuItem17: TMenuItem;
    4650    MenuItem2: TMenuItem;
    4751    MenuItem3: TMenuItem;
     
    5963    Splitter1: TSplitter;
    6064    TreeView1: TTreeView;
     65    procedure AConnectExecute(Sender: TObject);
    6166    procedure AExitExecute(Sender: TObject);
    6267    procedure AItemAddExecute(Sender: TObject);
     
    6671    procedure AObjectGroupAddGroupExecute(Sender: TObject);
    6772    procedure AObjectGroupEditExecute(Sender: TObject);
     73    procedure ASettingsExecute(Sender: TObject);
    6874    procedure AToggleFullscreenExecute(Sender: TObject);
    6975    procedure ButtonAddClick(Sender: TObject);
     
    8591    RegistryKey: string;
    8692    RegistryRootKey: HKEY;
    87     procedure LoadConfiguration;
    8893    procedure LoadFromRegistry;
    8994    procedure SaveToRegistry;
     95    procedure InitStructure;
    9096  public
    9197    SelectedObjectId: Integer;
     
    112118
    113119uses
    114   UItemView, UItemEdit, UItemAdd;
     120  UItemView, UItemEdit, UItemAdd, ULoginForm, USettingForm, UApplicationInfo;
    115121
    116122{$R *.lfm}
    117123
    118124{ TMainForm }
    119 
    120 procedure TMainForm.LoadConfiguration;
    121 var
    122   Config: TXMLDocument;
    123   I1: Integer;
    124   I2: Integer;
    125   I3: Integer;
    126 begin
    127   if FileExists(ConfigFileName) then try
    128     ReadXMLFile(Config, ConfigFileName);
    129     for I1 := 0 to Config.ChildNodes.Count - 1 do
    130     with Config.ChildNodes[I1] do begin
    131       if NodeName = 'configuration' then
    132       for I2 := 0 to ChildNodes.Count - 1 do
    133       with ChildNodes[I2] do begin
    134         if NodeName = 'database' then
    135         for I3 := 0 to ChildNodes.Count - 1 do
    136         with ChildNodes[I3] do begin
    137           if NodeName = 'hostname' then
    138             System.Database.HostName := TextContent;
    139           if NodeName = 'schema' then
    140             System.Database.Database := TextContent;
    141           if NodeName = 'username' then
    142             System.Database.UserName := TextContent;
    143           if NodeName = 'password' then
    144             System.Database.Password := TextContent;
    145         end;
    146       end;
    147     end;
    148   finally
    149     Config.Free;
    150   end;
    151 end;
    152125
    153126procedure TMainForm.LoadFromRegistry;
     
    158131    OpenKey(RegistryKey, True);
    159132    Panel1.Width := ReadIntegerWithDefault('GroupTreeWidth', 200);
     133    System.Database.Database := ReadStringWithDefault('DatabaseSchema', 'chronis');
     134    System.Database.Hostname := ReadStringWithDefault('DatabaseHostName', 'localhost');
     135    System.Database.UserName := ReadStringWithDefault('DatabaseUserName', 'chronis');
     136    System.Database.Password := ReadStringWithDefault('DatabasePassword', '');
    160137  finally
    161138    Free;
     
    170147    OpenKey(RegistryKey, True);
    171148    WriteInteger('GroupTreeWidth', Panel1.Width);
     149    WriteString('DatabaseSchema', System.Database.Database);
     150    WriteString('DatabaseHostName', System.Database.Hostname);
     151    WriteString('DatabaseUserName', System.Database.UserName);
     152    WriteString('DatabasePassword', System.Database.Password);
    172153  finally
    173154    Free;
     
    175156end;
    176157
     158procedure TMainForm.InitStructure;
     159begin
     160
     161end;
     162
    177163procedure TMainForm.FormCreate(Sender: TObject);
    178164begin
    179165  System := TChronisBase.Create;
    180166  System.Database := TSqlDatabase.Create;
    181   LoadConfiguration;
    182   System.Database.Connect;
    183167  TreeState := TTreeState.Create;
    184168  Report := TReport.Create;
     
    187171  SelectedObject.Base := System;
    188172  RegistryRootKey := HKEY_CURRENT_USER;
    189   RegistryKey := '\Software\Chronosoft\Chronis';
     173  RegistryKey := '\Software\' + ApplicationInfo.CompanyName + '\' +
     174    ApplicationInfo.Name;
    190175  PersistentForm := TPersistentForm.Create;
    191176  PersistentForm.RegistryKey := RegistryKey;
     
    237222    ItemEditForm.Show;
    238223  end;
     224end;
     225
     226procedure TMainForm.ASettingsExecute(Sender: TObject);
     227begin
     228  SettingForm.ShowModal;
    239229end;
    240230
     
    281271end;
    282272
     273procedure TMainForm.AConnectExecute(Sender: TObject);
     274begin
     275  LoginForm.ShowModal;
     276end;
     277
    283278procedure TMainForm.FormShow(Sender: TObject);
    284279begin
    285280  PersistentForm.Load(Self);
     281  LoadFromRegistry;
     282  System.Database.Connect;
     283  InitStructure;
    286284  LoadTree;
    287   LoadFromRegistry;
    288285end;
    289286
Note: See TracChangeset for help on using the changeset viewer.