forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelpWindowHelper.cs
More file actions
55 lines (50 loc) · 1.92 KB
/
Copy pathHelpWindowHelper.cs
File metadata and controls
55 lines (50 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using System.Diagnostics.CodeAnalysis;
using System.Management.Automation;
using System.Threading;
using System.Windows;
using Microsoft.Management.UI;
using Microsoft.PowerShell.Commands.ShowCommandInternal;
namespace Microsoft.PowerShell.Commands.Internal
{
/// <summary>
/// Implements thw WPF window part of the the ShowWindow option of get-help.
/// </summary>
internal static class HelpWindowHelper
{
/// <summary>
/// Shows the help window.
/// </summary>
/// <param name="helpObj">Object with help information.</param>
/// <param name="cmdlet">Cmdlet calling this method.</param>
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Called from methods called using reflection")]
private static void ShowHelpWindow(PSObject helpObj, PSCmdlet cmdlet)
{
Window ownerWindow = ShowCommandHelper.GetHostWindow(cmdlet);
if (ownerWindow != null)
{
ownerWindow.Dispatcher.Invoke(
new SendOrPostCallback(
(_) =>
{
HelpWindow helpWindow = new HelpWindow(helpObj);
helpWindow.Owner = ownerWindow;
helpWindow.Show();
helpWindow.Closed += new EventHandler((sender, 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();
}
}
}