Changeset 28 for trunk/UCore.pas


Ignore:
Timestamp:
Dec 22, 2016, 6:01:41 PM (8 years ago)
Author:
chronos
Message:
  • Added: Remember forms dimensions.
  • Added: Remember recent opened files.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r27 r28  
    66
    77uses
    8   Classes, SysUtils, FileUtil, ActnList, UProject, UFGraphics, Controls, Graphics,
    9   ExtDlgs, ExtCtrls;
     8  Classes, SysUtils, FileUtil, ActnList, UProject, UFGraphics, UPersistentForm,
     9  Controls, Graphics, ExtDlgs, ExtCtrls, UREgistry, UApplicationInfo, Registry;
    1010
    1111const
     
    2929    AFileClose: TAction;
    3030    AFileOpen: TAction;
     31    ApplicationInfo1: TApplicationInfo;
    3132    AZoomNormal: TAction;
    3233    AZoomAll: TAction;
     
    3940    ImageList1: TImageList;
    4041    OpenPictureDialog1: TOpenPictureDialog;
     42    PersistentForm1: TPersistentForm;
    4143    SavePictureDialog1: TSavePictureDialog;
    4244    procedure AExitExecute(Sender: TObject);
     
    5961    procedure DataModuleDestroy(Sender: TObject);
    6062  private
    61     { private declarations }
    6263  public
    6364    Project: TProject;
     65    procedure ProjectOpen(FileName: string);
    6466    procedure Init;
    6567  end;
     
    9496end;
    9597
     98procedure TCore.ProjectOpen(FileName: string);
     99var
     100  Image: TImage;
     101begin
     102  FormMain.LastOpenedList1.AddItem(FileName);
     103  Image := TImage.Create(nil);
     104  Image.Picture.LoadFromFile(FileName);
     105  Image.Picture.Bitmap.BeginUpdate(True);
     106  Project.Bitmap.Size := Point(Image.Picture.Bitmap.Width, Image.Picture.Bitmap.Height);
     107  Project.Bitmap.LoadFromCanvas(Image.Picture.Bitmap.Canvas);
     108  Image.Picture.Bitmap.EndUpdate;
     109  Image.Free;
     110  AZoomAll.Execute;
     111  FormMain.Redraw;
     112  Project.FileName := FileName;
     113end;
     114
    96115procedure TCore.Init;
    97116begin
     117  PersistentForm1.RegistryContext := RegContext(HKEY(ApplicationInfo1.RegistryRoot),
     118    ApplicationInfo1.RegistryKey);
     119
    98120  // Set default
    99121  Project.Bitmap.ColorFormat := ColorFormatManager.Formats[0];
     
    162184
    163185procedure TCore.AFileOpenExecute(Sender: TObject);
    164 var
    165   Image: TImage;
    166186begin
    167187  if OpenPictureDialog1.Execute then begin
    168     Image := TImage.Create(nil);
    169     Image.Picture.LoadFromFile(OpenPictureDialog1.FileName);
    170     Image.Picture.Bitmap.BeginUpdate(True);
    171     Project.Bitmap.Size := Point(Image.Picture.Bitmap.Width, Image.Picture.Bitmap.Height);
    172     Project.Bitmap.LoadFromCanvas(Image.Picture.Bitmap.Canvas);
    173     Image.Picture.Bitmap.EndUpdate;
    174     Image.Free;
    175     AZoomAll.Execute;
    176     FormMain.Redraw;
    177     Project.FileName := OpenPictureDialog1.FileName;
     188    ProjectOpen(OpenPictureDialog1.FileName);
    178189  end;
    179190end;
     
    184195  if SavePictureDialog1.Execute then begin
    185196    Project.FileName := SavePictureDialog1.FileName;
     197    FormMain.LastOpenedList1.AddItem(SavePictureDialog1.FileName);
    186198    AFileSave.Execute;
    187199  end;
     
    194206  if Project.FileName = '' then AFileSaveAs.Execute
    195207  else begin
     208    FormMain.LastOpenedList1.AddItem(SavePictureDialog1.FileName);
    196209    Image := TImage.Create(nil);
    197210    Image.Picture.Bitmap.SetSize(Project.Bitmap.Size.X, Project.Bitmap.Size.Y);
Note: See TracChangeset for help on using the changeset viewer.