Changeset 15 for trunk/StudioPackage/Forms/UFormMain.pas
- Timestamp:
- Aug 6, 2012, 2:35:22 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/StudioPackage/Forms/UFormMain.pas
r14 r15 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus, 9 ActnList, ComCtrls, ExtCtrls, UDataModule; 9 ActnList, ComCtrls, ExtCtrls, ULastOpenedList, UCoolTranslator, UDataModule, 10 URegistry; 10 11 11 12 type … … 44 45 AClipboardCut: TAction; 45 46 ActionListMain: TActionList; 47 LastOpenedList1: TLastOpenedList; 46 48 MainMenu: TMainMenu; 47 49 MenuItem15: TMenuItem; … … 60 62 MenuItem27: TMenuItem; 61 63 MenuItem28: TMenuItem; 62 MenuItem 29: TMenuItem;64 MenuItemFileOpenRecent: TMenuItem; 63 65 MenuItem30: TMenuItem; 64 66 MenuItem31: TMenuItem; … … 89 91 PageControlBottom: TPageControl; 90 92 PageControlCenter: TPageControl; 93 PopupMenuRecentFiles: TPopupMenu; 91 94 SaveDialogFile: TSaveDialog; 92 95 Splitter1: TSplitter; … … 102 105 procedure AFileNewExecute(Sender: TObject); 103 106 procedure AFileOpenExecute(Sender: TObject); 107 procedure AFileOpenRecentExecute(Sender: TObject); 108 procedure AFileSaveAsExecute(Sender: TObject); 109 procedure AFileSaveExecute(Sender: TObject); 104 110 procedure AViewModulesExecute(Sender: TObject); 105 111 procedure AViewSettingsExecute(Sender: TObject); … … 108 114 procedure FormDestroy(Sender: TObject); 109 115 procedure FormShow(Sender: TObject); 116 procedure LastOpenedList1Change(Sender: TObject); 117 procedure MenuItemFileOpenRecentClick(Sender: TObject); 110 118 private 111 119 procedure DockInit; 112 120 public 121 procedure UpdateInterface; 113 122 procedure OpenedFileChange(Sender: TObject); 123 procedure LoadFromRegistry(Context: TRegistryContext); 124 procedure SaveToRegistry(Context: TRegistryContext); 114 125 end; 115 126 … … 117 128 FormMain: TFormMain; 118 129 130 119 131 implementation 120 132 … … 122 134 123 135 uses 124 UFormSourceCode, UFormSettings, UFormModuleList ;136 UFormSourceCode, UFormSettings, UFormModuleList, UFormNewFile, USource; 125 137 126 138 { TFormMain } … … 133 145 procedure TFormMain.AFileCloseExecute(Sender: TObject); 134 146 begin 135 DataModule1.OpenedFiles.CloseFile(DataModule1.OpenedFiles.Selected .FileName);147 DataModule1.OpenedFiles.CloseFile(DataModule1.OpenedFiles.Selected); 136 148 end; 137 149 138 150 procedure TFormMain.AFileNewExecute(Sender: TObject); 139 begin 140 DataModule1.OpenedFiles.NewFile; 151 var 152 NewFile: TSource; 153 begin 154 if FormNewFile.ShowModal = mrOk then 155 if Assigned(FormNewFile.ListView1.Selected) then begin 156 NewFile := TFileTemplate(FormNewFile.ListView1.Selected.Data).Execute; 157 DataModule1.OpenedFiles.OpenFile(NewFile); 158 end; 141 159 end; 142 160 … … 145 163 OpenDialogFile.Filter := DataModule1.FileTypes.GetDialogFilter; 146 164 if OpenDialogFile.Execute then begin 147 DataModule1.OpenedFiles.OpenFile(OpenDialogFile.FileName); 148 end; 165 LastOpenedList1.AddItem(OpenDialogFile.FileName); 166 DataModule1.OpenedFiles.OpenFileName(OpenDialogFile.FileName); 167 end; 168 end; 169 170 procedure TFormMain.AFileOpenRecentExecute(Sender: TObject); 171 begin 172 if Sender is TMenuItem then 173 DataModule1.OpenedFiles.OpenFileName(TMenuItem(Sender).Caption); 174 end; 175 176 procedure TFormMain.AFileSaveAsExecute(Sender: TObject); 177 begin 178 SaveDialogFile.FileName := DataModule1.OpenedFiles.Selected.Name; 179 if SaveDialogFile.Execute then begin 180 LastOpenedList1.AddItem(SaveDialogFile.FileName); 181 DataModule1.OpenedFiles.Selected.Name := SaveDialogFile.FileName; 182 end; 183 end; 184 185 procedure TFormMain.AFileSaveExecute(Sender: TObject); 186 begin 187 149 188 end; 150 189 … … 177 216 begin 178 217 DockInit; 218 UpdateInterface; 219 end; 220 221 procedure TFormMain.LastOpenedList1Change(Sender: TObject); 222 begin 223 LastOpenedList1.LoadToMenuItem(PopupMenuRecentFiles.Items, AFileOpenRecentExecute); 224 LastOpenedList1.LoadToMenuItem(MenuItemFileOpenRecent, AFileOpenRecentExecute); 225 end; 226 227 procedure TFormMain.MenuItemFileOpenRecentClick(Sender: TObject); 228 begin 229 179 230 end; 180 231 … … 186 237 }end; 187 238 239 procedure TFormMain.UpdateInterface; 240 begin 241 AFileClose.Enabled := Assigned(DataModule1.OpenedFiles.Selected); 242 AFileSave.Enabled := Assigned(DataModule1.OpenedFiles.Selected); 243 AFileSaveAs.Enabled := Assigned(DataModule1.OpenedFiles.Selected); 244 end; 245 188 246 procedure TFormMain.OpenedFileChange(Sender: TObject); 189 247 var … … 193 251 with DataModule1.OpenedFiles do begin 194 252 for I := 0 to Count - 1 do 195 with T OpenedFile(Items[I]) do begin253 with TSource(Items[I]) do begin 196 254 if not Assigned(Form.Parent) then begin 197 255 NewTabSheet := PageControlCenter.AddTabSheet; 198 NewTabSheet.Caption := ExtractFileName( FileName);256 NewTabSheet.Caption := ExtractFileName(Name); 199 257 //NewTabSheet.PopupMenu := ; 200 258 Form.ManualDock(NewTabSheet, nil, alClient); … … 206 264 end; 207 265 266 procedure TFormMain.LoadFromRegistry(Context: TRegistryContext); 267 begin 268 LastOpenedList1.LoadFromRegistry(Context.RootKey, Context.Key + '\RecentFiles'); 269 end; 270 271 procedure TFormMain.SaveToRegistry(Context: TRegistryContext); 272 begin 273 LastOpenedList1.SaveToRegistry(Context.RootKey, Context.Key + '\RecentFiles'); 274 end; 275 208 276 end. 209 277
Note:
See TracChangeset
for help on using the changeset viewer.