예제 #1
0
        private void ShowToolWindow(object sender, EventArgs e)
        {
            try
            {
                // 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.
                //ToolWindowPane window = this.FindToolWindow(typeof(MyToolWindow), 0, true);

                //if ((null == window) || (null == window.Frame))
                //{
                //    throw new NotSupportedException("Can not create tool window.");
                //}
                //IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
                //Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());

                var txtxMgr = (IVsTextManager)GetService(typeof(SVsTextManager));

                IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
                IntPtr     mainWnd;
                uiShell.GetDialogOwnerHwnd(out mainWnd);

                var dialog = new ConfigWindow();
                WindowInteropHelper helper = new WindowInteropHelper(dialog);
                helper.Owner = mainWnd;

                dialog.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void ShowToolWindow(object sender, EventArgs e)
        {
            try
            {
                // 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.
                //ToolWindowPane window = this.FindToolWindow(typeof(MyToolWindow), 0, true);

                //if ((null == window) || (null == window.Frame))
                //{
                //    throw new NotSupportedException("Can not create tool window.");
                //}
                //IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
                //Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());

                var txtxMgr = (IVsTextManager)GetService(typeof(SVsTextManager));

                IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
                IntPtr mainWnd;
                uiShell.GetDialogOwnerHwnd(out mainWnd);

                var dialog = new ConfigWindow();
                WindowInteropHelper helper = new WindowInteropHelper(dialog);
                helper.Owner = mainWnd;

                dialog.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }