예제 #1
0
        private static void ShowHelpWindow(PSObject helpObj, PSCmdlet cmdlet)
        {
            Window ownerWindow = ShowCommandHelper.GetHostWindow(cmdlet);
            if (ownerWindow != null)
            {
                ownerWindow.Dispatcher.Invoke(
                    new SendOrPostCallback(
                        delegate(object ignored)
                        {
                            HelpWindow helpWindow = new HelpWindow(helpObj);
                            helpWindow.Owner = ownerWindow;
                            helpWindow.Show();

                            helpWindow.Closed += new EventHandler(delegate(object sender, EventArgs e) { ownerWindow.Focus(); });
                        }),
                        String.Empty);
                return;
            }

            Thread guiThread = new Thread(
            (ThreadStart)delegate
            {
                HelpWindow helpWindow = new HelpWindow(helpObj);
                helpWindow.ShowDialog();
            });
            guiThread.SetApartmentState(ApartmentState.STA);
            guiThread.Start();
        }
예제 #2
0
 private void DisplayHelp(Collection<PSObject> getHelpResults)
 {
     if (this.window != null && getHelpResults != null && getHelpResults.Count > 0)
     {
         this.window.Dispatcher.Invoke(
             new SendOrPostCallback(
                 delegate(object ignored)
                 {
                     HelpWindow help = new HelpWindow(getHelpResults[0]);
                     help.Owner = this.window;
                     help.Show();
                 }),
                 String.Empty);
     }
 }