⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vcsprj3.dpr

📁 Delphi高级开发指南是开发程序的好帮手
💻 DPR
字号:
library VcsPrj3;
            
uses
  Sharemem, SysUtils, Classes, ExptIntf, EditIntf, Forms,
  ToolIntf, Dialogs, Windows, VcsIntf, VirtIntf,
  ComCtrls, PrjForm in 'PrjForm.pas' {PrjInfoForm};

type
  TDdhProjectVcs = class (TIVCSClient)
  public
    // store the name in each file?
    StoreAuthor: Boolean;
    // list of installed module notifiers:
    NotifList: TStrings;
  public
    constructor Create;
    function GetIDString: string; override;
    procedure ExecuteVerb(Index: Integer); override;
    function GetMenuName: string; override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
    function GetVerbState(Index: Integer): Word; override;
    procedure ProjectChange; override;
    destructor Destroy; override;
    // custom methods used to add/remove a module notifier
    procedure InstallNotifier (FileName: string);
    procedure RemoveNotifier (FileName: string);
  end;

  // project-wide notifier
  TDdhPrjNotifier = class(TIAddInNotifier)
  public
    procedure FileNotification(NotifyCode: TFileNotification;
      const FileName: string; var Cancel: Boolean); override;
    procedure EventNotification(NotifyCode: TEventNotification;
      var Cancel: Boolean); override;
  end;

  // module notifier
  TDdhModNotif = class (TIModuleNotifier)
  private
    // the file this notifier refers to
    FileName: string;
    // module interface this notifier is installed into
    ModIntf: TIModuleInterface;
    // file has changed?
    Modified: Boolean;
  public
    constructor Create (FileN: string; ModInterface: TIModuleInterface);
    destructor Destroy; override;
    // override notifier interface
    procedure Notify(NotifyCode: TNotifyCode); override;
    procedure ComponentRenamed(ComponentHandle: Pointer;
      const OldName, NewName: string); override;
  end;

var
  // global objects
  PrjNotif: TDdhPrjNotifier;
  DdhPrjVcs: TDdhProjectVcs;

// VCS methods

constructor TDdhProjectVcs.Create;
begin
  inherited Create;
  // default: don't store the name
  StoreAuthor := False;
  // create the list
  NotifList := TStringList.Create;
end;

function TDdhProjectVcs.GetIDString: string;
begin
  Result := 'DDHandbook.DdhProjectVCS';
end;

function TDdhProjectVcs.GetMenuName: string;
begin
  Result := 'DHH Project VCS';
end;

function TDdhProjectVcs.GetVerbCount: Integer;
begin
  Result := 4;
end;

function TDdhProjectVcs.GetVerb(Index: Integer): string;
begin
  case Index of
    0: Result := '&Project Information...';
    1: Result := '&Store Author on Save';
    2: Result := ''; // separator
    3: Result := '&About DDH Project VCS...';
  end;
end;

procedure TDdhProjectVcs.ExecuteVerb(Index: Integer);
begin
  case Index of
    0: try
        PrjInfoForm.UpdateTree;
        PrjInfoForm.Show;
      except
        ToolServices.RaiseException(ReleaseException);
      end;
    1: // toggle the flag
      StoreAuthor := not StoreAuthor;
    3: // about box
      MessageDlg ('DDH Project Version Control System'#13#13 +
      'From the "Delphi Developer''s Handbook"'#13 +
      'by Marco Cant

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -