-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainWindow.xaml
104 lines (104 loc) · 5.66 KB
/
MainWindow.xaml
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
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:HyperVPeek"
xmlns:tk="clr-namespace:Xceed.Wpf.Toolkit;assembly=DotNetProjects.Wpf.Extended.Toolkit"
xmlns:System="clr-namespace:System;assembly=System.Runtime"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
x:Class="HyperVPeek.MainWindow"
mc:Ignorable="d"
Title="Hyper-V Peek" Height="450" Width="800">
<Window.Resources>
<local:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
<Style TargetType="{x:Type Button}" x:Key="VisibleWhenConnected">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Value="True" Binding="{Binding IsConnected}">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type Button}" x:Key="VisibleWhenDisconnected">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Value="True" Binding="{Binding IsDisconnected}">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type Button}" x:Key="VisibleWhenNoAutoRefresh">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Value="False" Binding="{Binding AutoRefresh}">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type Button}" x:Key="VisibleWhenExceededMaxEnvelopeSize">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Value="True" Binding="{Binding ExceededMaxEnvelopeSize}">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Window.DataContext>
<local:MainWindowViewModel/>
</Window.DataContext>
<b:Interaction.Triggers>
<b:EventTrigger EventName="Loaded">
<b:InvokeCommandAction Command="{Binding LoadSettingsCommand}"/>
</b:EventTrigger>
<b:EventTrigger EventName="Closed">
<b:InvokeCommandAction Command="{Binding SaveSettingsCommand}"/>
</b:EventTrigger>
</b:Interaction.Triggers>
<DockPanel>
<StackPanel Orientation="Vertical" DockPanel.Dock="Top">
<StackPanel Orientation="Horizontal" Margin="0, 3, 0, 3">
<StackPanel Orientation="Horizontal" IsEnabled="{Binding IsConnected, Converter={StaticResource InverseBooleanConverter}}">
<tk:WatermarkTextBox Margin="3,3,3,3" TextWrapping="NoWrap" Width="120" Watermark="Domain Name" Text="{Binding TargetDomain}"/>
<tk:WatermarkTextBox Margin="3,3,3,3" TextWrapping="NoWrap" Width="120" Watermark="Hyper-V Hostname" Text="{Binding TargetHostname}"/>
<tk:WatermarkTextBox Margin="3,3,3,3" TextWrapping="NoWrap" Width="120" Watermark="Username" Text="{Binding Username}"/>
<tk:WatermarkPasswordBox x:Name="PasswordTextBox" Margin="3,3,3,3" TextWrapping="NoWrap" Width="120" Watermark="Password"/>
</StackPanel>
<Button Content="Connect" Margin="3,3,3,3" Width="80" Style="{Binding Mode=OneWay, Source={StaticResource VisibleWhenDisconnected}}">
<b:Interaction.Triggers>
<b:EventTrigger EventName="Click">
<b:InvokeCommandAction Command="{Binding ConnectCommand}" CommandParameter="{Binding ElementName=PasswordTextBox}"/>
<b:InvokeCommandAction Command="{Binding UpdateVirtualMachineListCommand}" />
</b:EventTrigger>
</b:Interaction.Triggers>
</Button>
<Button Content="Disconnect" Margin="3,3,3,3" Width="80" Style="{Binding Mode=OneWay, Source={StaticResource VisibleWhenConnected}}" Command="{Binding DisconnectCommand, Mode=OneWay}" />
<Button Content="Refresh" Margin="3,3,3,3" Width="80" Style="{Binding Mode=OneWay, Source={StaticResource VisibleWhenNoAutoRefresh}}" Command="{Binding RefreshVirtualMachineImageCommand, Mode=OneWay}"/>
</StackPanel>
</StackPanel>
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal">
<Label Content="{Binding Status}"></Label>
<Button Content="Try Making it 2MB" Margin="3,3,3,3" Width="80" Style="{Binding Mode=OneWay, Source={StaticResource VisibleWhenExceededMaxEnvelopeSize}}" Command="{Binding SetMaxEnvelopeSizeCommand, Mode=OneWay}">
<Button.CommandParameter>
<System:Int32>2048</System:Int32>
</Button.CommandParameter>
</Button>
</StackPanel>
<DockPanel>
<Grid Width="100" IsEnabled="{Binding IsConnected}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Content="VMs"></Label>
<ListBox Margin="3,3,3,3" Grid.Row="1" ItemsSource="{Binding VirtualMachines}" SelectedValue="{Binding SelectedVirtualMachine}"/>
<CheckBox Content="Auto-Refresh" Grid.Row="2" IsChecked="{Binding AutoRefresh}"></CheckBox>
</Grid>
<StackPanel DockPanel.Dock="Right" x:Name="VmImagePanel" Margin="3,3,3,3" SizeChanged="VmImagePanel_SizeChanged">
<Image x:Name="VmImage" Stretch="Fill" Source="{Binding LastVirtualMachineImage}" />
</StackPanel>
</DockPanel>
</DockPanel>
</Window>