|
| 1 | +<UserControl x:Class="Rubberduck.UI.Refactorings.AnnotateDeclaration.AnnotateDeclarationView" |
| 2 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 3 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 4 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 5 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 6 | + xmlns:converters="clr-namespace:Rubberduck.UI.Converters" |
| 7 | + xmlns:local="clr-namespace:Rubberduck.UI.Refactorings.AnnotateDeclaration" |
| 8 | + xmlns:annotations="clr-namespace:Rubberduck.Parsing.Annotations;assembly=Rubberduck.Parsing" |
| 9 | + mc:Ignorable="d" |
| 10 | + d:DesignHeight="300" d:DesignWidth="300"> |
| 11 | + <UserControl.Resources> |
| 12 | + <ResourceDictionary> |
| 13 | + <ResourceDictionary.MergedDictionaries> |
| 14 | + <ResourceDictionary Source="../../Controls/ToolBar.xaml"/> |
| 15 | + </ResourceDictionary.MergedDictionaries> |
| 16 | + |
| 17 | + <converters:EnumToLocalizedStringConverter ResourcePrefix="AnnotationArgumentType_" x:Key="AnnotationArgumentTypeToStringConverter"/> |
| 18 | + <converters:InspectionToLocalizedNameConverter x:Key="InspectionToLocalizedNameConverter"/> |
| 19 | + <converters:DeclarationToQualifiedNameConverter x:Key="DeclarationToQualifiedNameConverter"/> |
| 20 | + |
| 21 | + <BitmapImage x:Key="InvalidTextImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/cross-circle.png" /> |
| 22 | + <Style x:Key="TextBoxErrorStyle" TargetType="{x:Type TextBox}"> |
| 23 | + <Setter Property="Validation.ErrorTemplate"> |
| 24 | + <Setter.Value> |
| 25 | + <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> |
| 34 | + </ControlTemplate> |
| 35 | + </Setter.Value> |
| 36 | + </Setter> |
| 37 | + <Style.Triggers> |
| 38 | + <Trigger Property="Validation.HasError" |
| 39 | + Value="True"> |
| 40 | + <Setter Property="ToolTip" |
| 41 | + Value="{Binding RelativeSource={x:Static RelativeSource.Self}, |
| 42 | + Path=(Validation.Errors)[0].ErrorContent}"> |
| 43 | + </Setter> |
| 44 | + </Trigger> |
| 45 | + </Style.Triggers> |
| 46 | + </Style> |
| 47 | + </ResourceDictionary> |
| 48 | + </UserControl.Resources> |
| 49 | + |
| 50 | + <Grid> |
| 51 | + <Grid.RowDefinitions> |
| 52 | + <RowDefinition Height="auto" /> |
| 53 | + <RowDefinition Height="auto" /> |
| 54 | + <RowDefinition Height="*" /> |
| 55 | + <RowDefinition Height="40" /> |
| 56 | + </Grid.RowDefinitions> |
| 57 | + <StackPanel Background="{StaticResource BackgroundLightBrush}"> |
| 58 | + <Label Content="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=AnnotateDeclarationDialog_TitleText}" FontWeight="Bold" /> |
| 59 | + <TextBlock Text="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=AnnotateDeclarationDialog_Instructions}" Margin="5,0" TextWrapping="Wrap" /> |
| 60 | + </StackPanel> |
| 61 | + <StackPanel Grid.Row="1"> |
| 62 | + <TextBlock Text="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=AnnotateDeclarationDialog_DeclarationLabel}" Margin="5,0" /> |
| 63 | + <TextBlock Text="{Binding Model.Target, Converter={StaticResource DeclarationToQualifiedNameConverter}}" Margin="10,0" /> |
| 64 | + <TextBlock Text="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=AnnotateDeclarationDialog_AnnotationLabel}" Margin="5,5,0,0" /> |
| 65 | + <ComboBox |
| 66 | + ItemsSource="{Binding ApplicableAnnotations}" |
| 67 | + SelectedItem="{Binding Annotation}" |
| 68 | + IsSynchronizedWithCurrentItem="True" |
| 69 | + Margin="5,0"> |
| 70 | + <ComboBox.ItemTemplate> |
| 71 | + <DataTemplate DataType="{x:Type annotations:IAnnotation}"> |
| 72 | + <TextBlock Text="{Binding Name, StringFormat=@{}{0}}"/> |
| 73 | + </DataTemplate> |
| 74 | + </ComboBox.ItemTemplate> |
| 75 | + </ComboBox> |
| 76 | + <TextBlock Text="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=AnnotateDeclarationDialog_ArgumentsLabel}" Margin="5,5,0,0" /> |
| 77 | + </StackPanel> |
| 78 | + <Grid Grid.Row="2"> |
| 79 | + <Grid.ColumnDefinitions> |
| 80 | + <ColumnDefinition Width="*" /> |
| 81 | + <ColumnDefinition Width="auto" /> |
| 82 | + </Grid.ColumnDefinitions> |
| 83 | + <Grid.Resources> |
| 84 | + <DataTemplate DataType="{x:Type local:IAnnotationArgumentViewModel}" x:Key="ArgumentSingleTypeTemplate"> |
| 85 | + <TextBlock Text="{Binding ArgumentType, Converter={StaticResource AnnotationArgumentTypeToStringConverter}}"/> |
| 86 | + </DataTemplate> |
| 87 | + <DataTemplate DataType="{x:Type local:IAnnotationArgumentViewModel}" x:Key="ArgumentMultiTypeTemplate"> |
| 88 | + <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}" |
| 109 | + IsSynchronizedWithCurrentItem="True"> |
| 110 | + <ComboBox.ItemTemplate> |
| 111 | + <DataTemplate> |
| 112 | + <TextBlock Text="{Binding Path=., Converter={StaticResource InspectionToLocalizedNameConverter}}"/> |
| 113 | + </DataTemplate> |
| 114 | + </ComboBox.ItemTemplate> |
| 115 | + </ComboBox> |
| 116 | + </DataTemplate> |
| 117 | + <local:AnnotationArgumentTypeCellDataTemplateSelector x:Key="AnnotationArgumentTypeCellDataTemplateSelector"/> |
| 118 | + <local:AnnotationArgumentValueCellDataTemplateSelector x:Key="AnnotationArgumentValueCellDataTemplateSelector"/> |
| 119 | + </Grid.Resources> |
| 120 | + <DataGrid |
| 121 | + Grid.Column="0" |
| 122 | + VerticalAlignment="Stretch" |
| 123 | + ItemsSource="{Binding Path=AnnotationArguments}" |
| 124 | + AutoGenerateColumns="False" |
| 125 | + VerticalScrollBarVisibility="Auto" |
| 126 | + Margin="5,0,0,5"> |
| 127 | + <DataGrid.Columns> |
| 128 | + <DataGridTemplateColumn |
| 129 | + Header="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=AnnotateDeclarationDialog_ArgumentTypeHeader}" |
| 130 | + CellTemplateSelector="{StaticResource AnnotationArgumentTypeCellDataTemplateSelector}" |
| 131 | + CellEditingTemplateSelector="{StaticResource AnnotationArgumentTypeCellDataTemplateSelector}"> |
| 132 | + </DataGridTemplateColumn> |
| 133 | + <DataGridTemplateColumn |
| 134 | + Header="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=AnnotateDeclarationDialog_ArgumentValueHeader}" |
| 135 | + CellTemplateSelector="{StaticResource AnnotationArgumentValueCellDataTemplateSelector}" |
| 136 | + CellEditingTemplateSelector="{StaticResource AnnotationArgumentValueCellDataTemplateSelector}"> |
| 137 | + </DataGridTemplateColumn> |
| 138 | + </DataGrid.Columns> |
| 139 | + </DataGrid> |
| 140 | + <StackPanel |
| 141 | + Grid.Column="1" |
| 142 | + VerticalAlignment="Center"> |
| 143 | + <Button Content="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=AnnotateDeclarationDialog_AddArgumentButtonLabel}" |
| 144 | + Height="20" |
| 145 | + Margin="5,2.5" |
| 146 | + Padding="10,0" |
| 147 | + Command="{Binding AddAnnotationArgument}"/> |
| 148 | + <Button Content="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=AnnotateDeclarationDialog_RemoveArgumentButtonLabel}" |
| 149 | + Height="20" |
| 150 | + Margin="5,2.5" |
| 151 | + Padding="10,0" |
| 152 | + Command="{Binding RemoveAnnotationArgument}"/> |
| 153 | + </StackPanel> |
| 154 | + </Grid> |
| 155 | + <Grid Grid.Row="3" Background="{x:Static SystemColors.ControlDarkBrush}" Grid.IsSharedSizeScope="True"> |
| 156 | + <Grid HorizontalAlignment="Right" |
| 157 | + Margin="5,0"> |
| 158 | + <Grid.ColumnDefinitions> |
| 159 | + <ColumnDefinition SharedSizeGroup="SettingsButtons" /> |
| 160 | + <ColumnDefinition SharedSizeGroup="SettingsButtons" /> |
| 161 | + </Grid.ColumnDefinitions> |
| 162 | + <Button Content="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=OK}" |
| 163 | + Grid.Column="0" |
| 164 | + Height="20" |
| 165 | + Margin="5,0" |
| 166 | + Padding="10,0" |
| 167 | + IsEnabled="{Binding IsValidAnnotation}" |
| 168 | + IsDefault="True" |
| 169 | + Command="{Binding OkButtonCommand}" /> |
| 170 | + <Button Content="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=CancelButtonText}" |
| 171 | + Grid.Column="1" |
| 172 | + Height="20" |
| 173 | + Margin="5,0" |
| 174 | + Padding="10,0" |
| 175 | + IsCancel="True" |
| 176 | + Command="{Binding CancelButtonCommand}"> |
| 177 | + </Button> |
| 178 | + </Grid> |
| 179 | + </Grid> |
| 180 | + </Grid> |
| 181 | +</UserControl> |
0 commit comments