<Window x:Class="BallanceTasEditor.Frontend.Views.MainWindow"
        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:local="clr-namespace:BallanceTasEditor.Frontend.Views"
        xmlns:vm="clr-namespace:BallanceTasEditor.Frontend.ViewModels"
        xmlns:widget="clr-namespace:BallanceTasEditor.Frontend.Widgets"
        mc:Ignorable="d"
        d:DataContext="{d:DesignInstance vm:MainWindow}"
        WindowStartupLocation="CenterScreen"
        Title="{Binding WindowTitle, Mode=OneWay}" Height="600" Width="800" Icon="/Frontend/Assets/App.ico">
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>

        <Menu Grid.Row="0">
            <Menu.Resources>
                <!-- Menu Icons -->
                <Image x:Key="IconNewFile" Source="/Frontend/Assets/NewFile.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconOpenFile" Source="/Frontend/Assets/OpenFile.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconSaveFile" Source="/Frontend/Assets/SaveFile.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconSaveFileAs" Source="/Frontend/Assets/SaveFileAs.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconSaveFileThenRunGame" Source="/Frontend/Assets/SaveFileThenRunGame.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconCloseFile" Source="/Frontend/Assets/CloseFile.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconExit" Source="/Frontend/Assets/Exit.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconUndo" Source="/Frontend/Assets/Undo.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconRedo" Source="/Frontend/Assets/Redo.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconNextItem" Source="/Frontend/Assets/NextItem.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconNextPage" Source="/Frontend/Assets/NextPage.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconPreviousItem" Source="/Frontend/Assets/PreviousItem.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconPreviousPage" Source="/Frontend/Assets/PreviousPage.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconGoto" Source="/Frontend/Assets/Goto.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconDrawMode" Source="/Frontend/Assets/DrawMode.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconFillMode" Source="/Frontend/Assets/FillMode.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconSelectMode" Source="/Frontend/Assets/SelectMode.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconClearKeys" Source="/Frontend/Assets/ClearKeys.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconUniformFps" Source="/Frontend/Assets/SetFps.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconPreference" Source="/Frontend/Assets/Preference.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconReportBug" Source="/Frontend/Assets/ReportBug.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                <Image x:Key="IconAbout" Source="/Frontend/Assets/About.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
            </Menu.Resources>
            
            <MenuItem Header="_File" Padding="5">
                <MenuItem Header="_New File" Icon="{StaticResource IconNewFile}" InputGestureText="Ctrl+N" Command="{Binding NewFileCommand}"/>
                <MenuItem Header="_Open File" Icon="{StaticResource IconOpenFile}" InputGestureText="Ctrl+O" Command="{Binding OpenFileCommand}"/>
                <Separator/>
                <MenuItem Header="_Save File" Icon="{StaticResource IconSaveFile}" InputGestureText="Ctrl+S" Command="{Binding SaveFileCommand}"/>
                <MenuItem Header="Save File as ..." Icon="{StaticResource IconSaveFileAs}" Command="{Binding SaveFileAsCommand}"/>
                <MenuItem Header="Save File then _Run Game" Icon="{StaticResource IconSaveFileThenRunGame}" InputGestureText="B"/>
                <Separator/>
                <MenuItem Header="Close File" Icon="{StaticResource IconCloseFile}" Command="{Binding CloseFileCommand}"/>
                <MenuItem Header="Exit" Icon="{StaticResource IconExit}" Command="{Binding ExitCommand}"/>
            </MenuItem>
            <MenuItem Header="_Edit" Padding="5">
                <MenuItem Header="_Undo" Icon="{StaticResource IconUndo}" InputGestureText="Ctrl+Z"/>
                <MenuItem Header="_Redo" Icon="{StaticResource IconRedo}" InputGestureText="Ctrl+Y"/>
                <Separator/>
                <MenuItem Header="Previous Page" Icon="{StaticResource IconPreviousPage}" InputGestureText="A"/>
                <MenuItem Header="Previous Item" Icon="{StaticResource IconPreviousItem}" InputGestureText="S"/>
                <MenuItem Header="Next Page" Icon="{StaticResource IconNextPage}" InputGestureText="D"/>
                <MenuItem Header="Next Item" Icon="{StaticResource IconNextItem}" InputGestureText="F"/>
                <MenuItem Header="Goto Item" Icon="{StaticResource IconGoto}" InputGestureText="G"/>
                <Separator/>
                <MenuItem Header="Select Mode" Icon="{StaticResource IconSelectMode}" InputGestureText="Q"/>
                <MenuItem Header="Fill Mode" Icon="{StaticResource IconFillMode}" InputGestureText="W"/>
                <MenuItem Header="Draw Mode" Icon="{StaticResource IconDrawMode}" InputGestureText="E"/>
                <Separator/>
                <MenuItem Header="Clear Keys" Icon="{StaticResource IconClearKeys}"/>
                <MenuItem Header="Uniform FPS" Icon="{StaticResource IconUniformFps}"/>
                <Separator/>
                <MenuItem Header="Preference" Icon="{StaticResource IconPreference}" InputGestureText="Ctrl+P" Command="{Binding PreferenceCommand}"/>
            </MenuItem>
            <MenuItem Header="_Help" Padding="5">
                <MenuItem Header="Report Bug" Icon="{StaticResource IconReportBug}" Command="{Binding ReportBugCommand}"/>
                <MenuItem Header="About" Icon="{StaticResource IconAbout}" Command="{Binding AboutCommand}"/>
            </MenuItem>
        </Menu>

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="auto"/>
            </Grid.ColumnDefinitions>

            <StackPanel Orientation="Horizontal" Grid.Column="0">
                <widget:IconButton ButtonText="Select Mode"
                                   ButtonIcon="/Frontend/Assets/SelectMode.ico"
                                   Margin="5" Padding="5"/>
                <widget:IconButton ButtonText="Fill Mode"
                                   ButtonIcon="/Frontend/Assets/FillMode.ico"
                                   Margin="5" Padding="5"/>
                <widget:IconButton ButtonText="Draw Mode"
                                   ButtonIcon="/Frontend/Assets/DrawMode.ico"
                                   Margin="5" Padding="5"/>
            </StackPanel>

            <widget:IconButton ButtonText="Save File then Run Game"
                               ButtonIcon="/Frontend/Assets/SaveFileThenRunGame.ico"
                               Grid.Column="1" Margin="5" Padding="5"/>

        </Grid>

        <Grid Grid.Row="2">
            <Grid VerticalAlignment="Center" HorizontalAlignment="Center" AllowDrop="True">
                <Rectangle StrokeThickness="4" Stroke="Gray" StrokeDashArray="4 4" Fill="Transparent"/>
                <StackPanel Orientation="Horizontal" Margin="20">
                    <Image Source="/Frontend/Assets/OpenFile.ico" Width="24" Height="24" Margin="5" VerticalAlignment="Center"/>
                    <TextBlock Margin="5" Text="Create, Open or Drop a TAS File in There for Editing" Foreground="Gray" FontSize="16" VerticalAlignment="Center"/>
                </StackPanel>
            </Grid>

            <local:TasViewer>
                <local:TasViewer.ContextMenu>
                    <ContextMenu>
                        <ContextMenu.Resources>
                            <!-- Context Menu Icons -->
                            <Image x:Key="IconSet" Source="/Frontend/Assets/SetCell.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                            <Image x:Key="IconUnset" Source="/Frontend/Assets/UnsetCell.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                            <Image x:Key="IconFlip" Source="/Frontend/Assets/FlipCell.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                            <Image x:Key="IconCut" Source="/Frontend/Assets/CutFrame.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                            <Image x:Key="IconCopy" Source="/Frontend/Assets/CopyFrame.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                            <Image x:Key="IconPaste" Source="/Frontend/Assets/PasteFrame.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                            <Image x:Key="IconDelete" Source="/Frontend/Assets/DeleteFrame.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                            <Image x:Key="IconAdd" Source="/Frontend/Assets/AddFrame.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                            <Image x:Key="IconFps" Source="/Frontend/Assets/SetFps.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
                        </ContextMenu.Resources>

                        <MenuItem Header="Set" Icon="{StaticResource IconSet}"/>
                        <MenuItem Header="Unset" Icon="{StaticResource IconUnset}"/>
                        <MenuItem Header="Flip" Icon="{StaticResource IconFlip}"/>
                        <Separator/>
                        <MenuItem Header="Cut" Icon="{StaticResource IconCut}" InputGestureText="Ctrl+X"/>
                        <MenuItem Header="Copy" Icon="{StaticResource IconCopy}" InputGestureText="Ctrl+C"/>
                        <MenuItem Header="Paste after This" Icon="{StaticResource IconPaste}" InputGestureText="Ctrl+V"/>
                        <MenuItem Header="Paste before This"/>
                        <Separator/>
                        <MenuItem Header="Delete" Icon="{StaticResource IconDelete}"/>
                        <MenuItem Header="Delete after This" InputGestureText="Del"/>
                        <MenuItem Header="Delete before This" InputGestureText="Backspace"/>
                        <Separator/>
                        <MenuItem Header="Add after This" Icon="{StaticResource IconAdd}"/>
                        <MenuItem Header="Add before This"/>
                        <Separator/>
                        <MenuItem Header="Set FPS" Icon="{StaticResource IconFps}"/>
                    </ContextMenu>
                </local:TasViewer.ContextMenu>
            </local:TasViewer>
        </Grid>

        <StatusBar Grid.Row="3">
            <!-- 这玩意要逆序排列才能达到我想要的需求也是奇葩 -->
            <StatusBarItem Content="v2.0 stable" DockPanel.Dock="Right" Foreground="Gray" FontStyle="Italic"/>
            <Separator DockPanel.Dock="Right"/>
            <StatusBarItem Content="$Selection" DockPanel.Dock="Right"/>
            <Separator DockPanel.Dock="Right"/>
            <StatusBarItem Content="$ToolMode" DockPanel.Dock="Right"/>
            <Separator DockPanel.Dock="Right"/>

            <StatusBarItem Content="{Binding StatusMessage, Mode=OneWay}" HorizontalAlignment="Stretch"/>
        </StatusBar>

    </Grid>
</Window>
