Ignore:
Timestamp:
Nov 9, 2011, 1:58:00 PM (13 years ago)
Author:
george
Message:
  • Modified: Login form now use connection profile form for selecting connection parameters.
  • Added: About application dialog.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UMainForm.pas

    r24 r25  
    1717  published
    1818    AConnect: TAction;
     19    AAbout: TAction;
    1920    AImportStructure: TAction;
    2021    AInitSystemValues: TAction;
     
    5354    MenuItem2: TMenuItem;
    5455    MenuItem20: TMenuItem;
     56    MenuItem21: TMenuItem;
    5557    MenuItem3: TMenuItem;
    5658    MenuItem4: TMenuItem;
     
    6769    Splitter1: TSplitter;
    6870    TreeView1: TTreeView;
     71    procedure AAboutExecute(Sender: TObject);
    6972    procedure AConnectExecute(Sender: TObject);
    7073    procedure AExitExecute(Sender: TObject);
     
    9194    procedure ListView1SelectItem(Sender: TObject; Item: TListItem;
    9295      Selected: Boolean);
     96    procedure MenuItem17Click(Sender: TObject);
    9397    procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
    9498  private
     
    96100    OriginalWindowState: TWindowState;
    97101    ScreenBounds: TRect;
    98     RegistryKey: string;
    99     RegistryRootKey: HKEY;
    100102    procedure LoadFromRegistry;
    101103    procedure SaveToRegistry;
     
    128130uses
    129131  UItemView, UItemEdit, UItemAdd, ULoginForm, USettingForm, UApplicationInfo,
    130   UCore, UImportStructureForm;
     132  UCore, UImportStructureForm, UAboutForm, ULoginProfileForm;
    131133
    132134{$R *.lfm}
     
    138140  with TRegistryEx.Create do
    139141  try
    140     RootKey := RegistryRootKey;
    141     OpenKey(RegistryKey, True);
     142    RootKey := Core.RegistryRootKey;
     143    OpenKey(Core.RegistryKey, True);
    142144    Panel1.Width := ReadIntegerWithDefault('GroupTreeWidth', 200);
    143     Core.System.Database.Database := ReadStringWithDefault('DatabaseSchema', 'chronis');
    144     Core.System.Database.Hostname := ReadStringWithDefault('DatabaseHostName', 'localhost');
    145     Core.System.Database.UserName := ReadStringWithDefault('DatabaseUserName', 'chronis');
    146     Core.System.Database.Password := ReadStringWithDefault('DatabasePassword', '');
    147145    with Core.CoolTranslator1 do
    148146      Language := Languages.SearchByCode(ReadStringWithDefault('LanguageCode', ''));
     
    156154  with TRegistryEx.Create do
    157155  try
    158     RootKey := RegistryRootKey;
    159     OpenKey(RegistryKey, True);
     156    RootKey := Core.RegistryRootKey;
     157    OpenKey(Core.RegistryKey, True);
    160158    WriteInteger('GroupTreeWidth', Panel1.Width);
    161     WriteString('DatabaseSchema', Core.System.Database.Database);
    162     WriteString('DatabaseHostName', Core.System.Database.Hostname);
    163     WriteString('DatabaseUserName', Core.System.Database.UserName);
    164     WriteString('DatabasePassword', Core.System.Database.Password);
    165159    with Core.CoolTranslator1 do
    166160      WriteString('LanguageCode', Language.Code);
     
    520514  SelectedObject := TChronisObject.Create;
    521515  SelectedObject.Base := Core.System;
    522   RegistryRootKey := HKEY_CURRENT_USER;
    523   RegistryKey := '\Software\' + ApplicationInfo.CompanyName + '\' +
    524     ApplicationInfo.Name;
    525516  PersistentForm := TPersistentForm.Create;
    526   PersistentForm.RegistryKey := RegistryKey;
     517  PersistentForm.RegistryKey := Core.RegistryKey;
    527518end;
    528519
     
    641632procedure TMainForm.AConnectExecute(Sender: TObject);
    642633begin
    643   LoginForm.ShowModal;
     634  Core.Profiles.LoadFromRegistry(Core.RegistryRootKey, Core.RegistryKey);
     635  if LoginForm.ShowModal = mrOK then begin
     636    with TConnectProfile(Core.Profiles[Core.LastProfile]) do begin
     637      Core.System.Database.HostName := HostName;
     638      Core.System.Database.Database := Database;
     639      Core.System.Database.UserName := Core.LastUserName;
     640      Core.System.Database.Password := Core.LastPassword;
     641      Core.System.Database.Connect;
     642    end;
     643    InitStructure;
     644    Core.System.LoadTypes;
     645    LoadTree;
     646  end;
     647end;
     648
     649procedure TMainForm.AAboutExecute(Sender: TObject);
     650begin
     651  AboutForm.ShowModal;
    644652end;
    645653
     
    648656  PersistentForm.Load(Self);
    649657  LoadFromRegistry;
    650   Core.System.Database.Connect;
    651   InitStructure;
    652   Core.System.LoadTypes;
    653   LoadTree;
     658  AConnect.Execute;
    654659end;
    655660
     
    696701  AItemView.Enabled := Assigned(ListView1.Selected);
    697702  AItemEdit.Enabled := Assigned(ListView1.Selected);
     703end;
     704
     705procedure TMainForm.MenuItem17Click(Sender: TObject);
     706begin
     707  LoginForm.ShowModal;
    698708end;
    699709
Note: See TracChangeset for help on using the changeset viewer.