<Window x:Uid="ChangeSignatureDialog"
        x:Name="dialog"
        x:Class="RoslynPad.Roslyn.LanguageServices.ChangeSignature.ChangeSignatureDialog"
        x:ClassModifier="internal"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:roslyn="clr-namespace:RoslynPad.Roslyn"
        Height="420"
        Width="560"
        MinHeight="420"
        MinWidth="560"
        Title="{Binding ElementName=dialog, Path=ChangeSignatureDialogTitle}"
        ResizeMode="CanResizeWithGrip"
        ShowInTaskbar="False"
        WindowStartupLocation="CenterOwner">
    <Window.Resources>
        <Style x:Key="DataGridStyle"
               TargetType="DataGrid">
            <Setter Property="CellStyle">
                <Setter.Value>
                    <Style TargetType="DataGridCell">
                        <Setter Property="BorderThickness"
                                Value="0" />
                    </Style>
                </Setter.Value>
            </Setter>
        </Style>
        <Thickness x:Key="okCancelButtonPadding">9,2,9,2</Thickness>
        <Thickness x:Key="cellPadding">4 0 8 0</Thickness>
        <RoutedUICommand x:Key="MoveUp" />
        <RoutedUICommand x:Key="MoveDown" />
        <RoutedUICommand x:Key="MoveSelectionUp" />
        <RoutedUICommand x:Key="MoveSelectionDown" />
        <RoutedUICommand x:Key="ClickOK" />
        <RoutedUICommand x:Key="ToggleRemovedState" />
        <roslyn:TaggedTextToTextBlockConverter x:Key="TaggedTextConverter" />
    </Window.Resources>
    <Window.CommandBindings>
        <CommandBinding Command="{StaticResource MoveUp}"
                        Executed="MoveUp_Click" />
        <CommandBinding Command="{StaticResource MoveDown}"
                        Executed="MoveDown_Click" />
        <CommandBinding Command="{StaticResource ToggleRemovedState}"
                        Executed="ToggleRemovedState" />
    </Window.CommandBindings>
    <Window.InputBindings>
        <KeyBinding Key="Up"
                    Modifiers="Alt"
                    Command="{StaticResource MoveUp}" />
        <KeyBinding Key="Down"
                    Modifiers="Alt"
                    Command="{StaticResource MoveDown}" />
        <KeyBinding Key="Delete"
                    Command="{StaticResource ToggleRemovedState}" />
    </Window.InputBindings>
    <Grid Name="ContentGrid"
          Margin="11,6,11,11">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <TextBlock Grid.Row="0"
                   Height="Auto"
                   Width="Auto"
                   Padding="0,4,0,0"
                   Text="{Binding ElementName=dialog, Path=Parameters}" />
        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition MinHeight="180" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition MinWidth="400" />
                <ColumnDefinition Width="Auto"
                                  MinWidth="35" />
            </Grid.ColumnDefinitions>
            <DataGrid x:Uid="MemberSelectionList"
                      x:Name="Members"
                      Grid.Row="0"
                      Grid.Column="0"
                      Margin="0, 3, 0, 0"
                      SelectionMode="Single"
                      SelectionUnit="FullRow"
                      ItemsSource="{Binding AllParameters, Mode=OneWay}"
                      SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}"
                      AutoGenerateColumns="False"
                      CanUserReorderColumns="False"
                      CanUserSortColumns="False"
                      CanUserAddRows="False"
                      CanUserDeleteRows="False"
                      CanUserResizeRows="False"
                      BorderThickness="1"
                      BorderBrush="Gray"
                      RowHeaderWidth="0"
                      GridLinesVisibility="None"
                      VerticalAlignment="Stretch"
                      HorizontalAlignment="Stretch"
                      VerticalScrollBarVisibility="Auto"
                      HorizontalScrollBarVisibility="Auto"
                      IsTabStop="True"
                      Style="{StaticResource ResourceKey=DataGridStyle}"
                      GotKeyboardFocus="Members_GotKeyboardFocus">
                <DataGrid.CommandBindings>
                    <CommandBinding Command="{StaticResource MoveSelectionUp}"
                                    Executed="MoveSelectionUp_Click" />
                    <CommandBinding Command="{StaticResource MoveSelectionDown}"
                                    Executed="MoveSelectionDown_Click" />
                    <CommandBinding Command="{StaticResource ClickOK}"
                                    Executed="OK_Click" />
                </DataGrid.CommandBindings>
                <DataGrid.InputBindings>
                    <KeyBinding Key="Up"
                                Command="{StaticResource MoveSelectionUp}" />
                    <KeyBinding Key="Down"
                                Command="{StaticResource MoveSelectionDown}" />
                    <KeyBinding Key="Delete"
                                Command="{StaticResource ToggleRemovedState}" />
                    <KeyBinding Key="Enter"
                                Command="{StaticResource ClickOK}" />
                </DataGrid.InputBindings>
                <DataGrid.CellStyle>
                    <Style TargetType="DataGridCell">
                        <Setter Property="BorderThickness"
                                Value="0" />
                        <Setter Property="Padding"
                                Value="2" />
                        <Setter Property="KeyboardNavigation.IsTabStop"
                                Value="False" />
                        <Setter Property="FocusVisualStyle"
                                Value="{x:Null}" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="DataGridCell">
                                    <Border Background="{TemplateBinding Background}"
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            BorderThickness="{TemplateBinding BorderThickness}"
                                            Padding="{TemplateBinding Padding}"
                                            KeyboardNavigation.IsTabStop="False">
                                        <ContentPresenter />
                                    </Border>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </DataGrid.CellStyle>
                <DataGrid.RowStyle>
                    <Style TargetType="DataGridRow">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type DataGridRow}">
                                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                                            BorderThickness="{TemplateBinding BorderThickness}"
                                            Background="{TemplateBinding Background}"
                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                                        <SelectiveScrollingGrid>
                                            <SelectiveScrollingGrid.RowDefinitions>
                                                <RowDefinition Height="*" />
                                                <RowDefinition Height="Auto" />
                                            </SelectiveScrollingGrid.RowDefinitions>
                                            <SelectiveScrollingGrid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="*" />
                                            </SelectiveScrollingGrid.ColumnDefinitions>
                                            <DataGridCellsPresenter Grid.Column="1"
                                                                    ItemsPanel="{TemplateBinding ItemsPanel}"
                                                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                            <DataGridDetailsPresenter Grid.Column="1"
                                                                      Grid.Row="1"
                                                                      SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
                                                                      Visibility="{TemplateBinding DetailsVisibility}" />
                                            <DataGridRowHeader Grid.RowSpan="1"
                                                               SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
                                                               Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
                                            <Path Name="CustomStrikethrough"
                                                  Grid.ColumnSpan="4"
                                                  Visibility="Collapsed"
                                                  Data="M0.1,0.5 L0.9,0.5"
                                                  Stretch="Fill"
                                                  Stroke="{Binding ElementName=dialog, Path=StrikethroughBrush}"
                                                  StrokeThickness="2"
                                                  Opacity="0.4" />
                                        </SelectiveScrollingGrid>
                                    </Border>
                                    <ControlTemplate.Triggers>
                                        <DataTrigger Binding="{Binding IsRemoved}"
                                                     Value="True">
                                            <Setter TargetName="CustomStrikethrough"
                                                    Property="Visibility"
                                                    Value="Visible" />
                                        </DataTrigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsDisabled}"
                                         Value="True">
                                <Setter Property="Background"
                                        Value="{Binding ElementName=dialog, Path=DisabledParameterBackground}" />
                                <Setter Property="Foreground"
                                        Value="{Binding ElementName=dialog, Path=DisabledParameterForeground}" />
                                <Setter Property="IsEnabled"
                                        Value="False" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding NeedsBottomBorder}"
                                         Value="True">
                                <Setter Property="BorderBrush"
                                        Value="Gray" />
                                <Setter Property="BorderThickness"
                                        Value="0,0,0,1" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding IsRemoved}"
                                         Value="True">
                                <Setter Property="Foreground"
                                        Value="{Binding ElementName=dialog, Path=RemovedParameterText}" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding IsRemoved}"
                                         Value="False">
                                <Setter Property="Foreground"
                                        Value="{Binding ElementName=dialog, Path=ParameterText}" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </DataGrid.RowStyle>
                <DataGrid.Columns>
                    <DataGridTextColumn x:Name="modifierHeader"
                                        Binding="{Binding Modifier, Mode=OneWay}"
                                        IsReadOnly="True">
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="Padding"
                                        Value="{StaticResource ResourceKey=cellPadding}" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn x:Name="typeHeader"
                                        Binding="{Binding Type, Mode=OneWay}"
                                        IsReadOnly="True">
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="Padding"
                                        Value="{StaticResource ResourceKey=cellPadding}" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn x:Name="parameterHeader"
                                        Binding="{Binding Parameter, Mode=OneWay}"
                                        IsReadOnly="True">
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="Padding"
                                        Value="{StaticResource ResourceKey=cellPadding}" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn x:Name="defaultHeader"
                                        Binding="{Binding Default, Mode=OneWay}"
                                        Width="*"
                                        IsReadOnly="True">
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="Padding"
                                        Value="{StaticResource ResourceKey=cellPadding}" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>

            <Border Grid.Column="0"
                    Margin="0, 3, 0, 0"
                    Grid.Row="2"
                    Height="80"
                    Width="Auto"
                    BorderThickness="1"
                    BorderBrush="LightGray">
                <ScrollViewer Name="Scroller"
                              Padding="8, 4, 4, 4"
                              VerticalScrollBarVisibility="Auto"
                              HorizontalScrollBarVisibility="Disabled"
                              Content="{Binding SignatureDisplay, Converter={StaticResource TaggedTextConverter}}" />
            </Border>
            <StackPanel Name="ControlButtonsPanel"
                        Grid.Column="1"
                        Grid.Row="0"
                        Height="Auto"
                        Width="Auto"
                        Margin="0, 3, 0, 0">
                <Button Name="UpButton"
                        Margin="9 0 0 0"
                        IsEnabled="{Binding CanMoveUp, Mode=OneWay}"
                        AutomationProperties.AutomationId="Up"
                        Height="Auto"
                        Width="Auto"
                        Command="{StaticResource MoveUp}"
                        FontFamily="Segoe UI Symbol"
                        Content="" />
                <Button Name="DownButton"
                        Margin="9 9 0 0"
                        IsEnabled="{Binding CanMoveDown, Mode=OneWay}"
                        AutomationProperties.AutomationId="Down"
                        Height="Auto"
                        Width="Auto"
                        Command="{StaticResource MoveDown}"
                        FontFamily="Segoe UI Symbol"
                        Content="" />
                <Button Margin="9 29 0 0"
                        IsEnabled="{Binding CanRemove, Mode=OneWay}"
                        Click="Remove_Click"
                        AutomationProperties.AutomationId="Remove"
                        Content="{Binding ElementName=dialog, Path=Remove}"
                        Height="Auto"
                        Width="Auto" />

                <Button Margin="9 9 0 0"
                        IsEnabled="{Binding CanRestore, Mode=OneWay}"
                        Click="Restore_Click"
                        AutomationProperties.AutomationId="Restore"
                        Content="{Binding ElementName=dialog, Path=Restore}"
                        Height="Auto"
                        Width="Auto" />
            </StackPanel>
        </Grid>

        <StackPanel Grid.Row="3"
                    HorizontalAlignment="Right"
                    Margin="0, 11, 0, 0"
                    Orientation="Horizontal"
                    Width="153">
            <Button x:Uid="OkButton"
                    Content="{Binding ElementName=dialog, Path=OK}"
                    Margin="0, 0, 0, 0"
                    Padding="{StaticResource ResourceKey=okCancelButtonPadding}"
                    Click="OK_Click"
                    IsDefault="True"
                    IsEnabled="{Binding IsOkButtonEnabled, Mode=OneWay}"
                    MinWidth="73"
                    MinHeight="21" />
            <Button x:Uid="CancelButton"
                    Content="{Binding ElementName=dialog, Path=Cancel}"
                    Margin="7, 0, 0, 0"
                    Padding="{StaticResource ResourceKey=okCancelButtonPadding}"
                    Click="Cancel_Click"
                    IsCancel="True"
                    MinWidth="73"
                    MinHeight="21" />
        </StackPanel>
    </Grid>
</Window>
