<UserControl x:Class="VIZ.Package.Module.MainTopView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
             xmlns:dxbt="http://schemas.devexpress.com/winfx/2008/xaml/bars/themekeys"
             xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
             xmlns:dxn="http://schemas.devexpress.com/winfx/2008/xaml/core/internal"
             xmlns:dxet="http://schemas.devexpress.com/winfx/2008/xaml/editors/themekeys"
             xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
             xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
             d:DataContext="{d:DesignInstance Type=local:MainTopViewModel}" 
             xmlns:local="clr-namespace:VIZ.Package.Module"
             mc:Ignorable="d" x:Name="uc"
             d:DesignHeight="450" d:DesignWidth="800">

    <UserControl.Resources>
        <fcore:Bool2BoolConverterSimple x:Key="Bool2BoolConverterSimple"></fcore:Bool2BoolConverterSimple>

        <local:MainTopViewMenuDataTemplateSelector x:Key="MainTopViewMenuDataTemplateSelector">
            <local:MainTopViewMenuDataTemplateSelector.ButtonDataTemplate>
                <DataTemplate>
                    <ContentControl>
                        <dxb:BarButtonItem Glyph="{Binding Icon}" Content="{Binding Header}"
                                           Command="{Binding Path=Command}" CommandParameter="{Binding Path=FilePath}" ></dxb:BarButtonItem>
                    </ContentControl>
                </DataTemplate>
            </local:MainTopViewMenuDataTemplateSelector.ButtonDataTemplate>
            <local:MainTopViewMenuDataTemplateSelector.CheckBoxDataTemplate>
                <DataTemplate>
                    <ContentControl>
                        <dxb:BarCheckItem Content="{Binding Data.Name}"
                                          IsChecked="{Binding Path=Data.IsClosed,Mode=TwoWay,Converter={StaticResource Bool2BoolConverterSimple}}"></dxb:BarCheckItem>
                    </ContentControl>
                </DataTemplate>
            </local:MainTopViewMenuDataTemplateSelector.CheckBoxDataTemplate>
            <local:MainTopViewMenuDataTemplateSelector.SeparatorTemplate>
                <DataTemplate>
                    <ContentControl>
                        <dxb:BarItemSeparator></dxb:BarItemSeparator>
                    </ContentControl>
                </DataTemplate>
            </local:MainTopViewMenuDataTemplateSelector.SeparatorTemplate>
        </local:MainTopViewMenuDataTemplateSelector>

    </UserControl.Resources>

    <dxmvvm:Interaction.Behaviors>
        <dxmvvm:EventToCommand EventName="Loaded" Command="{Binding Path=LoadedCommand}"></dxmvvm:EventToCommand>
    </dxmvvm:Interaction.Behaviors>

    <StackPanel Orientation="Horizontal">
        <Image Source="/VIZ.Package;component/logo.ico" Margin="2,5,2,2"
               VerticalAlignment="Center"></Image>

        <dxb:MainMenuControl Caption="MainMenu" VerticalAlignment="Center" Margin="5,0,0,0">
            <dxb:MainMenuControl.Resources>
                <Style TargetType="dxb:BarSubItem">
                    <Setter Property="Margin" Value="0,0,3,0"></Setter>
                    <Setter Property="ContentTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <TextBlock Text="{Binding .}" FontSize="14"></TextBlock>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </dxb:MainMenuControl.Resources>
            <dxb:BarSubItem Content="项目" IsEnabled="{Binding Path=IsVizPreviewReady}">
                <dxb:BarButtonItem Content="新建" Glyph="/VIZ.Package.Module.Resource;component/Icons/top_icon_create_20x20.png"
                                   Command="{Binding Path=CreateProjectCommand}" />
                <dxb:BarButtonItem Content="打开" Glyph="/VIZ.Package.Module.Resource;component/Icons/top_icon_open_20x20.png"  
                                   Command="{Binding Path=OpenProjectCommand}" />
                <dxb:BarButtonItem Content="保存" Glyph="/VIZ.Package.Module.Resource;component/Icons/top_icon_save_20x20.png" 
                                   Command="{Binding Path=SaveProjectCommand}" />

                <dxb:BarButtonItem Content="另保存" Glyph="/VIZ.Package.Module.Resource;component/Icons/icon_save_as_30x30.png" 
                                   Command="{Binding Path=SaveAsProjectCommand}" />
                <dxb:BarButtonItem Content="关闭" Glyph="/VIZ.Package.Module.Resource;component/Icons/top_icon_close_20x20.png" 
                                   Command="{Binding Path=CloseProjectCommand}" />

            </dxb:BarSubItem>
            <dxb:BarSubItem Content="设置" Command="{Binding Path=SettingCommand}">
            </dxb:BarSubItem>
            <dxb:BarSubItem Content="视图" ItemLinksSource="{Binding Path=ItemsSource}" 
                            ItemTemplateSelector="{StaticResource MainTopViewMenuDataTemplateSelector}">
            </dxb:BarSubItem>
            <dxb:BarSubItem Content="帮助">
                <dxb:BarButtonItem Content="关于" Glyph="/VIZ.Package.Module.Resource;component/Icons/top_icon_about_20x20.png" 
                                   Command="{Binding Path=AboutCommand}"/>
                <dxb:BarButtonItem Content="关于自定义控制字段" Glyph="/VIZ.Package.Module.Resource;component/Icons/icon_custom_32x32.png" 
                                   Command="{Binding Path=AboutCustomControlFieldCommand}"/>
                <dxb:BarButtonItem Content="关于页命令" Glyph="/VIZ.Package.Module.Resource;component/Icons/icon_cmd_32x32.png" 
                                   Command="{Binding Path=AboutPageCommandCommand}"/>
            </dxb:BarSubItem>
        </dxb:MainMenuControl>
    </StackPanel>
</UserControl>