Changeset 14 for trunk/Form


Ignore:
Timestamp:
Apr 2, 2016, 1:15:20 PM (9 years ago)
Author:
chronos
Message:
  • Added: Open recent project menu.
Location:
trunk/Form
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Form/UFormMain.lfm

    r13 r14  
    354354        Action = AFileOpen
    355355      end
     356      object MenuItemOpenRecent: TMenuItem
     357        Caption = 'Open recent'
     358      end
    356359      object MenuItem9: TMenuItem
    357360        Action = AFileSave
     
    403406    top = 573
    404407  end
     408  object LastOpenedList1: TLastOpenedList
     409    MaxCount = 10
     410    left = 906
     411    top = 167
     412  end
    405413end
  • trunk/Form/UFormMain.pas

    r13 r14  
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    99  Menus, ComCtrls, ExtCtrls, ActnList, dateutils, syncobjs, UProject,
    10   UDriveScan, UPrefixMultiplier, XMLConf, UPhysDrive;
     10  UDriveScan, UPrefixMultiplier, ULastOpenedList, XMLConf, UPhysDrive;
    1111
    1212type
     
    5454    LabelSize: TLabel;
    5555    LabelSectorPerBlock: TLabel;
     56    LastOpenedList1: TLastOpenedList;
    5657    ListView1: TListView;
    5758    MainMenu1: TMainMenu;
     
    6364    MenuItem14: TMenuItem;
    6465    MenuItem15: TMenuItem;
     66    MenuItemOpenRecent: TMenuItem;
    6567    MenuItem2: TMenuItem;
    6668    MenuItem3: TMenuItem;
     
    103105    LastBlockPos: Integer;
    104106    RedrawPending: Boolean;
    105     LastProjectFileName: string;
    106107    LastDriveName: string;
     108    procedure OpenRecentClick(Sender: TObject);
    107109    procedure ReloadOperationList;
    108110    procedure ProjectOpen(FileName: string);
     
    147149  Detect;
    148150  LoadConfig;
    149   if FileExists(LastProjectFileName) then
    150     ProjectOpen(LastProjectFileName)
     151  if (LastOpenedList1.Items.Count > 0) then
     152    ProjectOpen(LastOpenedList1.Items[0])
    151153  else begin
    152154    AFileNew.Execute;
     
    279281  if SaveDialog1.Execute then begin
    280282    Project.SaveToFile(SaveDialog1.FileName);
     283    LastOpenedList1.AddItem(SaveDialog1.FileName);
     284    LastOpenedList1.LoadToMenuItem(MenuItemOpenRecent, OpenRecentClick);
    281285    UpdateInterface;
    282286  end;
     
    289293    else begin
    290294      Project.SaveToFile(Project.FileName);
     295      LastOpenedList1.AddItem(SaveDialog1.FileName);
     296      LastOpenedList1.LoadToMenuItem(MenuItemOpenRecent, OpenRecentClick);
    291297      UpdateInterface;
    292298    end;
     
    437443begin
    438444  XMLConfig1.SetValue('DriveName', LastDriveName);
    439   XMLConfig1.SetValue('LastProjectFileName', LastProjectFileName);
     445  LastOpenedList1.SaveToXMLConfig(XMLConfig1, 'RecentProjects');
    440446end;
    441447
     
    443449begin
    444450  LastDriveName := XMLConfig1.GetValue('DriveName', '');
    445   LastProjectFileName := XMLConfig1.GetValue('LastProjectFileName', '');
     451  LastOpenedList1.LoadFromXMLConfig(XMLConfig1, 'RecentProjects');
    446452end;
    447453
     
    449455begin
    450456  Redraw;
     457end;
     458
     459procedure TFormMain.OpenRecentClick(Sender: TObject);
     460begin
     461  ProjectOpen(TMenuItem(Sender).Caption);
    451462end;
    452463
     
    467478  ComboBoxDrive.ItemIndex := DriveList.IndexOf(DriveList.FindByModel(Project.DriveInfo.Model));
    468479  if (ComboBoxDrive.ItemIndex = -1) and (ComboBoxDrive.Items.Count > 0) then ComboBoxDrive.ItemIndex := 0;
    469   LastProjectFileName := FileName;
     480  LastOpenedList1.AddItem(FileName);
     481  LastOpenedList1.LoadToMenuItem(MenuItemOpenRecent, OpenRecentClick);
    470482  UpdateInterface;
    471483  Redraw;
     
    483495
    484496procedure TFormMain.Detect;
    485 var
    486   I: Integer;
    487497begin
    488498  DriveList.Detect;
Note: See TracChangeset for help on using the changeset viewer.