<!-- **************************************************************************

  Copyright (c) 2010 CubeSoft, Inc.

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as published
  by the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

*************************************************************************** -->
<UserControl
    x:Class="Cube.Pdf.Editor.RibbonControl"
    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:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:r="urn:fluent-ribbon"
    xmlns:my="clr-namespace:Cube.Pdf.Editor"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="150"
    d:DesignWidth="800">

    <!-- **********************************************************************
      Resources
    *********************************************************************** -->
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/Themes/RibbonStyle.xaml" />
                <ResourceDictionary Source="pack://application:,,,/Themes/RibbonTemplate.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <!-- **********************************************************************
      Main
    *********************************************************************** -->
    <r:Ribbon>
        <r:RibbonTabItem Header="{Binding Ribbon.Edit.Text}">
            <r:RibbonGroupBox>
                <!-- **********************************************************
                  Open
                *********************************************************** -->
                <r:Button
                    Header="{Binding Ribbon.Open.Text}"
                    Icon="{Binding Ribbon.Open.SmallIcon}"
                    LargeIcon="{Binding Ribbon.Open.LargeIcon}"
                    IsEnabled="{Binding Ribbon.Open.Enabled}"
                    Command="{Binding Ribbon.Open.Command}" />

                <!-- **********************************************************
                  Save
                *********************************************************** -->
                <r:SplitButton
                    Header="{Binding Ribbon.Save.Text}"
                    Icon="{Binding Ribbon.Save.SmallIcon}"
                    LargeIcon="{Binding Ribbon.Save.LargeIcon}"
                    IsEnabled="{Binding Ribbon.Save.Enabled}"
                    Command="{Binding Ribbon.Save.Command}">
                    <r:MenuItem
                        Header="{Binding Ribbon.Save.Tooltip}"
                        Icon="{Binding Ribbon.Save.SmallIcon}"
                        Command="{Binding Ribbon.Save.Command}" />
                    <r:MenuItem
                        Header="{Binding Ribbon.SaveAs.Tooltip}"
                        Icon="{Binding Ribbon.SaveAs.SmallIcon}"
                        Command="{Binding Ribbon.SaveAs.Command}" />
                </r:SplitButton>

                <!-- **********************************************************
                  Close
                *********************************************************** -->
                <r:Button
                    Header="{Binding Ribbon.Close.Text}"
                    Icon="{Binding Ribbon.Close.SmallIcon}"
                    LargeIcon="{Binding Ribbon.Close.LargeIcon}"
                    IsEnabled="{Binding Ribbon.Close.Enabled}"
                    Command="{Binding Ribbon.Close.Command}" />
            </r:RibbonGroupBox>

            <r:RibbonGroupBox>
                <!-- **********************************************************
                  Undo
                *********************************************************** -->
                <r:Button
                    Header="{Binding Ribbon.Undo.Text}"
                    Icon="{Binding Ribbon.Undo.SmallIcon}"
                    LargeIcon="{Binding Ribbon.Undo.LargeIcon}"
                    IsEnabled="{Binding Ribbon.Undo.Enabled}"
                    Command="{Binding Ribbon.Undo.Command}" />

                <!-- **********************************************************
                  Redo
                *********************************************************** -->
                <r:Button
                    Header="{Binding Ribbon.Redo.Text}"
                    Icon="{Binding Ribbon.Redo.SmallIcon}"
                    LargeIcon="{Binding Ribbon.Redo.LargeIcon}"
                    IsEnabled="{Binding Ribbon.Redo.Enabled}"
                    Command="{Binding Ribbon.Redo.Command}" />
            </r:RibbonGroupBox>

            <r:RibbonGroupBox>
                <!-- **********************************************************
                  Select
                *********************************************************** -->
                <r:SplitButton
                    Header="{Binding Ribbon.Select.Text}"
                    Icon="{Binding Ribbon.Select.SmallIcon}"
                    LargeIcon="{Binding Ribbon.Select.LargeIcon}"
                    IsEnabled="{Binding Ribbon.Select.Enabled}"
                    Command="{Binding Ribbon.Select.Command}">
                    <r:MenuItem
                        Header="{Binding Ribbon.SelectAll.Tooltip}"
                        Icon="{Binding Ribbon.SelectAll.SmallIcon}"
                        Command="{Binding Ribbon.SelectAll.Command}" />
                    <r:MenuItem
                        Header="{Binding Ribbon.SelectFlip.Tooltip}"
                        Command="{Binding Ribbon.SelectFlip.Command}" />
                    <r:MenuItem
                        Header="{Binding Ribbon.SelectClear.Tooltip}"
                        Command="{Binding Ribbon.SelectClear.Command}" />
                </r:SplitButton>
            </r:RibbonGroupBox>

            <r:RibbonGroupBox>
                <!-- **********************************************************
                  Insert
                *********************************************************** -->
                <r:SplitButton
                    Header="{Binding Ribbon.Insert.Text}"
                    Icon="{Binding Ribbon.Insert.SmallIcon}"
                    LargeIcon="{Binding Ribbon.Insert.LargeIcon}"
                    IsEnabled="{Binding Ribbon.Insert.Enabled}"
                    Command="{Binding Ribbon.Insert.Command}">
                    <r:MenuItem
                        Header="{Binding Ribbon.Insert.Tooltip}"
                        Icon="{Binding Ribbon.Insert.SmallIcon}"
                        Command="{Binding Ribbon.Insert.Command}" />
                    <r:MenuItem
                        Header="{Binding Ribbon.InsertFront.Tooltip}"
                        Command="{Binding Ribbon.InsertFront.Command}" />
                    <r:MenuItem
                        Header="{Binding Ribbon.InsertBack.Tooltip}"
                        Command="{Binding Ribbon.InsertBack.Command}" />
                    <r:MenuItem
                        Header="{Binding Ribbon.InsertOthers.Tooltip}"
                        Icon="{Binding Ribbon.InsertOthers.SmallIcon}"
                        Command="{Binding Ribbon.InsertOthers.Command}" />
                </r:SplitButton>

                <!-- **********************************************************
                  Extract
                *********************************************************** -->
                <r:SplitButton
                    Header="{Binding Ribbon.Extract.Text}"
                    Icon="{Binding Ribbon.Extract.SmallIcon}"
                    LargeIcon="{Binding Ribbon.Extract.LargeIcon}"
                    IsEnabled="{Binding Ribbon.Extract.Enabled}"
                    Command="{Binding Ribbon.Extract.Command}">
                    <r:MenuItem
                        Header="{Binding Ribbon.Extract.Tooltip}"
                        Icon="{Binding Ribbon.Extract.SmallIcon}"
                        Command="{Binding Ribbon.Extract.Command}" />
                    <r:MenuItem
                        Header="{Binding Ribbon.ExtractOthers.Tooltip}"
                        Icon="{Binding Ribbon.ExtractOthers.SmallIcon}"
                        Command="{Binding Ribbon.ExtractOthers.Command}" />
                </r:SplitButton>

                <!-- **********************************************************
                  Remove
                *********************************************************** -->
                <r:SplitButton
                    Header="{Binding Ribbon.Remove.Text}"
                    Icon="{Binding Ribbon.Remove.SmallIcon}"
                    LargeIcon="{Binding Ribbon.Remove.LargeIcon}"
                    IsEnabled="{Binding Ribbon.Remove.Enabled}"
                    Command="{Binding Ribbon.Remove.Command}">
                    <r:MenuItem
                        Header="{Binding Ribbon.Remove.Tooltip}"
                        Icon="{Binding Ribbon.Remove.SmallIcon}"
                        Command="{Binding Ribbon.Remove.Command}" />
                    <r:MenuItem
                        Header="{Binding Ribbon.RemoveOthers.Tooltip}"
                        Icon="{Binding Ribbon.RemoveOthers.SmallIcon}"
                        Command="{Binding Ribbon.RemoveOthers.Command}" />
                </r:SplitButton>
            </r:RibbonGroupBox>

            <r:RibbonGroupBox>
                <!-- **********************************************************
                  MovePrevious
                *********************************************************** -->
                <r:Button
                    Header="{Binding Ribbon.MovePrevious.Text}"
                    Icon="{Binding Ribbon.MovePrevious.SmallIcon}"
                    LargeIcon="{Binding Ribbon.MovePrevious.LargeIcon}"
                    IsEnabled="{Binding Ribbon.MovePrevious.Enabled}"
                    Command="{Binding Ribbon.MovePrevious.Command}" />

                <!-- **********************************************************
                  MoveNext
                *********************************************************** -->
                <r:Button
                    Header="{Binding Ribbon.MoveNext.Text}"
                    Icon="{Binding Ribbon.MoveNext.SmallIcon}"
                    LargeIcon="{Binding Ribbon.MoveNext.LargeIcon}"
                    IsEnabled="{Binding Ribbon.MoveNext.Enabled}"
                    Command="{Binding Ribbon.MoveNext.Command}" />
            </r:RibbonGroupBox>

            <r:RibbonGroupBox>
                <!-- **********************************************************
                  RotateLeft
                *********************************************************** -->
                <r:Button
                    Header="{Binding Ribbon.RotateLeft.Text}"
                    Icon="{Binding Ribbon.RotateLeft.SmallIcon}"
                    LargeIcon="{Binding Ribbon.RotateLeft.LargeIcon}"
                    IsEnabled="{Binding Ribbon.RotateLeft.Enabled}"
                    Command="{Binding Ribbon.RotateLeft.Command}" />

                <!-- **********************************************************
                  RotateRight
                *********************************************************** -->
                <r:Button
                    Header="{Binding Ribbon.RotateRight.Text}"
                    Icon="{Binding Ribbon.RotateRight.SmallIcon}"
                    LargeIcon="{Binding Ribbon.RotateRight.LargeIcon}"
                    IsEnabled="{Binding Ribbon.RotateRight.Enabled}"
                    Command="{Binding Ribbon.RotateRight.Command}" />
            </r:RibbonGroupBox>

            <r:RibbonGroupBox>
                <!-- **********************************************************
                  Metadata
                *********************************************************** -->
                <r:Button
                    Header="{Binding Ribbon.Metadata.Text}"
                    Icon="{Binding Ribbon.Metadata.SmallIcon}"
                    LargeIcon="{Binding Ribbon.Metadata.LargeIcon}"
                    IsEnabled="{Binding Ribbon.Metadata.Enabled}"
                    Command="{Binding Ribbon.Metadata.Command}" />

                <!-- **********************************************************
                  Encryption
                *********************************************************** -->
                <r:Button
                    Header="{Binding Ribbon.Encryption.Text}"
                    Icon="{Binding Ribbon.Encryption.SmallIcon}"
                    LargeIcon="{Binding Ribbon.Encryption.LargeIcon}"
                    IsEnabled="{Binding Ribbon.Encryption.Enabled}"
                    Command="{Binding Ribbon.Encryption.Command}" />
            </r:RibbonGroupBox>
        </r:RibbonTabItem>

        <r:RibbonTabItem Header="{Binding Ribbon.Others.Text}">
            <r:RibbonGroupBox>
                <!-- **********************************************************
                  Redraw
                *********************************************************** -->
                <r:Button
                    Header="{Binding Ribbon.Redraw.Text}"
                    Icon="{Binding Ribbon.Redraw.SmallIcon}"
                    LargeIcon="{Binding Ribbon.Redraw.LargeIcon}"
                    IsEnabled="{Binding Ribbon.Redraw.Enabled}"
                    Command="{Binding Ribbon.Redraw.Command}" />
            </r:RibbonGroupBox>

            <r:RibbonGroupBox>
                <!-- **********************************************************
                  ZoomIn
                *********************************************************** -->
                <r:Button
                    Header="{Binding Ribbon.ZoomIn.Text}"
                    Icon="{Binding Ribbon.ZoomIn.SmallIcon}"
                    LargeIcon="{Binding Ribbon.ZoomIn.LargeIcon}"
                    IsEnabled="{Binding Ribbon.ZoomIn.Enabled}"
                    Command="{Binding Ribbon.ZoomIn.Command}" />

                <!-- **********************************************************
                  ZoomOut
                *********************************************************** -->
                <r:Button
                    Header="{Binding Ribbon.ZoomOut.Text}"
                    Icon="{Binding Ribbon.ZoomOut.SmallIcon}"
                    LargeIcon="{Binding Ribbon.ZoomOut.LargeIcon}"
                    IsEnabled="{Binding Ribbon.ZoomOut.Enabled}"
                    Command="{Binding Ribbon.ZoomOut.Command}" />
            </r:RibbonGroupBox>

            <r:RibbonGroupBox>
                <!-- **********************************************************
                  ItemSize
                *********************************************************** -->
                <ComboBox
                    ItemsSource="{Binding Value.Images.Preferences.ItemSizeOptions}"
                    SelectedItem="{Binding Value.ItemSize, Mode=TwoWay}"
                    Style="{StaticResource RibbonItemSizeStyle}" />

                <!-- **********************************************************
                  FrameOnly
                *********************************************************** -->
                <CheckBox
                    Content="{Binding Ribbon.FrameOnly.Text}"
                    IsChecked="{Binding Ribbon.FrameOnly.Value, Mode=TwoWay}"
                    Style="{StaticResource RibbonFrameOnlyStyle}" />
            </r:RibbonGroupBox>

            <r:RibbonGroupBox>
                <!-- **********************************************************
                  Setting
                *********************************************************** -->
                <r:Button
                    Header="{Binding Ribbon.Setting.Text}"
                    Icon="{Binding Ribbon.Setting.SmallIcon}"
                    LargeIcon="{Binding Ribbon.Setting.LargeIcon}"
                    IsEnabled="{Binding Ribbon.Setting.Enabled}"
                    Command="{Binding Ribbon.Setting.Command}" />
            </r:RibbonGroupBox>
        </r:RibbonTabItem>

        <r:Ribbon.Menu>
            <r:ApplicationMenu Header="{Binding Ribbon.File.Text}">
                <!-- **********************************************************
                  Open (ApplicationMenu)
                *********************************************************** -->
                <r:MenuItem
                    Header="{Binding Ribbon.Open.Tooltip}"
                    Icon="{Binding Ribbon.Open.LargeIcon}"
                    Command="{Binding Ribbon.Open.Command}" />

                <!-- **********************************************************
                  Save (ApplicationMenu)
                *********************************************************** -->
                <r:MenuItem
                    Header="{Binding Ribbon.Save.Tooltip}"
                    Icon="{Binding Ribbon.Save.LargeIcon}"
                    Command="{Binding Ribbon.Save.Command}" />

                <!-- **********************************************************
                  SaveAs (ApplicationMenu)
                *********************************************************** -->
                <r:MenuItem
                    Header="{Binding Ribbon.SaveAs.Tooltip}"
                    Icon="{Binding Ribbon.SaveAs.LargeIcon}"
                    Command="{Binding Ribbon.SaveAs.Command}" />
                <Separator />

                <!-- **********************************************************
                  Setting (ApplicationMenu)
                *********************************************************** -->
                <r:MenuItem
                    Header="{Binding Ribbon.Setting.Tooltip}"
                    Icon="{Binding Ribbon.Setting.LargeIcon}"
                    Command="{Binding Ribbon.Setting.Command}" />
                <Separator />

                <!-- **********************************************************
                  Close (ApplicationMenu)
                *********************************************************** -->
                <r:MenuItem
                    Header="{Binding Ribbon.Close.Tooltip}"
                    Icon="{Binding Ribbon.Close.LargeIcon}"
                    Command="{Binding Ribbon.Close.Command}" />

                <!-- **********************************************************
                  Exit (ApplicationMenu)
                *********************************************************** -->
                <r:MenuItem
                    Header="{Binding Ribbon.Exit.Tooltip}"
                    Icon="{Binding Ribbon.Exit.LargeIcon}"
                    Command="{Binding Ribbon.Exit.Command}" />

                <!-- **********************************************************
                  Recent files
                *********************************************************** -->
                <r:ApplicationMenu.RightPaneContent>
                    <DockPanel Style="{StaticResource RibbonRecentMenuStyle}">
                        <TextBlock
                            Text="{Binding Recent.Menu.Text}"
                            Style="{StaticResource RibbonRecentTitleStyle}"
                            DockPanel.Dock="Top" />
                        <ListBox
                            ItemsSource="{Binding Recent.Items}"
                            ItemTemplate="{StaticResource RibbonRecentItemTemplate}"
                            ItemContainerStyle="{StaticResource RibbonRecentItemStyle}"
                            Template="{StaticResource RibbonRecentCollectionTemplate}">
                            <i:Interaction.Behaviors>
                                <my:SelectionBehavior
                                    Command="{Binding Recent.Open}"
                                    Popup="True" />
                            </i:Interaction.Behaviors>
                        </ListBox>
                    </DockPanel>
                </r:ApplicationMenu.RightPaneContent>
            </r:ApplicationMenu>
        </r:Ribbon.Menu>
    </r:Ribbon>
</UserControl>
