Ignore:
Timestamp:
Aug 6, 2012, 2:35:22 PM (12 years ago)
Author:
chronos
Message:
  • Added: Registration of new file templates for modules.
  • Added: Program stores last opened file list in registry.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/StudioModules/LDModuleProject/ULDModuleProject.pas

    r14 r15  
    77uses
    88  Classes, SysUtils, FileUtil, ActnList, Menus, Dialogs, UModularSystem,
    9   UProject;
     9  ULastOpenedList, UProject, URegistry, USource;
    1010
    1111type
     
    2222    ANew: TAction;
    2323    ActionList1: TActionList;
     24    LastOpenedList1: TLastOpenedList;
    2425    MenuItem1: TMenuItem;
    2526    MenuItem2: TMenuItem;
    26     MenuItem3: TMenuItem;
     27    MenuItemOpenRecent: TMenuItem;
    2728    MenuItem4: TMenuItem;
    2829    MenuItem5: TMenuItem;
     
    3637    procedure ANewExecute(Sender: TObject);
    3738    procedure AOpenExecute(Sender: TObject);
     39    procedure AOpenRecentExecute(Sender: TObject);
    3840    procedure AProjectManagerExecute(Sender: TObject);
    3941    procedure ASaveAsExecute(Sender: TObject);
    4042    procedure ASaveExecute(Sender: TObject);
     43    procedure DataModuleCreate(Sender: TObject);
    4144    procedure DataModuleDestroy(Sender: TObject);
     45    procedure LastOpenedList1Change(Sender: TObject);
    4246  private
    4347    { private declarations }
     
    4549    Project: TProject;
    4650    procedure UpdateInterface;
     51    procedure LoadFromRegistry(Context: TRegistryContext);
     52    procedure SaveToRegistry(Context: TRegistryContext);
    4753  end;
    4854
     
    5157  TLDModuleProject = class(TModule)
    5258  private
     59    ProjectFileType: TSourceType;
    5360  public
    5461    constructor Create; override;
     
    93100end;
    94101
     102procedure TDataModuleProject.DataModuleCreate(Sender: TObject);
     103begin
     104
     105end;
     106
    95107procedure TDataModuleProject.DataModuleDestroy(Sender: TObject);
    96108begin
    97109  AClose.Execute;
     110end;
     111
     112procedure TDataModuleProject.LastOpenedList1Change(Sender: TObject);
     113begin
     114  LastOpenedList1.LoadToMenuItem(MenuItemOpenRecent, AOpenRecentExecute);
    98115end;
    99116
     
    103120  ASaveAs.Enabled := Assigned(Project);
    104121  AClose.Enabled := Assigned(Project);
     122end;
     123
     124procedure TDataModuleProject.LoadFromRegistry(Context: TRegistryContext);
     125begin
     126  LastOpenedList1.LoadFromRegistry(Context.RootKey, Context.Key + '\RecentFile');
     127end;
     128
     129procedure TDataModuleProject.SaveToRegistry(Context: TRegistryContext);
     130begin
     131  LastOpenedList1.SaveToRegistry(Context.RootKey, Context.Key + '\RecentFile');
    105132end;
    106133
     
    122149procedure TDataModuleProject.AOpenExecute(Sender: TObject);
    123150begin
    124   OpenDialog1.FileName := Project.FileName;
     151  if Assigned(Project) then
     152    OpenDialog1.FileName := Project.FileName;
    125153  if OpenDialog1.Execute then begin
    126154    Project.FileName := OpenDialog1.FileName;
     
    128156    UpdateInterface;
    129157  end;
     158end;
     159
     160procedure TDataModuleProject.AOpenRecentExecute(Sender: TObject);
     161begin
     162
    130163end;
    131164
     
    150183    DataModuleProject.PopupMenu1.Items.Caption := SProject;
    151184    RegisterMainMenuItem(DataModuleProject.PopupMenu1.Items, nil, 1);
     185    DataModuleProject.LoadFromRegistry(RegContext(GetRegistryContext.RootKey,
     186      GetRegistryContext.Key + '\Project'));
     187    DataModuleProject.UpdateInterface;
     188    ProjectFileType := TSourceType.Create;
     189    ProjectFileType.Extension := '.ldp';
     190    ProjectFileType.Title := 'LibreDevelop project';
     191    RegisterFileType(ProjectFileType);
    152192  end;
    153193  inherited;
     
    158198  inherited;
    159199  with TLDStudioAPI(API) do begin
     200    UnregisterFileType(ProjectFileType);
     201    DataModuleProject.SaveToRegistry(RegContext(GetRegistryContext.RootKey,
     202      GetRegistryContext.Key + '\Project'));
    160203    UnregisterMainMenuItem(DataModuleProject.PopupMenu1.Items);
    161204    FreeAndNil(DataModuleProject);
Note: See TracChangeset for help on using the changeset viewer.