/// <param name="pkg"></param> /// <param name="svc">Command service to add command to, not null.</param> /// <param name="evt">Supported public events, not null.</param> private MainToolCommand(IPkg pkg, OleMenuCommandService svc, IEventLevel evt) { this.pkg = pkg ?? throw new ArgumentNullException(nameof(pkg)); svc = svc ?? throw new ArgumentNullException(nameof(svc)); apievt = evt ?? throw new ArgumentNullException(nameof(evt)); mcmd = new MenuCommand ( onAction, new CommandID(GuidList.MAIN_CMD_SET, (int)PkgCmdIDList.CMD_MAIN) ); svc.AddCommand(mcmd); }
public static MainToolCommand Init(IPkg pkg, IEventLevel evt) { if (Instance != null) { return(Instance); } Instance = new MainToolCommand ( pkg, pkg.getSvc(typeof(IMenuCommandService)) as OleMenuCommandService, evt ); return(Instance); }
/// <param name="pkg">Owner package.</param> /// <param name="evt">Supported public events, not null.</param> public static StatusToolCommand Init(IPkg pkg, IEventLevel evt) { if(Instance != null) { return Instance; } Instance = new StatusToolCommand ( pkg, pkg.getSvc(typeof(IMenuCommandService)) as OleMenuCommandService, evt ); Instance.toolPane = Instance.initToolPane(); return Instance; }
public static async Task <MainToolCommand> InitAsync(IPkg pkg, IEventLevel evt) { if (Instance != null) { return(Instance); } // Switch to the main thread - the call to AddCommand in MainToolCommand's constructor requires // the UI thread. await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(pkg.CancellationToken); Instance = new MainToolCommand ( pkg, await pkg.getSvcAsync(typeof(IMenuCommandService)) as OleMenuCommandService, evt ); return(Instance); }