Changeset 13 for trunk/UProject.pas


Ignore:
Timestamp:
Apr 2, 2016, 1:06:34 PM (8 years ago)
Author:
chronos
Message:
  • Modified: All drive dimensions are now stored in project file.
  • Added: Confirmation dialog for saving project on application exit.
  • Modified: ComboBox for selection of current drive now behaves correctly to update project parameters.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UProject.pas

    r10 r13  
    66
    77uses
    8   Classes, SysUtils, Contnrs, DOM, XMLRead, XMLWrite, UXMLUtils, UDriveScan;
     8  Classes, SysUtils, Contnrs, DOM, XMLRead, XMLWrite, UXMLUtils, UDriveScan,
     9  UPhysDrive;
    910
    1011type
     
    1314
    1415  TProject = class
     16  private
     17    function GetCurrentScan: TDriveScan;
     18    function GetSectorCount: Integer;
     19  public
    1520    Name: string;
    1621    FileName: string;
    17     SectorSize: Integer;
    18     SectorCount: Integer;
    1922    Modified: Boolean;
    2023    Scans: TDriveScanList;
    21     DriveName: string;
     24    DriveInfo: TDriveInfo;
    2225    constructor Create;
    2326    destructor Destroy; override;
    2427    procedure LoadFromFile(FileName: string);
    2528    procedure SaveToFile(FileName: string);
     29    property SectorCount: Integer read GetSectorCount;
     30    property CurrentScan: TDriveScan read GetCurrentScan;
    2631  end;
    2732
     
    3540{ TProject }
    3641
     42function TProject.GetCurrentScan: TDriveScan;
     43begin
     44  if Scans.Count > 0 then Result := TDriveScan(Scans[Scans.Count - 1])
     45    else Result := nil;
     46end;
     47
     48function TProject.GetSectorCount: Integer;
     49begin
     50  Result := DriveInfo.SectorCount;
     51end;
     52
    3753constructor TProject.Create;
    3854begin
    39   SectorSize := 4096;
    4055  Scans := TDriveScanList.Create;
     56  DriveInfo := TDriveInfo.Create;
    4157end;
    4258
    4359destructor TProject.Destroy;
    4460begin
     61  FreeAndNil(DriveInfo);
    4562  FreeAndNil(Scans);
    4663  inherited Destroy;
     
    5976    AppendChild(RootNode);
    6077    with RootNode do begin
    61       WriteInteger(RootNode, 'SectorSize', SectorSize);
    62       WriteInteger(RootNode, 'SectorCount', SectorCount);
    63       WriteString(RootNode, 'DriveName', DriveName);
     78      WriteInteger(RootNode, 'SectorCount', DriveInfo.SectorCount);
     79      WriteInteger(RootNode, 'SectorSize', DriveInfo.SectorSize);
     80      WriteString(RootNode, 'DriveName', DriveInfo.Model);
     81      WriteString(RootNode, 'DrivePath', DriveInfo.Path);
     82      WriteInt64(RootNode, 'DriveSize', DriveInfo.Size);
    6483
    6584      NewNode := OwnerDocument.CreateElement('Scans');
     
    89108    RootNode := Doc.DocumentElement;
    90109    with RootNode do begin
    91       SectorSize := ReadInteger(RootNode, 'SectorSize', 4096);
    92       SectorCount := ReadInteger(RootNode, 'SectorCount', 0);
    93       DriveName := ReadString(RootNode, 'DriveName', '');
     110      DriveInfo.SectorSize := ReadInteger(RootNode, 'SectorSize', 4096);
     111      DriveInfo.SectorCount := ReadInteger(RootNode, 'SectorCount', 0);
     112      DriveInfo.Model := ReadString(RootNode, 'DriveName', '');
     113      DriveInfo.Path := ReadString(RootNode, 'DrivePath', '');
     114      DriveInfo.Size := ReadInt64(RootNode, 'DriveSize', 0);
    94115
    95116      NewNode := FindNode('Scans');
Note: See TracChangeset for help on using the changeset viewer.