Changeset 12 for trunk/Form/UFormMain.pas
- Timestamp:
- Apr 2, 2016, 11:08:30 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Form/UFormMain.pas
r11 r12 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 9 Menus, ComCtrls, ExtCtrls, ActnList, dateutils, syncobjs, UProject, 10 UDriveScan, UPrefixMultiplier, XMLConf ;10 UDriveScan, UPrefixMultiplier, XMLConf, UPhysDrive; 11 11 12 12 type … … 27 27 AScanStop: TAction; 28 28 ActionList1: TActionList; 29 Button1: TButton;30 29 Button2: TButton; 31 30 Button3: TButton; … … 33 32 ButtonScan1: TButton; 34 33 ButtonScan2: TButton; 35 EditDrive: TEdit;34 ComboBoxDrive: TComboBox; 36 35 Image1: TImage; 37 36 Label1: TLabel; … … 75 74 Timer1: TTimer; 76 75 XMLConfig1: TXMLConfig; 77 procedure ABrowseDiskExecute(Sender: TObject);78 76 procedure AExitExecute(Sender: TObject); 79 77 procedure AFileCloseExecute(Sender: TObject); … … 87 85 procedure AScanStartExecute(Sender: TObject); 88 86 procedure AScanStopExecute(Sender: TObject); 87 procedure ComboBoxDriveChange(Sender: TObject); 89 88 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 90 89 procedure FormCreate(Sender: TObject); … … 100 99 LastProjectFileName: string; 101 100 procedure ReloadOperationList; 102 procedure CheckDrive;103 101 procedure ProjectOpen(FileName: string); 104 102 procedure DriveScanChange(Sender: TObject); … … 108 106 procedure UpdateInterface; 109 107 public 108 DriveList: TDriveList; 110 109 DriveScan: TDriveScan; 111 110 Project: TProject; … … 134 133 SBytes = 'bytes'; 135 134 136 const137 DefaultDriveName = '/dev/sda';138 139 135 { TFormMain } 140 136 141 137 procedure TFormMain.FormShow(Sender: TObject); 142 138 begin 139 Detect; 143 140 LoadConfig; 144 141 if FileExists(LastProjectFileName) then … … 171 168 begin 172 169 PrefixMultiplier := TPrefixMultiplier.Create; 173 EditDrive.Text := DefaultDriveName;174 170 XMLConfig1.Filename := 'config.xml'; 175 171 Project := nil; 172 DriveList := TDriveList.Create; 176 173 end; 177 174 … … 182 179 end; 183 180 181 procedure TFormMain.ComboBoxDriveChange(Sender: TObject); 182 begin 183 DriveScan.SectorCount := TDriveInfo(DriveList[ComboBoxDrive.ItemIndex]).SectorCount; 184 DriveScan.DriveName := TDriveInfo(DriveList[ComboBoxDrive.ItemIndex]).Path; 185 DriveScan.SectorStart := 0; 186 DriveScan.SectorEnd := DriveScan.SectorCount - 1; 187 end; 188 184 189 procedure TFormMain.AScanStartExecute(Sender: TObject); 185 190 begin 186 191 LastBlockPos := 0; 187 DriveScan.DriveName := EditDrive.Text;192 DriveScan.DriveName := TDriveInfo(DriveList[ComboBoxDrive.ItemIndex]).Path; 188 193 DriveScan.Reset; 189 194 DriveScan.SectorSize := Project.SectorSize; … … 197 202 procedure TFormMain.AProjectOptionsExecute(Sender: TObject); 198 203 begin 199 CheckDrive;200 204 FormProject.Load(Project); 201 205 if FormProject.ShowModal = mrOk then begin … … 211 215 Project.Modified := True; 212 216 UpdateInterface; 213 end;214 215 procedure TFormMain.ABrowseDiskExecute(Sender: TObject);216 begin217 OpenDialog1.Title := SSelectDriveForScan;218 OpenDialog1.DefaultExt := '';219 OpenDialog1.FileName := EditDrive.Text;220 if OpenDialog1.Execute then221 EditDrive.Text := OpenDialog1.FileName;222 217 end; 223 218 … … 243 238 DriveScan := TDriveScan(Project.Scans[0]); 244 239 245 CheckDrive;246 240 DriveScan.SectorStart := 0; 247 241 DriveScan.SectorEnd := DriveScan.SectorCount - 1; … … 304 298 if Assigned(Project) then FreeAndNil(Project); 305 299 FreeAndNil(PrefixMultiplier); 300 FreeAndNil(DriveList); 306 301 end; 307 302 … … 394 389 procedure TFormMain.SaveConfig; 395 390 begin 396 XMLConfig1.SetValue('DriveName', EditDrive.Text);391 XMLConfig1.SetValue('DriveName', TDriveInfo(DriveList[ComboBoxDrive.ItemIndex]).Model); 397 392 XMLConfig1.SetValue('LastProjectFileName', LastProjectFileName); 398 393 end; … … 400 395 procedure TFormMain.LoadConfig; 401 396 begin 402 EditDrive.Text := XMLConfig1.GetValue('DriveName', DefaultDriveName);397 ComboBoxDrive.ItemIndex := DriveList.IndexOf(DriveList.FindByModel(XMLConfig1.GetValue('DriveName', ''))); 403 398 LastProjectFileName := XMLConfig1.GetValue('LastProjectFileName', ''); 404 399 end; … … 419 414 end; 420 415 421 procedure TFormMain.CheckDrive;422 begin423 DriveScan.CheckDrive;424 Project.SectorCount := DriveScan.SectorCount;425 end;426 427 416 procedure TFormMain.ProjectOpen(FileName: string); 428 417 begin … … 445 434 446 435 procedure TFormMain.Detect; 447 begin 448 436 var 437 I: Integer; 438 begin 439 DriveList.Detect; 440 while ComboBoxDrive.Items.Count > DriveList.Count do 441 ComboBoxDrive.Items.Delete(ComboBoxDrive.Items.Count - 1); 442 while ComboBoxDrive.Items.Count < DriveList.Count do 443 ComboBoxDrive.Items.Add(''); 444 for I := 0 to DriveList.Count - 1 do 445 ComboBoxDrive.Items[I] := TDriveInfo(DriveList[I]).Model + ' (' + 446 PrefixMultiplier.Add(TDriveInfo(DriveList[I]).Size, BasePrefixMultipliers, 'B') + ')'; 449 447 end; 450 448
Note:
See TracChangeset
for help on using the changeset viewer.