/// <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 Execute(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            //If Dte service is unavailable or if there is no active document, GS Assist won't be used.
            if (Dte == null)
            {
                ErrorHandler.ShowMessageBox("GS Assist is unavailable.");
                return;
            }
            if (Dte.ActiveDocument == null)
            {
                ErrorHandler.ShowMessageBox("Can not use GS Assist because there is no active header file.");
                return;
            }
            if (Dte.ActiveDocument.Language != "C/C++")
            {
                ErrorHandler.ShowMessageBox("Can not use GS Assist with a language different of C++.");
                return;
            }
            if (Dte.ActiveDocument.Name.Contains(".cpp"))
            {
                ErrorHandler.ShowMessageBox("Can not use GS Assist with an active source file. You need a header file.");
                return;
            }

            GSAssistWindow window = new GSAssistWindow();

            GSAssistWindowControl windowControl = window.Content as GSAssistWindowControl;

            //if GS AssistViewModel is null, then we
            if (windowControl.GSAssistViewModel != null)
            {
                window.ShowDialog();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GSAssistWindow"/> class.
        /// </summary>
        public GSAssistWindow()
        {
            Title = "GS Assist";

            Width     = 400;
            MaxHeight = 450;

            SizeToContent = System.Windows.SizeToContent.Height;

            // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable,
            // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on
            // the object returned by the Content property.

            Action closeWindow = () =>
            {
                Close();
            };

            Content = new GSAssistWindowControl(closeWindow);
        }