Ignore:
Timestamp:
Feb 20, 2007, 9:43:29 PM (18 years ago)
Author:
alloc
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.