forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCmdletControl.xaml.cs
More file actions
104 lines (93 loc) · 3.57 KB
/
Copy pathCmdletControl.xaml.cs
File metadata and controls
104 lines (93 loc) · 3.57 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//-----------------------------------------------------------------------
// <copyright file="CmdletControl.xaml.cs" company="Microsoft">
// Copyright © Microsoft Corporation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Microsoft.PowerShell.Commands.ShowCommandInternal
{
using System.Windows;
using System.Windows.Controls;
/// <summary>
/// Interaction logic for CmdletControl.xaml
/// </summary>
public partial class CmdletControl : UserControl
{
/// <summary>
/// Field used for the CurrentCommandViewModel parameter.
/// </summary>
private CommandViewModel currentCommandViewModel;
#region Construction and Destructor
/// <summary>
/// Initializes a new instance of the CmdletControl class
/// </summary>
public CmdletControl()
{
InitializeComponent();
this.NotImportedControl.ImportModuleButton.Click += new RoutedEventHandler(ImportModuleButton_Click);
this.ParameterSetTabControl.DataContextChanged += new DependencyPropertyChangedEventHandler(this.ParameterSetTabControl_DataContextChanged);
this.KeyDown += new System.Windows.Input.KeyEventHandler(this.CmdletControl_KeyDown);
this.helpButton.innerButton.Click += new RoutedEventHandler(this.HelpButton_Click);
}
#endregion
#region Properties
/// <summary>
/// Gets the owner of the ViewModel.
/// </summary>
private CommandViewModel CurrentCommandViewModel
{
get { return this.currentCommandViewModel; }
}
#endregion
#region Private Events
/// <summary>
/// DataContextChanged event.
/// </summary>
/// <param name="sender">Event sender</param>
/// <param name="e">Event args</param>
private void ParameterSetTabControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (this.DataContext == null)
{
return;
}
CommandViewModel viewModel = (CommandViewModel)this.DataContext;
this.currentCommandViewModel = viewModel;
if (viewModel.ParameterSets.Count == 0)
{
return;
}
this.ParameterSetTabControl.SelectedItem = viewModel.ParameterSets[0];
}
/// <summary>
/// Key down event for user press F1 button.
/// </summary>
/// <param name="sender">Event sender</param>
/// <param name="e">Event args</param>
private void CmdletControl_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key == System.Windows.Input.Key.F1)
{
this.CurrentCommandViewModel.OpenHelpWindow();
}
}
/// <summary>
/// Help button event.
/// </summary>
/// <param name="sender">Event sender</param>
/// <param name="e">Event args</param>
private void HelpButton_Click(object sender, RoutedEventArgs e)
{
this.CurrentCommandViewModel.OpenHelpWindow();
}
/// <summary>
/// Import Module Button event
/// </summary>
/// <param name="sender">Event sender</param>
/// <param name="e">Event args</param>
private void ImportModuleButton_Click(object sender, RoutedEventArgs e)
{
this.CurrentCommandViewModel.OnImportModule();
}
#endregion
}
}