Changeset 16 for trunk


Ignore:
Timestamp:
Apr 2, 2016, 8:18:30 PM (9 years ago)
Author:
chronos
Message:
  • Added: Ability to add and remove scan operation.
  • Modified: XMLConfig moved from TMainForm to TCore as more proper place for general object.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Form/UFormMain.lfm

    r15 r16  
    1414  OnShow = FormShow
    1515  LCLVersion = '1.7'
    16   object ButtonScan: TButton
    17     Left = 16
    18     Height = 25
    19     Top = 104
    20     Width = 75
    21     Action = AScanStart
    22     TabOrder = 0
    23   end
    24   object Image1: TImage
    25     Left = 600
    26     Height = 856
    27     Top = 40
    28     Width = 1092
    29     Anchors = [akTop, akLeft, akRight, akBottom]
    30     OnResize = Image1Resize
    31   end
    32   object Label1: TLabel
    33     Left = 15
    34     Height = 24
    35     Top = 675
    36     Width = 101
    37     Caption = 'Sector size:'
    38     ParentColor = False
    39   end
    40   object LabelSectorSize: TLabel
    41     Left = 256
    42     Height = 24
    43     Top = 675
    44     Width = 10
    45     Caption = '  '
    46     ParentColor = False
    47   end
    48   object LabelSectorCount: TLabel
    49     Left = 256
    50     Height = 24
    51     Top = 704
    52     Width = 10
    53     Caption = '  '
    54     ParentColor = False
    55   end
    56   object Label2: TLabel
    57     Left = 16
    58     Height = 24
    59     Top = 704
    60     Width = 119
    61     Caption = 'Sector count:'
    62     ParentColor = False
    63   end
    64   object LabelBlockCurrent: TLabel
    65     Left = 256
    66     Height = 24
    67     Top = 736
    68     Width = 10
    69     Caption = '  '
    70     ParentColor = False
    71   end
    72   object Label3: TLabel
    73     Left = 16
    74     Height = 24
    75     Top = 736
    76     Width = 136
    77     Caption = 'Current sector:'
    78     ParentColor = False
    79   end
    80   object Label4: TLabel
    81     Left = 17
    82     Height = 24
    83     Top = 768
    84     Width = 162
    85     Caption = 'Damaged sectors:'
    86     ParentColor = False
    87   end
    88   object LabelBlockDamaged: TLabel
    89     Left = 256
    90     Height = 24
    91     Top = 764
    92     Width = 10
    93     Caption = '  '
    94     ParentColor = False
    95   end
    96   object Label5: TLabel
    97     Left = 16
    98     Height = 24
    99     Top = 796
    100     Width = 122
    101     Caption = 'Elapsed time:'
    102     ParentColor = False
    103   end
    104   object LabelElapsedTime: TLabel
    105     Left = 256
    106     Height = 24
    107     Top = 792
    108     Width = 10
    109     Caption = '  '
    110     ParentColor = False
    111   end
    112   object Label6: TLabel
    113     Left = 17
    114     Height = 24
    115     Top = 824
    116     Width = 142
    117     Caption = 'Estimated time:'
    118     ParentColor = False
    119   end
    120   object LabelEstimatedTime: TLabel
    121     Left = 257
    122     Height = 24
    123     Top = 820
    124     Width = 10
    125     Caption = '  '
    126     ParentColor = False
    127   end
    128   object Label7: TLabel
    129     Left = 17
    130     Height = 24
    131     Top = 644
    132     Width = 160
    133     Caption = 'Sectors per Block:'
    134     ParentColor = False
    135   end
    136   object LabelSectorPerBlock: TLabel
    137     Left = 256
    138     Height = 24
    139     Top = 640
    140     Width = 10
    141     Caption = '  '
    142     ParentColor = False
    143   end
    144   object LabelIOSpeed: TLabel
    145     Left = 256
    146     Height = 24
    147     Top = 848
    148     Width = 10
    149     Caption = '  '
    150     ParentColor = False
    151   end
    152   object Label8: TLabel
    153     Left = 16
    154     Height = 24
    155     Top = 852
    156     Width = 94
    157     Caption = 'I/O speed:'
    158     ParentColor = False
    159   end
    160   object ButtonScan1: TButton
    161     Left = 440
    162     Height = 25
    163     Top = 48
    164     Width = 120
    165     Action = AProjectOptions
    166     TabOrder = 1
    167   end
    168   object ButtonScan2: TButton
    169     Left = 104
    170     Height = 25
    171     Top = 104
    172     Width = 75
    173     Action = AScanStop
    174     TabOrder = 2
    175   end
    176   object Label10: TLabel
    177     Left = 16
    178     Height = 24
    179     Top = 612
    180     Width = 40
    181     Caption = 'Size:'
    182     ParentColor = False
    183   end
    184   object LabelSize: TLabel
    185     Left = 256
    186     Height = 24
    187     Top = 608
    188     Width = 10
    189     Caption = '  '
    190     ParentColor = False
    191   end
    192   object Button2: TButton
    193     Left = 192
    194     Height = 25
    195     Top = 104
    196     Width = 107
    197     Action = AScanContinue
    198     TabOrder = 3
    199   end
    200   object ListView1: TListView
    201     Left = 17
    202     Height = 414
    203     Top = 168
    204     Width = 567
    205     Columns = <   
    206       item
    207         Caption = 'Name'
    208       end   
    209       item
    210         Caption = 'Time start'
    211       end   
    212       item
    213         Caption = 'Time end'
    214       end   
    215       item
    216         Caption = 'First sector'
    217       end   
    218       item
    219         Caption = 'Last sector'
    220         Width = 347
    221       end>
    222     OwnerData = True
    223     ReadOnly = True
    224     RowSelect = True
    225     TabOrder = 4
    226     ViewStyle = vsReport
    227     OnData = ListView1Data
    228   end
    229   object Label11: TLabel
    230     Left = 17
    231     Height = 24
    232     Top = 141
    233     Width = 107
    234     Caption = 'Operations:'
    235     ParentColor = False
    236   end
    237   object Button3: TButton
    238     Left = 312
    239     Height = 25
    240     Top = 104
    241     Width = 112
    242     Action = AOperationOptions
    243     TabOrder = 5
    244   end
    245   object ComboBoxDrive: TComboBox
    246     Left = 8
    247     Height = 38
    248     Top = 40
    249     Width = 416
    250     ItemHeight = 0
    251     OnChange = ComboBoxDriveChange
    252     Style = csDropDownList
    253     TabOrder = 6
    254   end
    25516  object ToolBar1: TToolBar
    25617    Left = 0
     
    25920    Width = 1703
    26021    Caption = 'ToolBar1'
    261     Images = ImageList1
    262     TabOrder = 7
     22    Images = Core.ImageList1
     23    TabOrder = 0
    26324    object ToolButton1: TToolButton
    26425      Left = 1
     
    27738    end
    27839  end
     40  object Panel1: TPanel
     41    Left = 597
     42    Height = 883
     43    Top = 26
     44    Width = 1106
     45    Align = alClient
     46    BevelOuter = bvNone
     47    ClientHeight = 883
     48    ClientWidth = 1106
     49    TabOrder = 1
     50    object Image1: TImage
     51      Left = 8
     52      Height = 867
     53      Top = 8
     54      Width = 1090
     55      Align = alClient
     56      BorderSpacing.Around = 8
     57      OnResize = Image1Resize
     58    end
     59  end
     60  object Panel2: TPanel
     61    Left = 0
     62    Height = 883
     63    Top = 26
     64    Width = 592
     65    Align = alLeft
     66    BevelOuter = bvNone
     67    ClientHeight = 883
     68    ClientWidth = 592
     69    TabOrder = 2
     70    object ButtonScan: TButton
     71      Left = 16
     72      Height = 25
     73      Top = 104
     74      Width = 75
     75      Action = AScanStart
     76      TabOrder = 0
     77    end
     78    object Label1: TLabel
     79      Left = 15
     80      Height = 24
     81      Top = 675
     82      Width = 101
     83      Caption = 'Sector size:'
     84      ParentColor = False
     85    end
     86    object LabelSectorSize: TLabel
     87      Left = 256
     88      Height = 24
     89      Top = 675
     90      Width = 10
     91      Caption = '  '
     92      ParentColor = False
     93    end
     94    object LabelSectorCount: TLabel
     95      Left = 256
     96      Height = 24
     97      Top = 704
     98      Width = 10
     99      Caption = '  '
     100      ParentColor = False
     101    end
     102    object Label2: TLabel
     103      Left = 15
     104      Height = 24
     105      Top = 704
     106      Width = 119
     107      Caption = 'Sector count:'
     108      ParentColor = False
     109    end
     110    object LabelBlockCurrent: TLabel
     111      Left = 256
     112      Height = 24
     113      Top = 736
     114      Width = 10
     115      Caption = '  '
     116      ParentColor = False
     117    end
     118    object Label3: TLabel
     119      Left = 15
     120      Height = 24
     121      Top = 736
     122      Width = 136
     123      Caption = 'Current sector:'
     124      ParentColor = False
     125    end
     126    object Label4: TLabel
     127      Left = 15
     128      Height = 24
     129      Top = 768
     130      Width = 162
     131      Caption = 'Damaged sectors:'
     132      ParentColor = False
     133    end
     134    object LabelBlockDamaged: TLabel
     135      Left = 256
     136      Height = 24
     137      Top = 764
     138      Width = 10
     139      Caption = '  '
     140      ParentColor = False
     141    end
     142    object Label5: TLabel
     143      Left = 15
     144      Height = 24
     145      Top = 796
     146      Width = 122
     147      Caption = 'Elapsed time:'
     148      ParentColor = False
     149    end
     150    object LabelElapsedTime: TLabel
     151      Left = 256
     152      Height = 24
     153      Top = 792
     154      Width = 10
     155      Caption = '  '
     156      ParentColor = False
     157    end
     158    object Label6: TLabel
     159      Left = 15
     160      Height = 24
     161      Top = 824
     162      Width = 142
     163      Caption = 'Estimated time:'
     164      ParentColor = False
     165    end
     166    object LabelEstimatedTime: TLabel
     167      Left = 257
     168      Height = 24
     169      Top = 820
     170      Width = 10
     171      Caption = '  '
     172      ParentColor = False
     173    end
     174    object Label7: TLabel
     175      Left = 15
     176      Height = 24
     177      Top = 644
     178      Width = 160
     179      Caption = 'Sectors per Block:'
     180      ParentColor = False
     181    end
     182    object LabelSectorPerBlock: TLabel
     183      Left = 256
     184      Height = 24
     185      Top = 640
     186      Width = 10
     187      Caption = '  '
     188      ParentColor = False
     189    end
     190    object LabelIOSpeed: TLabel
     191      Left = 256
     192      Height = 24
     193      Top = 848
     194      Width = 10
     195      Caption = '  '
     196      ParentColor = False
     197    end
     198    object Label8: TLabel
     199      Left = 15
     200      Height = 24
     201      Top = 852
     202      Width = 94
     203      Caption = 'I/O speed:'
     204      ParentColor = False
     205    end
     206    object ButtonScan1: TButton
     207      Left = 440
     208      Height = 25
     209      Top = 16
     210      Width = 120
     211      Action = AProjectOptions
     212      Anchors = [akTop, akRight]
     213      TabOrder = 1
     214    end
     215    object ButtonScan2: TButton
     216      Left = 104
     217      Height = 25
     218      Top = 104
     219      Width = 75
     220      Action = AScanStop
     221      TabOrder = 2
     222    end
     223    object Label10: TLabel
     224      Left = 15
     225      Height = 24
     226      Top = 612
     227      Width = 40
     228      Caption = 'Size:'
     229      ParentColor = False
     230    end
     231    object LabelSize: TLabel
     232      Left = 256
     233      Height = 24
     234      Top = 608
     235      Width = 10
     236      Caption = '  '
     237      ParentColor = False
     238    end
     239    object Button2: TButton
     240      Left = 192
     241      Height = 25
     242      Top = 104
     243      Width = 107
     244      Action = AScanContinue
     245      TabOrder = 3
     246    end
     247    object ListView1: TListView
     248      Left = 17
     249      Height = 398
     250      Top = 168
     251      Width = 567
     252      Anchors = [akTop, akLeft, akRight]
     253      Columns = <     
     254        item
     255          Caption = 'Name'
     256          Width = 100
     257        end     
     258        item
     259          Caption = 'Time start'
     260          Width = 100
     261        end     
     262        item
     263          Caption = 'Time end'
     264          Width = 100
     265        end     
     266        item
     267          Caption = 'First sector'
     268          Width = 100
     269        end     
     270        item
     271          Caption = 'Last sector'
     272          Width = 347
     273        end>
     274      OwnerData = True
     275      PopupMenu = PopupMenu1
     276      ReadOnly = True
     277      RowSelect = True
     278      TabOrder = 4
     279      ViewStyle = vsReport
     280      OnData = ListView1Data
     281      OnSelectItem = ListView1SelectItem
     282    end
     283    object Label11: TLabel
     284      Left = 17
     285      Height = 24
     286      Top = 141
     287      Width = 107
     288      Caption = 'Operations:'
     289      ParentColor = False
     290    end
     291    object Button3: TButton
     292      Left = 312
     293      Height = 25
     294      Top = 104
     295      Width = 112
     296      Action = AOperationOptions
     297      TabOrder = 5
     298    end
     299    object ComboBoxDrive: TComboBox
     300      Left = 8
     301      Height = 38
     302      Top = 16
     303      Width = 416
     304      Anchors = [akTop, akLeft, akRight]
     305      ItemHeight = 0
     306      OnChange = ComboBoxDriveChange
     307      Style = csDropDownList
     308      TabOrder = 6
     309    end
     310    object Button1: TButton
     311      Left = 21
     312      Height = 25
     313      Top = 576
     314      Width = 75
     315      Action = AOperationAdd
     316      TabOrder = 7
     317    end
     318    object Button4: TButton
     319      Left = 112
     320      Height = 25
     321      Top = 576
     322      Width = 115
     323      Action = AOperationRemove
     324      TabOrder = 8
     325    end
     326  end
     327  object Splitter1: TSplitter
     328    Left = 592
     329    Height = 883
     330    Top = 26
     331    Width = 5
     332  end
    279333  object Timer1: TTimer
    280334    Interval = 500
     
    284338  end
    285339  object ActionList1: TActionList
     340    Images = Core.ImageList1
    286341    left = 672
    287342    top = 291
     
    294349      OnExecute = AScanStopExecute
    295350    end
     351    object AScanContinue: TAction
     352      Caption = 'Continue'
     353      OnExecute = AScanContinueExecute
     354    end
    296355    object AProjectOptions: TAction
    297356      Caption = 'Options'
     
    317376      OnExecute = AFileSaveExecute
    318377    end
    319     object AScanContinue: TAction
    320       Caption = 'Continue'
    321       OnExecute = AScanContinueExecute
    322     end
    323378    object AFileNew: TAction
    324379      Caption = 'New'
     
    329384      OnExecute = AFileCloseExecute
    330385    end
     386    object AViewToolbar: TAction
     387      Caption = 'Toolbar'
     388      OnExecute = AViewToolbarExecute
     389    end
    331390    object AOperationOptions: TAction
    332391      Caption = 'Options'
    333392      OnExecute = AOperationOptionsExecute
    334393    end
     394    object AOperationRemove: TAction
     395      Caption = 'Remove'
     396      OnExecute = AOperationRemoveExecute
     397    end
     398    object AOperationAdd: TAction
     399      Caption = 'Add'
     400      OnExecute = AOperationAddExecute
     401    end
    335402  end
    336403  object OpenDialog1: TOpenDialog
     
    343410  end
    344411  object MainMenu1: TMainMenu
    345     Images = ImageList1
     412    Images = Core.ImageList1
    346413    left = 672
    347414    top = 504
     
    394461      end
    395462    end
    396   end
    397   object XMLConfig1: TXMLConfig
    398     StartEmpty = False
    399     RootName = 'CONFIG'
    400     ReadOnly = False
    401     left = 672
    402     top = 160
    403   end
    404   object ImageList1: TImageList
    405     left = 672
    406     top = 573
     463    object MenuItem16: TMenuItem
     464      Caption = 'View'
     465      object MenuItem17: TMenuItem
     466        Action = AViewToolbar
     467      end
     468    end
    407469  end
    408470  object LastOpenedList1: TLastOpenedList
    409471    MaxCount = 10
    410     left = 904
     472    left = 672
    411473    top = 144
    412474  end
     475  object PopupMenu1: TPopupMenu
     476    left = 257
     477    top = 425
     478    object MenuItem18: TMenuItem
     479      Action = AOperationAdd
     480    end
     481    object MenuItem19: TMenuItem
     482      Action = AOperationRemove
     483    end
     484  end
    413485end
  • trunk/Form/UFormMain.pas

    r15 r16  
    1515
    1616  TFormMain = class(TForm)
     17    AOperationAdd: TAction;
     18    AOperationRemove: TAction;
     19    AViewToolbar: TAction;
    1720    ADriveSelect: TAction;
    1821    AOperationOptions: TAction;
     
    2831    AScanStop: TAction;
    2932    ActionList1: TActionList;
     33    Button1: TButton;
    3034    Button2: TButton;
    3135    Button3: TButton;
     36    Button4: TButton;
    3237    ButtonScan: TButton;
    3338    ButtonScan1: TButton;
     
    3540    ComboBoxDrive: TComboBox;
    3641    Image1: TImage;
    37     ImageList1: TImageList;
    3842    Label1: TLabel;
    3943    Label10: TLabel;
     
    4650    Label7: TLabel;
    4751    Label8: TLabel;
    48     LabelElapsedTime: TLabel;
    49     LabelSectorSize: TLabel;
    50     LabelSectorCount: TLabel;
    5152    LabelBlockCurrent: TLabel;
    5253    LabelBlockDamaged: TLabel;
     54    LabelElapsedTime: TLabel;
    5355    LabelEstimatedTime: TLabel;
    5456    LabelIOSpeed: TLabel;
     57    LabelSectorCount: TLabel;
     58    LabelSectorPerBlock: TLabel;
     59    LabelSectorSize: TLabel;
    5560    LabelSize: TLabel;
    56     LabelSectorPerBlock: TLabel;
    5761    LastOpenedList1: TLastOpenedList;
    5862    ListView1: TListView;
     
    6569    MenuItem14: TMenuItem;
    6670    MenuItem15: TMenuItem;
     71    MenuItem16: TMenuItem;
     72    MenuItem17: TMenuItem;
     73    MenuItem18: TMenuItem;
     74    MenuItem19: TMenuItem;
    6775    MenuItemOpenRecent: TMenuItem;
    6876    MenuItem2: TMenuItem;
     
    7583    MenuItem9: TMenuItem;
    7684    OpenDialog1: TOpenDialog;
     85    Panel1: TPanel;
     86    Panel2: TPanel;
     87    PopupMenu1: TPopupMenu;
    7788    SaveDialog1: TSaveDialog;
     89    Splitter1: TSplitter;
    7890    Timer1: TTimer;
    7991    ToolBar1: TToolBar;
     
    8193    ToolButton2: TToolButton;
    8294    ToolButton3: TToolButton;
    83     XMLConfig1: TXMLConfig;
    8495    procedure AExitExecute(Sender: TObject);
    8596    procedure AFileCloseExecute(Sender: TObject);
     
    8899    procedure AFileSaveAsExecute(Sender: TObject);
    89100    procedure AFileSaveExecute(Sender: TObject);
     101    procedure AOperationAddExecute(Sender: TObject);
    90102    procedure AOperationOptionsExecute(Sender: TObject);
     103    procedure AOperationRemoveExecute(Sender: TObject);
    91104    procedure AProjectOptionsExecute(Sender: TObject);
    92105    procedure AScanContinueExecute(Sender: TObject);
    93106    procedure AScanStartExecute(Sender: TObject);
    94107    procedure AScanStopExecute(Sender: TObject);
     108    procedure AViewToolbarExecute(Sender: TObject);
    95109    procedure ComboBoxDriveChange(Sender: TObject);
    96110    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     
    101115    procedure Image1Resize(Sender: TObject);
    102116    procedure ListView1Data(Sender: TObject; Item: TListItem);
     117    procedure ListView1SelectItem(Sender: TObject; Item: TListItem;
     118      Selected: Boolean);
    103119    procedure Timer1Timer(Sender: TObject);
    104120  private
     
    107123    RedrawPending: Boolean;
    108124    LastDriveName: string;
     125    ShowToolBar: Boolean;
    109126    procedure OpenRecentClick(Sender: TObject);
    110127    procedure ReloadOperationList;
     
    165182procedure TFormMain.ListView1Data(Sender: TObject; Item: TListItem);
    166183begin
    167   if (Item.Index >= 0) and (Item.Index < Core.Project.Scans.Count) then
    168   with TDriveScan(Core.Project.Scans[Item.Index]) do begin
     184  with Core.Project do
     185  if (Item.Index >= 0) and (Item.Index < Scans.Count) then
     186  with TDriveScan(Scans[Item.Index]) do begin
    169187    Item.Caption := IntToStr(Item.Index);
     188    Item.Data := TDriveScan(Scans[Item.Index]);
    170189    Item.SubItems.Add(DateTimeToStr(TimeStart));
    171190    Item.SubItems.Add(DateTimeToStr(TimeEnd));
     
    175194end;
    176195
     196procedure TFormMain.ListView1SelectItem(Sender: TObject; Item: TListItem;
     197  Selected: Boolean);
     198begin
     199  Core.Project.CurrentScan := TDriveScan(Item.Data);
     200  Redraw;
     201  ReloadOperationList;
     202end;
     203
    177204procedure TFormMain.FormCreate(Sender: TObject);
    178205begin
    179206  PrefixMultiplier := TPrefixMultiplier.Create;
    180   XMLConfig1.Filename := 'config.xml';
    181207end;
    182208
     
    187213    UpdateInterface;
    188214  end;
     215end;
     216
     217procedure TFormMain.AViewToolbarExecute(Sender: TObject);
     218begin
     219  ShowToolBar := not ShowToolBar;
     220  ToolBar1.Visible := ShowToolBar;
     221  AViewToolbar.Checked := ShowToolBar;
    189222end;
    190223
     
    255288  Core.Project.Modified := False;
    256289  Core.Project.Scans.Add(TDriveScan.Create);
     290  Core.Project.CurrentScan := TDriveScan(Core.Project.Scans.Last);
    257291
    258292  ComboBoxDrive.ItemIndex := Core.DriveList.IndexOf(Core.DriveList.FindByModel(Core.Project.DriveInfo.Model));
     
    300334end;
    301335
     336procedure TFormMain.AOperationAddExecute(Sender: TObject);
     337var
     338  NewOperation: TDriveScan;
     339begin
     340  with Core.Project do begin
     341    NewOperation := TDriveScan.Create;
     342    Scans.Add(NewOperation);
     343    CurrentScan := TDriveScan(Scans.Last);
     344    ReloadOperationList;
     345    Redraw;
     346    Core.Project.Modified := True;
     347  end;
     348end;
     349
    302350procedure TFormMain.AOperationOptionsExecute(Sender: TObject);
    303351begin
     
    308356    UpdateInterface;
    309357  end;
     358end;
     359
     360procedure TFormMain.AOperationRemoveExecute(Sender: TObject);
     361begin
     362  Core.Project.CurrentScan := nil;
     363  Core.Project.Scans.Remove(ListView1.Selected.Data);
     364  ReloadOperationList;
     365  Redraw;
     366  Core.Project.Modified := True;
    310367end;
    311368
     
    347404procedure TFormMain.DoDraw;
    348405begin
    349   if Assigned(Core.Project) then
     406  if Assigned(Core.Project) and Assigned(Core.Project.CurrentScan) then
    350407  with Core.Project do begin
    351   if RedrawPending then
    352   with Image1 do begin
    353     if (Width <> Picture.Bitmap.Width) or (Height <> Picture.Bitmap.Height) then
    354       Picture.Bitmap.SetSize(Width, Height);
     408    if RedrawPending then
     409    with Image1 do begin
     410      if (Width <> Picture.Bitmap.Width) or (Height <> Picture.Bitmap.Height) then
     411        Picture.Bitmap.SetSize(Width, Height);
     412      try
     413        Core.Project.CurrentScan.Lock.Acquire;
     414        try
     415          Picture.Bitmap.BeginUpdate(True);
     416          CurrentScan.BlockMap.Draw(Picture.Bitmap.Canvas);
     417        finally
     418          Picture.Bitmap.EndUpdate;
     419        end;
     420        LabelSectorPerBlock.Caption := IntToStr(CurrentScan.BlockMap.SectorPerBlock);
     421        LabelBlockCurrent.Caption := IntToStr(CurrentScan.SectorCurrent);
     422        LabelBlockDamaged.Caption := IntToStr(CurrentScan.DamagedBlockCount);
     423      finally
     424        CurrentScan.Lock.Release;
     425      end;
     426      RedrawPending := False;
     427    end;
    355428    try
    356       Core.Project.CurrentScan.Lock.Acquire;
    357       try
    358         Picture.Bitmap.BeginUpdate(True);
    359         CurrentScan.BlockMap.Draw(Picture.Bitmap.Canvas);
    360       finally
    361         Picture.Bitmap.EndUpdate;
     429      CurrentScan.Lock.Acquire;
     430      if not CurrentScan.Terminated then begin
     431        LabelElapsedTime.Caption := TimeToStr(CurrentScan.GetElapsedTime);
     432        LabelEstimatedTime.Caption := TimeToStr((Now - CurrentScan.TimeStart) /
     433          CurrentScan.SectorCurrent * (CurrentScan.BlockMap.SectorCount - CurrentScan.SectorCurrent));
     434        LabelIOSpeed.Caption := PrefixMultiplier.Add((CurrentScan.SectorCurrent - LastBlockPos) *
     435          CurrentScan.SectorSize / (Timer1.Interval / 1000), BasePrefixMultipliers, 'B/s');
     436        LastBlockPos := CurrentScan.SectorCurrent;
     437      end else begin
     438        LabelElapsedTime.Caption := '';
     439        LabelEstimatedTime.Caption := '';
     440        LabelIOSpeed.Caption := '';
    362441      end;
    363       LabelSectorPerBlock.Caption := IntToStr(CurrentScan.BlockMap.SectorPerBlock);
    364       LabelBlockCurrent.Caption := IntToStr(CurrentScan.SectorCurrent);
    365       LabelBlockDamaged.Caption := IntToStr(CurrentScan.DamagedBlockCount);
    366442    finally
    367443      CurrentScan.Lock.Release;
    368444    end;
    369     RedrawPending := False;
    370   end;
    371   try
    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;
    380     end else begin
    381       LabelElapsedTime.Caption := '';
    382       LabelEstimatedTime.Caption := '';
    383       LabelIOSpeed.Caption := '';
    384     end;
    385   finally
    386     CurrentScan.Lock.Release;
    387   end;
    388445  end else
    389446  with Image1 do begin
     
    445502procedure TFormMain.SaveConfig;
    446503begin
    447   XMLConfig1.SetValue('DriveName', LastDriveName);
    448   LastOpenedList1.SaveToXMLConfig(XMLConfig1, 'RecentProjects');
     504  Core.XMLConfig1.SetValue('DriveName', LastDriveName);
     505  LastOpenedList1.SaveToXMLConfig(Core.XMLConfig1, 'RecentProjects');
     506  Core.XMLConfig1.SetValue('ShowToolBar', ShowToolBar);
    449507end;
    450508
    451509procedure TFormMain.LoadConfig;
    452510begin
    453   LastDriveName := XMLConfig1.GetValue('DriveName', '');
    454   LastOpenedList1.LoadFromXMLConfig(XMLConfig1, 'RecentProjects');
     511  LastDriveName := Core.XMLConfig1.GetValue('DriveName', '');
     512  LastOpenedList1.LoadFromXMLConfig(Core.XMLConfig1, 'RecentProjects');
     513  ShowToolBar := Core.XMLConfig1.GetValue('ShowToolBar', False);
     514  ToolBar1.Visible := ShowToolBar;
     515  AViewToolbar.Checked := ShowToolBar;
    455516end;
    456517
     
    473534  end;
    474535  ListView1.Refresh;
     536
     537  AOperationRemove.Enabled := Assigned(ListView1.Selected);
    475538end;
    476539
  • trunk/UConfig.pas

    r1 r16  
    99
    1010const
    11   ConfigTest = False;
     11  ConfigTest = True;
    1212
    1313implementation
  • trunk/UCore.lfm

    r15 r16  
    1313    top = 208
    1414  end
     15  object ImageList1: TImageList
     16    left = 224
     17    top = 136
     18  end
     19  object XMLConfig1: TXMLConfig
     20    Filename = 'config.xml'
     21    StartEmpty = False
     22    RootName = 'CONFIG'
     23    ReadOnly = False
     24    left = 424
     25    top = 136
     26  end
    1527end
  • trunk/UCore.pas

    r15 r16  
    66
    77uses
    8   Classes, SysUtils, FileUtil, UProject, UPhysDrive, UPersistentForm;
     8  Classes, SysUtils, XMLConf, FileUtil, Controls, UProject, UPhysDrive,
     9  UPersistentForm;
    910
    1011type
     
    1314
    1415  TCore = class(TDataModule)
     16    ImageList1: TImageList;
    1517    PersistentForm1: TPersistentForm;
     18    XMLConfig1: TXMLConfig;
    1619    procedure DataModuleCreate(Sender: TObject);
    1720    procedure DataModuleDestroy(Sender: TObject);
     
    3639  DriveList := TDriveList.Create;
    3740  Project := nil;
     41  XMLConfig1.Filename := 'config.xml';
    3842end;
    3943
  • trunk/UDriveScan.pas

    r13 r16  
    175175      Lock.Release;
    176176      DoChange;
    177 
    178       if ConfigTest then begin
    179         if Random < 0.000001 then RealSize := 0
    180           else RealSize := SectorSize;
    181         //Sleep(1);
    182       end else begin
    183         F.Position := FSectorCurrent * SectorSize;
    184         if Mode = rmRead then RealSize := F.Read(Buffer[0], SectorSize)
    185           else if Mode = rmWrite then RealSize := F.Write(Buffer[0], SectorSize)
    186           else raise Exception.Create(SUnknownRunMode);
    187       end;
     177      F.Position := FSectorCurrent * SectorSize;
     178      if Mode = rmRead then RealSize := F.Read(Buffer[0], SectorSize)
     179        else if Mode = rmWrite then RealSize := F.Write(Buffer[0], SectorSize)
     180        else raise Exception.Create(SUnknownRunMode);
    188181    finally
    189182      Lock.Acquire;
  • trunk/UPhysDrive.pas

    r13 r16  
    99
    1010type
     11  TDriveKind = (dkPhysical, dkFile);
    1112
    1213  { TDriveInfo }
    1314
    1415  TDriveInfo = class
     16    Kind: TDriveKind;
    1517    Model: string;
    1618    Size: Int64;
     
    9799    if FileExists(List[I] + '/device') then begin
    98100      NewDriveInfo := TDriveInfo.Create;
     101      NewDriveInfo.Kind := dkPhysical;
    99102      NewDriveInfo.Model := Trim(LoadFileToStr(List[I] + '/device/model'));
    100103      NewDriveInfo.SectorSize := StrToInt(Trim(LoadFileToStr(List[I] + '/queue/physical_block_size')));
     
    106109  end;
    107110  {$ENDIF}
     111{  NewDriveInfo := TDriveInfo.Create;
     112  NewDriveInfo.Kind := dkFile;
     113  NewDriveInfo.Model := 'File';
     114  NewDriveInfo.SectorSize := 4096;
     115  NewDriveInfo.SectorCount := 0;
     116  NewDriveInfo.Size := 0;
     117  NewDriveInfo.Path := '';
     118  Add(NewDriveInfo);
     119  }
    108120end;
    109121
  • trunk/UProject.pas

    r13 r16  
    1515  TProject = class
    1616  private
     17    FCurrentScan: TDriveScan;
    1718    function GetCurrentScan: TDriveScan;
    1819    function GetSectorCount: Integer;
     
    2829    procedure SaveToFile(FileName: string);
    2930    property SectorCount: Integer read GetSectorCount;
    30     property CurrentScan: TDriveScan read GetCurrentScan;
     31    property CurrentScan: TDriveScan read FCurrentScan write FCurrentScan;
    3132  end;
    3233
Note: See TracChangeset for help on using the changeset viewer.