Changeset 10 for trunk/Forms/UMainForm.pas
- Timestamp:
- Jun 9, 2011, 9:33:21 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 3 3 chronis 4 4 heaptrclog.trc 5 chronis.exe
-
- Property svn:ignore
-
trunk/Forms/UMainForm.pas
r9 r10 17 17 18 18 TMainForm = class(TForm) 19 AConnect: TAction; 20 ASettings: TAction; 19 21 AToggleFullscreen: TAction; 20 22 AExit: TAction; … … 44 46 MenuItem14: TMenuItem; 45 47 MenuItem15: TMenuItem; 48 MenuItem16: TMenuItem; 49 MenuItem17: TMenuItem; 46 50 MenuItem2: TMenuItem; 47 51 MenuItem3: TMenuItem; … … 59 63 Splitter1: TSplitter; 60 64 TreeView1: TTreeView; 65 procedure AConnectExecute(Sender: TObject); 61 66 procedure AExitExecute(Sender: TObject); 62 67 procedure AItemAddExecute(Sender: TObject); … … 66 71 procedure AObjectGroupAddGroupExecute(Sender: TObject); 67 72 procedure AObjectGroupEditExecute(Sender: TObject); 73 procedure ASettingsExecute(Sender: TObject); 68 74 procedure AToggleFullscreenExecute(Sender: TObject); 69 75 procedure ButtonAddClick(Sender: TObject); … … 85 91 RegistryKey: string; 86 92 RegistryRootKey: HKEY; 87 procedure LoadConfiguration;88 93 procedure LoadFromRegistry; 89 94 procedure SaveToRegistry; 95 procedure InitStructure; 90 96 public 91 97 SelectedObjectId: Integer; … … 112 118 113 119 uses 114 UItemView, UItemEdit, UItemAdd ;120 UItemView, UItemEdit, UItemAdd, ULoginForm, USettingForm, UApplicationInfo; 115 121 116 122 {$R *.lfm} 117 123 118 124 { TMainForm } 119 120 procedure TMainForm.LoadConfiguration;121 var122 Config: TXMLDocument;123 I1: Integer;124 I2: Integer;125 I3: Integer;126 begin127 if FileExists(ConfigFileName) then try128 ReadXMLFile(Config, ConfigFileName);129 for I1 := 0 to Config.ChildNodes.Count - 1 do130 with Config.ChildNodes[I1] do begin131 if NodeName = 'configuration' then132 for I2 := 0 to ChildNodes.Count - 1 do133 with ChildNodes[I2] do begin134 if NodeName = 'database' then135 for I3 := 0 to ChildNodes.Count - 1 do136 with ChildNodes[I3] do begin137 if NodeName = 'hostname' then138 System.Database.HostName := TextContent;139 if NodeName = 'schema' then140 System.Database.Database := TextContent;141 if NodeName = 'username' then142 System.Database.UserName := TextContent;143 if NodeName = 'password' then144 System.Database.Password := TextContent;145 end;146 end;147 end;148 finally149 Config.Free;150 end;151 end;152 125 153 126 procedure TMainForm.LoadFromRegistry; … … 158 131 OpenKey(RegistryKey, True); 159 132 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', ''); 160 137 finally 161 138 Free; … … 170 147 OpenKey(RegistryKey, True); 171 148 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); 172 153 finally 173 154 Free; … … 175 156 end; 176 157 158 procedure TMainForm.InitStructure; 159 begin 160 161 end; 162 177 163 procedure TMainForm.FormCreate(Sender: TObject); 178 164 begin 179 165 System := TChronisBase.Create; 180 166 System.Database := TSqlDatabase.Create; 181 LoadConfiguration;182 System.Database.Connect;183 167 TreeState := TTreeState.Create; 184 168 Report := TReport.Create; … … 187 171 SelectedObject.Base := System; 188 172 RegistryRootKey := HKEY_CURRENT_USER; 189 RegistryKey := '\Software\Chronosoft\Chronis'; 173 RegistryKey := '\Software\' + ApplicationInfo.CompanyName + '\' + 174 ApplicationInfo.Name; 190 175 PersistentForm := TPersistentForm.Create; 191 176 PersistentForm.RegistryKey := RegistryKey; … … 237 222 ItemEditForm.Show; 238 223 end; 224 end; 225 226 procedure TMainForm.ASettingsExecute(Sender: TObject); 227 begin 228 SettingForm.ShowModal; 239 229 end; 240 230 … … 281 271 end; 282 272 273 procedure TMainForm.AConnectExecute(Sender: TObject); 274 begin 275 LoginForm.ShowModal; 276 end; 277 283 278 procedure TMainForm.FormShow(Sender: TObject); 284 279 begin 285 280 PersistentForm.Load(Self); 281 LoadFromRegistry; 282 System.Database.Connect; 283 InitStructure; 286 284 LoadTree; 287 LoadFromRegistry;288 285 end; 289 286
Note:
See TracChangeset
for help on using the changeset viewer.