<controls:MetroWindow xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      x:Class="SPCode.UI.Windows.SearchWindow"
                      WindowStartupLocation="Manual"
                      GlowBrush="{DynamicResource AccentColorBrush}" 
                      Background="{DynamicResource WhiteBrush}" 
                      ResizeMode="NoResize" 
                      ShowTitleBar="True"
                      ShowInTaskbar="False" 
                      Height="290" 
                      Width="580"
                      HorizontalAlignment="Center" 
                      VerticalAlignment="Center" 
                      UseNoneWindowStyle="False"
                      TitleCharacterCasing="Normal"
                      KeyDown="MetroWindow_KeyDown">

  <controls:MetroWindow.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Red.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/FlatButton.xaml" />
        <ResourceDictionary>
        </ResourceDictionary>
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </controls:MetroWindow.Resources>

  <Grid Name="SearchGrid">
    <Grid.RowDefinitions>
      <RowDefinition Height="130"/>
      <RowDefinition/>
      <RowDefinition Height="20"/>
    </Grid.RowDefinitions>

    <Grid Grid.Row="0" VerticalAlignment="Center">
      <StackPanel>
        <TextBox x:Name="FindBox" Margin="10,0,10,5" Height="55" VerticalScrollBarVisibility="Visible" TextChanged="SearchBoxTextChanged" KeyDown="SearchBoxKeyUp" />
        <TextBox x:Name="ReplaceBox" Margin="10,0,10,5" Height="55" VerticalScrollBarVisibility="Visible" KeyDown="ReplaceBoxKeyUp" TextChanged="ReplaceBoxTextChanged" />
      </StackPanel>
    </Grid>

    <Grid Grid.Row="1">
      <Grid>

        <Grid.ColumnDefinitions>
          <ColumnDefinition/>
          <ColumnDefinition/>
          <ColumnDefinition/>
        </Grid.ColumnDefinitions>

        <Grid Grid.Column="0">
          <StackPanel>
            <StackPanel.Resources>
              <Style BasedOn="{StaticResource {x:Type RadioButton}}" TargetType="{x:Type RadioButton}">
                <Setter Property="Margin" Value="3"/>
              </Style>
            </StackPanel.Resources>
            <RadioButton x:Name="NSearch_RButton" Foreground="{DynamicResource BlackBrush}" Checked="RadioButtonsChanged"/>
            <RadioButton x:Name="WSearch_RButton" Foreground="{DynamicResource BlackBrush}" Checked="RadioButtonsChanged"/>
            <RadioButton x:Name="ASearch_RButton" Foreground="{DynamicResource BlackBrush}" Checked="RadioButtonsChanged" />
            <RadioButton x:Name="RSearch_RButton" Foreground="{DynamicResource BlackBrush}" Checked="RadioButtonsChanged" />
          </StackPanel>
        </Grid>

        <Grid Grid.Column="1" HorizontalAlignment="Left">
          <StackPanel>
            <ComboBox x:Name="FindDestinies" Width="150" Height="26" Margin="0,3,0,10" SelectionChanged="DocumentChanged">
              <ComboBoxItem x:Name="MenuFR_CurrDoc" />
              <ComboBoxItem x:Name="MenuFR_AllDoc" />
            </ComboBox>
            <CheckBox x:Name="CCBox" Foreground="{DynamicResource BlackBrush}" Margin="0,3,0,0" Checked="CaseSensitiveChanged" Unchecked="CaseSensitiveChanged">
              <TextBlock x:Name="CCBoxText" TextWrapping="Wrap"/>
            </CheckBox>
            <CheckBox x:Name="MLRBox" Foreground="{DynamicResource BlackBrush}" Margin="0,5,0,0" Checked="MultilineRegexChanged" Unchecked="MultilineRegexChanged">
              <TextBlock x:Name="MLRBoxText" TextWrapping="Wrap"/>
            </CheckBox>
          </StackPanel>
        </Grid>

        <Grid Grid.Column="2">
          <StackPanel>
            <Button x:Name="Find_Button" Click="SearchButtonClicked" Margin="3" Style="{DynamicResource MetroFlatButton}" />
            <controls:SplitButton Name="ReplaceButton" Margin="3" Click="ReplaceButtonClicked" SelectionChanged="ReplaceChanged"/>
            <Button x:Name="Count_Button" Click="CountButtonClicked" Margin="3" Style="{DynamicResource MetroFlatButton}" />
          </StackPanel>
        </Grid>

      </Grid>
    </Grid>

    <Grid Grid.Row="2">
      <TextBlock x:Name="FindResultBlock" FontSize="14" Margin="5,-1,0,0" Foreground="{DynamicResource AccentColorBrush}" IsHitTestVisible="False" />
    </Grid>
    
  </Grid>
</controls:MetroWindow>
