Esempio n. 1
0
        public async Task ExecuteAsync()
        {
            VsShell.ToolWindowPane window = await _package.ShowToolWindowAsync(typeof(SessionManagerToolWindow), 0, true, _package.DisposalToken);

            if ((null == window) || (null == window.Frame))
            {
                throw new NotSupportedException("Cannot create tool window");
            }
        }
Esempio n. 2
0
        public MyControl(ToolWindowPane pane)
        {
            this.pane = pane;

            InitializeComponent();

            labelPath.Text = "";
            RefreshResultsLabel();
            ValidateButtonState();
        }
Esempio n. 3
0
 public static void summaryWarn(ToolWindowPane tool)
 {
     try {
         Log._.raw(String.Format("========== Build-Events completed: {0} Warnings ==========", ((UI.Xaml.IStatusTool)tool.Content).Warnings));
         //Log._.raw(String.Format("{0}{1}", new String('=', 80), System.Environment.NewLine));
         //Log._.raw(String.Format("Warnings: {0}", ((UI.Xaml.IStatusTool)tool.Content).Warnings));
         Log._.raw(String.Format("{0}{0}", System.Environment.NewLine));
     }
     catch(Exception ex) {
         Log.Debug("Failed summaryWarn: '{0}'", ex.ToString());
     }
 }
Esempio n. 4
0
        // The function can be used to bring back the provider's toolwindow if it was previously closed
        private void Exec_icmdViewToolWindow(object sender, EventArgs e)
        {
            MsVsShell.ToolWindowPane window      = this.FindToolWindow(typeof(HGPendingChangesToolWindow), 0, true);
            IVsWindowFrame           windowFrame = null;

            if (window != null && window.Frame != null)
            {
                windowFrame = (IVsWindowFrame)window.Frame;
            }
            if (windowFrame != null)
            {
                ErrorHandler.ThrowOnFailure(windowFrame.Show());
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Event handler for our menu item.
        /// This result in the tool window being shown.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="arguments"></param>
        private void ShowDynamicWindow(object sender, EventArgs arguments)
        {
            // Get the one (index 0) and only instance of our tool window (if it does not already exist it will get created)
            MsVsShell.ToolWindowPane pane = FindToolWindow(typeof(DynamicWindowPane), 0, true);
            if (pane == null)
            {
                throw new COMException(GetResourceString("@101"));
            }
            IVsWindowFrame frame = pane.Frame as IVsWindowFrame;

            if (frame == null)
            {
                throw new COMException(GetResourceString("@102"));
            }
            // Bring the tool window to the front and give it focus
            ErrorHandler.ThrowOnFailure(frame.Show());
        }
Esempio n. 6
0
        /// <summary>
        /// Event handler for our menu item.
        /// This results in the tool window being shown.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="arguments"></param>
        private void ShowPersistedWindow(object sender, EventArgs arguments)
        {
            // Get the 1 (index 0) and only instance of our tool window (if it does not already exist it will get created)
            MsVsShell.ToolWindowPane pane = FindToolWindow(typeof(ListenerWindowPane), 0, true);
            if (pane == null)
            {
                throw new COMException("Unable to locate NLV Listener pane");
            }

            IVsWindowFrame frame = pane.Frame as IVsWindowFrame;

            if (frame == null)
            {
                throw new COMException("Unable to locate NLV Listener frame");
            }

            // Bring the tool window to the front and give it focus
            ErrorHandler.ThrowOnFailure(frame.Show());
        }
Esempio n. 7
0
        /// <summary>
        /// Display the SCC Provider Toolwindow if it is not already visible
        /// </summary>
        private void ShowSccProviderToolWindow()
        {
            IVsWindowFrame windowFrame = null;

            try
            {
                // This function is called when the package is auto-loaded (as result of our command UI context
                // guidSccProvider being set active). This can happen on startup, if this scc provider was active
                // last time the shell was started.
                // However, at that time we cannot create the toolwindow because the shell is not fully initialized
                // and the window profile is not yet loaded. We need to protect
                MsVsShell.ToolWindowPane window = FindToolWindow(typeof(SccProviderToolWindow), 0, true);
                if (window != null && window.Frame != null)
                {
                    windowFrame = (IVsWindowFrame)window.Frame;
                }
            }
            catch (COMException e)
            {
                if (e.ErrorCode != VSConstants.E_UNEXPECTED)
                {
                    throw;
                }
            }

            if (windowFrame == null)
            {
                return;
            }

            if (sccService.Active)
            {
                ErrorHandler.ThrowOnFailure(windowFrame.Show());
            }
            else
            {
                ErrorHandler.ThrowOnFailure(windowFrame.Hide());
            }
        }
Esempio n. 8
0
        private void ShowSccProviderToolWindow()
        {
            MsVsShell.ToolWindowPane window      = this.FindToolWindow(typeof(SccProviderToolWindow), 0, true);
            IVsWindowFrame           windowFrame = null;

            if (window != null && window.Frame != null)
            {
                windowFrame = (IVsWindowFrame)window.Frame;
            }
            if (windowFrame == null)
            {
                throw new InvalidOperationException("No valid window frame object was returned from Toolwindow pane");
            }
            if (sccService.Active)
            {
                ErrorHandler.ThrowOnFailure(windowFrame.Show());
            }
            else
            {
                ErrorHandler.ThrowOnFailure(windowFrame.Hide());
            }
        }
        private void ShowToolWindow()
        {
            if (toolWindow == null)
              {
            // Get the instance number 0 of this tool window. This window is single instance so this instance
            // is actually the only one.
            // The last flag is set to true so that if the tool window does not exists it will be created.
            toolWindow = this.FindToolWindow(typeof(LocalHistoryToolWindow), 0, true);
            if ((toolWindow == null) || (toolWindow.Frame == null))
            {
              throw new NotSupportedException(Resources.CanNotCreateWindow);
            }

            // Provide the control with the Visual Studio Difference Service to compare files
            LocalHistoryControl control = (LocalHistoryControl)toolWindow.Content;

            // TODO: remove this
            // BUG: This will cause a null pointer exception if no solution is open when the user opens the tool window.
            documentRepository.Control = control;
              }

              // Make sure the tool window is visible to the user
              IVsWindowFrame windowFrame = (IVsWindowFrame)toolWindow.Frame;
              Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
        /// <summary>
        /// When a solution is opened, this function creates a new <code>DocumentRepository</code> and 
        /// registers the <code>LocalHistoryDocumentListener</code> to listen for save events.
        /// </summary>
        public int OnAfterOpenSolution(object pUnkReserved, int fNewSolution)
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering OnAfterOpenSolution() of: {0}", this.ToString()));

              dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));
              if (dte == null) ErrorHandler.ThrowOnFailure(1);

              // The solution name can be empty if the user opens a file without opening a solution
              if (dte.Solution != null && dte.Solution.FullName.Length != 0)
              {
            RegisterDocumentListener();

            RegisterSelectionListener();
              }

              // Get the instance of the ToolWindow if there is one
              toolWindow = this.FindToolWindow(typeof(LocalHistoryToolWindow), 0, false);

              if(toolWindow != null) {
            // TODO: remove this
            // BUG: This will cause a null pointer exception if no solution is open when the user opens the tool window.
            documentRepository.Control = (LocalHistoryControl)toolWindow.Content;
              }

              return VSConstants.S_OK;
        }
Esempio n. 11
0
 public static ControlViewModel GetViewModel(ToolWindowPane toolWindow)
 {
     var myControlView = (ControlView)toolWindow.Content;
     return (ControlViewModel)myControlView.DataContext;
 }
 public SelectionUtils(ToolWindowPane owner)
 {
     _owner = owner;
     _selectionTracker = new Lazy<ITrackSelection>(() => CreateTrackSelection(_owner));
 }
Esempio n. 13
0
        /// <summary>
        /// Shows the tool window when the menu item is clicked.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event args.</param>
        private void ShowOrHideToolWindow(object sender, EventArgs e)
        {
            _window = this.FindToolWindow(typeof(FeedbackWindowToolPane), 0, true);

            if ((null == _window) || (null == _window.Frame))
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            IVsWindowFrame windowFrame = (IVsWindowFrame)_window.Frame;

            if (windowFrame.IsVisible() == VSConstants.S_OK)
            {
                ErrorHandler.ThrowOnFailure(windowFrame.Hide());
            }
            else
            {
                ErrorHandler.ThrowOnFailure(windowFrame.Show());
            }

            if (_window.Content != null)
            {
                _toolWindow = _window.Content as NewFeedbackWindowControl;

                if (_toolWindow != null)
                {
                    _control = _toolWindow.WindowsFormsHost.Child as FeedbackWindow;
                }
            }
        }
Esempio n. 14
-1
        public InteractiveWindow(string title, AutomationElement element, VisualStudioApp app)
            : base(null, element) {
            _app = app;
            _title = title;

            var compModel = _app.GetService<IComponentModel>(typeof(SComponentModel));
            var replWindowProvider = compModel.GetService<InteractiveWindowProvider>();
            _replWindow = replWindowProvider
#if DEV14_OR_LATER
                .GetReplToolWindows()
#else
                .GetReplWindows()
#endif
                .OfType<ToolWindowPane>()
                .FirstOrDefault(p => p.Caption.Equals(title, StringComparison.CurrentCulture));
#if DEV14_OR_LATER
            _interactive = ((IVsInteractiveWindow)_replWindow).InteractiveWindow;
#else
            _interactive = (IReplWindow)_replWindow;
#endif

            _replWindowInfo = _replWindows.GetValue(_replWindow, window => {
                var info = new InteractiveWindowInfo();
                _interactive.ReadyForInput += new Action(info.OnReadyForInput);
                return info;
            });
        }