<controls:UserWindow x:Class="XamlViewer.Views.MainWindow"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:views="clr-namespace:XamlViewer.Views"
                     xmlns:ms="clr-namespace:XamlService;assembly=XamlService"
                     xmlns:controls="clr-namespace:XamlTheme.Controls;assembly=XamlTheme"
                     xmlns:swm="clr-namespace:System.Windows.Media;assembly=PresentationCore"
                     xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
                     xmlns:prism="http://prismlibrary.com/"
                     xmlns:themes="clr-namespace:XamlTheme;assembly=XamlTheme"
                     xmlns:themeUtils="clr-namespace:XamlTheme.Utils;assembly=XamlTheme"
                     xmlns:utils="clr-namespace:XamlViewer.Utils"
                     prism:ViewModelLocator.AutoWireViewModel="True"
                     Style="{StaticResource {x:Static themes:ResourceKeys.NormalUserWindowStyleKey}}"
                     Title="{Binding Title}" HideOriginalTitle="True" AllowDrop="True"
                     WindowStartupLocation="CenterScreen" Height="600" Width="900" MinWidth="500" MinHeight="500">
    <behaviors:Interaction.Triggers>
        <behaviors:EventTrigger EventName="Loaded">
            <behaviors:InvokeCommandAction Command="{Binding LoadedCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}"/>
        </behaviors:EventTrigger>
        <behaviors:EventTrigger EventName="Activated">
            <behaviors:InvokeCommandAction Command="{Binding ActivatedCommand}"/>
        </behaviors:EventTrigger>
        <behaviors:EventTrigger EventName="Drop">
            <behaviors:InvokeCommandAction Command="{Binding DropCommand}" PassEventArgsToCommand="true"/>
        </behaviors:EventTrigger>
        <behaviors:EventTrigger EventName="Closing">
            <behaviors:InvokeCommandAction Command="{Binding ClosingCommand}" PassEventArgsToCommand="true"/>
        </behaviors:EventTrigger>
    </behaviors:Interaction.Triggers>
    <controls:UserWindow.InputBindings>
        <KeyBinding Command="{Binding AppCommands.NewCommand}" Gesture="Ctrl+N"/>
        <KeyBinding Command="{Binding AppCommands.OpenCommand}" Gesture="Ctrl+O"/>
        <KeyBinding Command="{Binding AppCommands.SaveCommand}" Gesture="Ctrl+S"/>
        <KeyBinding Command="{Binding AppCommands.SaveAllCommand}" Gesture="Ctrl+Shift+S"/>
        <KeyBinding Command="{Binding AppCommands.CompileCommand}" Gesture="F5"/>
        <KeyBinding Command="{Binding AppCommands.HelpCommand}" Gesture="F1"/>
    </controls:UserWindow.InputBindings>
    <controls:UserWindow.CaptionContent>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <views:ToolbarControl Grid.Row="0"/>
            <TextBlock Grid.Column="1" Margin="5,0" Text="{Binding Title}" Foreground="#717171" FontSize="13" FontWeight="Medium"  VerticalAlignment="Center" HorizontalAlignment="Center" IsHitTestVisible="False"/>
            <controls:StatusToggle x:Name="SettingStatusToggle" Grid.Column="2" Width="37" CheckedToolTip="Back" UnCheckedToolTip="Setting"
                                   IsChecked="{Binding IsExpandSetting, Mode=TwoWay}"
                                   Command="{Binding ExpandOrCollapseCommand}">
                <controls:StatusToggle.CheckedContent>
                    <Path Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType=controls:StatusToggle}}" Stretch="Fill" Margin="0,1,0,0" Height="8" Width="12" VerticalAlignment="Center" HorizontalAlignment="Center" 
                          Data="M312.916 658.584l-62.058-62.052 262.174-262.174 260.112 260.174-62.058 62.052-198.054-198.114z"/>
                </controls:StatusToggle.CheckedContent>
                <controls:StatusToggle.UnCheckedContent>
                    <Path Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType=controls:StatusToggle}}" Stretch="Fill" Height="13" Width="13" VerticalAlignment="Center" HorizontalAlignment="Center" 
                          Data="M967 568.888889h-118.689185a338.394074 338.394074 0 0 1-58.500741 140.515555l84.119704 84.195556a56.888889 56.888889 0 0 1-80.459852 80.402963l-84.15763-84.195556A339.607704 339.607704 0 0 1 568.888889 848.213333V967.111111a56.888889 56.888889 0 0 1-113.777778 0v-118.897778a339.607704 339.607704 0 0 1-140.534518-58.405926l-84.15763 84.195556a56.888889 56.888889 0 0 1-80.459852-80.402963l84.100741-84.195556A338.375111 338.375111 0 0 1 175.578074 568.888889H56.888889a56.888889 56.888889 0 1 1 0-113.777778h118.689185a338.375111 338.375111 0 0 1 58.481778-140.515555l-84.100741-84.195556a56.888889 56.888889 0 0 1 80.459852-80.402963l84.15763 84.195556A339.607704 339.607704 0 0 1 455.111111 175.786667V56.888889a56.888889 56.888889 0 0 1 113.777778 0v118.897778a339.607704 339.607704 0 0 1 140.534518 58.405926l84.15763-84.195556a56.888889 56.888889 0 0 1 80.459852 80.402963l-84.119704 84.195556A338.394074 338.394074 0 0 1 848.421926 455.111111H967.111111a56.888889 56.888889 0 0 1 0 113.777778zM512 284.444444a227.555556 227.555556 0 1 0 227.555556 227.555556 227.555556 227.555556 0 0 0-227.555556-227.555556z" />
                </controls:StatusToggle.UnCheckedContent>
            </controls:StatusToggle>
            <Button Grid.Column="3" ToolTip="Help" Width="37"
                    Command="{Binding AppCommands.HelpCommand}"
                    Style="{StaticResource {x:Static themes:ResourceKeys.TitlebarButtonStyleKey}}">
                <controls:DrawingIcon>
                    <controls:DrawingIcon.Drawing>
                        <GeometryDrawing Brush="{Binding Foreground, RelativeSource={RelativeSource AncestorType=Button},FallbackValue={x:Static swm:Brushes.Transparent}}"
                                         Geometry="M1,0 H5V1 H6V5 H5V6 H4V7 H2V5 H3V4 H4V2 H2V4 H0V1 H1 M2,8 H4V10 H2z" />
                    </controls:DrawingIcon.Drawing>
                    <controls:DrawingIcon.HDPIDrawing>
                        <GeometryDrawing Brush="{Binding Foreground, RelativeSource={RelativeSource AncestorType=Button},FallbackValue={x:Static swm:Brushes.Transparent}}"
                                         Geometry="M0.11866834,4.2522464 L1.8049657,4.2569221 C1.388299,3.5902555 1.458125,2.55525 1.8883161,2.1054232 2.392598,1.448111 4.208125,1.337 4.59875,2.289625 4.91125,2.80575 4.8175,3.587 4.5675,4.133375 3.9529337,4.9511261 2.801875,5.540125 2.424566,6.4184232 2.4109517,6.4501147 2.408941,6.9491732 2.4091324,7.3194221 L4.3726911,7.3085482 C4.388316,7.1527982 4.376973,6.698111 4.3800214,6.5013307 4.3825953,6.3351778 4.9820661,6.1054232 5.7214798,5.3714095 6.7460168,3.9340482 6.3743974,2.1389081 5.9918812,1.4072938 5.76575,0.9747873 5.422,0.6461623 4.9716323,0.39874929 4.3595,0.17526151 3.84875,-0.094416004 2.7112157,0.032632119 0.71861567,0.16528894 -0.37730895,1.6532982 0.11866834,4.2522464 z M2.3674657,10.048589 L4.3674657,10.048589 4.3674657,8.0485887 2.3674657,8.0485887 z" />
                    </controls:DrawingIcon.HDPIDrawing>
                </controls:DrawingIcon>
            </Button>
        </Grid>
    </controls:UserWindow.CaptionContent>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="{Binding SettingRowHeight}"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <!--Setting-->
        <views:SettingControl Height="120" Margin="6,0"/>
        <Grid Grid.Row="1" Margin="0,6,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="3*" MinWidth="300"/>
                <ColumnDefinition Width="{Binding GridSplitterColumnWidth}"/>
                <ColumnDefinition Width="{Binding DataSourceColumnWidth, Mode=TwoWay}" 
                                  MinWidth="{Binding DataSourceMinColumnWidth}"/>
            </Grid.ColumnDefinitions>
            <Grid Grid.Column="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <!--Tab-->
                <views:TabsControl Grid.Row="0"/>
                <!--Work Area-->
                <Grid Grid.Row="1" prism:RegionManager.RegionName="{x:Static ms:RegionNames.WorkName}"/>
            </Grid>
            <GridSplitter Grid.Column="1" Width="10" Background="Transparent"
                          HorizontalAlignment="Center" VerticalAlignment="Stretch"
                          utils:CursorUtil.Source="/XamlViewer;component/Assets/Cursors/Splitter_lr.cur"/>
            <!--Data-->
            <views:DataControl Grid.Column="2" Margin="0,0,5,5"/>
        </Grid>
        <!--Status-->
        <views:StatusControl Grid.Row="2" Height="25" Background="#007ACC"/>
    </Grid>
</controls:UserWindow>
