|
7 | 7 | xmlns:local="clr-namespace:Rubberduck.UI.Refactorings.AnnotateDeclaration"
|
8 | 8 | xmlns:annotations="clr-namespace:Rubberduck.Parsing.Annotations;assembly=Rubberduck.Parsing"
|
9 | 9 | mc:Ignorable="d"
|
10 |
| - d:DesignHeight="300" d:DesignWidth="300"> |
| 10 | + d:DesignHeight="400" d:DesignWidth="300"> |
11 | 11 | <UserControl.Resources>
|
12 | 12 | <ResourceDictionary>
|
13 | 13 | <ResourceDictionary.MergedDictionaries>
|
|
17 | 17 | <converters:EnumToLocalizedStringConverter ResourcePrefix="AnnotationArgumentType_" x:Key="AnnotationArgumentTypeToStringConverter"/>
|
18 | 18 | <converters:InspectionToLocalizedNameConverter x:Key="InspectionToLocalizedNameConverter"/>
|
19 | 19 | <converters:DeclarationToQualifiedNameConverter x:Key="DeclarationToQualifiedNameConverter"/>
|
| 20 | + <converters:AnnotationToCodeStringConverter x:Key="AnnotationToCodeStringConverter"/> |
20 | 21 |
|
21 | 22 | <BitmapImage x:Key="InvalidTextImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/cross-circle.png" />
|
22 | 23 | <Style x:Key="TextBoxErrorStyle" TargetType="{x:Type TextBox}">
|
23 | 24 | <Setter Property="Validation.ErrorTemplate">
|
24 | 25 | <Setter.Value>
|
25 | 26 | <ControlTemplate x:Name="TextBoxErrorTemplate">
|
26 |
| - <DockPanel LastChildFill="True"> |
27 |
| - <AdornedElementPlaceholder/> |
28 |
| - <Image Source="{StaticResource InvalidTextImage}" |
29 |
| - Height="16" |
30 |
| - Margin="0,-8,-8,0" |
31 |
| - HorizontalAlignment="Right" |
32 |
| - VerticalAlignment="Top"/> |
33 |
| - </DockPanel> |
| 27 | + <Canvas> |
| 28 | + <DockPanel LastChildFill="True" ClipToBounds="False"> |
| 29 | + <AdornedElementPlaceholder/> |
| 30 | + <Image Source="{StaticResource InvalidTextImage}" |
| 31 | + Height="16" |
| 32 | + Margin="0,-8,-8,0" |
| 33 | + HorizontalAlignment="Right" |
| 34 | + VerticalAlignment="Top" |
| 35 | + ClipToBounds="False"/> |
| 36 | + </DockPanel> |
| 37 | + </Canvas> |
34 | 38 | </ControlTemplate>
|
35 | 39 | </Setter.Value>
|
36 | 40 | </Setter>
|
|
69 | 73 | Margin="5,0">
|
70 | 74 | <ComboBox.ItemTemplate>
|
71 | 75 | <DataTemplate DataType="{x:Type annotations:IAnnotation}">
|
72 |
| - <TextBlock Text="{Binding Name, StringFormat=@{}{0}}"/> |
| 76 | + <TextBlock Text="{Binding Path=., Converter={StaticResource AnnotationToCodeStringConverter}}"/> |
73 | 77 | </DataTemplate>
|
74 | 78 | </ComboBox.ItemTemplate>
|
75 | 79 | </ComboBox>
|
|
86 | 90 | </DataTemplate>
|
87 | 91 | <DataTemplate DataType="{x:Type local:IAnnotationArgumentViewModel}" x:Key="ArgumentMultiTypeTemplate">
|
88 | 92 | <ComboBox
|
89 |
| - ItemsSource="{Binding Path=ApplicableArgumentTypes, Converter={StaticResource AnnotationArgumentTypeToStringConverter}}" |
90 |
| - SelectedItem="{Binding Path=ArgumentType, Converter={StaticResource AnnotationArgumentTypeToStringConverter}}" |
91 |
| - IsSynchronizedWithCurrentItem="True"/> |
92 |
| - </DataTemplate> |
93 |
| - <DataTemplate DataType="{x:Type local:IAnnotationArgumentViewModel}" x:Key="ArgumentValueTemplate"> |
94 |
| - <TextBox |
95 |
| - Text="{Binding Path=ArgumentValue, ValidatesOnNotifyDataErrors=True}" |
96 |
| - Style="{StaticResource TextBoxErrorStyle}"/> |
97 |
| - </DataTemplate> |
98 |
| - <DataTemplate DataType="{x:Type local:IAnnotationArgumentViewModel}" x:Key="ArgumentValueBooleanTemplate"> |
99 |
| - <ComboBox |
100 |
| - SelectedItem="{Binding Path=ArgumentValue}" |
101 |
| - IsSynchronizedWithCurrentItem="True"> |
102 |
| - <TextBlock Text="True"/> |
103 |
| - <TextBlock Text="False"/> |
104 |
| - </ComboBox> |
105 |
| - </DataTemplate> |
106 |
| - <DataTemplate DataType="{x:Type local:IAnnotationArgumentViewModel}" x:Key="ArgumentValueInspectionTemplate"> |
107 |
| - <ComboBox |
108 |
| - SelectedItem="{Binding Path=ArgumentValue}" |
| 93 | + ItemsSource="{Binding Path=ApplicableArgumentTypes}" |
| 94 | + SelectedItem="{Binding Path=ArgumentType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" |
109 | 95 | IsSynchronizedWithCurrentItem="True">
|
110 | 96 | <ComboBox.ItemTemplate>
|
111 |
| - <DataTemplate> |
112 |
| - <TextBlock Text="{Binding Path=., Converter={StaticResource InspectionToLocalizedNameConverter}}"/> |
| 97 | + <DataTemplate DataType="{x:Type annotations:AnnotationArgumentType}"> |
| 98 | + <TextBlock Text="{Binding Path=., Converter={StaticResource AnnotationArgumentTypeToStringConverter}}"/> |
113 | 99 | </DataTemplate>
|
114 | 100 | </ComboBox.ItemTemplate>
|
115 | 101 | </ComboBox>
|
116 | 102 | </DataTemplate>
|
| 103 | + <x:Array Type="sys:Object" xmlns:sys="clr-namespace:System;assembly=mscorlib" x:Key="NonDefaultInputArgumentTypes"> |
| 104 | + <annotations:AnnotationArgumentType>Boolean</annotations:AnnotationArgumentType> |
| 105 | + <annotations:AnnotationArgumentType>Inspection</annotations:AnnotationArgumentType> |
| 106 | + </x:Array> |
| 107 | + <converters:SpecificValuesToVisibilityConverter SpecialValues="{StaticResource NonDefaultInputArgumentTypes}" CollapseSpecialValues="True" x:Key="DefaultArgumentVisibilityConverter"/> |
| 108 | + <converters:SpecificValueToVisibilityConverter SpecialValue="{x:Static annotations:AnnotationArgumentType.Boolean}" CollapseSpecialValue="False" x:Key="BooleanArgumentVisibilityConverter"/> |
| 109 | + <converters:SpecificValueToVisibilityConverter SpecialValue="{x:Static annotations:AnnotationArgumentType.Inspection}" CollapseSpecialValue="False" x:Key="InspectionArgumentVisibilityConverter"/> |
| 110 | + <DataTemplate DataType="{x:Type local:IAnnotationArgumentViewModel}" x:Key="ArgumentValueTemplate"> |
| 111 | + <StackPanel> |
| 112 | + <TextBox Text="{Binding ArgumentValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" |
| 113 | + Style="{StaticResource TextBoxErrorStyle}" |
| 114 | + Visibility="{Binding ArgumentType, Converter={StaticResource DefaultArgumentVisibilityConverter}}"> |
| 115 | + </TextBox> |
| 116 | + <ComboBox |
| 117 | + Visibility="{Binding ArgumentType, Converter={StaticResource BooleanArgumentVisibilityConverter}}" |
| 118 | + ItemsSource="{Binding Path=BooleanValues}" |
| 119 | + SelectedItem="{Binding Path=ArgumentValue, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"> |
| 120 | + </ComboBox> |
| 121 | + <ComboBox |
| 122 | + Visibility="{Binding ArgumentType, Converter={StaticResource InspectionArgumentVisibilityConverter}}" |
| 123 | + ItemsSource="{Binding Path=InspectionNames}" |
| 124 | + SelectedItem="{Binding Path=ArgumentValue, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"> |
| 125 | + <ComboBox.ItemTemplate> |
| 126 | + <DataTemplate> |
| 127 | + <TextBlock Text="{Binding Path=., Converter={StaticResource InspectionToLocalizedNameConverter}, UpdateSourceTrigger=PropertyChanged}"/> |
| 128 | + </DataTemplate> |
| 129 | + </ComboBox.ItemTemplate> |
| 130 | + </ComboBox> |
| 131 | + </StackPanel> |
| 132 | + </DataTemplate> |
117 | 133 | <local:AnnotationArgumentTypeCellDataTemplateSelector x:Key="AnnotationArgumentTypeCellDataTemplateSelector"/>
|
118 |
| - <local:AnnotationArgumentValueCellDataTemplateSelector x:Key="AnnotationArgumentValueCellDataTemplateSelector"/> |
119 | 134 | </Grid.Resources>
|
120 | 135 | <DataGrid
|
121 | 136 | Grid.Column="0"
|
|
128 | 143 | <DataGridTemplateColumn
|
129 | 144 | Header="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=AnnotateDeclarationDialog_ArgumentTypeHeader}"
|
130 | 145 | CellTemplateSelector="{StaticResource AnnotationArgumentTypeCellDataTemplateSelector}"
|
131 |
| - CellEditingTemplateSelector="{StaticResource AnnotationArgumentTypeCellDataTemplateSelector}"> |
132 |
| - </DataGridTemplateColumn> |
| 146 | + CellEditingTemplateSelector="{StaticResource AnnotationArgumentTypeCellDataTemplateSelector}" |
| 147 | + Width="Auto"/> |
133 | 148 | <DataGridTemplateColumn
|
134 | 149 | Header="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=AnnotateDeclarationDialog_ArgumentValueHeader}"
|
135 |
| - CellTemplateSelector="{StaticResource AnnotationArgumentValueCellDataTemplateSelector}" |
136 |
| - CellEditingTemplateSelector="{StaticResource AnnotationArgumentValueCellDataTemplateSelector}"> |
137 |
| - </DataGridTemplateColumn> |
| 150 | + CellTemplate="{StaticResource ArgumentValueTemplate}" |
| 151 | + CellEditingTemplate="{StaticResource ArgumentValueTemplate}" |
| 152 | + Width="*"/> |
138 | 153 | </DataGrid.Columns>
|
139 | 154 | </DataGrid>
|
140 | 155 | <StackPanel
|
|
0 commit comments