Changeset 5 for trunk


Ignore:
Timestamp:
Jul 8, 2024, 11:31:59 PM (5 months ago)
Author:
chronos
Message:
  • Added: Show source tab with source text which is automatically loaded on start and saved on close.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Car.pas

    r4 r5  
    9898    destructor Destroy; override;
    9999    procedure LoadFromFile(FileName: string);
     100    procedure LoadFromStrings(Lines: TStrings);
    100101    function Print: string;
    101102    property OnLog: TLogEvent read FOnLog write FOnLog;
     
    388389procedure TSummary.LoadFromFile(FileName: string);
    389390var
    390   I: Integer;
    391391  Lines: TStringList;
     392begin
     393  Lines := TStringList.Create;
     394  try
     395    Lines.LoadFromFile(FileName);
     396    LoadFromStrings(Lines);
     397  finally
     398    Lines.Free;
     399  end;
     400end;
     401
     402procedure TSummary.LoadFromStrings(Lines: TStrings);
     403var
     404  I: Integer;
    392405  Line: string;
    393406  CarComparer: TCarComparer;
     
    426439  TableLineCellSeparator = '||';
    427440begin
    428   Lines := TStringList.Create;
    429   Lines.LoadFromFile(FileName);
    430441  for I := 0 to Lines.Count - 1 do begin
    431442    Line := Lines[I];
     
    539550  SaveAndFreeCar(CarName, EngineType, CompanyName, Distance, Odometer, Price,
    540551    PriceWithFuel, RentTime, Consumption);
    541   Lines.Free;
    542552  CarComparer := TCarComparer.Create;
    543553  Cars.Sort(CarComparer);
  • trunk/FormMain.lfm

    r3 r5  
    11object FormMain: TFormMain
    2   Left = 484
     2  Left = 456
    33  Height = 869
    4   Top = 253
     4  Top = 228
    55  Width = 1128
    66  Caption = 'Car rental summary'
     
    88  ClientWidth = 1128
    99  DesignTimePPI = 144
     10  OnClose = FormClose
    1011  OnCreate = FormCreate
    1112  OnDestroy = FormDestroy
    1213  OnShow = FormShow
    13   LCLVersion = '2.2.6.0'
     14  LCLVersion = '3.4.0.0'
    1415  WindowState = wsMaximized
    1516  object LabelSummary: TLabel
     
    4344    Top = 104
    4445    Width = 1099
    45     ActivePage = TabSheet1
     46    ActivePage = TabSheetSource
    4647    Anchors = [akTop, akLeft, akRight, akBottom]
    4748    TabIndex = 0
    4849    TabOrder = 1
    49     object TabSheet1: TTabSheet
     50    object TabSheetSource: TTabSheet
     51      Caption = 'Source'
     52      ClientHeight = 724
     53      ClientWidth = 1089
     54      object MemoSource: TMemo
     55        Left = 8
     56        Height = 708
     57        Top = 8
     58        Width = 1073
     59        Align = alClient
     60        BorderSpacing.Around = 8
     61        ScrollBars = ssAutoBoth
     62        TabOrder = 0
     63      end
     64    end
     65    object TabSheetSummary: TTabSheet
    5066      Caption = 'Summary'
    5167      ClientHeight = 724
  • trunk/FormMain.pas

    r3 r5  
    1717    MemoSummary: TMemo;
    1818    MemoLog: TMemo;
     19    MemoSource: TMemo;
    1920    PageControlSummary: TPageControl;
    20     TabSheet1: TTabSheet;
     21    TabSheetSummary: TTabSheet;
     22    TabSheetSource: TTabSheet;
    2123    TabSheetLog: TTabSheet;
     24    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    2225    procedure FormCreate(Sender: TObject);
    2326    procedure FormDestroy(Sender: TObject);
     
    4043procedure TFormMain.FormShow(Sender: TObject);
    4144begin
     45  if FileExists(EditSource.Text) then
     46    MemoSource.Lines.LoadFromFile(EditSource.Text);
    4247  Summary.OnLog := Log;
    43   Summary.LoadFromFile(EditSource.Text);
     48  Summary.LoadFromStrings(MemoSource.Lines);
    4449  MemoSummary.Text := Summary.Print;
     50  //PageControlSummary.TabIndex := 1;
    4551end;
    4652
     
    5561end;
    5662
     63procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
     64begin
     65  MemoSource.Lines.SaveToFile(EditSource.Text);
     66end;
     67
    5768procedure TFormMain.FormDestroy(Sender: TObject);
    5869begin
Note: See TracChangeset for help on using the changeset viewer.