<Window x:Class="FooEditor.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:avalonDock="http://avalondock.codeplex.com"
        xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock"
        xmlns:foo="clr-namespace:FooEditEngine.WPF;assembly=FooEditEngine.WPF"
        xmlns:local="clr-namespace:FooEditor"
        Title="FooEditor" Height="350" Width="525">
    <Window.Resources>
        <local:EncodingConverter x:Key="EncodingConverter" />
        <local:LineFeedConverter x:Key="LineFeedConverter" />
        <local:TextPointConverter x:Key="TextPointConverter" />
        <local:HilightTypeConverter x:Key="HilightTypeConverter" />
        <local:ObjectToTypeStringConverter x:Key="ObjectToTypeStringConverter"/>
        <ContextMenu x:Key="ContextMenu">
            <MenuItem Header="元に戻す" Command="ApplicationCommands.Undo"/>
            <MenuItem Header="やり直す" Command="ApplicationCommands.Redo"/>
            <Separator/>
            <MenuItem Header="カット" Command="ApplicationCommands.Cut"/>
            <MenuItem Header="コピー" Command="ApplicationCommands.Copy"/>
            <MenuItem Header="貼り付け" Command="ApplicationCommands.Paste"/>
            <Separator/>
            <MenuItem Header="矩形選択を行う"
                          Command="{x:Static foo:FooTextBoxCommands.ToggleRectSelectMode}"
                          IsChecked="{Binding ActiveDocument.TextBox.RectSelectMode,Mode=OneWay}"
                          IsCheckable="True"/>
            <Separator/>
            <MenuItem Header="右から左に表示する" IsCheckable="True" Command="{x:Static foo:FooTextBoxCommands.ToggleFlowDirection}">
                <Style TargetType="MenuItem">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ActiveDocument.TextBox.FlowDirection,Mode=OneWay}" Value="FlowDirection.LeftToRight">
                            <Setter Property="IsChecked" Value="False"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ActiveDocument.TextBox.FlowDirection,Mode=OneWay}" Value="FlowDirection.RightToLeft">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </MenuItem>
            <Separator/>
            <MenuItem Header="検索" Command="ApplicationCommands.Find"/>
            <MenuItem Header="置き換え" Command="ApplicationCommands.Replace"/>
            <MenuItem Header="ジャンプ" Command="{x:Static local:FooEditorCommands.LineJump}"/>
        </ContextMenu>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="24"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="24"/>
        </Grid.RowDefinitions>
        <Menu Grid.Row="0">
            <MenuItem Header="ファイル" Name="FileMenuItem">
                <MenuItem Header="新規作成" Command="ApplicationCommands.New"/>
                <MenuItem Header="開く" Command="ApplicationCommands.Open"/>
                <Separator/>
                <MenuItem Header="保存" Command="ApplicationCommands.Save"/>
                <MenuItem Header="名前を付けて保存..." Command="ApplicationCommands.SaveAs"/>
                <Separator/>
                <MenuItem Header="最近使ったファイル" ItemsSource="{Binding RecentFiles}">
                    <MenuItem.ItemContainerStyle>
                        <Style TargetType="MenuItem">
                            <Setter Property="Header" Value="{Binding FileName}"/>
                            <Setter Property="Command" Value="{x:Static local:FooEditorCommands.OpenRecentFile}"/>
                            <Setter Property="CommandParameter" Value="{Binding FilePath}"/>
                            <Setter Property="ToolTip" Value="{Binding FilePath}"/>
                        </Style>
                    </MenuItem.ItemContainerStyle>
                </MenuItem>
                <Separator/>
                <MenuItem Header="印刷..." Command="ApplicationCommands.Print" />
                <Separator/>
                <MenuItem Header="終了" Command="{x:Static local:FooEditorCommands.Quit}" />
            </MenuItem>
            <MenuItem Header="編集" Name="EditMenuItem">
                <MenuItem Header="元に戻す" Command="ApplicationCommands.Undo"/>
                <MenuItem Header="やり直す" Command="ApplicationCommands.Redo"/>
                <Separator/>
                <MenuItem Header="カット" Command="ApplicationCommands.Cut"/>
                <MenuItem Header="コピー" Command="ApplicationCommands.Copy"/>
                <MenuItem Header="貼り付け" Command="ApplicationCommands.Paste"/>
                <Separator/>
                <MenuItem Header="矩形選択を行う"
                          Command="{x:Static foo:FooTextBoxCommands.ToggleRectSelectMode}"
                          IsChecked="{Binding ActiveDocument.TextBox.RectSelectMode,Mode=OneWay}"
                          IsCheckable="True"/>
                <Separator/>
                <MenuItem Header="検索" Command="ApplicationCommands.Find"/>
                <MenuItem Header="置き換え" Command="ApplicationCommands.Replace"/>
                <MenuItem Header="ジャンプ" Command="{x:Static local:FooEditorCommands.LineJump}"/>
            </MenuItem>
            <MenuItem Header="表示" Name="LookMenuItem">
                <MenuItem Header="文章タイプ" ItemsSource="{Binding DocumentTypes}">
                    <MenuItem.ItemContainerStyle>
                        <Style TargetType="MenuItem">
                            <Setter Property="Header" Value="{Binding Name}"/>
                            <Setter Property="Command" Value="{x:Static local:FooEditorCommands.SelectDocumentType}"/>
                            <Setter Property="CommandParameter" Value="{Binding Name}"/>
                            <Setter Property="IsChecked" Value="{Binding IsActive}"/>
                        </Style>
                    </MenuItem.ItemContainerStyle>
                </MenuItem>
            </MenuItem>
            <MenuItem Header="ツール" Name="ToolMenuItem">
                <MenuItem Header="Grep" Command="{x:Static local:FooEditorCommands.Grep}"/>
                <Separator/>
                <MenuItem Header="作業環境を保存する" Command="{x:Static local:FooEditorCommands.SaveWorkSpace}"/>
                <Separator/>
                <MenuItem Header="ウィンドウ">
                    <MenuItem Header="上下に整列する" Command="{x:Static local:FooEditorCommands.TileVertical}"/>
                    <MenuItem Header="左右に整列する" Command="{x:Static local:FooEditorCommands.TileHorizontal}"/>
                    <MenuItem Header="カスケード" Command="{x:Static local:FooEditorCommands.Casecade}"/>
                </MenuItem>
                <Separator/>
                <MenuItem Header="設定" Command="Properties"/>
            </MenuItem>
            <MenuItem Header="ヘルプ">
                <MenuItem Header="ヘルプ" Command="Help" />
                <MenuItem Header="バージョン情報" Command="{x:Static local:FooEditorCommands.About}" />
            </MenuItem>
        </Menu>
        <ad:DockingManager Grid.Row="1"
                           DocumentsSource="{Binding Documents}"
                           AllowDrop="True"
                           Name="DockManager">
            <ad:DockingManager.LayoutItemContainerStyle>
                <Style TargetType="{x:Type avalonDock:LayoutItem}">
                    <Setter Property="Title" Value="{Binding Model.Title}"/>
                    <Style.Triggers>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding Model, Converter={StaticResource ResourceKey=ObjectToTypeStringConverter}}" Value="DocumentWindow"/>
                                <Condition Binding="{Binding Model.Dirty}" Value="True"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Title" Value="{Binding Model.Title,StringFormat='{}{0}*'}"/>
                            <Setter Property="ToolTip" Value="{Binding Model.FilePath}"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding Model, Converter={StaticResource ResourceKey=ObjectToTypeStringConverter}}" Value="DocumentWindow"/>
                                <Condition Binding="{Binding Model.Dirty}" Value="False"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Title" Value="{Binding Model.Title}"/>
                            <Setter Property="ToolTip" Value="{Binding Model.FilePath}"/>
                        </MultiDataTrigger>
                    </Style.Triggers>
                </Style>
            </ad:DockingManager.LayoutItemContainerStyle>
            <avalonDock:LayoutRoot>
                <avalonDock:LayoutPanel Orientation="Horizontal">
                    <avalonDock:LayoutAnchorablePane x:Name="ToolsPanel" DockWidth="230"/>
                    <avalonDock:LayoutDocumentPaneGroup x:Name="DocumentPanels">
                        <avalonDock:LayoutDocumentPane/>
                    </avalonDock:LayoutDocumentPaneGroup>
                </avalonDock:LayoutPanel>
            </avalonDock:LayoutRoot>
        </ad:DockingManager>
        <StatusBar Grid.Row="2">
            <StatusBarItem Content="{Binding ActiveDocument.TextBox.CaretPostion,Converter={StaticResource ResourceKey=TextPointConverter}}"/>
            <StatusBarItem Content="{Binding ActiveDocument.DocumentType,Converter={StaticResource ResourceKey=HilightTypeConverter}}" />
            <StatusBarItem Content="{Binding ActiveDocument.LineFeed,Converter={StaticResource ResourceKey=LineFeedConverter}}"/>
            <StatusBarItem Content="{Binding ActiveDocument.Encoding,Converter={StaticResource ResourceKey=EncodingConverter}}"/>
            <StatusBarItem>
                <StatusBarItem.Style>
                    <Style TargetType="StatusBarItem">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ActiveDocument.TextBox.RectSelectMode}" Value="True">
                                <Setter Property="Content" Value="矩形選択"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding ActiveDocument.TextBox.RectSelectMode}" Value="False">
                                <Setter Property="Content" Value="行選択"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </StatusBarItem.Style>
            </StatusBarItem>
            <StatusBarItem>
                <StatusBarItem.Style>
                    <Style TargetType="StatusBarItem">
                        <Style.Triggers>
                            <MultiDataTrigger>
                                <MultiDataTrigger.Conditions>
                                    <Condition  Binding="{Binding ImeState}" Value="On"/>
                                    <Condition  Binding="{Binding ImeConversionMode}" Value="Native, FullShape, Roman"/>
                                </MultiDataTrigger.Conditions>
                                <Setter Property="Content" Value="あ"/>
                            </MultiDataTrigger>
                            <MultiDataTrigger>
                                <MultiDataTrigger.Conditions>
                                    <Condition  Binding="{Binding ImeState}" Value="On"/>
                                    <Condition  Binding="{Binding ImeConversionMode}" Value="Native, Katakana, FullShape, Roman"/>
                                </MultiDataTrigger.Conditions>
                                <Setter Property="Content" Value="カ"/>
                            </MultiDataTrigger>
                            <MultiDataTrigger>
                                <MultiDataTrigger.Conditions>
                                    <Condition  Binding="{Binding ImeState}" Value="On"/>
                                    <Condition  Binding="{Binding ImeConversionMode}" Value="FullShape, Roman, Alphanumeric"/>
                                </MultiDataTrigger.Conditions>
                                <Setter Property="Content" Value="Ａ"/>
                            </MultiDataTrigger>
                            <MultiDataTrigger>
                                <MultiDataTrigger.Conditions>
                                    <Condition  Binding="{Binding ImeState}" Value="On"/>
                                    <Condition  Binding="{Binding ImeConversionMode}" Value="Native, Katakana, Roman"/>
                                </MultiDataTrigger.Conditions>
                                <Setter Property="Content" Value="ｶ"/>
                            </MultiDataTrigger>
                            <MultiDataTrigger>
                                <MultiDataTrigger.Conditions>
                                    <Condition  Binding="{Binding ImeState}" Value="On"/>
                                    <Condition  Binding="{Binding ImeConversionMode}" Value="Native, FullShape"/>
                                </MultiDataTrigger.Conditions>
                                <Setter Property="Content" Value="あ"/>
                            </MultiDataTrigger>
                            <MultiDataTrigger>
                                <MultiDataTrigger.Conditions>
                                    <Condition  Binding="{Binding ImeState}" Value="On"/>
                                    <Condition  Binding="{Binding ImeConversionMode}" Value="Native, Katakana, FullShape"/>
                                </MultiDataTrigger.Conditions>
                                <Setter Property="Content" Value="カ"/>
                            </MultiDataTrigger>
                            <MultiDataTrigger>
                                <MultiDataTrigger.Conditions>
                                    <Condition  Binding="{Binding ImeState}" Value="On"/>
                                    <Condition  Binding="{Binding ImeConversionMode}" Value="FullShape, Alphanumeric"/>
                                </MultiDataTrigger.Conditions>
                                <Setter Property="Content" Value="Ａ"/>
                            </MultiDataTrigger>
                            <MultiDataTrigger>
                                <MultiDataTrigger.Conditions>
                                    <Condition  Binding="{Binding ImeState}" Value="On"/>
                                    <Condition  Binding="{Binding ImeConversionMode}" Value="Native, Katakana"/>
                                </MultiDataTrigger.Conditions>
                                <Setter Property="Content" Value="_ｶ"/>
                            </MultiDataTrigger>
                            <DataTrigger Binding="{Binding ImeState}" Value="Off">
                                <Setter Property="Content" Value="_A"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </StatusBarItem.Style>
            </StatusBarItem>
        </StatusBar>
    </Grid>
</Window>
