public void OnLoaded(object sender, System.Windows.RoutedEventArgs e) { if (!this.addedToolbarButton) { IVsWindowFrame windowFrame = (IVsWindowFrame)GetService(typeof(SVsWindowFrame)); object dteWindow; windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_ExtWindowObject, out dteWindow); Window2 window = (Window2)dteWindow; var controls = ((CommandBars)window.CommandBars)[1].Controls; this.owningPackage.ImageButtons.Add((CommandBarButton)controls[1]); this.owningPackage.ImageButtons.Add((CommandBarButton)controls[2]); this.owningPackage.ImageButtons.Add((CommandBarButton)controls[3]); this.addedToolbarButton = true; } IRecorderPrivate macroRecorder = (IRecorderPrivate)this.GetService(typeof(IRecorder)); if (macroRecorder.IsRecording) { this.owningPackage.ChangeMenuIcons(this.owningPackage.StopIcon, 0); } }
protected override int QueryClose(out bool canClose) { IRecorderPrivate macroRecorder = (IRecorderPrivate)this.GetService(typeof(IRecorder)); if (macroRecorder.IsRecording) { string message = Resources.ExitMessage; string caption = Resources.ExitCaption; MessageBoxButtons buttons = MessageBoxButtons.YesNo; System.Windows.Forms.DialogResult result; // Displays the MessageBox. result = MessageBox.Show(message, caption, buttons); canClose = (result == System.Windows.Forms.DialogResult.Yes); } else { canClose = true; } // Close manager Manager.Instance.Close(); if (Executor.Job != null) { Executor.Job.Close(); } return((int)VSConstants.S_OK); }
internal CommandExecutionWatcher(IServiceProvider serviceProvider) { Validate.IsNotNull(serviceProvider, "serviceProvider"); this.serviceProvider = serviceProvider; var rpct = (IVsRegisterPriorityCommandTarget)this.serviceProvider.GetService(typeof(SVsRegisterPriorityCommandTarget)); if (rpct != null) { // We can ignore the return code here as there really isn't anything reasonable we could do to deal with failure, // and it is essentially a no-fail method. rpct.RegisterPriorityCommandTarget(dwReserved: 0U, pCmdTrgt: this, pdwCookie: out this.priorityCommandTargetCookie); } this.macroRecorder = (IRecorderPrivate)serviceProvider.GetService(typeof(IRecorder)); }
internal WindowActivationWatcher(IServiceProvider serviceProvider, RecorderDataModel dataModel) { Validate.IsNotNull(serviceProvider, "serviceProvider"); Validate.IsNotNull(dataModel, "dataModel"); this.serviceProvider = serviceProvider; this.dataModel = dataModel; var monSel = (IVsMonitorSelection)this.serviceProvider.GetService(typeof(SVsShellMonitorSelection)); if (monSel != null) { // NOTE: We can ignore the return code here as there really isn't anything reasonable we could do to deal with failure, // and it is essentially a no-fail method. monSel.AdviseSelectionEvents(pSink: this, pdwCookie: out this.monSelCookie); } this.macroRecorder = (IRecorderPrivate)serviceProvider.GetService(typeof(IRecorder)); }
private void Record_OnBeforeQueryStatus(object sender, EventArgs e) { var recordCommand = sender as OleMenuCommand; if (recordCommand != null) { IRecorderPrivate macroRecorder = (IRecorderPrivate)this.GetService(typeof(IRecorder)); if (macroRecorder.IsRecording) { recordCommand.Text = Resources.MenuTextRecording; } else { recordCommand.Text = Resources.MenuTextNormal; } } }
///////////////////////////////////////////////////////////////////////////// // Command Handlers #region Command Handlers private void Record(object sender, EventArgs arguments) { IRecorderPrivate macroRecorder = (IRecorderPrivate)this.GetService(typeof(IRecorder)); if (!macroRecorder.IsRecording) { Manager.Instance.StartRecording(); this.StatusBarChange(Resources.StatusBarRecordingText, 1); this.ChangeMenuIcons(this.StopIcon, 0); this.UpdateButtonsForRecording(true); } else { Manager.Instance.StopRecording(); this.StatusBarChange(Resources.StatusBarReadyText, 0); this.ChangeMenuIcons(this.StartIcon, 0); this.UpdateButtonsForRecording(false); } }
internal EditorCommandFilter(SVsServiceProvider serviceProvider) { Validate.IsNotNull(serviceProvider, "serviceProvider"); this.serviceProvider = serviceProvider; this.macroRecorder = (IRecorderPrivate)serviceProvider.GetService(typeof(IRecorder)); }