<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sqlDynamite="clr-namespace:SqlDynamite"
    x:Class="SqlDynamite.MainWindow"
    Title="SQL Dynamite" Loaded="Window_Loaded"  mc:Ignorable="d" Height="346" Width="638" WindowState="Maximized" Icon="/SqlDynamite;component/Resources/WindowIcon.ico">
    <Grid Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />

            <RowDefinition Height="*" />

            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="2*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <DockPanel Grid.Row="0" Grid.Column="0" HorizontalAlignment="Stretch" LastChildFill="True">
            <Label Content="Find:" Margin="2" DockPanel.Dock="Left" />

            <Button Margin="2" DockPanel.Dock="Right" Click="btn_About_Click" Content="About" TabIndex="7"/>
            <Button Margin="2" DockPanel.Dock="Right" Click="btn_SaveList_Click" Content="Save List" TabIndex="6"/>
            <Button Margin="2" DockPanel.Dock="Right" Click="btn_DbInfo_Click" Content="DB Info" TabIndex="5"/>
            <Button x:Name="btn_Stop" Click="button5_Click"   Content="Stop"   Margin="2" DockPanel.Dock="Right" IsEnabled="False" TabIndex="2"/>
            <Button x:Name="btn_Search" Click="button1_Click" Content="Search" Margin="2"  DockPanel.Dock="Right" TabIndex="1"/>
            <ComboBox x:Name="Search" HorizontalAlignment="Stretch" IsEditable="True" Margin="2" IsTextSearchEnabled="False" KeyUp="Search_KeyUp" TabIndex="0"/>
        </DockPanel>
        <DockPanel Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" LastChildFill="True">
            <Button Margin="2" Click="button2_Click" Content="Manage" DockPanel.Dock="Right" TabIndex="9"/>

            <Label Margin="2" Content="Search in DB:" />
            <ComboBox Margin="2" x:Name="Connections" SelectionChanged="Connections_SelectionChanged" TabIndex="8"/>
        </DockPanel>
        <Expander Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Header="Search options" VerticalAlignment="Top" ExpandDirection="Down">
            <StackPanel Orientation="Horizontal">
                <GroupBox Header="Objects for search" Margin="0" HorizontalAlignment="Stretch" >
                    <StackPanel VerticalAlignment="Top" HorizontalAlignment="Left" Orientation="Horizontal">
                        <StackPanel>
                            <CheckBox Margin="2" x:Name="FN_Check" IsChecked="True" Content="Functions" />
                            <CheckBox Margin="2" x:Name="SP_Check" IsChecked="True" Content="Stored procedures" />
                            <CheckBox Margin="2" x:Name="TR_Check" IsChecked="True" Content="Triggers" />
                            <CheckBox Margin="2" x:Name="Table_Check" IsChecked="True" Content="Tables" />
                            <CheckBox Margin="2" x:Name="Package_Check" IsChecked="True" Content="Packages" />
                            <CheckBox Margin="2" x:Name="Type_Check" IsChecked="True" Content="Types" />
                            <CheckBox Margin="2" x:Name="Job_Check" IsChecked="True" Content="Jobs" />
                            <CheckBox Margin="2" x:Name="Service_Broker_Check" IsChecked="True" Content="Service Broker" />
                        </StackPanel>
                        <StackPanel>
                            <CheckBox Margin="2" x:Name="View_Check" IsChecked="True" Content="Views" />
                            <CheckBox Margin="2" x:Name="FK_Check" IsChecked="True" Content="Foreign keys" />
                            <CheckBox Margin="2" x:Name="PK_Check" IsChecked="True" Content="Primary keys" />
                            <CheckBox Margin="2" x:Name="IX_Check" IsChecked="True" Content="Indexes" />
                            <CheckBox Margin="2" x:Name="Sequence_Check" IsChecked="True" Content="Sequences" />
                            <CheckBox Margin="2" x:Name="Synonym_Check" IsChecked="True" Content="Synonyms" />
                            <CheckBox Margin="2" x:Name="Report_Check" IsChecked="True" Content="Reports" />
                            <CheckBox Margin="2" x:Name="Computed_Column_Check" IsChecked="True" Content="Computed Columns" />
                        </StackPanel>
                        <StackPanel>
                            <Button Margin="2" Click="button3_Click" Content="Select all" />
                            <Button Margin="2" Click="button4_Click" Content="Deselect all" />
                        </StackPanel>
                    </StackPanel>
                </GroupBox>
                <StackPanel>
                    <GroupBox Header="Look in" HorizontalAlignment="Left"  VerticalAlignment="Top">
                        <StackPanel  VerticalAlignment="Top" HorizontalAlignment="Left" Orientation="Horizontal">
                            <CheckBox Margin="4" x:Name="search_in_names" IsChecked="True" Content="Name"/>
                            <CheckBox Margin="4" x:Name="search_in_def" IsChecked="True" Content="Body"/>
                            <CheckBox Margin="4" x:Name="search_in_all_databases" IsChecked="False" Content="All Databases"/>
                        </StackPanel>
                    </GroupBox>
                    <GroupBox Header="Options" HorizontalAlignment="Left"  VerticalAlignment="Top">
                        <StackPanel Orientation="Horizontal">
                            <CheckBox Margin="4" x:Name="syntax_highlighting" Checked="syntax_highlighting_Checked" Unchecked="syntax_highlighting_Unchecked" Content="Syntax highlighting" IsChecked="True"/>
                            <CheckBox Margin="4" Height="16" Width="Auto" Checked="word_wrap_Checked" Unchecked="word_wrap_Unchecked">Word wrap</CheckBox>
                            <CheckBox Margin="4" Height="16" x:Name="match_case" Width="Auto" Checked="match_case_Changed" Unchecked="match_case_Changed">Match case</CheckBox>
                        </StackPanel>
                    </GroupBox>
                </StackPanel>
            </StackPanel>
        </Expander>

        <GroupBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Header="Search results" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
            <Grid >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*" MinWidth="100" MaxWidth="480"/>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="2*" />
                </Grid.ColumnDefinitions>
                <ListView Grid.Column="0" Margin="2" x:Name="list1" 
                         SelectionChanged="list1_SelectionChanged" 
                         VerticalAlignment="Stretch" 
                         HorizontalAlignment="Stretch"/>
                <GridSplitter HorizontalAlignment="Right" 
                  VerticalAlignment="Stretch" 
                  Grid.Column="1" ResizeBehavior="PreviousAndNext"
                  Width="5" Background="#FFBCBCBC"/>
                <GroupBox Grid.Column="2" Header="Object text" Margin="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderThickness="0" Opacity="1">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />

                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <WindowsFormsHost HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                            <sqlDynamite:SyntaxHighlightingTextBox x:Name="box1" />
                        </WindowsFormsHost>
                    </Grid>
                </GroupBox>
            </Grid>

        </GroupBox>


        <StatusBar Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" >
            <StatusBarItem>Search result:</StatusBarItem>
            <StatusBarItem Padding="0">
                <Label x:Name="Msg" Margin="0" Width="Auto" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"></Label>
            </StatusBarItem>
            <Separator/>
            <StatusBarItem>
                <DockPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0">
                    <ProgressBar x:Name="progressBar1" Value="35" Height="18" Width="100"></ProgressBar>
                </DockPanel>
            </StatusBarItem>
        </StatusBar>
    </Grid>

</Window>
