Changeset 101 for oup/rewrite/Tools


Ignore:
Timestamp:
Feb 20, 2007, 9:43:29 PM (18 years ago)
Author:
alloc
Message:
 
Location:
oup/rewrite/Tools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • oup/rewrite/Tools/Preview.dfm

    r93 r101  
    11inherited Form_Preview: TForm_Preview
    22  Caption = 'Preview'
     3  OnCreate = FormCreate
     4  ExplicitWidth = 500
     5  ExplicitHeight = 450
    36  PixelsPerInch = 96
    47  TextHeight = 13
  • oup/rewrite/Tools/Preview.pas

    r97 r101  
    8484procedure TForm_Preview.LoadImage(fileid, index: Integer);
    8585var
    86   Data:      TByteData;
    8786  memstream: TMemoryStream;
    8887  OniImage:  TOniImage;
    89 
    9088begin
    9189  OniImage := TOniImage.Create;
    9290  OniImage.Load(ConnectionID, fileid);
    93   OniImage.GetAsBMP(Data);
     91  memstream := TMemoryStream.Create;
     92  OniImage.GetAsBMP(TStream(memstream));
    9493  OniImage.Free;
    95 
    96   memstream := TMemoryStream.Create;
    97   memstream.Write(Data[0], Length(Data));
    98   memstream.Seek(0, soFromBeginning);
    9994  bitmaps[index].LoadFromStream(memstream);
    10095  memstream.Free;
  • oup/rewrite/Tools/Template.dfm

    r97 r101  
    1919  OnActivate = FormActivate
    2020  OnClose = FormClose
    21   OnResize = FormResize
    2221  PixelsPerInch = 96
    2322  TextHeight = 13
     
    247246        Font.Color = clWindowText
    248247        Font.Height = -11
    249         Font.Name = 'Tahoma'
     248        Font.Name = 'Courier'
    250249        Font.Style = []
    251250        ItemHeight = 13
  • oup/rewrite/Tools/Template.pas

    r97 r101  
    5454      Shift: TShiftState; X, Y: Integer);
    5555
    56     procedure FormResize(Sender: TObject);
    5756    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    5857    procedure popup_importClick(Sender: TObject);
     
    220219  fs: TFileStream;
    221220begin
    222   id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]);
    223   finfo := ConManager.Connection[FConnectionID].GetFileInfo(id);
    224 
    225   importd.Filter := 'Files of matching extension (*.' + finfo.Extension + ')|*.' +
    226         finfo.Extension + '|All files|*.*';
    227   if importd.Execute then
    228   begin
    229     fs := TFileStream.Create(importd.FileName, fmOpenRead);
    230     if fs.Size <> finfo.Size then
    231       ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) +
    232         ', file has to have same size as file in .dat.' + CrLf +
    233         'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf +
    234         'Size of chosen file: ' + FormatFileSize(fs.Size))
    235     else begin
     221  if CR_EditDat in ConManager.Connection[FConnectionID].ChangeRights then
     222  begin
     223    id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]);
     224    finfo := ConManager.Connection[FConnectionID].GetFileInfo(id);
     225
     226    importd.Filter := 'Files of matching extension (*.' + finfo.Extension + ')|*.' +
     227          finfo.Extension + '|All files|*.*';
     228    if importd.Execute then
     229    begin
     230      fs := TFileStream.Create(importd.FileName, fmOpenRead);
     231      if fs.Size <> finfo.Size then
     232      begin
     233        if not (CR_ResizeDat in ConManager.Connection[FConnectionID].ChangeRights) then
     234        begin
     235          ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) +
     236            ', file has to have same size as file in .dat with this backend.' + CrLf +
     237            'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf +
     238            'Size of chosen file: ' + FormatFileSize(fs.Size));
     239          Exit;
     240        end else begin
     241          if MessageBox(Self.Handle,
     242              PChar('File has different size from the file in the .dat.' + CrLf +
     243                    'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf +
     244                    'Size of chosen file: ' + FormatFileSize(fs.Size) + CrLf +
     245                    'Replace anyway?'), PChar('Different size'), MB_YESNO + MB_ICONWARNING) = ID_NO then
     246          begin
     247            Exit;
     248          end;
     249        end;
     250      end;
    236251      ConManager.Connection[FConnectionID].UpdateDatFile(id, fs);
    237252      Self.listClick(Self);
     253      fs.Free;
    238254    end;
    239     fs.Free;
     255  end else begin
     256    ShowMessage('Editing .dat-contents not allowed with this backend.');
    240257  end;
    241258end;
     
    449466
    450467
    451 procedure TForm_ToolTemplate.FormResize(Sender: TObject);
    452 begin
    453   if Self.Width < 300 then
    454     Self.Width := 300;
    455   if Self.Height < 200 then
    456     Self.Height := 200;
    457 end;
    458 
    459 
    460 
    461468function TForm_ToolTemplate.GetToolCloseable: Boolean;
    462469begin
Note: See TracChangeset for help on using the changeset viewer.