Ignore:
Timestamp:
Aug 3, 2012, 3:17:28 PM (12 years ago)
Author:
chronos
Message:
  • Modified: Some base project manager actions handling.
File:
1 edited

Legend:

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

    r11 r12  
    66
    77uses
    8   Classes, SysUtils, FileUtil, ActnList, Menus, UModularSystem;
     8  Classes, SysUtils, FileUtil, ActnList, Menus, Dialogs, UModularSystem,
     9  UProject;
    910
    1011type
     
    2930    MenuItem7: TMenuItem;
    3031    MenuItem8: TMenuItem;
     32    OpenDialog1: TOpenDialog;
    3133    PopupMenu1: TPopupMenu;
     34    SaveDialog1: TSaveDialog;
     35    procedure ACloseExecute(Sender: TObject);
     36    procedure ANewExecute(Sender: TObject);
     37    procedure AOpenExecute(Sender: TObject);
     38    procedure AProjectManagerExecute(Sender: TObject);
     39    procedure ASaveAsExecute(Sender: TObject);
     40    procedure ASaveExecute(Sender: TObject);
     41    procedure DataModuleDestroy(Sender: TObject);
    3242  private
    3343    { private declarations }
    3444  public
    35     { public declarations }
     45    Project: TProject;
     46    procedure UpdateInterface;
    3647  end;
    3748
     
    5869  SProject = 'Project';
    5970
     71{ TDataModuleProject }
     72
     73procedure TDataModuleProject.AProjectManagerExecute(Sender: TObject);
     74begin
     75  FormProject.Show;
     76end;
     77
     78procedure TDataModuleProject.ASaveAsExecute(Sender: TObject);
     79begin
     80  SaveDialog1.FileName := Project.FileName;
     81  if SaveDialog1.Execute then begin
     82    Project.FileName := SaveDialog1.FileName;
     83    Project.Save;
     84    UpdateInterface;
     85  end;
     86end;
     87
     88procedure TDataModuleProject.ASaveExecute(Sender: TObject);
     89begin
     90  if Project.Modified then ASaveAs.Execute
     91    else Project.Save;
     92  UpdateInterface;
     93end;
     94
     95procedure TDataModuleProject.DataModuleDestroy(Sender: TObject);
     96begin
     97  AClose.Execute;
     98end;
     99
     100procedure TDataModuleProject.UpdateInterface;
     101begin
     102  ASave.Enabled := Assigned(Project) and Project.Modified;
     103  ASaveAs.Enabled := Assigned(Project);
     104  AClose.Enabled := Assigned(Project);
     105end;
     106
     107procedure TDataModuleProject.ACloseExecute(Sender: TObject);
     108begin
     109  if Project.Modified then ASaveAs.Execute;
     110  FreeAndNil(Project);
     111  UpdateInterface;
     112end;
     113
     114procedure TDataModuleProject.ANewExecute(Sender: TObject);
     115begin
     116  Project := TProject.Create;
     117  UpdateInterface;
     118end;
     119
     120procedure TDataModuleProject.AOpenExecute(Sender: TObject);
     121begin
     122  OpenDialog1.FileName := Project.FileName;
     123  if OpenDialog1.Execute then begin
     124    Project.FileName := OpenDialog1.FileName;
     125    Project.Load;
     126    UpdateInterface;
     127  end;
     128end;
     129
    60130{ TLDModuleProject }
    61131
     
    74144    DataModuleProject := TDataModuleProject.Create(nil);
    75145    FormProject := TFormProject.Create(nil);
     146    FormProject.API := TLDStudioAPI(API);
    76147    DataModuleProject.PopupMenu1.Items.Caption := SProject;
    77148    RegisterMainMenuItem(DataModuleProject.PopupMenu1.Items, nil, 1);
Note: See TracChangeset for help on using the changeset viewer.