Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
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));
        }
Esempio n. 4
0
        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));
        }
Esempio n. 6
0
        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;
                }
            }
        }
Esempio n. 7
0
        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));
        }
Esempio n. 8
0
        /////////////////////////////////////////////////////////////////////////////
        // 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);
            }
        }
Esempio n. 9
0
 internal EditorCommandFilter(SVsServiceProvider serviceProvider)
 {
     Validate.IsNotNull(serviceProvider, "serviceProvider");
     this.serviceProvider = serviceProvider;
     this.macroRecorder = (IRecorderPrivate)serviceProvider.GetService(typeof(IRecorder));
 }
Esempio n. 10
0
 internal EditorCommandFilter(SVsServiceProvider serviceProvider)
 {
     Validate.IsNotNull(serviceProvider, "serviceProvider");
     this.serviceProvider = serviceProvider;
     this.macroRecorder   = (IRecorderPrivate)serviceProvider.GetService(typeof(IRecorder));
 }