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

  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/>.

*************************************************************************** -->
<Window
    x:Class="Cube.Pdf.App.Editor.EncryptionWindow"
    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="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:xb="clr-namespace:Cube.Xui.Behaviors;assembly=Cube.Xui"
    xmlns:xc="clr-namespace:Cube.Xui.Converters;assembly=Cube.Xui"
    xmlns:my="clr-namespace:Cube.Pdf.App.Editor"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Title="{Binding Title.Text}"
    Height="520"
    Width="500"
    FontFamily="Meiryo UI"
    WindowStartupLocation="CenterOwner"
    ResizeMode="NoResize"
    ShowInTaskbar="False">

    <!-- **********************************************************************
      Resources
    *********************************************************************** -->
    <Window.Resources>
        <ResourceDictionary Source="pack://application:,,,/Themes/GenericDialog.xaml" />
    </Window.Resources>

    <!-- **********************************************************************
      Interaction
    *********************************************************************** -->
    <i:Interaction.Behaviors>
        <xb:CloseBehavior />
    </i:Interaction.Behaviors>

    <!-- **********************************************************************
      Main
    *********************************************************************** -->
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="60" />
        </Grid.RowDefinitions>

        <GroupBox Margin="12" Padding="8,12">
            <GroupBox.Header>
                <CheckBox
                    Content="{Binding Enabled.Text}"
                    IsChecked="{Binding Enabled.Value}" />
            </GroupBox.Header>

            <Grid IsEnabled="{Binding Enabled.Value}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="26" />
                    <RowDefinition Height="26" />
                    <RowDefinition Height="26" />
                    <RowDefinition Height="24" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <!-- **********************************************************
                  OwnerPassword
                *********************************************************** -->
                <TextBlock
                    Text="{Binding OwnerPassword.Text}"
                    Grid.Column="0"
                    Grid.Row="0" />
                <PasswordBox
                    Grid.Column="1"
                    Grid.Row="0">
                    <i:Interaction.Behaviors>
                        <xb:PasswordBehavior Password="{Binding OwnerPassword.Value, Mode=TwoWay}" />
                    </i:Interaction.Behaviors>
                </PasswordBox>

                <TextBlock
                    Text="{Binding OwnerConfirm.Text}"
                    Grid.Column="0"
                    Grid.Row="1" />
                <PasswordBox
                    Grid.Column="1"
                    Grid.Row="1">
                    <i:Interaction.Behaviors>
                        <xb:PasswordBehavior Password="{Binding OwnerConfirm.Value, Mode=TwoWay}" />
                    </i:Interaction.Behaviors>
                </PasswordBox>

                <!-- **********************************************************
                  EncryptionMethod
                *********************************************************** -->
                <TextBlock
                    Text="{Binding Method.Text}"
                    Grid.Column="0"
                    Grid.Row="2" />
                <ComboBox
                    ItemsSource="{Binding Methods}"
                    SelectedValue="{Binding Method.Value}"
                    Grid.Column="1"
                    Grid.Row="2">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Converter={my:EncryptionMethodConverter}}" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>

                <!-- **********************************************************
                  Operations
                *********************************************************** -->
                <TextBlock
                    Text="{Binding Operation.Text}"
                    Grid.Column="0"
                    Grid.Row="3" />

                <!-- **********************************************************
                  UserPassword
                *********************************************************** -->
                <CheckBox
                    Content="{Binding IsOpenPassword.Text}"
                    IsChecked="{Binding IsOpenPassword.Value}"
                    Grid.Column="1"
                    Grid.Row="3" />

                <Grid
                    IsEnabled="{Binding IsOpenPassword.Value}"
                    Grid.Column="1"
                    Grid.Row="4">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="100" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <Grid.RowDefinitions>
                        <RowDefinition Height="26" />
                        <RowDefinition Height="26" />
                        <RowDefinition Height="24" />
                    </Grid.RowDefinitions>

                    <TextBlock
                        Text="{Binding UserPassword.Text}"
                        Grid.Column="0"
                        Grid.Row="0" />
                    <PasswordBox
                        IsEnabled="{Binding IsSharePassword.Value, Converter={xc:Inverse}}"
                        Grid.Column="1"
                        Grid.Row="0">
                        <i:Interaction.Behaviors>
                            <xb:PasswordBehavior Password="{Binding UserPassword.Value, Mode=TwoWay}" />
                        </i:Interaction.Behaviors>
                    </PasswordBox>

                    <TextBlock
                        Text="{Binding UserConfirm.Text}"
                        Grid.Column="0"
                        Grid.Row="1" />
                    <PasswordBox
                        IsEnabled="{Binding IsSharePassword.Value, Converter={xc:Inverse}}"
                        Grid.Column="1"
                        Grid.Row="1">
                        <i:Interaction.Behaviors>
                            <xb:PasswordBehavior Password="{Binding UserConfirm.Value, Mode=TwoWay}" />
                        </i:Interaction.Behaviors>
                    </PasswordBox>

                    <CheckBox
                        Content="{Binding IsSharePassword.Text}"
                        IsChecked="{Binding IsSharePassword.Value}"
                        Grid.Column="1"
                        Grid.Row="2" />
                </Grid>

                <!-- **********************************************************
                  Permissions
                *********************************************************** -->
                <Grid
                    IsEnabled="{Binding Operation.Value}"
                    Grid.Column="1"
                    Grid.Row="5">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="24" />
                        <RowDefinition Height="24" />
                        <RowDefinition Height="24" />
                        <RowDefinition Height="24" />
                        <RowDefinition Height="24" />
                        <RowDefinition Height="24" />
                    </Grid.RowDefinitions>

                    <CheckBox
                        Content="{Binding AllowPrint.Text}"
                        IsChecked="{Binding AllowPrint.Value}"
                        Grid.Row="0" />
                    <CheckBox
                        Content="{Binding AllowCopy.Text}"
                        IsChecked="{Binding AllowCopy.Value}"
                        Grid.Row="1" />
                    <CheckBox
                        Content="{Binding AllowModify.Text}"
                        IsChecked="{Binding AllowModify.Value}"
                        Grid.Row="2" />
                    <CheckBox
                        Content="{Binding AllowAccessibility.Text}"
                        IsChecked="{Binding AllowAccessibility.Value}"
                        Grid.Row="3" />
                    <CheckBox
                        Content="{Binding AllowForm.Text}"
                        IsChecked="{Binding AllowForm.Value}"
                        Grid.Row="4" />
                    <CheckBox
                        Content="{Binding AllowAnnotation.Text}"
                        IsChecked="{Binding AllowAnnotation.Value}"
                        Grid.Row="5" />
                </Grid>
            </Grid>
        </GroupBox>

        <!-- ******************************************************************
          Buttons
        ******************************************************************* -->
        <StackPanel
            Style="{StaticResource DialogFooterStyle}"
            Grid.Row="2">
            <Button
                Content="{Binding Cancel.Text}"
                Command="{Binding Cancel.Command}"
                Style="{StaticResource CancelButtonStyle}" />
            <Button
                Content="{Binding OK.Text}"
                Command="{Binding OK.Command}"
                IsDefault="True"
                Style="{StaticResource DialogButtonStyle}" />
        </StackPanel>
    </Grid>
</Window>
