| Line | |
|---|
| 1 | unit FormStorage;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, Storage,
|
|---|
| 7 | Device;
|
|---|
| 8 |
|
|---|
| 9 | type
|
|---|
| 10 |
|
|---|
| 11 | { TFormStorage }
|
|---|
| 12 |
|
|---|
| 13 | TFormStorage = class(TFormDevice)
|
|---|
| 14 | ListView1: TListView;
|
|---|
| 15 | procedure FormShow(Sender: TObject);
|
|---|
| 16 | procedure ListView1Data(Sender: TObject; Item: TListItem);
|
|---|
| 17 | protected
|
|---|
| 18 | function GetDevice: TDevice; override;
|
|---|
| 19 | procedure SetDevice(AValue: TDevice); override;
|
|---|
| 20 | public
|
|---|
| 21 | Storage: TStorage;
|
|---|
| 22 | procedure Reload;
|
|---|
| 23 | end;
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 | implementation
|
|---|
| 27 |
|
|---|
| 28 | {$R *.lfm}
|
|---|
| 29 |
|
|---|
| 30 | const
|
|---|
| 31 | ItemsPerLine = 16;
|
|---|
| 32 |
|
|---|
| 33 | { TFormStorage }
|
|---|
| 34 |
|
|---|
| 35 | procedure TFormStorage.ListView1Data(Sender: TObject; Item: TListItem);
|
|---|
| 36 | var
|
|---|
| 37 | Line: string;
|
|---|
| 38 | I: Integer;
|
|---|
| 39 | Text: string;
|
|---|
| 40 | One: Byte;
|
|---|
| 41 | begin
|
|---|
| 42 | if Item.Index < Storage.Size div ItemsPerLine then begin
|
|---|
| 43 | Line := '';
|
|---|
| 44 | Text := '';
|
|---|
| 45 | for I := 0 to ItemsPerLine - 1 do begin
|
|---|
| 46 | One := Storage.ReadByte(Item.Index * ItemsPerLine + I);
|
|---|
| 47 | Line := Line + IntToHex(One, 2) + ' ';
|
|---|
| 48 | if One >= 32 then Text := Text + Char(One)
|
|---|
| 49 | else Text := Text + ' ';
|
|---|
| 50 | end;
|
|---|
| 51 | Item.Caption := IntToHex(Item.Index * ItemsPerLine, 8);
|
|---|
| 52 | Item.SubItems.Add(Line);
|
|---|
| 53 | Item.SubItems.Add(Text);
|
|---|
| 54 | end;
|
|---|
| 55 | end;
|
|---|
| 56 |
|
|---|
| 57 | procedure TFormStorage.FormShow(Sender: TObject);
|
|---|
| 58 | begin
|
|---|
| 59 | Reload;
|
|---|
| 60 | end;
|
|---|
| 61 |
|
|---|
| 62 | function TFormStorage.GetDevice: TDevice;
|
|---|
| 63 | begin
|
|---|
| 64 | Result := Storage;
|
|---|
| 65 | end;
|
|---|
| 66 |
|
|---|
| 67 | procedure TFormStorage.SetDevice(AValue: TDevice);
|
|---|
| 68 | begin
|
|---|
| 69 | if AValue is TStorage then
|
|---|
| 70 | Storage := TStorage(AValue);
|
|---|
| 71 | end;
|
|---|
| 72 |
|
|---|
| 73 | procedure TFormStorage.Reload;
|
|---|
| 74 | begin
|
|---|
| 75 | ListView1.Items.Count := Storage.Size div ItemsPerLine;
|
|---|
| 76 | ListView1.Refresh;
|
|---|
| 77 | end;
|
|---|
| 78 |
|
|---|
| 79 | end.
|
|---|
| 80 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.