<ext:BorderlessWindow x:Class="RecordWindow"
        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:御魂方案录制宏桌面版" AllowsTransparency="True" WindowStyle="None"
        MinWidth="550" MinHeight="250"
        xmlns:ext="clr-namespace:Nukepayload2.UI.Xaml;assembly=Nukepayload2.UI.Win32"
        mc:Ignorable="d" BorderBrush="DodgerBlue" BorderThickness="1"
        Title="御魂方案录制宏" Height="600" Width="900">
    <Grid>
        <Grid.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="pack://application:,,,/Nukepayload2.UI.Win32;component/Themes/Generic.xaml"/>
                </ResourceDictionary.MergedDictionaries>
                <local:InvisibleConverter x:Key="InvisibleConverter"/>
                <local:VisibleConverter x:Key="VisibleConverter"/>
                <local:NotConverter x:Key="NotConverter"/>
            </ResourceDictionary>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="32"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid x:Name="TitleBar">
            <Grid.Resources>
                <Style TargetType="Button" x:Key="TitleBarIconButtonStyle">
                    <Setter Property="Background" Value="Transparent"/>
                    <Setter Property="Foreground" Value="Black"/>
                    <Setter Property="BorderThickness" Value="0"/>
                    <Setter Property="Margin" Value="0,0,8,0"/>
                    <Setter Property="VerticalAlignment" Value="Top"/>
                    <Setter Property="Padding" Value="8"/>
                    <Setter Property="TextElement.FontFamily" Value="Segoe MDL2 Assets"/>
                    <Setter Property="TextElement.FontSize" Value="16"/>
                </Style>
            </Grid.Resources>
            <Rectangle x:Name="TitleBarDragElement">
                <Rectangle.Fill>
                    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                        <GradientStop Color="#1F9FCFFF"/>
                        <GradientStop Color="Transparent" Offset="1"/>
                    </LinearGradientBrush>
                </Rectangle.Fill>
            </Rectangle>
            <StackPanel Orientation="Horizontal">
                <TextBlock Margin="16,8" IsHitTestVisible="False">御魂方案录制宏</TextBlock>
                <Button x:Name="BtnSave" Command="{Binding Save}" ToolTip="保存" Style="{StaticResource TitleBarIconButtonStyle}">&#xE105;</Button>
                <Button x:Name="BtnSaveAs" Command="{Binding SaveAs}" ToolTip="另存为" Style="{StaticResource TitleBarIconButtonStyle}">&#xE792;</Button>
                <Button x:Name="BtnUndo" Command="{Binding Undo}" ToolTip="撤销" Style="{StaticResource TitleBarIconButtonStyle}">&#xE10E;</Button>
                <Button x:Name="BtnRedo" Command="{Binding Redo}" ToolTip="重做" Style="{StaticResource TitleBarIconButtonStyle}">&#xE10D;</Button>
                <Button x:Name="BtnLoad" Command="{Binding OpenFile}" ToolTip="打开" Style="{StaticResource TitleBarIconButtonStyle}">&#xED25;</Button>
                <Button x:Name="BtnNew" Command="{Binding NewFile}" ToolTip="新建" Style="{StaticResource TitleBarIconButtonStyle}">&#xE160;</Button>
                <TextBlock Text="{Binding ActiveDocument.信息.名称,FallbackValue=清理方案1}" Padding="8" ToolTip="整理方案文件名" IsHitTestVisible="False"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,88,0">
                <Button x:Name="BtnViewSource" Background="#FF3EA8FF" Foreground="WhiteSmoke" BorderThickness="0" Margin="0,0,4,0" VerticalAlignment="Top" Padding="18,4">源码</Button>
                <Button x:Name="BtnAbout" Background="#FF3EA8FF" Foreground="WhiteSmoke" BorderThickness="0" Margin="0,0,8,0" VerticalAlignment="Top" Padding="18,4">关于</Button>
            </StackPanel>
        </Grid>
        <Border x:Name="ClientArea" Grid.Row="1">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <ScrollViewer VerticalScrollBarVisibility="Disabled" 
                              HorizontalScrollBarVisibility="Auto" 
                              Background="WhiteSmoke" TextElement.Foreground="#FF3F3F3F">
                    <ScrollViewer.Resources>
                        <Style TargetType="Button">
                            <Setter Property="Foreground" Value="#FF3F3F3F"/>
                        </Style>
                    </ScrollViewer.Resources>
                    <StackPanel Orientation="Horizontal">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <StackPanel Orientation="Horizontal">
                                <Button Command="{Binding ImportYyxJson}" BorderThickness="0" Background="Transparent" Margin="4,0">
                                    <Grid Width="72" Margin="4">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition/>
                                        </Grid.RowDefinitions>
                                        <local:JsonIcon />
                                        <TextBlock HorizontalAlignment="Center" Grid.Row="1">从痒痒熊</TextBlock>
                                    </Grid>
                                </Button>
                            </StackPanel>
                            <TextBlock Grid.Row="1" HorizontalAlignment="Center" Margin="0,4">获取数据</TextBlock>
                        </Grid>
                        <Rectangle Width="1" Margin="0,4" Fill="DarkGray"/>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <StackPanel Orientation="Horizontal">
                                <Button Command="{Binding ViewCode}" BorderThickness="0" Background="Transparent" Margin="4,0">
                                    <Grid Width="72" Margin="4">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition/>
                                        </Grid.RowDefinitions>
                                        <local:VBIcon />
                                        <TextBlock HorizontalAlignment="Center" Grid.Row="1">Visual Basic</TextBlock>
                                    </Grid>
                                </Button>
                                <Button Command="{Binding ViewMacroList}" BorderThickness="0" Background="Transparent" Margin="4,0">
                                    <Grid Width="72" Margin="4">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition/>
                                        </Grid.RowDefinitions>
                                        <local:MacroIcon />
                                        <TextBlock HorizontalAlignment="Center" Grid.Row="1">宏</TextBlock>
                                    </Grid>
                                </Button>
                                <Button Command="{Binding RecordMacro}"
                                        Visibility="{Binding IsRecording,Converter={StaticResource InvisibleConverter}}" 
                                        BorderThickness="0" Background="Transparent" Margin="4,0">
                                    <Grid Width="72" Margin="4">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition/>
                                        </Grid.RowDefinitions>
                                        <local:RecordIcon />
                                        <TextBlock HorizontalAlignment="Center" Grid.Row="1">录制宏</TextBlock>
                                    </Grid>
                                </Button>
                                <Button Command="{Binding StopRecordMacro}" BorderThickness="0" 
                                        Visibility="{Binding IsRecording,Converter={StaticResource VisibleConverter}}" 
                                        Background="Transparent" Margin="4,0">
                                    <Grid Width="72" Margin="4">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition/>
                                        </Grid.RowDefinitions>
                                        <local:StopRecordIcon />
                                        <TextBlock HorizontalAlignment="Center" Grid.Row="1">停止录制</TextBlock>
                                    </Grid>
                                </Button>
                            </StackPanel>
                            <TextBlock Grid.Row="1" HorizontalAlignment="Center" Margin="0,4">开发工具</TextBlock>
                        </Grid>
                        <Rectangle Width="1" Margin="0,4" Fill="DarkGray"/>
                    </StackPanel>
                </ScrollViewer>
                <Grid Grid.Row="1" Margin="4">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="5*"/>
                        <ColumnDefinition Width="6*"/>
                    </Grid.ColumnDefinitions>
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left">
                        <RadioButton Content="已弃置" 
                                     IsChecked="{Binding ViewDiscarded,Mode=TwoWay}"
                                     GroupName="DiscardFilter" Margin="4"/>
                        <RadioButton Content="待整理" 
                                     IsChecked="{Binding ViewDiscarded,Mode=OneWay,Converter={StaticResource NotConverter}}" 
                                     GroupName="DiscardFilter" Margin="4"/>
                    </StackPanel>
                    <ListBox Grid.Row="1" Margin="4" ItemsSource="{Binding ViewingEquipments}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <local:EquipmentControl Equipment="{Binding .}"/>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="ListBoxItem">
                                <Setter Property="HorizontalAlignment" Value="Left"/>
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                                <Setter Property="VerticalAlignment" Value="Top"/>
                                <Setter Property="VerticalContentAlignment" Value="Top"/>
                            </Style>
                        </ListBox.ItemContainerStyle>
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <local:VirtualizingWrapPanel IsItemsHost="True" 
                                                             CanHorizontallyScroll="False"
                                                             CanVerticallyScroll="True"/>
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                    </ListBox>
                    <Button Grid.Row="1" Command="{Binding SortEquipments}" Margin="0,0,24,4" HorizontalAlignment="Right" VerticalAlignment="Bottom" Padding="32,8">排序</Button>
                    <Button Grid.Column="1" Command="{Binding Reset}" HorizontalAlignment="Left" Margin="8,4" Padding="32,8">重置</Button>
                    <Button Grid.Column="1" Command="{Binding ApplyFiltersAndDiscard}" HorizontalAlignment="Right" Margin="8,4" Padding="32,8">全选并弃置</Button>
                    <ScrollViewer Grid.Column="1" Grid.Row="1" Margin="4" VerticalScrollBarVisibility="Auto">
                        <ScrollViewer.Resources>
                            <DataTemplate x:Key="IncludeButtonTemplate">
                                <ToggleButton Content="{Binding Name}" Padding="12.5,12" IsChecked="{Binding IsSelected}"/>
                            </DataTemplate>
                            <DataTemplate x:Key="IncludeExcludeButtonTemplate">
                                <local:IncludeExcludeToggleButton 
                                    Header="{Binding Name}" MinWidth="190"
                                    IsIncludeChecked="{Binding IncludeProperty, Mode=TwoWay}"
                                    IsExcludeChecked="{Binding ExcludeProperty, Mode=TwoWay}"/>
                            </DataTemplate>
                            <DataTemplate x:Key="IncludeButtonWithVisibilityTemplate">
                                <ToggleButton Content="{Binding Name}" Padding="12.5,12"
                                              IsChecked="{Binding IsSelected}"
                                              Visibility="{Binding IsVisible, Converter={StaticResource VisibleConverter}}"/>
                            </DataTemplate>
                            <ItemsPanelTemplate x:Key="IncludeButtonListTemplate">
                                <WrapPanel IsItemsHost="True" Orientation="Horizontal"/>
                            </ItemsPanelTemplate>
                        </ScrollViewer.Resources>
                        <StackPanel Margin="0,0,4,0">
                            <StackPanel.Resources>
                                <Style TargetType="ToggleButton">
                                    <Setter Property="BorderThickness" Value="0"/>
                                </Style>
                            </StackPanel.Resources>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Margin="4">类型</TextBlock>
                                <ItemsControl Grid.Column="1" ItemsSource="{Binding EquipmentKinds}">
                                    <ItemsControl.ItemsPanel>
                                        <ItemsPanelTemplate>
                                            <WrapPanel IsItemsHost="True"/>
                                        </ItemsPanelTemplate>
                                    </ItemsControl.ItemsPanel>
                                    <ItemsControl.ItemTemplate>
                                        <DataTemplate>
                                            <ToggleButton Margin="4" Padding="12"/>
                                        </DataTemplate>
                                    </ItemsControl.ItemTemplate>
                                </ItemsControl>
                                <Button Grid.Column="2" Command="{Binding PickEquipmentKinds}" Margin="4" Padding="16,8">选择</Button>
                            </Grid>
                            <Rectangle Height="1" Fill="DarkGray" Margin="4"/>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Margin="4">位置</TextBlock>
                                <ItemsControl Margin="4" Grid.Column="1" HorizontalAlignment="Right"
                                              ItemsSource="{Binding Positions}" 
                                              ItemsPanel="{StaticResource IncludeButtonListTemplate}"
                                              ItemTemplate="{StaticResource IncludeButtonTemplate}"/>
                            </Grid>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Margin="4">星级</TextBlock>
                                <ItemsControl Margin="4" Grid.Column="1" HorizontalAlignment="Right"
                                              ItemsSource="{Binding Stars}" 
                                              ItemsPanel="{StaticResource IncludeButtonListTemplate}"
                                              ItemTemplate="{StaticResource IncludeButtonTemplate}"/>
                            </Grid>
                            <Rectangle Height="1" Fill="DarkGray" Margin="4"/>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Margin="4">主属性</TextBlock>
                                <ItemsControl Margin="4" Grid.Column="1" HorizontalAlignment="Right"
                                              ItemsSource="{Binding PrimaryProperties}" 
                                              ItemsPanel="{StaticResource IncludeButtonListTemplate}"
                                              ItemTemplate="{StaticResource IncludeButtonWithVisibilityTemplate}"/>
                            </Grid>
                            <Grid Margin="4">
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <TextBlock VerticalAlignment="Top">副属性</TextBlock>
                                <ItemsControl Margin="4" Grid.Column="1" Grid.ColumnSpan="2"
                                              ItemsSource="{Binding SecondaryProperties}" 
                                              ItemsPanel="{StaticResource IncludeButtonListTemplate}"
                                              ItemTemplate="{StaticResource IncludeExcludeButtonTemplate}"/>
                                <TextBlock Grid.Column="1" Grid.Row="1" MinWidth="70"
                                           TextAlignment="Center" VerticalAlignment="Center">条数</TextBlock>
                                <ItemsControl Margin="4" Grid.Column="2" Grid.Row="1"
                                              ItemsSource="{Binding SecondaryCounts}" 
                                              ItemsPanel="{StaticResource IncludeButtonListTemplate}"
                                              ItemTemplate="{StaticResource IncludeButtonTemplate}"/>
                            </Grid>
                        </StackPanel>
                    </ScrollViewer>
                </Grid>
            </Grid>
        </Border>
        <Grid Grid.RowSpan="2" x:Name="FlyoutHost" Visibility="Collapsed">
            <Rectangle x:Name="RectFlyoutHostBack" Fill="#3F000000"/>
        </Grid>
        <StackPanel x:Name="ControlBox" Orientation="Horizontal" HorizontalAlignment="Right">
            <Button x:Name="BtnMinimize" ToolTip="最小化" Style="{StaticResource MinimizeButtonStyle}"/>
            <Button x:Name="BtnClose" ToolTip="关闭" Style="{StaticResource CloseButtonStyle}"/>
        </StackPanel>
    </Grid>
</ext:BorderlessWindow>
