Changeset 15 for trunk/Form
- Timestamp:
- Apr 2, 2016, 1:39:42 PM (9 years ago)
- Location:
- trunk/Form
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Form/UFormMain.lfm
r14 r15 23 23 end 24 24 object Image1: TImage 25 Left = 59226 Height = 8 4825 Left = 600 26 Height = 856 27 27 Top = 40 28 28 Width = 1092 … … 408 408 object LastOpenedList1: TLastOpenedList 409 409 MaxCount = 10 410 left = 90 6411 top = 1 67410 left = 904 411 top = 144 412 412 end 413 413 end -
trunk/Form/UFormMain.pas
r14 r15 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 9 Menus, ComCtrls, ExtCtrls, ActnList, dateutils, syncobjs, UProject, 10 UDriveScan, UPrefixMultiplier, ULastOpenedList, XMLConf, UPhysDrive; 10 UDriveScan, UPrefixMultiplier, ULastOpenedList, UPersistentForm, XMLConf, 11 UPhysDrive; 11 12 12 13 type … … 115 116 procedure UpdateInterface; 116 117 public 117 DriveList: TDriveList;118 Project: TProject;119 118 procedure SaveConfig; 120 119 procedure LoadConfig; … … 131 130 132 131 uses 133 U FormProject, UFormOperation;132 UCore, UFormProject, UFormOperation; 134 133 135 134 resourcestring … … 149 148 Detect; 150 149 LoadConfig; 150 Core.PersistentForm1.Load(Self); 151 151 if (LastOpenedList1.Items.Count > 0) then 152 152 ProjectOpen(LastOpenedList1.Items[0]) … … 165 165 procedure TFormMain.ListView1Data(Sender: TObject; Item: TListItem); 166 166 begin 167 if (Item.Index >= 0) and (Item.Index < Project.Scans.Count) then168 with TDriveScan( Project.Scans[Item.Index]) do begin167 if (Item.Index >= 0) and (Item.Index < Core.Project.Scans.Count) then 168 with TDriveScan(Core.Project.Scans[Item.Index]) do begin 169 169 Item.Caption := IntToStr(Item.Index); 170 170 Item.SubItems.Add(DateTimeToStr(TimeStart)); … … 179 179 PrefixMultiplier := TPrefixMultiplier.Create; 180 180 XMLConfig1.Filename := 'config.xml'; 181 Project := nil;182 DriveList := TDriveList.Create;183 181 end; 184 182 185 183 procedure TFormMain.AScanStopExecute(Sender: TObject); 186 184 begin 187 if Assigned( Project) and Assigned(Project.CurrentScan) then begin188 Project.CurrentScan.Stop;185 if Assigned(Core.Project) and Assigned(Core.Project.CurrentScan) then begin 186 Core.Project.CurrentScan.Stop; 189 187 UpdateInterface; 190 188 end; … … 193 191 procedure TFormMain.ComboBoxDriveChange(Sender: TObject); 194 192 begin 195 if Project.DriveInfo.Path <> TDriveInfo(ComboBoxDrive.Items.Objects[ComboBoxDrive.ItemIndex]).Path then begin 196 Project.DriveInfo.Assign(TDriveInfo(ComboBoxDrive.Items.Objects[ComboBoxDrive.ItemIndex])); 197 Project.Modified := True; 198 Project.CurrentScan.SectorCount := Project.DriveInfo.SectorCount; 199 Project.CurrentScan.SectorSize := Project.DriveInfo.SectorSize; 200 Project.CurrentScan.SectorStart := 0; 201 Project.CurrentScan.SectorEnd := Project.CurrentScan.SectorCount - 1; 202 Project.CurrentScan.Reset; 193 with Core.Project do 194 if DriveInfo.Path <> TDriveInfo(ComboBoxDrive.Items.Objects[ComboBoxDrive.ItemIndex]).Path then begin 195 DriveInfo.Assign(TDriveInfo(ComboBoxDrive.Items.Objects[ComboBoxDrive.ItemIndex])); 196 Modified := True; 197 CurrentScan.SectorCount := DriveInfo.SectorCount; 198 CurrentScan.SectorSize := DriveInfo.SectorSize; 199 CurrentScan.SectorStart := 0; 200 CurrentScan.SectorEnd := CurrentScan.SectorCount - 1; 201 CurrentScan.Reset; 203 202 UpdateInterface; 204 203 Redraw; … … 209 208 begin 210 209 LastBlockPos := 0; 211 Project.CurrentScan.DriveName := Project.DriveInfo.Path; 212 Project.CurrentScan.SectorSize := Project.DriveInfo.SectorSize; 213 Project.CurrentScan.Reset; 214 Project.CurrentScan.OnChange := DriveScanChange; 215 Project.CurrentScan.OnTerminate := DriveScanTerminate; 216 Project.CurrentScan.Start; 217 Project.Modified := True; 210 with Core.Project do begin 211 CurrentScan.DriveName := DriveInfo.Path; 212 CurrentScan.SectorSize := DriveInfo.SectorSize; 213 CurrentScan.Reset; 214 CurrentScan.OnChange := DriveScanChange; 215 CurrentScan.OnTerminate := DriveScanTerminate; 216 CurrentScan.Start; 217 Modified := True; 218 end; 218 219 UpdateInterface; 219 220 end; … … 221 222 procedure TFormMain.AProjectOptionsExecute(Sender: TObject); 222 223 begin 223 FormProject.Load( Project);224 FormProject.Load(Core.Project); 224 225 if FormProject.ShowModal = mrOk then begin 225 FormProject.Save( Project);226 Project.Modified := True;226 FormProject.Save(Core.Project); 227 Core.Project.Modified := True; 227 228 UpdateInterface; 228 229 end; … … 231 232 procedure TFormMain.AScanContinueExecute(Sender: TObject); 232 233 begin 233 Project.CurrentScan.Start;234 Project.Modified := True;234 Core.Project.CurrentScan.Start; 235 Core.Project.Modified := True; 235 236 UpdateInterface; 236 237 end; … … 243 244 procedure TFormMain.AFileCloseExecute(Sender: TObject); 244 245 begin 245 FreeAndNil( Project);246 FreeAndNil(Core.Project); 246 247 UpdateInterface; 247 248 end; … … 250 251 begin 251 252 AFileClose.Execute; 252 Project := TProject.Create;253 Project.FileName := SNewProject;254 Project.Modified := False;255 Project.Scans.Add(TDriveScan.Create);256 257 ComboBoxDrive.ItemIndex := DriveList.IndexOf(DriveList.FindByModel(Project.DriveInfo.Model));253 Core.Project := TProject.Create; 254 Core.Project.FileName := SNewProject; 255 Core.Project.Modified := False; 256 Core.Project.Scans.Add(TDriveScan.Create); 257 258 ComboBoxDrive.ItemIndex := Core.DriveList.IndexOf(Core.DriveList.FindByModel(Core.Project.DriveInfo.Model)); 258 259 if (ComboBoxDrive.ItemIndex = -1) and (ComboBoxDrive.Items.Count > 0) then ComboBoxDrive.ItemIndex := 0; 259 260 ComboBoxDriveChange(Self); … … 267 268 OpenDialog1.Title := SOpenStoredProject; 268 269 OpenDialog1.DefaultExt := '.cdp'; 269 if Assigned( Project) then270 OpenDialog1.FileName := Project.FileName;270 if Assigned(Core.Project) then 271 OpenDialog1.FileName := Core.Project.FileName; 271 272 if OpenDialog1.Execute then begin 272 273 ProjectOpen(OpenDialog1.FileName); … … 278 279 SaveDialog1.Title := SSaveProject; 279 280 SaveDialog1.DefaultExt := '.cdp'; 280 SaveDialog1.FileName := Project.FileName;281 SaveDialog1.FileName := Core.Project.FileName; 281 282 if SaveDialog1.Execute then begin 282 Project.SaveToFile(SaveDialog1.FileName);283 Core.Project.SaveToFile(SaveDialog1.FileName); 283 284 LastOpenedList1.AddItem(SaveDialog1.FileName); 284 285 LastOpenedList1.LoadToMenuItem(MenuItemOpenRecent, OpenRecentClick); … … 289 290 procedure TFormMain.AFileSaveExecute(Sender: TObject); 290 291 begin 291 if not FileExists( Project.FileName) then292 if not FileExists(Core.Project.FileName) then 292 293 AFileSaveAs.Execute 293 294 else begin 294 Project.SaveToFile(Project.FileName);295 Core.Project.SaveToFile(Core.Project.FileName); 295 296 LastOpenedList1.AddItem(SaveDialog1.FileName); 296 297 LastOpenedList1.LoadToMenuItem(MenuItemOpenRecent, OpenRecentClick); … … 301 302 procedure TFormMain.AOperationOptionsExecute(Sender: TObject); 302 303 begin 303 FormOperation.Load( Project.CurrentScan);304 FormOperation.Load(Core.Project.CurrentScan); 304 305 if FormOperation.ShowModal = mrOk then begin 305 FormOperation.Save( Project.CurrentScan);306 Project.Modified := True;306 FormOperation.Save(Core.Project.CurrentScan); 307 Core.Project.Modified := True; 307 308 UpdateInterface; 308 309 end; … … 313 314 AFileClose.Execute; 314 315 SaveConfig; 316 Core.PersistentForm1.Save(Self); 315 317 end; 316 318 … … 319 321 R: TModalResult; 320 322 begin 321 if Assigned( Project) andProject.Modified then begin323 if Assigned(Core.Project) and Core.Project.Modified then begin 322 324 R := MessageDlg(SProjectModified, SProjectModifiedQuestion, mtConfirmation, [mbYes, mbNo, mbCancel], 0); 323 325 if R = mrCancel then begin … … 334 336 begin 335 337 Timer1.Enabled := False; 336 if Assigned(Project) then FreeAndNil(Project);337 338 FreeAndNil(PrefixMultiplier); 338 FreeAndNil(DriveList);339 339 end; 340 340 … … 347 347 procedure TFormMain.DoDraw; 348 348 begin 349 if Assigned(Project) then begin 349 if Assigned(Core.Project) then 350 with Core.Project do begin 350 351 if RedrawPending then 351 352 with Image1 do begin … … 353 354 Picture.Bitmap.SetSize(Width, Height); 354 355 try 355 Project.CurrentScan.Lock.Acquire;356 Core.Project.CurrentScan.Lock.Acquire; 356 357 try 357 358 Picture.Bitmap.BeginUpdate(True); 358 Project.CurrentScan.BlockMap.Draw(Picture.Bitmap.Canvas);359 CurrentScan.BlockMap.Draw(Picture.Bitmap.Canvas); 359 360 finally 360 361 Picture.Bitmap.EndUpdate; 361 362 end; 362 LabelSectorPerBlock.Caption := IntToStr( Project.CurrentScan.BlockMap.SectorPerBlock);363 LabelBlockCurrent.Caption := IntToStr( Project.CurrentScan.SectorCurrent);364 LabelBlockDamaged.Caption := IntToStr( Project.CurrentScan.DamagedBlockCount);363 LabelSectorPerBlock.Caption := IntToStr(CurrentScan.BlockMap.SectorPerBlock); 364 LabelBlockCurrent.Caption := IntToStr(CurrentScan.SectorCurrent); 365 LabelBlockDamaged.Caption := IntToStr(CurrentScan.DamagedBlockCount); 365 366 finally 366 Project.CurrentScan.Lock.Release;367 CurrentScan.Lock.Release; 367 368 end; 368 369 RedrawPending := False; 369 370 end; 370 371 try 371 Project.CurrentScan.Lock.Acquire;372 if not Project.CurrentScan.Terminated then begin373 LabelElapsedTime.Caption := TimeToStr( Project.CurrentScan.GetElapsedTime);374 LabelEstimatedTime.Caption := TimeToStr((Now - Project.CurrentScan.TimeStart) /375 Project.CurrentScan.SectorCurrent * (Project.CurrentScan.BlockMap.SectorCount - Project.CurrentScan.SectorCurrent));376 LabelIOSpeed.Caption := PrefixMultiplier.Add(( Project.CurrentScan.SectorCurrent - LastBlockPos) *377 Project.CurrentScan.SectorSize / (Timer1.Interval / 1000), BasePrefixMultipliers, 'B/s');378 LastBlockPos := Project.CurrentScan.SectorCurrent;372 CurrentScan.Lock.Acquire; 373 if not CurrentScan.Terminated then begin 374 LabelElapsedTime.Caption := TimeToStr(CurrentScan.GetElapsedTime); 375 LabelEstimatedTime.Caption := TimeToStr((Now - CurrentScan.TimeStart) / 376 CurrentScan.SectorCurrent * (CurrentScan.BlockMap.SectorCount - CurrentScan.SectorCurrent)); 377 LabelIOSpeed.Caption := PrefixMultiplier.Add((CurrentScan.SectorCurrent - LastBlockPos) * 378 CurrentScan.SectorSize / (Timer1.Interval / 1000), BasePrefixMultipliers, 'B/s'); 379 LastBlockPos := CurrentScan.SectorCurrent; 379 380 end else begin 380 381 LabelElapsedTime.Caption := ''; … … 383 384 end; 384 385 finally 385 Project.CurrentScan.Lock.Release;386 CurrentScan.Lock.Release; 386 387 end; 387 388 end else … … 401 402 Title: string; 402 403 begin 404 with Core do begin 403 405 if Assigned(Project) and Assigned(Project.CurrentScan) then begin 404 406 AScanStart.Enabled := Project.CurrentScan.Terminated = True; … … 438 440 LabelSectorSize.Caption := ''; 439 441 end; 442 end; 440 443 end; 441 444 … … 464 467 procedure TFormMain.ReloadOperationList; 465 468 begin 466 if Assigned( Project) then begin467 ListView1.Items.Count := Project.Scans.Count;469 if Assigned(Core.Project) then begin 470 ListView1.Items.Count := Core.Project.Scans.Count; 468 471 end else begin 469 472 ListView1.Items.Count := 0; … … 475 478 begin 476 479 AFileNew.Execute; 477 Project.LoadFromFile(FileName);478 ComboBoxDrive.ItemIndex := DriveList.IndexOf(DriveList.FindByModel(Project.DriveInfo.Model));480 Core.Project.LoadFromFile(FileName); 481 ComboBoxDrive.ItemIndex := Core.DriveList.IndexOf(Core.DriveList.FindByModel(Core.Project.DriveInfo.Model)); 479 482 if (ComboBoxDrive.ItemIndex = -1) and (ComboBoxDrive.Items.Count > 0) then ComboBoxDrive.ItemIndex := 0; 480 483 LastOpenedList1.AddItem(FileName); … … 496 499 procedure TFormMain.Detect; 497 500 begin 498 DriveList.Detect;499 DriveList.LoadToStrings(ComboBoxDrive.Items);501 Core.DriveList.Detect; 502 Core.DriveList.LoadToStrings(ComboBoxDrive.Items); 500 503 end; 501 504 -
trunk/Form/UFormProject.pas
r13 r15 38 38 39 39 uses 40 U FormMain;40 UCore; 41 41 42 42 { TFormProject } … … 44 44 procedure TFormProject.Load(Project: TProject); 45 45 begin 46 FormMain.DriveList.LoadToStrings(ComboBoxDrive.Items);46 Core.DriveList.LoadToStrings(ComboBoxDrive.Items); 47 47 EditName.Text := Project.Name; 48 48 SpinEditSectorSize.Value := Project.DriveInfo.SectorSize; 49 ComboBoxDrive.ItemIndex := FormMain.DriveList.IndexOf(FormMain.DriveList.FindByModel(Project.DriveInfo.Model));49 ComboBoxDrive.ItemIndex := Core.DriveList.IndexOf(Core.DriveList.FindByModel(Project.DriveInfo.Model)); 50 50 end; 51 51
Note:
See TracChangeset
for help on using the changeset viewer.