Changeset 8 for trunk/UFormMain.pas


Ignore:
Timestamp:
Apr 1, 2016, 12:04:16 AM (9 years ago)
Author:
chronos
Message:
  • Added: Reopen last openned project file.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UFormMain.pas

    r7 r8  
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    99  Menus, ComCtrls, ExtCtrls, ActnList, dateutils, syncobjs, UProject,
    10   UDriveScan, UPrefixMultiplier;
     10  UDriveScan, UPrefixMultiplier, XMLConf;
    1111
    1212type
     
    6262    SaveDialog1: TSaveDialog;
    6363    Timer1: TTimer;
     64    XMLConfig1: TXMLConfig;
    6465    procedure ABrowseDiskExecute(Sender: TObject);
    6566    procedure AExitExecute(Sender: TObject);
     
    7980    LastBlockPos: Integer;
    8081    RedrawPending: Boolean;
     82    LastProjectFileName: string;
     83    procedure ProjectOpen(FileName: string);
    8184    procedure DriveScanChange(Sender: TObject);
    8285    procedure DriveScanTerminate(Sender: TObject);
     
    8790    DriveScan: TDriveScan;
    8891    Project: TProject;
     92    procedure SaveConfig;
     93    procedure LoadConfig;
    8994    procedure Detect;
    9095    procedure ShowBuffer(Buffer: array of Byte);
     
    105110procedure TFormMain.FormShow(Sender: TObject);
    106111begin
     112  LoadConfig;
     113  if FileExists(LastProjectFileName) then
     114    ProjectOpen(LastProjectFileName);
    107115  Redraw;
    108116  UpdateInterface;
     
    123131  DriveScan.OnTerminate := DriveScanTerminate;
    124132  EditDrive.Text := '/dev/sdb';
     133  XMLConfig1.Filename := 'config.xml';
    125134end;
    126135
     
    169178  OpenDialog1.DefaultExt := '.cdp';
    170179  if OpenDialog1.Execute then begin
    171     Project.LoadFromFile(OpenDialog1.FileName);
     180    ProjectOpen(OpenDialog1.FileName);
    172181  end;
    173182end;
     
    184193procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    185194begin
     195  SaveConfig;
    186196end;
    187197
     
    252262end;
    253263
     264procedure TFormMain.SaveConfig;
     265begin
     266  XMLConfig1.SetValue('DriveName', EditDrive.Text);
     267  XMLConfig1.SetValue('LastProjectFileName', LastProjectFileName);
     268end;
     269
     270procedure TFormMain.LoadConfig;
     271begin
     272  EditDrive.Text := XMLConfig1.GetValue('DriveName', '/dev/sda');
     273  LastProjectFileName := XMLConfig1.GetValue('LastProjectFileName', '');
     274end;
     275
    254276procedure TFormMain.Timer1Timer(Sender: TObject);
    255277begin
    256278  Redraw;
     279end;
     280
     281procedure TFormMain.ProjectOpen(FileName: string);
     282begin
     283  Project.LoadFromFile(FileName);
     284  LastProjectFileName := FileName;
    257285end;
    258286
Note: See TracChangeset for help on using the changeset viewer.