1 | unit UFormOperation;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
---|
9 | Spin, UDriveScan;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TFormOperation }
|
---|
14 |
|
---|
15 | TFormOperation = class(TForm)
|
---|
16 | ButtonOk: TButton;
|
---|
17 | ButtonCancel: TButton;
|
---|
18 | CheckBoxRandomPattern: TCheckBox;
|
---|
19 | ComboBoxRunMode: TComboBox;
|
---|
20 | EditPattern: TEdit;
|
---|
21 | Label2: TLabel;
|
---|
22 | Label3: TLabel;
|
---|
23 | Label9: TLabel;
|
---|
24 | SpinEditFirstSector: TSpinEdit;
|
---|
25 | SpinEditLastSector: TSpinEdit;
|
---|
26 | procedure CheckBoxRandomPatternChange(Sender: TObject);
|
---|
27 | procedure ComboBoxRunModeChange(Sender: TObject);
|
---|
28 | procedure SpinEditFirstSectorChange(Sender: TObject);
|
---|
29 | procedure SpinEditLastSectorChange(Sender: TObject);
|
---|
30 | private
|
---|
31 | procedure UpdateMaxValues;
|
---|
32 | procedure UpdateWritePattern;
|
---|
33 | public
|
---|
34 | procedure Load(DriveScan: TDriveScanProfile);
|
---|
35 | procedure Save(DriveScan: TDriveScanProfile);
|
---|
36 | end;
|
---|
37 |
|
---|
38 | var
|
---|
39 | FormOperation: TFormOperation;
|
---|
40 |
|
---|
41 | implementation
|
---|
42 |
|
---|
43 | {$R *.lfm}
|
---|
44 |
|
---|
45 | { TFormOperation }
|
---|
46 |
|
---|
47 | procedure TFormOperation.SpinEditFirstSectorChange(Sender: TObject);
|
---|
48 | begin
|
---|
49 | UpdateMaxValues;
|
---|
50 | end;
|
---|
51 |
|
---|
52 | procedure TFormOperation.ComboBoxRunModeChange(Sender: TObject);
|
---|
53 | begin
|
---|
54 | UpdateWritePattern;
|
---|
55 | end;
|
---|
56 |
|
---|
57 | procedure TFormOperation.CheckBoxRandomPatternChange(Sender: TObject);
|
---|
58 | begin
|
---|
59 | UpdateWritePattern;
|
---|
60 | end;
|
---|
61 |
|
---|
62 | procedure TFormOperation.SpinEditLastSectorChange(Sender: TObject);
|
---|
63 | begin
|
---|
64 | UpdateMaxValues;
|
---|
65 | end;
|
---|
66 |
|
---|
67 | procedure TFormOperation.UpdateMaxValues;
|
---|
68 | begin
|
---|
69 | SpinEditFirstSector.MaxValue := SpinEditLastSector.Value;
|
---|
70 | SpinEditLastSector.MinValue := SpinEditFirstSector.Value;
|
---|
71 | end;
|
---|
72 |
|
---|
73 | procedure TFormOperation.UpdateWritePattern;
|
---|
74 | begin
|
---|
75 | CheckBoxRandomPattern.Enabled := (ComboBoxRunMode.ItemIndex = Integer(rmWrite));
|
---|
76 | EditPattern.Enabled := not CheckBoxRandomPattern.Checked and (ComboBoxRunMode.ItemIndex = Integer(rmWrite));
|
---|
77 | end;
|
---|
78 |
|
---|
79 | procedure TFormOperation.Load(DriveScan: TDriveScanProfile);
|
---|
80 | begin
|
---|
81 | CheckBoxRandomPattern.Checked := DriveScan.WritePatternRandom;
|
---|
82 | UpdateWritePattern;
|
---|
83 | ComboBoxRunMode.ItemIndex := Integer(DriveScan.Mode);
|
---|
84 | EditPattern.Text := '$' + IntToHex(DriveScan.WritePattern, 2);
|
---|
85 | SpinEditLastSector.MaxValue := DriveScan.SectorCount - 1;
|
---|
86 | SpinEditFirstSector.Value := DriveScan.SectorStart;
|
---|
87 | SpinEditLastSector.Value := DriveScan.SectorEnd;
|
---|
88 | UpdateMaxValues;
|
---|
89 | end;
|
---|
90 |
|
---|
91 | procedure TFormOperation.Save(DriveScan: TDriveScanProfile);
|
---|
92 | begin
|
---|
93 | DriveScan.Mode := TRunMode(ComboBoxRunMode.ItemIndex);
|
---|
94 | DriveScan.WritePattern := StrToInt(EditPattern.Text);
|
---|
95 | DriveScan.SectorStart := SpinEditFirstSector.Value;
|
---|
96 | DriveScan.SectorEnd := SpinEditLastSector.Value;
|
---|
97 | DriveScan.WritePatternRandom := CheckBoxRandomPattern.Checked;
|
---|
98 | end;
|
---|
99 |
|
---|
100 | end.
|
---|
101 |
|
---|