Changeset 13 for trunk/Form
- Timestamp:
- Apr 2, 2016, 1:06:34 PM (9 years ago)
- Location:
- trunk/Form
- Files:
-
- 2 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Form/UFormMain.lfm
r12 r13 9 9 Menu = MainMenu1 10 10 OnClose = FormClose 11 OnCloseQuery = FormCloseQuery 11 12 OnCreate = FormCreate 12 13 OnDestroy = FormDestroy … … 14 15 LCLVersion = '1.7' 15 16 object ButtonScan: TButton 16 Left = 1 2017 Left = 16 17 18 Height = 25 18 Top = 5619 Top = 104 19 20 Width = 75 20 21 Action = AScanStart … … 23 24 object Image1: TImage 24 25 Left = 592 25 Height = 8 7826 Top = 1026 Height = 848 27 Top = 40 27 28 Width = 1092 28 29 Anchors = [akTop, akLeft, akRight, akBottom] … … 37 38 ParentColor = False 38 39 end 39 object Label BlockSize: TLabel40 object LabelSectorSize: TLabel 40 41 Left = 256 41 42 Height = 24 … … 45 46 ParentColor = False 46 47 end 47 object Label BlockCount: TLabel48 object LabelSectorCount: TLabel 48 49 Left = 256 49 50 Height = 24 … … 158 159 end 159 160 object ButtonScan1: TButton 160 Left = 17161 Left = 440 161 162 Height = 25 162 Top = 56163 Width = 93163 Top = 48 164 Width = 120 164 165 Action = AProjectOptions 165 166 TabOrder = 1 166 167 end 167 168 object ButtonScan2: TButton 168 Left = 200169 Left = 104 169 170 Height = 25 170 Top = 56171 Top = 104 171 172 Width = 75 172 173 Action = AScanStop … … 190 191 end 191 192 object Button2: TButton 192 Left = 286193 Left = 192 193 194 Height = 25 194 Top = 56195 Top = 104 195 196 Width = 107 196 197 Action = AScanContinue … … 235 236 end 236 237 object Button3: TButton 237 Left = 16238 Left = 312 238 239 Height = 25 239 Top = 96240 Width = 1 87240 Top = 104 241 Width = 112 241 242 Action = AOperationOptions 242 Caption = 'Options options'243 243 TabOrder = 5 244 244 end 245 245 object ComboBoxDrive: TComboBox 246 Left = 15246 Left = 8 247 247 Height = 38 248 Top = 8249 Width = 4 64248 Top = 40 249 Width = 416 250 250 ItemHeight = 0 251 251 OnChange = ComboBoxDriveChange … … 253 253 TabOrder = 6 254 254 end 255 object ToolBar1: TToolBar 256 Left = 0 257 Height = 26 258 Top = 0 259 Width = 1703 260 Caption = 'ToolBar1' 261 Images = ImageList1 262 TabOrder = 7 263 object ToolButton1: TToolButton 264 Left = 1 265 Top = 2 266 Action = AScanStart 267 end 268 object ToolButton2: TToolButton 269 Left = 24 270 Top = 2 271 Action = AScanStop 272 end 273 object ToolButton3: TToolButton 274 Left = 47 275 Top = 2 276 Action = AScanContinue 277 end 278 end 255 279 object Timer1: TTimer 256 280 Interval = 500 … … 274 298 OnExecute = AProjectOptionsExecute 275 299 end 276 object A BrowseDisk: TAction300 object ADriveSelect: TAction 277 301 Caption = 'Select...' 278 302 end … … 319 343 end 320 344 object MainMenu1: TMainMenu 345 Images = ImageList1 321 346 left = 672 322 347 top = 504 … … 374 399 top = 160 375 400 end 401 object ImageList1: TImageList 402 left = 672 403 top = 573 404 end 376 405 end -
trunk/Form/UFormMain.pas
r12 r13 14 14 15 15 TFormMain = class(TForm) 16 A BrowseDisk: TAction;16 ADriveSelect: TAction; 17 17 AOperationOptions: TAction; 18 18 AFileClose: TAction; … … 34 34 ComboBoxDrive: TComboBox; 35 35 Image1: TImage; 36 ImageList1: TImageList; 36 37 Label1: TLabel; 37 38 Label10: TLabel; … … 45 46 Label8: TLabel; 46 47 LabelElapsedTime: TLabel; 47 Label BlockSize: TLabel;48 Label BlockCount: TLabel;48 LabelSectorSize: TLabel; 49 LabelSectorCount: TLabel; 49 50 LabelBlockCurrent: TLabel; 50 51 LabelBlockDamaged: TLabel; … … 73 74 SaveDialog1: TSaveDialog; 74 75 Timer1: TTimer; 76 ToolBar1: TToolBar; 77 ToolButton1: TToolButton; 78 ToolButton2: TToolButton; 79 ToolButton3: TToolButton; 75 80 XMLConfig1: TXMLConfig; 76 81 procedure AExitExecute(Sender: TObject); … … 87 92 procedure ComboBoxDriveChange(Sender: TObject); 88 93 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 94 procedure FormCloseQuery(Sender: TObject; var CanClose: boolean); 89 95 procedure FormCreate(Sender: TObject); 90 96 procedure FormDestroy(Sender: TObject); … … 98 104 RedrawPending: Boolean; 99 105 LastProjectFileName: string; 106 LastDriveName: string; 100 107 procedure ReloadOperationList; 101 108 procedure ProjectOpen(FileName: string); … … 107 114 public 108 115 DriveList: TDriveList; 109 DriveScan: TDriveScan;110 116 Project: TProject; 111 117 procedure SaveConfig; … … 126 132 127 133 resourcestring 128 S ProjectModified= '(modified)';134 SModifiedFlag = '(modified)'; 129 135 SNewProject = 'New project'; 130 136 SSelectDriveForScan = 'Select drive for scan'; … … 132 138 SSaveProject = 'Save scan project'; 133 139 SBytes = 'bytes'; 140 SProjectModified = 'Project modified'; 141 SProjectModifiedQuestion = 'Project was modified. Do you want to save it?'; 134 142 135 143 { TFormMain } … … 175 183 procedure TFormMain.AScanStopExecute(Sender: TObject); 176 184 begin 177 DriveScan.Stop; 178 UpdateInterface; 185 if Assigned(Project) and Assigned(Project.CurrentScan) then begin 186 Project.CurrentScan.Stop; 187 UpdateInterface; 188 end; 179 189 end; 180 190 181 191 procedure TFormMain.ComboBoxDriveChange(Sender: TObject); 182 192 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; 193 if Project.DriveInfo.Path <> TDriveInfo(ComboBoxDrive.Items.Objects[ComboBoxDrive.ItemIndex]).Path then begin 194 Project.DriveInfo.Assign(TDriveInfo(ComboBoxDrive.Items.Objects[ComboBoxDrive.ItemIndex])); 195 Project.Modified := True; 196 Project.CurrentScan.SectorCount := Project.DriveInfo.SectorCount; 197 Project.CurrentScan.SectorSize := Project.DriveInfo.SectorSize; 198 Project.CurrentScan.SectorStart := 0; 199 Project.CurrentScan.SectorEnd := Project.CurrentScan.SectorCount - 1; 200 Project.CurrentScan.Reset; 201 UpdateInterface; 202 Redraw; 203 end; 187 204 end; 188 205 … … 190 207 begin 191 208 LastBlockPos := 0; 192 DriveScan.DriveName := TDriveInfo(DriveList[ComboBoxDrive.ItemIndex]).Path;193 DriveScan.Reset;194 DriveScan.SectorSize := Project.SectorSize;195 DriveScan.OnChange := DriveScanChange;196 DriveScan.OnTerminate := DriveScanTerminate;197 DriveScan.Start;209 Project.CurrentScan.DriveName := Project.DriveInfo.Path; 210 Project.CurrentScan.SectorSize := Project.DriveInfo.SectorSize; 211 Project.CurrentScan.Reset; 212 Project.CurrentScan.OnChange := DriveScanChange; 213 Project.CurrentScan.OnTerminate := DriveScanTerminate; 214 Project.CurrentScan.Start; 198 215 Project.Modified := True; 199 216 UpdateInterface; … … 212 229 procedure TFormMain.AScanContinueExecute(Sender: TObject); 213 230 begin 214 DriveScan.Start;231 Project.CurrentScan.Start; 215 232 Project.Modified := True; 216 233 UpdateInterface; … … 224 241 procedure TFormMain.AFileCloseExecute(Sender: TObject); 225 242 begin 226 DriveScan := nil;227 243 FreeAndNil(Project); 228 244 UpdateInterface; … … 236 252 Project.Modified := False; 237 253 Project.Scans.Add(TDriveScan.Create); 238 DriveScan := TDriveScan(Project.Scans[0]); 239 240 DriveScan.SectorStart:= 0;241 DriveScan.SectorEnd := DriveScan.SectorCount - 1;242 DriveScan.Reset; 254 255 ComboBoxDrive.ItemIndex := DriveList.IndexOf(DriveList.FindByModel(Project.DriveInfo.Model)); 256 if (ComboBoxDrive.ItemIndex = -1) and (ComboBoxDrive.Items.Count > 0) then ComboBoxDrive.ItemIndex := 0; 257 ComboBoxDriveChange(Self); 258 243 259 Redraw; 244 260 UpdateInterface; … … 279 295 procedure TFormMain.AOperationOptionsExecute(Sender: TObject); 280 296 begin 281 FormOperation.Load( DriveScan);297 FormOperation.Load(Project.CurrentScan); 282 298 if FormOperation.ShowModal = mrOk then begin 283 FormOperation.Save( DriveScan);299 FormOperation.Save(Project.CurrentScan); 284 300 Project.Modified := True; 285 301 UpdateInterface; … … 291 307 AFileClose.Execute; 292 308 SaveConfig; 309 end; 310 311 procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: boolean); 312 var 313 R: TModalResult; 314 begin 315 if Assigned(Project) and Project.Modified then begin 316 R := MessageDlg(SProjectModified, SProjectModifiedQuestion, mtConfirmation, [mbYes, mbNo, mbCancel], 0); 317 if R = mrCancel then begin 318 CanClose := False; 319 Exit; 320 end else 321 if R = mrYes then begin 322 AFileSave.Execute; 323 end; 324 end; 293 325 end; 294 326 … … 315 347 Picture.Bitmap.SetSize(Width, Height); 316 348 try 317 DriveScan.Lock.Acquire;349 Project.CurrentScan.Lock.Acquire; 318 350 try 319 351 Picture.Bitmap.BeginUpdate(True); 320 DriveScan.BlockMap.Draw(Picture.Bitmap.Canvas);352 Project.CurrentScan.BlockMap.Draw(Picture.Bitmap.Canvas); 321 353 finally 322 354 Picture.Bitmap.EndUpdate; 323 355 end; 324 LabelSize.Caption := PrefixMultiplier.Add(DriveScan.BlockMap.SectorCount * DriveScan.SectorSize, 325 BasePrefixMultipliers, SBytes); 326 LabelSectorPerBlock.Caption := IntToStr(DriveScan.BlockMap.SectorPerBlock); 327 LabelBlockSize.Caption := IntToStr(DriveScan.SectorSize) + ' ' + SBytes; 328 LabelBlockCount.Caption := IntToStr(DriveScan.BlockMap.SectorCount); 329 LabelBlockCurrent.Caption := IntToStr(DriveScan.SectorCurrent); 330 LabelBlockDamaged.Caption := IntToStr(DriveScan.DamagedBlockCount); 356 LabelSectorPerBlock.Caption := IntToStr(Project.CurrentScan.BlockMap.SectorPerBlock); 357 LabelBlockCurrent.Caption := IntToStr(Project.CurrentScan.SectorCurrent); 358 LabelBlockDamaged.Caption := IntToStr(Project.CurrentScan.DamagedBlockCount); 331 359 finally 332 DriveScan.Lock.Release;360 Project.CurrentScan.Lock.Release; 333 361 end; 334 362 RedrawPending := False; 335 363 end; 336 364 try 337 DriveScan.Lock.Acquire;338 if not DriveScan.Terminated then begin339 LabelElapsedTime.Caption := TimeToStr( DriveScan.GetElapsedTime);340 LabelEstimatedTime.Caption := TimeToStr((Now - DriveScan.TimeStart) /341 DriveScan.SectorCurrent * (DriveScan.BlockMap.SectorCount - DriveScan.SectorCurrent));342 LabelIOSpeed.Caption := PrefixMultiplier.Add(( DriveScan.SectorCurrent - LastBlockPos) *343 DriveScan.SectorSize / (Timer1.Interval / 1000), BasePrefixMultipliers, 'B/s');344 LastBlockPos := DriveScan.SectorCurrent;365 Project.CurrentScan.Lock.Acquire; 366 if not Project.CurrentScan.Terminated then begin 367 LabelElapsedTime.Caption := TimeToStr(Project.CurrentScan.GetElapsedTime); 368 LabelEstimatedTime.Caption := TimeToStr((Now - Project.CurrentScan.TimeStart) / 369 Project.CurrentScan.SectorCurrent * (Project.CurrentScan.BlockMap.SectorCount - Project.CurrentScan.SectorCurrent)); 370 LabelIOSpeed.Caption := PrefixMultiplier.Add((Project.CurrentScan.SectorCurrent - LastBlockPos) * 371 Project.CurrentScan.SectorSize / (Timer1.Interval / 1000), BasePrefixMultipliers, 'B/s'); 372 LastBlockPos := Project.CurrentScan.SectorCurrent; 345 373 end else begin 346 374 LabelElapsedTime.Caption := ''; … … 349 377 end; 350 378 finally 351 DriveScan.Lock.Release;379 Project.CurrentScan.Lock.Release; 352 380 end; 353 381 end else … … 367 395 Title: string; 368 396 begin 369 if Assigned(DriveScan) then begin 370 AScanStart.Enabled := DriveScan.Terminated = True; 371 AScanStop.Enabled := DriveScan.Terminated = False; 372 AScanContinue.Enabled := (DriveScan.Terminated = True) and (DriveScan.SectorCurrent > DriveScan.SectorStart) and 373 (DriveScan.SectorCurrent < DriveScan.SectorEnd); 397 if Assigned(Project) and Assigned(Project.CurrentScan) then begin 398 AScanStart.Enabled := Project.CurrentScan.Terminated = True; 399 AScanStop.Enabled := Project.CurrentScan.Terminated = False; 400 AScanContinue.Enabled := (Project.CurrentScan.Terminated = True) and 401 (Project.CurrentScan.SectorCurrent > Project.CurrentScan.SectorStart) and 402 (Project.CurrentScan.SectorCurrent < Project.CurrentScan.SectorEnd); 403 end else begin 404 AScanStart.Enabled := False; 405 AScanStop.Enabled := False; 406 AScanContinue.Enabled := False; 374 407 end; 375 408 AFileSave.Enabled := Assigned(Project) and Project.Modified; 376 409 AFileSaveAs.Enabled := Assigned(Project); 377 410 AFileClose.Enabled := Assigned(Project); 411 ComboBoxDrive.Enabled := Assigned(Project); 412 AProjectOptions.Enabled := Assigned(Project);; 413 AOperationOptions.Enabled := Assigned(Project);; 378 414 ReloadOperationList; 379 415 … … 383 419 Title := Title + Application.Title; 384 420 if Assigned(Project) and Project.Modified then 385 Title := Title + ' ' + S ProjectModified;421 Title := Title + ' ' + SModifiedFlag; 386 422 Caption := Title; 423 424 if Assigned(Project) then begin 425 LabelSize.Caption := PrefixMultiplier.Add(Project.DriveInfo.Size, 426 BasePrefixMultipliers, SBytes); 427 LabelSectorCount.Caption := IntToStr(Project.DriveInfo.SectorCount); 428 LabelSectorSize.Caption := IntToStr(Project.DriveInfo.SectorSize) + ' ' + SBytes; 429 end else begin 430 LabelSize.Caption := ''; 431 LabelSectorCount.Caption := ''; 432 LabelSectorSize.Caption := ''; 433 end; 387 434 end; 388 435 389 436 procedure TFormMain.SaveConfig; 390 437 begin 391 XMLConfig1.SetValue('DriveName', TDriveInfo(DriveList[ComboBoxDrive.ItemIndex]).Model);438 XMLConfig1.SetValue('DriveName', LastDriveName); 392 439 XMLConfig1.SetValue('LastProjectFileName', LastProjectFileName); 393 440 end; … … 395 442 procedure TFormMain.LoadConfig; 396 443 begin 397 ComboBoxDrive.ItemIndex := DriveList.IndexOf(DriveList.FindByModel(XMLConfig1.GetValue('DriveName', '')));444 LastDriveName := XMLConfig1.GetValue('DriveName', ''); 398 445 LastProjectFileName := XMLConfig1.GetValue('LastProjectFileName', ''); 399 446 end; … … 418 465 AFileNew.Execute; 419 466 Project.LoadFromFile(FileName); 467 ComboBoxDrive.ItemIndex := DriveList.IndexOf(DriveList.FindByModel(Project.DriveInfo.Model)); 468 if (ComboBoxDrive.ItemIndex = -1) and (ComboBoxDrive.Items.Count > 0) then ComboBoxDrive.ItemIndex := 0; 420 469 LastProjectFileName := FileName; 421 470 UpdateInterface; … … 438 487 begin 439 488 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') + ')'; 489 DriveList.LoadToStrings(ComboBoxDrive.Items); 447 490 end; 448 491 -
trunk/Form/UFormOperation.lfm
r11 r13 71 71 Width = 138 72 72 MaxValue = 100000 73 MinValue = 174 73 OnChange = SpinEditFirstSectorChange 75 74 TabOrder = 4 … … 82 81 Width = 138 83 82 MaxValue = 100000 84 MinValue = 185 83 OnChange = SpinEditLastSectorChange 86 84 TabOrder = 5 -
trunk/Form/UFormProject.lfm
r11 r13 1 1 object FormProject: TFormProject 2 2 Left = 537 3 Height = 3 404 Top = 4 925 Width = 4613 Height = 392 4 Top = 440 5 Width = 612 6 6 Caption = 'Project settings' 7 ClientHeight = 3 408 ClientWidth = 4617 ClientHeight = 392 8 ClientWidth = 612 9 9 LCLVersion = '1.7' 10 10 object SpinEditSectorSize: TSpinEdit 11 11 Left = 192 12 12 Height = 34 13 Top = 5613 Top = 152 14 14 Width = 101 15 15 MaxValue = 100000 … … 21 21 Left = 16 22 22 Height = 24 23 Top = 6423 Top = 160 24 24 Width = 101 25 25 Caption = 'Sector size:' … … 44 44 TabOrder = 2 45 45 end 46 object Edit 1: TEdit46 object EditName: TEdit 47 47 Left = 192 48 48 Height = 34 … … 50 50 Width = 240 51 51 TabOrder = 3 52 Text = 'Edit1'53 52 end 54 53 object Label2: TLabel … … 60 59 ParentColor = False 61 60 end 61 object ComboBoxDrive: TComboBox 62 Left = 192 63 Height = 38 64 Top = 56 65 Width = 384 66 ItemHeight = 0 67 Style = csDropDownList 68 TabOrder = 4 69 end 70 object Label3: TLabel 71 Left = 16 72 Height = 24 73 Top = 64 74 Width = 53 75 Caption = 'Drive:' 76 ParentColor = False 77 end 78 object Label4: TLabel 79 Left = 16 80 Height = 24 81 Top = 112 82 Width = 119 83 Caption = 'Sector count:' 84 ParentColor = False 85 end 86 object LabelSectorCount: TLabel 87 Left = 192 88 Height = 24 89 Top = 112 90 Width = 15 91 Caption = ' ' 92 ParentColor = False 93 end 62 94 end -
trunk/Form/UFormProject.pas
r11 r13 16 16 Button1: TButton; 17 17 Button2: TButton; 18 Edit1: TEdit; 18 ComboBoxDrive: TComboBox; 19 EditName: TEdit; 19 20 Label1: TLabel; 20 21 Label2: TLabel; 22 Label3: TLabel; 23 Label4: TLabel; 24 LabelSectorCount: TLabel; 21 25 SpinEditSectorSize: TSpinEdit; 22 26 private … … 33 37 {$R *.lfm} 34 38 39 uses 40 UFormMain; 41 35 42 { TFormProject } 36 43 37 44 procedure TFormProject.Load(Project: TProject); 38 45 begin 39 Edit1.Text := Project.Name; 40 SpinEditSectorSize.Value := Project.SectorSize; 46 FormMain.DriveList.LoadToStrings(ComboBoxDrive.Items); 47 EditName.Text := Project.Name; 48 SpinEditSectorSize.Value := Project.DriveInfo.SectorSize; 49 ComboBoxDrive.ItemIndex := FormMain.DriveList.IndexOf(FormMain.DriveList.FindByModel(Project.DriveInfo.Model)); 41 50 end; 42 51 43 52 procedure TFormProject.Save(Project: TProject); 44 53 begin 45 Project.Name := Edit 1.Text;46 Project. SectorSize := SpinEditSectorSize.Value;54 Project.Name := EditName.Text; 55 Project.DriveInfo.SectorSize := SpinEditSectorSize.Value; 47 56 end; 48 57
Note:
See TracChangeset
for help on using the changeset viewer.