|
4 | 4 | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
5 | 5 | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
6 | 6 | xmlns:Validator="clr-namespace:NETworkManager.Validators" |
7 | | - xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" |
| 7 | + xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" |
| 8 | + xmlns:WpfHelper="clr-namespace:NETworkManager.WpfHelper" |
| 9 | + xmlns:Converter="clr-namespace:NETworkManager.Converters" |
| 10 | + xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" |
8 | 11 | mc:Ignorable="d" Loaded="UserControl_Loaded"> |
| 12 | + <UserControl.Resources> |
| 13 | + <Converter:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> |
| 14 | + <Converter:BooleanReverseToVisibilityConverter x:Key="BooleanReverseToVisibilityConverter" /> |
| 15 | + </UserControl.Resources> |
9 | 16 | <Grid Margin="0,20"> |
10 | 17 | <Grid.RowDefinitions> |
11 | | - <RowDefinition Height="*" /> |
| 18 | + <RowDefinition Height="Auto" /> |
| 19 | + <RowDefinition Height="Auto" /> |
12 | 20 | <RowDefinition Height="10" /> |
13 | 21 | <RowDefinition Height="Auto" /> |
14 | 22 | </Grid.RowDefinitions> |
15 | 23 | <Grid Grid.Row="0"> |
16 | 24 | <Grid.Resources> |
17 | 25 | <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource CenterTextBlock}" /> |
18 | 26 | <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource DefaultTextBox}" /> |
19 | | - <Style TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource DefaultPasswordBox}" /> |
20 | 27 | </Grid.Resources> |
21 | | - <Grid.RowDefinitions> |
22 | | - <RowDefinition Height="Auto" /> |
23 | | - </Grid.RowDefinitions> |
24 | 28 | <Grid.ColumnDefinitions> |
25 | 29 | <ColumnDefinition Width="*" /> |
26 | 30 | <ColumnDefinition Width="10" /> |
27 | 31 | <ColumnDefinition Width="*" /> |
28 | 32 | </Grid.ColumnDefinitions> |
| 33 | + <Grid.RowDefinitions> |
| 34 | + <RowDefinition Height="Auto" /> |
| 35 | + <RowDefinition Height="10" /> |
| 36 | + <RowDefinition Height="Auto" /> |
| 37 | + <RowDefinition Height="10" /> |
| 38 | + <RowDefinition Height="Auto" /> |
| 39 | + </Grid.RowDefinitions> |
29 | 40 | <TextBlock Grid.Column="0" Grid.Row="0" Text="{DynamicResource String_Hostname}" /> |
30 | 41 | <TextBox x:Name="txtHostname" Grid.Column="2" Grid.Row="0" mah:TextBoxHelper.Watermark="{DynamicResource String_Watermark_ExampleHostname}"> |
31 | 42 | <TextBox.Text> |
32 | | - <Binding Path="Hostname" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" > |
| 43 | + <Binding Path="Hostname" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"> |
33 | 44 | <Binding.ValidationRules> |
34 | 45 | <Validator:EmptyValidator ValidatesOnTargetUpdated="True" /> |
35 | 46 | </Binding.ValidationRules> |
36 | 47 | </Binding> |
37 | 48 | </TextBox.Text> |
38 | 49 | </TextBox> |
| 50 | + <TextBlock Grid.Column="0" Grid.Row="2" Text="{DynamicResource String_UseCredentials}" /> |
| 51 | + <mah:ToggleSwitch Grid.Column="2" Grid.Row="2" OffLabel="" OnLabel="" IsChecked="{Binding UseCredential}" /> |
| 52 | + <StackPanel Grid.Column="2" Grid.Row="4" Orientation="Horizontal" Visibility="{Binding UseCredential, Converter={StaticResource BooleanToVisibilityConverter}}"> |
| 53 | + <RadioButton Content="{DynamicResource String_Credentials}" /> |
| 54 | + <RadioButton Content="{DynamicResource String_Custom}" IsChecked="{Binding CustomCredentials}" Margin="10,0,0,0"/> |
| 55 | + </StackPanel> |
| 56 | + </Grid> |
| 57 | + <Grid Grid.Row="1" Visibility="{Binding UseCredential, Converter={StaticResource BooleanToVisibilityConverter}}" Margin="0,10,0,0"> |
| 58 | + <Grid Visibility="{Binding CustomCredentials, Converter={StaticResource BooleanToVisibilityConverter}}"> |
| 59 | + <Grid.Resources> |
| 60 | + <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource CenterTextBlock}" /> |
| 61 | + <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource DefaultTextBox}" /> |
| 62 | + <Style TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource DefaultPasswordBox}" /> |
| 63 | + </Grid.Resources> |
| 64 | + <Grid.ColumnDefinitions> |
| 65 | + <ColumnDefinition Width="*" /> |
| 66 | + <ColumnDefinition Width="10" /> |
| 67 | + <ColumnDefinition Width="*" /> |
| 68 | + </Grid.ColumnDefinitions> |
| 69 | + <Grid.RowDefinitions> |
| 70 | + <RowDefinition Height="Auto" /> |
| 71 | + <RowDefinition Height="10" /> |
| 72 | + <RowDefinition Height="Auto" /> |
| 73 | + </Grid.RowDefinitions> |
| 74 | + <TextBlock Grid.Column="0" Grid.Row="0" Text="{DynamicResource String_Username}" /> |
| 75 | + <TextBox x:Name="txtUsername" Grid.Column="2" Grid.Row="0" mah:TextBoxHelper.Watermark="{DynamicResource String_Watermark_ExampleUsername}"> |
| 76 | + <TextBox.Text> |
| 77 | + <Binding Path="Username" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" > |
| 78 | + <Binding.ValidationRules> |
| 79 | + <Validator:EmptyValidator ValidatesOnTargetUpdated="True" /> |
| 80 | + </Binding.ValidationRules> |
| 81 | + </Binding> |
| 82 | + </TextBox.Text> |
| 83 | + </TextBox> |
| 84 | + <TextBlock Grid.Column="0" Grid.Row="2" Text="{DynamicResource String_Password}" /> |
| 85 | + <PasswordBox x:Name="passwordBoxPassword" Grid.Column="2" Grid.Row="2" Style="{StaticResource DefaultPasswordBox}" > |
| 86 | + <Interactivity:Interaction.Behaviors> |
| 87 | + <WpfHelper:PasswordBoxBindingBehavior Password="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> |
| 88 | + </Interactivity:Interaction.Behaviors> |
| 89 | + </PasswordBox> |
| 90 | + </Grid> |
| 91 | + <Grid Visibility="{Binding CustomCredentials, Converter={StaticResource BooleanReverseToVisibilityConverter}}"> |
| 92 | + <Grid.Resources> |
| 93 | + <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource CenterTextBlock}" /> |
| 94 | + <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource DefaultTextBox}" /> |
| 95 | + </Grid.Resources> |
| 96 | + <Grid.ColumnDefinitions> |
| 97 | + <ColumnDefinition Width="*" /> |
| 98 | + <ColumnDefinition Width="10" /> |
| 99 | + <ColumnDefinition Width="*" /> |
| 100 | + </Grid.ColumnDefinitions> |
| 101 | + <Grid.RowDefinitions> |
| 102 | + <RowDefinition Height="Auto" /> |
| 103 | + </Grid.RowDefinitions> |
| 104 | + <TextBlock Grid.Column="0" Grid.Row="0" Text="{DynamicResource String_Credential}" /> |
| 105 | + <ComboBox x:Name="cbCredentialID" Grid.Column="2" Grid.Row="0" SelectedValuePath="ID" SelectedValue="{Binding CredentialID}" Style="{StaticResource DefaultComboBox}" ItemsSource="{Binding Credentials}"> |
| 106 | + <ComboBox.InputBindings> |
| 107 | + <KeyBinding Command="{Binding UnselectCredentialCommand}" Key="Delete"/> |
| 108 | + </ComboBox.InputBindings> |
| 109 | + <ComboBox.ItemTemplate> |
| 110 | + <DataTemplate> |
| 111 | + <StackPanel Orientation="Horizontal"> |
| 112 | + <TextBlock> |
| 113 | + <TextBlock.Text> |
| 114 | + <MultiBinding StringFormat="{}[{0}] {1}"> |
| 115 | + <Binding Path="ID" /> |
| 116 | + <Binding Path="Name" /> |
| 117 | + </MultiBinding> |
| 118 | + </TextBlock.Text> |
| 119 | + </TextBlock> |
| 120 | + </StackPanel> |
| 121 | + </DataTemplate> |
| 122 | + </ComboBox.ItemTemplate> |
| 123 | + </ComboBox> |
| 124 | + <!--<Rectangle Width="24" Height="24" Grid.Column="3" Grid.Row="4" ToolTip="{DynamicResource String_HelpMessage_Credentials}" Visibility="{Binding ShowUnlockCredentialsHint, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource HelpImageRectangle}" Margin="10,0,0,0"> |
| 125 | + <Rectangle.Resources> |
| 126 | + <Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource HelpToolTip}" /> |
| 127 | + </Rectangle.Resources> |
| 128 | + </Rectangle>--> |
| 129 | + </Grid> |
39 | 130 | </Grid> |
40 | | - <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right"> |
| 131 | + <StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Right"> |
41 | 132 | <Button Content="{DynamicResource String_Button_Cancel}" Command="{Binding CancelCommand}" IsCancel="True" Style="{StaticResource DefaultButton}" /> |
42 | 133 | <Button Content="{DynamicResource String_Button_Connect}" Command="{Binding ConnectCommand}" IsDefault="True" Margin="10,0,0,0"> |
43 | 134 | <Button.Style> |
|
0 commit comments