-
Notifications
You must be signed in to change notification settings - Fork 296
/
EncapsulateFieldView.xaml
201 lines (200 loc) · 12.5 KB
/
EncapsulateFieldView.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<UserControl x:Class="Rubberduck.UI.Refactorings.EncapsulateField.EncapsulateFieldView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:Rubberduck.UI.Controls"
xmlns:converters="clr-namespace:Rubberduck.UI.Converters"
mc:Ignorable="d"
MinHeight="600"
d:DesignHeight="600"
d:DesignWidth="600">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../../Controls/ToolBar.xaml"/>
</ResourceDictionary.MergedDictionaries>
<converters:BoolToVisibleVisibilityConverter x:Key="BoolToVisibleVisibility" />
<BitmapImage x:Key="InvalidNameImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/cross-circle.png" />
<Style TargetType="Image" x:Key="InvalidNameIconStyle">
<Setter Property="Source" Value="{StaticResource InvalidNameImage}" />
<Setter Property="Height" Value="16" />
<Setter Property="Margin" Value="0,0,-8,0" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Top" />
</Style>
<Style TargetType="Button" x:Key="CommandButtonStyle">
<Setter Property="Height" Value="22" />
<Setter Property="Margin" Value="5,0" />
<Setter Property="Padding" Value="10,0" />
</Style>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Background="{StaticResource BackgroundLightBrush}">
<Label Content="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=EncapsulateField_TitleText}"
FontWeight="Bold" />
<TextBlock Text="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=EncapsulateField_InstructionText}"
Margin="5,0" />
</StackPanel>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="5" Orientation="Vertical">
<CheckBox Name="WrapAsUDTCheckBox"
Grid.Row="1"
Content="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=EncapsulateField_WrapFieldsInPrivateType}"
IsChecked="{Binding ConvertFieldsToUDTMembers, Mode=TwoWay}"
FontWeight="Bold"
VerticalAlignment="Top"
IsTabStop="False"
Width="200"
HorizontalAlignment="Left"
Margin="2"/>
<ComboBox ItemsSource="{Binding UDTFields}"
Margin="2"
Width="300"
HorizontalAlignment="Left"
DisplayMemberPath="FieldDeclarationBlock"
SelectedItem="{Binding SelectedObjectStateUDT, Mode=TwoWay}"
Visibility="{Binding ShowStateUDTSelections, Converter={StaticResource BoolToVisibleVisibility}}">
</ComboBox>
</StackPanel>
<Grid Grid.Row="1" Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Vertical" Margin="5">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Margin="0,5"
Text="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=ExtractInterface_MembersGroupBox}" />
<StackPanel Grid.Column="1" Margin="5" Orientation="Horizontal">
<Button Style="{StaticResource CommandButtonStyle}" TabIndex="2"
Content="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=SelectAll_Button}"
Command="{Binding SelectAllCommand}" />
<Button Style="{StaticResource CommandButtonStyle}" TabIndex="3"
Content="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=DeselectAll_Button}"
Command="{Binding DeselectAllCommand}">
</Button>
</StackPanel>
</Grid>
<ListBox TabIndex="0" Height="150"
ItemsSource="{Binding Path=EncapsulationFields}"
SelectedItem="{Binding Path= SelectedField, Mode=TwoWay}"
SelectionMode="Single"
ScrollViewer.VerticalScrollBarVisibility="Visible"
ScrollViewer.HorizontalScrollBarVisibility="Auto">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding EncapsulateFlag, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
FontWeight="Bold"
Command="{Binding Path=DataContext.EncapsulateFlagChangeCommand, RelativeSource={RelativeSource AncestorType=ListBox}}"
CommandParameter="{Binding ElementName=EncapsulationFields, Path=SelectedField}">
</CheckBox>
<TextBlock Grid.Column="1"
Margin="10,0,0,0"
Text="{Binding TargetDeclarationExpression, Mode=OneWay}"
FontWeight="Bold">
</TextBlock>
<Image Style="{StaticResource InvalidNameIconStyle}"
Visibility="{Binding Path=HasValidEncapsulationAttributes, Converter={StaticResource BoolToHiddenVisibility}}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Grid>
<Grid Grid.Row="2" Margin="5" Visibility="{Binding Path=SelectedFieldIsNotFlagged, Converter={StaticResource BoolToHiddenVisibility}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel>
<GroupBox Visibility="{Binding Path=IsEmptyList, Converter={StaticResource BoolToHiddenVisibility}}"
Margin="5">
<GroupBox.Header>
<TextBlock Text="{Binding Path=GroupBoxHeaderContent}" FontWeight="Bold" />
</GroupBox.Header>
<StackPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Visibility="{Binding Path=SelectedFieldIsPrivateUDT, Converter={StaticResource BoolToVisibleVisibility}}"
Text="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=EncapsulateField_PrivateUDTPropertyText}"
Margin="10,5" />
<TextBox Grid.Row="1" Visibility="{Binding Path=SelectedFieldHasEditablePropertyName, Converter={StaticResource BoolToVisibleVisibility}}"
Text="{Binding Path=PropertyName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
TabIndex="1" Margin="10,5"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
Height="22" />
<Image Grid.Row="1" Style="{StaticResource InvalidNameIconStyle}"
Visibility="{Binding Path=SelectionHasValidEncapsulationAttributes, Converter={StaticResource BoolToHiddenVisibility}}" />
</Grid>
<CheckBox IsChecked="{Binding Path=IsReadOnly, Mode=TwoWay}"
IsEnabled="{Binding Path=EnableReadOnlyOption}"
Content="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=EncapsulateField_ReadOnlyCheckBoxContent}"
Margin="10,2" FontWeight="Bold"
Command="{Binding Path=ReadOnlyChangeCommand}"
CommandParameter="{Binding ElementName=EncapsulationFields, Path=SelectedField}" />
</StackPanel>
</GroupBox>
</StackPanel>
<Grid Grid.Column="1">
<TextBlock Margin="5" Text="{Binding Path=ValidationErrorMessage, Mode=OneWay}"
Visibility="{Binding ElementName=PropertyInvalidIcon, Path=Visibility}"
TextWrapping="Wrap">
</TextBlock>
</Grid>
</Grid>
<StackPanel Grid.Row="3" Margin="10,5" Orientation="Horizontal">
<TextBlock Text="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=EncapsulateField_Preview}"
FontSize="14" FontWeight="Bold" />
<Image Style="{StaticResource InvalidNameIconStyle}" Margin="0,-4"
Visibility="{Binding Path=HasValidNames, Converter={StaticResource BoolToHiddenVisibility}}" />
</StackPanel>
<controls:BindableTextEditor Grid.Row="4" Margin="10" BorderThickness="1"
FontFamily="Courier New "
ShowLineNumbers="False"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Visible"
IsReadOnly="True" IsTabStop="False"
Text="{Binding PropertiesPreview,Mode=OneWay}" />
</Grid>
<Grid Grid.Row="2" Background="{x:Static SystemColors.ControlDarkBrush}" Grid.IsSharedSizeScope="True">
<Grid HorizontalAlignment="Right" Margin="5,0">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="SettingsButtons" />
<ColumnDefinition SharedSizeGroup="SettingsButtons" />
</Grid.ColumnDefinitions>
<Button Content="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=OK}"
Grid.Column="0"
Style="{StaticResource CommandButtonStyle}"
IsEnabled="{Binding IsValidInterfaceName}"
Command="{Binding OkButtonCommand}" />
<Button Content="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=CancelButtonText}"
Grid.Column="1"
Style="{StaticResource CommandButtonStyle}"
Command="{Binding CancelButtonCommand}"/>
</Grid>
</Grid>
</Grid>
</UserControl>