Przeglądaj źródła

compdfkit(win) - docs eidtor

liuaoran 1 rok temu
rodzic
commit
9af5f1cb10

+ 2 - 0
Demo/Examples/DocsEditor/DocsEditor.csproj

@@ -42,6 +42,8 @@
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Data" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Windows.Forms" />
     <Reference Include="System.Xml" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Core" />

+ 202 - 145
Demo/Examples/DocsEditor/MainWindow.xaml

@@ -1,13 +1,13 @@
-<Window x:Class="DocsEditControl.MainWindow"
+<Window x:Class="DocsEditor.MainWindow"
         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:cpdftools="clr-namespace:Compdfkit_Tools.PDFControl;assembly=Compdfkit_Tools"
+          xmlns:cpdftools="clr-namespace:Compdfkit_Tools.PDFControl;assembly=Compdfkit_Tools"
+        xmlns:local="clr-namespace:DocsEditor"
         xmlns:cpdfcommon="clr-namespace:Compdfkit_Tools.Common;assembly=Compdfkit_Tools"
-        xmlns:local="clr-namespace:DocsEditControl"
         mc:Ignorable="d"
-        Title="MainWindow" Height="450" Width="800">
+        Title="Docs Editor_ComPDFKit V1.9.1" Height="450" Width="800">
     <Window.Resources>
         <ResourceDictionary>
             <ResourceDictionary.MergedDictionaries>
@@ -15,25 +15,73 @@
                 <ResourceDictionary Source="pack://application:,,,/Compdfkit_Tools;component/Asset/Styles/ButtonStyle.xaml"></ResourceDictionary>
                 <ResourceDictionary Source="pack://application:,,,/Compdfkit_Tools;component/Asset/Styles/ComboBoxStyle.xaml"></ResourceDictionary>
             </ResourceDictionary.MergedDictionaries>
+            <!-- Shortcut -->
+            <RoutedUICommand x:Key="Open" Text="Open"/>
+            <RoutedUICommand x:Key="Save" Text="Right rotate"/>
+            <RoutedUICommand x:Key="SaveAs" Text="Delete"/>
+            <RoutedUICommand x:Key="ControlLeftPanel" Text="Control left panel"/>
+            <RoutedUICommand x:Key="ControlRightPanel" Text="Control right panel"/>
+            <RoutedUICommand x:Key="GoToBookmark" Text="Go to bookmark"></RoutedUICommand>
+            <RoutedUICommand x:Key="GoToOutline" Text="Go to outline"></RoutedUICommand>
+            <RoutedUICommand x:Key="GoToThumbnail" Text="Go to thumbnail"></RoutedUICommand>
+            <RoutedUICommand x:Key="GoToSearch" Text="Go to search"></RoutedUICommand>
+            <RoutedUICommand x:Key="ScaleAdd" Text="Scale add"></RoutedUICommand>
+            <RoutedUICommand x:Key="ScaleSubtract" Text="Scale reduce"></RoutedUICommand>
+            <RoutedUICommand x:Key="DisplaySettings" Text="Display settings"></RoutedUICommand>
+            <RoutedUICommand x:Key="DocumentInfo" Text="Document infomation"></RoutedUICommand>
         </ResourceDictionary>
     </Window.Resources>
+
+
+    <Window.CommandBindings>
+        <CommandBinding Command="{StaticResource Open}" Executed="CommandBinding_Executed_Open"/>
+        <CommandBinding Command="{StaticResource Save}" Executed="CommandBinding_Executed_Save"/>
+        <CommandBinding Command="{StaticResource SaveAs}" Executed="CommandBinding_Executed_SaveAs"/>
+        <CommandBinding Command="{StaticResource ControlLeftPanel}" Executed="CommandBinding_Executed_ControlLeftPanel"></CommandBinding>
+        <CommandBinding Command="{StaticResource ControlRightPanel}" Executed="CommandBinding_Executed_ControlRightPanel"></CommandBinding>
+        <CommandBinding Command="{StaticResource GoToBookmark}" Executed="CommandBinding_Executed_Bookmark"></CommandBinding>
+        <CommandBinding Command="{StaticResource GoToOutline}" Executed="CommandBinding_Executed_Outline"></CommandBinding>
+        <CommandBinding Command="{StaticResource GoToThumbnail}" Executed="CommandBinding_Executed_Thumbnail"></CommandBinding>
+        <CommandBinding Command="{StaticResource GoToSearch}" Executed="CommandBinding_Executed_Search"></CommandBinding>
+        <CommandBinding Command="{StaticResource ScaleAdd}" Executed="CommandBinding_Executed_ScaleAdd"></CommandBinding>
+        <CommandBinding Command="{StaticResource ScaleSubtract}" Executed="CommandBinding_Executed_ScaleSubtract"></CommandBinding>
+        <CommandBinding Command="{StaticResource DisplaySettings}" Executed="CommandBinding_Executed_DisplaySettings"></CommandBinding>
+        <CommandBinding Command="{StaticResource DocumentInfo}" Executed="CommandBinding_Executed_DocumentInfo"></CommandBinding>
+    </Window.CommandBindings>
+
+    <Window.InputBindings>
+        <KeyBinding Key="O" Modifiers="Control" Command="{StaticResource Open}"/>
+        <KeyBinding Key="S" Modifiers="Control" Command="{StaticResource Save}"/>
+        <KeyBinding Key="S" Modifiers="Control+Shift" Command="{StaticResource SaveAs}"/>
+        <KeyBinding Key="F4" Command="{StaticResource ControlLeftPanel}"/>
+        <KeyBinding Key="F4" Modifiers="Control" Command="{StaticResource ControlRightPanel}"/>
+        <KeyBinding Key="B" Modifiers="Control" Command="{StaticResource GoToBookmark}"></KeyBinding>
+        <KeyBinding Key="O" Modifiers="Control+Shift" Command="{StaticResource GoToOutline}"></KeyBinding>
+        <KeyBinding Key="T" Modifiers="Control" Command="{StaticResource GoToThumbnail}"></KeyBinding>
+        <KeyBinding Key="F" Modifiers="Control" Command="{StaticResource GoToSearch}"></KeyBinding>
+        <KeyBinding Key="Add" Modifiers="Control" Command="{StaticResource ScaleAdd}"></KeyBinding>
+        <KeyBinding Key="Subtract" Modifiers="Control" Command="{StaticResource ScaleSubtract}"></KeyBinding>
+        <KeyBinding Key="D" Modifiers="Control" Command="{StaticResource DisplaySettings}"></KeyBinding>
+        <KeyBinding Key="I" Modifiers="Control" Command="{StaticResource DocumentInfo}"></KeyBinding>
+    </Window.InputBindings>
+
     <Grid>
         <Grid>
+            <Grid.RowDefinitions>
+                <RowDefinition Height="40"></RowDefinition>
+                <RowDefinition Height="*"></RowDefinition>
+            </Grid.RowDefinitions>
             <Grid>
-                <Grid.RowDefinitions>
-                    <RowDefinition Height="40"></RowDefinition>
-                    <RowDefinition Height="*"></RowDefinition>
-                </Grid.RowDefinitions>
-                <Border Height="1" Background="LightGray" VerticalAlignment="Bottom"/>
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="auto"></ColumnDefinition>
+                    <ColumnDefinition Width="*"></ColumnDefinition>
+                    <ColumnDefinition Width="auto"></ColumnDefinition>
+                </Grid.ColumnDefinitions>
+                <Border Height="1" Background="LightGray" VerticalAlignment="Bottom" Grid.ColumnSpan="3"/>
                 <Grid>
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition Width="auto"></ColumnDefinition>
-                        <ColumnDefinition Width="*"></ColumnDefinition>
-                        <ColumnDefinition Width="auto"></ColumnDefinition>
-                    </Grid.ColumnDefinitions>
-
-                    <StackPanel Orientation="Horizontal" Height="40" Margin="20,0,0,0">
-                        <Button BorderThickness="0" VerticalContentAlignment="Center" Width="30" Height="30" Style="{StaticResource LightButtonStyle}" Background="Transparent">
+                    <StackPanel Orientation="Horizontal" Margin="20,0,0,0">
+
+                        <Button BorderThickness="0" VerticalContentAlignment="Center" Width="30" Height="30" Style="{StaticResource LightButtonStyle}" Background="Transparent" Click="OpenFile_Click">
                             <Button.Content>
                                 <Viewbox Width="20" Height="20">
                                     <Path Fill="#43474D" >
@@ -63,10 +111,22 @@
                         </Button>
 
                         <Button BorderThickness="0" VerticalContentAlignment="Center" Margin="10,0,0,0" Width="30" Height="30" Style="{StaticResource LightButtonStyle}" Background="Transparent" 
-                             IsEnabled="{Binding CanSave,Mode=OneWay}">
+                            Click="SaveFileBtn_Click" IsEnabled="{Binding CanSave,Mode=OneWay}">
                             <Button.Content>
                                 <Viewbox Width="20" Height="20">
-                                    <Path Fill="#43474D" >
+                                    <Path IsEnabled="{Binding CanSave,Mode=OneWay}">
+                                        <Path.Style>
+                                            <Style TargetType="Path">
+                                                <Style.Triggers>
+                                                    <Trigger Property="IsEnabled" Value="False">
+                                                        <Setter Property="Fill" Value="LightGray"/>
+                                                    </Trigger>
+                                                    <Trigger Property="IsEnabled" Value="True">
+                                                        <Setter Property="Fill" Value="#43474D"/>
+                                                    </Trigger>
+                                                </Style.Triggers>
+                                            </Style>
+                                        </Path.Style>
                                         <Path.Data>
                                             M11.707107,1 L15,4.29289322 L15,15 L1,15 L1,1 L11.707107,1 Z M11.293,2 L2,2 L2,14 L4,14 L4,8 L12,8 L12,14 L14,14 L14,4.707 L11.293,2 Z 
                                         M11,9 L5,9 L5,14 L11,14 L11,9 Z M7,5 L7,6 L4,6 L4,5 L7,5 Z
@@ -78,7 +138,8 @@
                                 <ToolTip Content="Save"></ToolTip>
                             </Button.ToolTip>
                         </Button>
-                        <ToggleButton Name="LeftToolPanelButton" Margin="13,0,0,0" BorderThickness="0" Width="30" Height="30" Style="{StaticResource ToggleButtonStyle}" Background="Transparent">
+
+                        <ToggleButton Name="LeftToolPanelButton" Margin="13,0,0,0" BorderThickness="0" Width="30" Height="30" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Click="LeftToolPanelButton_Click">
                             <ToggleButton.Content>
                                 <Path Fill="#43474D" Width="30" Height="30">
                                     <Path.Data>
@@ -93,155 +154,151 @@
 
                         <Line Margin="13,0,13,0" Stroke="#E0E0E0" X1="0" Y1="5" X2="0" Y2="35"></Line>
 
-                        <ToggleButton BorderThickness="0" Width="30" Height="30" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" IsChecked="True" IsEnabled="False" Visibility="Collapsed">
-                            <ToggleButton.Content>
-                                <Path Fill="#43474D">
-                                    <Path.Data>
-                                        M8.7463 7.94055L8.43134 3.20358C8.38986 2.6073 8.82031 2.08322 9.40947 2.01273L9.46546 2.00656C9.75502 1.97416 10.0451 2.06271 10.2681 2.25159C10.4911 
-                                2.44047 10.6276 2.71317 10.6457 3.00614L10.9886 8.17061C10.999 8.31659 11.1097 8.43516 11.2537 8.45444C11.3176 8.46288 11.382 8.44409 11.4315 
-                                8.40258C11.481 8.36108 11.5111 8.30063 11.5145 8.23584L11.7612 3.47595C11.7918 2.85998 12.3116 2.38523 12.923 2.41468H12.9309C13.5429 2.44972 
-                                14.0111 2.97745 13.9773 3.59407L13.7218 8.51438C13.7137 8.66679 13.8235 8.79975 13.9738 8.81936C14.1225 8.83876 14.2625 8.73915 14.2914 
-                                8.59018L14.8006 6.02337C14.9178 5.41517 15.497 5.01851 16.0954 5.13574L16.1041 5.13751C16.7058 5.25854 17.0969 5.84695 16.979 6.45353L16.3684 
-                                9.53687C15.8189 13.3474 15.0586 15.5052 14.3946 16.4246C13.3649 17.8508 11.5573 17.8667 10.1251 17.8667C8.69381 17.8667 7.16012 17.5291 6.44796 
-                                16.9993C5.73492 16.4696 4.77079 15.2575 4.15837 13.9327L4.16712 13.9283C4.11876 13.8639 4.0774 13.7945 4.04376 13.7212L3.105 11.685C2.84552 11.1243 
-                                3.08338 10.4577 3.63781 10.1918L3.64656 10.1874C3.91235 10.0626 4.21656 10.0497 4.49179 10.1517C4.76702 10.2536 4.99055 10.4619 5.11287 10.7304C5.62206 
-                                11.8234 5.94227 12.324 6.07526 12.2324C6.27386 12.0949 6.12075 11.7176 5.85478 9.21249C5.67578 7.53039 5.45319 5.85328 5.18724 4.18289C5.07653 3.5968 
-                                5.44002 3.02581 6.01489 2.88273L6.07526 2.86775C6.35866 2.79957 6.65742 2.85178 6.90147 3.01215C7.14552 3.17252 7.3134 3.42693 7.36572 3.71571L8.168 
-                                8.02341C8.19642 8.17613 8.33897 8.27937 8.49171 8.25787C8.64561 8.23564 8.75656 8.09774 8.7463 7.94143V7.94055Z
-                                    </Path.Data>
-                                </Path>
-                            </ToggleButton.Content>
-                        </ToggleButton>
-
-                        <Line Margin="13,0,13,0" Stroke="#E0E0E0" X1="0" Y1="5" X2="0" Y2="35"></Line>
                         <cpdftools:CPDFScalingControl x:Name="CPDFSaclingControl"></cpdftools:CPDFScalingControl>
+
                     </StackPanel>
+                </Grid>
 
-                    <ComboBox Width="120" Height="26" Grid.Column="1" HorizontalAlignment="Center" FontSize="14" Foreground="#001A4E">
-                        <ComboBoxItem IsSelected="True">Viewer</ComboBoxItem>
-                    </ComboBox>
+                <ComboBox Name="ViewComboBox" Width="120" Height="26" Grid.Column="1" HorizontalAlignment="Center" FontSize="14" Foreground="#001A4E"
+                         Style="{StaticResource ComboBoxStyle1}" SelectionChanged="ViewComboBox_SelectionChanged">
+                    <ComboBoxItem>Viewer</ComboBoxItem>
+                    <ComboBoxItem  IsSelected="True">Page Edit</ComboBoxItem>
+                </ComboBox>
+                <StackPanel Orientation="Horizontal" Grid.Column="2">
 
-                    <StackPanel Orientation="Horizontal" Grid.Column="2">
-                        <Button BorderThickness="0" Width="40" Height="40" Style="{StaticResource LightButtonStyle}" Background="Transparent">
-                            <Button.Content>
-                                <Path Fill="#43474D">
-                                    <Path.Data>
-                                        M5.10992 13.9353C2.71184 11.5372 2.71184 7.64917 5.10992 5.25108C7.50801 2.853 11.3961 2.853 13.7942 5.25108C16.1922 7.64917 
+                    <Button x:Name="SearchButton" BorderThickness="0" Width="40" Height="40" Style="{StaticResource LightButtonStyle}" Background="Transparent" Focusable="False" Click="ExpandSearchBtn_Click">
+                        <Button.Content>
+                            <Path Fill="#43474D">
+                                <Path.Data>
+                                    M5.10992 13.9353C2.71184 11.5372 2.71184 7.64917 5.10992 5.25108C7.50801 2.853 11.3961 2.853 13.7942 5.25108C16.1922 7.64917 
                                 16.1922 11.5372 13.7942 13.9353C11.3961 16.3334 7.50801 16.3334 5.10992 13.9353ZM4.04926 4.19042C1.06539 7.17429 1.06539 12.0121 
                                 4.04926 14.996C6.85422 17.8009 11.2975 17.9691 14.2989 15.5005L17.1989 18.4006C17.4918 18.6935 17.9667 18.6935 18.2596 
                                 18.4006C18.5525 18.1077 18.5525 17.6328 18.2596 17.3399L15.3595 14.4399C17.828 11.4384 17.6597 6.99533 14.8548 
                                 4.19042C11.8709 1.20655 7.03313 1.20655 4.04926 4.19042Z
-                                    </Path.Data>
-                                </Path>
-                            </Button.Content>
-                            <Button.ToolTip>
-                                <ToolTip Content="Search"></ToolTip>
-                            </Button.ToolTip>
-                        </Button>
+                                </Path.Data>
+                            </Path>
+                        </Button.Content>
+                        <Button.ToolTip>
+                            <ToolTip Content="Search"></ToolTip>
+                        </Button.ToolTip>
+                    </Button>
 
-                        <ToggleButton Name="ViewSettingBtn" BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}" Background="Transparent">
-                            <ToggleButton.Content>
-                                <Path Stroke="#43474D" VerticalAlignment="Center" StrokeThickness="2">
-                                    <Path.Data>
-                                        <CombinedGeometry GeometryCombineMode="Exclude">
-                                            <CombinedGeometry.Geometry1>
-                                                M18.3327 10C18.3327 10 14.6017 16.25 9.99935 16.25C5.39698 16.25 1.66602 10 1.66602 10C1.66602 10 5.39698 3.75 9.99935 3.75C14.6017 3.75 18.3327 10 18.3327 10Z
-                                            </CombinedGeometry.Geometry1>
-                                            <CombinedGeometry.Geometry2>
-                                                <EllipseGeometry Center="10,10" RadiusX="2" RadiusY="2"/>
-                                            </CombinedGeometry.Geometry2>
-                                        </CombinedGeometry>
-                                    </Path.Data>
-                                </Path>
-                            </ToggleButton.Content>
-                            <ToggleButton.ToolTip>
-                                <ToolTip Content="Page Display"></ToolTip>
-                            </ToggleButton.ToolTip>
-                        </ToggleButton>
+                    <ToggleButton BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Visibility="Collapsed">
+                        <ToggleButton.Content>
+                            <Path Fill="#43474D" Width="30" Height="30">
+                                <Path.Data>
+                                    M22.5 8.5H7.5V12.25H13H22.5V8.5ZM12.25 13.75H7.5V21.5H12.25V13.75ZM13.75 21.5V13.75H22.5V21.5H13.75ZM7.5 7H6V8.5V21.5V23H7.5H22.5H24V21.5V8.5V7H22.5H7.5Z
+                                </Path.Data>
+                            </Path>
+                        </ToggleButton.Content>
+                    </ToggleButton>
 
-                        <Button BorderThickness="0" Width="40" Height="40" Style="{StaticResource LightButtonStyle}" Background="Transparent">
-                            <Button.Content>
-                                <Path Fill="#43474D" VerticalAlignment="Center">
-                                    <Path.Data>
-                                        M2.75 10C2.75 5.99594 5.99594 2.75 10 2.75C14.0041 2.75 17.25 5.99594 17.25 10C17.25 14.0041 14.0041 17.25 10 
+                    <ToggleButton  x:Name="RightPanelButton" BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Click="RightPanelButton_Click">
+                        <ToggleButton.Content>
+                            <Path Fill="#43474D" Width="30" Height="30">
+                                <Path.Data>
+                                    M22.5 8.5H7.5V12.25H13H22.5V8.5ZM12.25 13.75H7.5V21.5H12.25V13.75ZM13.75 21.5V13.75H22.5V21.5H13.75ZM7.5 7H6V8.5V21.5V23H7.5H22.5H24V21.5V8.5V7H22.5H7.5Z
+                                </Path.Data>
+                            </Path>
+                        </ToggleButton.Content>
+                        <ToggleButton.ToolTip>
+                            <ToolTip Content="Properties"></ToolTip>
+                        </ToggleButton.ToolTip>
+                    </ToggleButton>
+
+                    <ToggleButton  Name="ViewSettingBtn" BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Click="ViewSettingBtn_Click">
+                        <ToggleButton.Content>
+                            <Path Stroke="#43474D" VerticalAlignment="Center" StrokeThickness="2">
+                                <Path.Data>
+                                    <CombinedGeometry GeometryCombineMode="Exclude">
+                                        <CombinedGeometry.Geometry1>
+                                            M18.3327 10C18.3327 10 14.6017 16.25 9.99935 16.25C5.39698 16.25 1.66602 10 1.66602 10C1.66602 10 5.39698 3.75 9.99935 3.75C14.6017 3.75 18.3327 10 18.3327 10Z
+                                        </CombinedGeometry.Geometry1>
+                                        <CombinedGeometry.Geometry2>
+                                            <EllipseGeometry Center="10,10" RadiusX="2" RadiusY="2"/>
+                                        </CombinedGeometry.Geometry2>
+                                    </CombinedGeometry>
+                                </Path.Data>
+                            </Path>
+                        </ToggleButton.Content>
+                        <ToggleButton.ToolTip>
+                            <ToolTip Content="Page Display"></ToolTip>
+                        </ToggleButton.ToolTip>
+                    </ToggleButton>
+
+                    <Button BorderThickness="0" Width="40" Height="40" Style="{StaticResource LightButtonStyle}" Background="Transparent"  Click="PageInfoBtn_Click">
+                        <Button.Content>
+                            <Path Fill="#43474D" VerticalAlignment="Center">
+                                <Path.Data>
+                                    M2.75 10C2.75 5.99594 5.99594 2.75 10 2.75C14.0041 2.75 17.25 5.99594 17.25 10C17.25 14.0041 14.0041 17.25 10 
                                 17.25C5.99594 17.25 2.75 14.0041 2.75 10ZM10 1.25C5.16751 1.25 1.25 5.16751 1.25 10C1.25 14.8325 5.16751 
                                 18.75 10 18.75C14.8325 18.75 18.75 14.8325 18.75 10C18.75 5.16751 14.8325 1.25 10 1.25ZM6.5 11C7.05228 11 
                                 7.5 10.5523 7.5 10C7.5 9.44771 7.05228 9 6.5 9C5.94772 9 5.5 9.44771 5.5 10C5.5 10.5523 5.94772 11 6.5 11ZM10 
                                 11C10.5523 11 11 10.5523 11 10C11 9.44771 10.5523 9 10 9C9.44771 9 9 9.44771 9 10C9 10.5523 9.44771 11 10 11ZM14.5 
                                 10C14.5 10.5523 14.0523 11 13.5 11C12.9477 11 12.5 10.5523 12.5 10C12.5 9.44771 12.9477 9 13.5 9C14.0523 9 14.5 9.44771 14.5 10Z
-                                    </Path.Data>
-                                </Path>
-                            </Button.Content>
-                            <Button.ToolTip>
-                                <ToolTip Content="Document Info"></ToolTip>
-                            </Button.ToolTip>
-                        </Button>
-                    </StackPanel>
-                </Grid>
-                <Grid Name="BodyGrid" Grid.Row="1">
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition Width="0"></ColumnDefinition>
-                        <ColumnDefinition Width="0"></ColumnDefinition>
-                        <ColumnDefinition Width="*"></ColumnDefinition>
-                        <ColumnDefinition Width="auto"></ColumnDefinition>
-                    </Grid.ColumnDefinitions>
-
-                    <cpdftools:CPDFBOTABarControl Visibility="Collapsed" Name="BotaSideTool"/>
-
-                    <GridSplitter Name="Splitter" Grid.Column="1" Width="15" ResizeBehavior="PreviousAndNext" Visibility="Collapsed">
-                        <GridSplitter.Template>
-                            <ControlTemplate TargetType="{x:Type GridSplitter}">
-                                <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
-                        BorderBrush="{TemplateBinding Border.BorderBrush}"
-                        Background="{TemplateBinding Panel.Background}" >
-                                    <Path Fill="Gray" VerticalAlignment="Center">
-                                        <Path.Data>
-                                            M15 3.75H1V2.25H15V3.75ZM15 8.75H1V7.25H15V8.75ZM1 13.75H15V12.25H1V13.75Z
-                                        </Path.Data>
-                                    </Path>
-                                </Border>
-                            </ControlTemplate>
-                        </GridSplitter.Template>
-                    </GridSplitter>
-
-                    <Grid Grid.Column="2" >
-                        <Border x:Name="PDFGrid" Background="#CECECE"></Border>
-                    </Grid>
-
-                    <Border Name="PropertyContainer" Grid.Column="3" Visibility="Hidden"></Border>
-                </Grid>
+                                </Path.Data>
+                            </Path>
+                        </Button.Content>
+                        <Button.ToolTip>
+                            <ToolTip Content="Document Info"></ToolTip>
+                        </Button.ToolTip>
+                    </Button>
+                </StackPanel>
             </Grid>
+            <Grid Name="BodyGrid" Grid.Row="1">
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="0"></ColumnDefinition>
+                    <ColumnDefinition Width="0"></ColumnDefinition>
+                    <ColumnDefinition Width="*"></ColumnDefinition>
+                    <ColumnDefinition Width="auto"></ColumnDefinition>
+                </Grid.ColumnDefinitions>
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="auto"/>
+                    <RowDefinition Height="*"/>
+                </Grid.RowDefinitions>
 
-            <Border Name="PopupBorder" Background="#A0000000" Visibility="Collapsed">
-                <Grid>
+                <cpdftools:CPDFBOTABarControl Grid.Row="1" Visibility="Collapsed" Name="BotaSideTool"/>
 
-                    <Grid Name="FileInfoUI"  Width="422" Height="680" HorizontalAlignment="Center" VerticalAlignment="Center" Background="White" Visibility="Collapsed">
-                        <Grid.ColumnDefinitions>
-                            <ColumnDefinition Width="*"></ColumnDefinition>
-                            <ColumnDefinition Width="*"></ColumnDefinition>
-                        </Grid.ColumnDefinitions>
-                        <Grid.RowDefinitions>
-                            <RowDefinition Height="auto"></RowDefinition>
-                            <RowDefinition Height="*"></RowDefinition>
-                        </Grid.RowDefinitions>
-
-                        <TextBlock Height="20" FontSize="14" LineHeight="16" Margin="12,6,0,0" HorizontalAlignment="Left">Document Info:</TextBlock>
-                        <Button Grid.Column="1" Width="16" Height="16" HorizontalAlignment="Right" Margin="0,8,8,0" BorderThickness="0">
-                            <Button.Content>
-                                <Path Fill="Black">
+                <GridSplitter Name="Splitter" Grid.Row="1" Grid.Column="1" Width="15" ResizeBehavior="PreviousAndNext" Visibility="Collapsed">
+                    <GridSplitter.Template>
+                        <ControlTemplate TargetType="{x:Type GridSplitter}">
+                            <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
+                        BorderBrush="{TemplateBinding Border.BorderBrush}"
+                        Background="{TemplateBinding Panel.Background}" >
+                                <Path Fill="Gray" VerticalAlignment="Center">
                                     <Path.Data>
-                                        M6.69495 6L11.5 1.19495L10.805 0.5L6 5.30505L1.19495 0.5L0.5 1.19495L5.30505 6L0.5 10.805L1.19495 11.5L6 6.69495L10.805 11.5L11.5 10.805L6.69495 6Z
+                                        M15 3.75H1V2.25H15V3.75ZM15 8.75H1V7.25H15V8.75ZM1 13.75H15V12.25H1V13.75Z
                                     </Path.Data>
                                 </Path>
-                            </Button.Content>
-                        </Button>
-                        <cpdftools:CPDFInfoControl Grid.Row="1" Margin="25,10,25,0" Grid.ColumnSpan="2" Name="FileInfoControl"></cpdftools:CPDFInfoControl>
-                    </Grid>
+                            </Border>
+                        </ControlTemplate>
+                    </GridSplitter.Template>
+                </GridSplitter>
+
+                <Grid Grid.Column="2" Grid.Row="1" >
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="auto"></RowDefinition>
+                        <RowDefinition Height="*"></RowDefinition>
+                    </Grid.RowDefinitions>
+                    <Border Grid.Row="1" x:Name="PDFGrid" Background="#CECECE" Grid.ColumnSpan="2"></Border>
+                    <Border x:Name="ToolBarContainer" Height="45" Visibility="Collapsed"  BorderThickness="1" BorderBrush="#1A000000" Background="#F2F3F5" Grid.ColumnSpan="2">
+                        <cpdftools:CPDFPageEditBarControl x:Name="CPDFPageEditBarControl" Grid.ColumnSpan="4" Height="44"/>
+                    </Border>
 
-                    <cpdfcommon:PasswordDialog x:Name="PasswordUI" Visibility="Collapsed"></cpdfcommon:PasswordDialog>
+                    <cpdfcommon:PageNumberControl Grid.Row="1" Name="FloatPageTool" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,20" Grid.Column="1"></cpdfcommon:PageNumberControl>
+                    <Border Name="PopupBorder" Background="#A0000000" Visibility="Collapsed"  Grid.Row="1">
+                        <Grid>
+                            <cpdftools:CPDFInfoControl x:Name="CPDFInfoControl" Visibility="Collapsed"></cpdftools:CPDFInfoControl>
+
+                            <cpdfcommon:PasswordDialog x:Name="PasswordUI" Visibility="Collapsed"/>
+                        </Grid>
+
+                    </Border>
                 </Grid>
 
-            </Border>
+                <Border Grid.Row="1" Name="PropertyContainer" Grid.Column="3" Visibility="Hidden"></Border>
+            </Grid>
+
         </Grid>
     </Grid>
 </Window>

+ 775 - 76
Demo/Examples/DocsEditor/MainWindow.xaml.cs

@@ -1,118 +1,364 @@
 using Compdfkit_Tools.Helper;
 using Compdfkit_Tools.PDFControl;
-using ComPDFKitViewer.PdfViewer;
+using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer;
 using System;
 using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Text;
-using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
 using System.Windows.Input;
-using System.Windows.Media;
 using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
+using System.Diagnostics;
+using System.IO;
+using System.Drawing;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+using ComPDFKit.PDFDocument;
+using Microsoft.Win32;
+using System.Windows.Controls.Primitives;
+using ComPDFKitViewer.PdfViewer; 
 
-namespace DocsEditControl
+namespace DocsEditor
 {
     public partial class MainWindow : Window, INotifyPropertyChanged
     {
-        private PDFViewControl pdfViewer;
+        #region Property
+        private bool isFirstLoad = true;
+        private string currentMode = "Page Edit";
+
         private PDFViewControl passwordViewer;
-        private PageEditControl pageEditControl = new PageEditControl();
-        private CPDFBOTABarControl botaBarControl = new CPDFBOTABarControl(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search | BOTATools.Annotation);
+        private PDFViewControl pdfViewControl;
+        private CPDFAnnotationControl pdfAnnotationControl = null;
+        private CPDFSearchControl searchControl = null;
+        private CPDFPageEditControl pageEditControl = null;
+        private CPDFDisplaySettingsControl displayPanel = new CPDFDisplaySettingsControl();
+        private double[] zoomLevelList = { 1f, 8f, 12f, 25, 33f, 50, 66f, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
 
-        public bool CanUndo
+        public bool CanSave
         {
             get
             {
-                if (pdfViewer != null && pdfViewer.PDFView != null)
+                if (pdfViewControl != null && pdfViewControl.PDFView != null)
                 {
-                    return pdfViewer.PDFView.UndoManager.CanUndo;
+                    return pdfViewControl.PDFView.UndoManager.CanSave;
                 }
                 return false;
             }
         }
 
-        public bool CanRedo
-        {
-            get
-            {
-                if (pdfViewer != null && pdfViewer.PDFView != null)
-                {
-                    return pdfViewer.PDFView.UndoManager.CanRedo;
-                }
+        public event PropertyChangedEventHandler PropertyChanged;
 
-                return false;
-            }
-        }
+        #endregion
 
-        private bool _canSave = false;
-        public bool CanSave
-        {
-            get => _canSave;
-            set
-            {
-                _canSave = value;
-                OnPropertyChanged();
-            }
-        }
-          
         public MainWindow()
         {
             InitializeComponent();
+            Loaded += MainWindow_Loaded;
+            DataContext = this;
+        }
+
+        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
+        {
+            BotaSideTool.AddBOTAContent(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search);
+            pdfAnnotationControl = new CPDFAnnotationControl();
             LoadDefaultDocument();
         }
 
         #region Load document
+
         private void LoadDefaultDocument()
         {
             string defaultFilePath = "PDF32000_2008.pdf";
-            pdfViewer = new PDFViewControl();
-            pdfViewer.PDFView.InitDocument(defaultFilePath);
+            LeftToolPanelButton.IsEnabled = false;
+            SearchButton.IsEnabled = false;
+            RightPanelButton.IsEnabled = false;
+            ViewSettingBtn.IsEnabled = false;
+            pdfViewControl = new PDFViewControl();
+            pdfViewControl.PDFView.InitDocument(defaultFilePath);
             LoadDocument();
         }
 
         private void LoadDocument()
         {
-            pdfViewer.PDFView.Load();
-            pdfViewer.PDFView.SetShowLink(true);
-
-            pdfViewer.PDFView.InfoChanged -= PdfViewer_InfoChanged;
-            pdfViewer.PDFView.InfoChanged += PdfViewer_InfoChanged;
-            PDFGrid.Child = pageEditControl;
-
-            pageEditControl.PDFViewControl = pdfViewer;
-
-            pageEditControl.OnAnnotEditHandler -= PageEditControlRefreshAnnotList;
-            pageEditControl.OnAnnotEditHandler += PageEditControlRefreshAnnotList;
+            if (pdfViewControl.PDFView.Document == null)
+            {
+                return;
+            }
+            pdfViewControl.PDFView?.SetMouseMode(MouseModes.Viewer);
+            pdfViewControl.PDFView?.Load();
+            pdfViewControl.PDFView?.SetShowLink(true);
+            if (ViewComboBox.SelectedIndex == 0)
+            {
+                PDFGrid.Child = pdfViewControl;
+            }
+            else
+            {
+                ToolBarContainer.Visibility = Visibility.Visible;
+                if (pageEditControl == null)
+                {
+                    pageEditControl = new CPDFPageEditControl();
+                }
+                pageEditControl.ExitPageEdit -= PageEditControl_ExitPageEdit;
+                pageEditControl.ExitPageEdit += PageEditControl_ExitPageEdit;
 
-            pageEditControl.PageMoved -= PageEditControl_PageMoved;
-            pageEditControl.PageMoved += PageEditControl_PageMoved;
+                pageEditControl.PageMoved -= PageEditControl_PageMoved;
+                pageEditControl.PageMoved += PageEditControl_PageMoved;
 
+                CPDFPageEditBarControl.PageEditEvent -= CPDFPageEditBarControl_PageEditEvent;
+                CPDFPageEditBarControl.PageEditEvent += CPDFPageEditBarControl_PageEditEvent;
+                pageEditControl.LoadThumbnails(pdfViewControl.PDFView);
+                PDFGrid.Child = pageEditControl;
+                FloatPageTool.Visibility = Visibility.Collapsed;
+            }
+            pdfViewControl.PDFView.InfoChanged -= PdfViewer_InfoChanged;
+            pdfViewControl.PDFView.InfoChanged += PdfViewer_InfoChanged;
+            pdfViewControl.PDFView.AnnotCommandHandler -= PDFView_AnnotCommandHandler;
+            pdfViewControl.PDFView.AnnotCommandHandler += PDFView_AnnotCommandHandler;
+            pdfViewControl.PDFView.UndoManager.PropertyChanged -= UndoManager_PropertyChanged;
+            pdfViewControl.PDFView.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
+            pdfViewControl.PDFView.SetFormFieldHighlight(true);
             PasswordUI.Closed -= PasswordUI_Closed;
             PasswordUI.Canceled -= PasswordUI_Canceled;
             PasswordUI.Confirmed -= PasswordUI_Confirmed;
             PasswordUI.Closed += PasswordUI_Closed;
             PasswordUI.Canceled += PasswordUI_Canceled;
             PasswordUI.Confirmed += PasswordUI_Confirmed;
-             
-            CPDFSaclingControl.InitWithPDFViewer(pdfViewer.PDFView);
-            CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.PDFView.ZoomFactor * 100)));
+
+            pdfViewControl.PDFView.ChangeFitMode(FitMode.FitWidth);
+            CPDFSaclingControl.InitWithPDFViewer(pdfViewControl.PDFView);
+            CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)));
 
             ViewSettingBtn.IsChecked = false;
-            botaBarControl.InitWithPDFViewer(pdfViewer.PDFView);
-            botaBarControl.SelectBotaTool(BOTATools.Thumbnail); 
+            PropertyContainer.Child = null;
+            PropertyContainer.Visibility = Visibility.Collapsed;
+            FloatPageTool.InitWithPDFViewer(pdfViewControl.PDFView);
+            BotaSideTool.InitWithPDFViewer(pdfViewControl.PDFView);
+            BotaSideTool.SelectBotaTool(BOTATools.Thumbnail);
+        }
+
+        #endregion
+
+        #region Context menu
+
+        private void PDFView_AnnotCommandHandler(object sender, AnnotCommandArgs e)
+        {
+            if (e != null && e.CommandType == CommandType.Context)
+            {
+                if (e.PressOnSelectedText)
+                {
+                    e.Handle = true;
+                    e.PopupMenu = new ContextMenu();
+                    e.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
+                }
+                else if (e.CommandTarget == TargetType.ImageSelection)
+                {
+                    if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.GetSelectImageCount() > 0)
+                    {
+                        e.Handle = true;
+                        e.PopupMenu = new ContextMenu();
+
+                        MenuItem imageCopyMenu = new MenuItem();
+                        imageCopyMenu = new MenuItem();
+                        imageCopyMenu.Header = "Copy Images";
+                        WeakEventManager<MenuItem, RoutedEventArgs>.AddHandler(imageCopyMenu, "Click", CopyImage_Click);
+                        imageCopyMenu.CommandParameter = e;
+                        e.PopupMenu.Items.Add(imageCopyMenu);
+
+                        MenuItem imageExtraMenu = new MenuItem();
+                        imageExtraMenu = new MenuItem();
+                        imageExtraMenu.Header = "Extract Images";
+                        WeakEventManager<MenuItem, RoutedEventArgs>.AddHandler(imageExtraMenu, "Click", ExtraImage_Click);
+                        imageExtraMenu.CommandParameter = e;
+                        e.PopupMenu.Items.Add(imageExtraMenu);
+                    }
+                }
+                else if (e.CommandTarget == TargetType.WidgetView)
+                {
+                    e.Handle = true;
+                    e.PopupMenu = new ContextMenu();
+                    e.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
+                    e.PopupMenu.Items.Add(new MenuItem() { Header = "Cut", Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
+                    e.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
+                }
+                else
+                {
+                    e.Handle = true;
+                    e.PopupMenu = new ContextMenu();
+
+                    e.PopupMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
+                    e.PopupMenu.Items.Add(new Separator());
+
+                    MenuItem fitWidthMenu = new MenuItem();
+                    fitWidthMenu.Header = "Automatically Resize";
+                    fitWidthMenu.Click += (o, p) =>
+                    {
+                        if (pdfViewControl != null)
+                        {
+                            pdfViewControl.PDFView?.ChangeFitMode(FitMode.FitWidth);
+                        }
+                    };
+
+                    e.PopupMenu.Items.Add(fitWidthMenu);
+
+                    MenuItem fitSizeMenu = new MenuItem();
+                    fitSizeMenu.Header = "Actual Size";
+                    fitSizeMenu.Click += (o, p) =>
+                    {
+                        if (pdfViewControl != null)
+                        {
+                            pdfViewControl.PDFView?.ChangeFitMode(FitMode.FitSize);
+                        }
+                    };
+
+                    e.PopupMenu.Items.Add(fitSizeMenu);
+
+                    MenuItem zoomInMenu = new MenuItem();
+                    zoomInMenu.Header = "Zoom In";
+                    zoomInMenu.Click += (o, p) =>
+                    {
+                        if (pdfViewControl != null)
+                        {
+                            double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true);
+                            pdfViewControl.PDFView?.Zoom(newZoom);
+                        }
+                    };
+
+                    e.PopupMenu.Items.Add(zoomInMenu);
+
+                    MenuItem zoomOutMenu = new MenuItem();
+                    zoomOutMenu.Header = "Zoom Out";
+                    zoomOutMenu.Click += (o, p) =>
+                    {
+                        if (pdfViewControl != null)
+                        {
+                            double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false);
+                            pdfViewControl.PDFView?.Zoom(newZoom);
+                        }
+                    };
+
+                    e.PopupMenu.Items.Add(zoomOutMenu);
+                    e.PopupMenu.Items.Add(new Separator());
+
+                    MenuItem singleView = new MenuItem();
+                    singleView.Header = "Single Page";
+                    singleView.Click += (o, p) =>
+                    {
+                        if (pdfViewControl != null)
+                        {
+                            pdfViewControl.PDFView?.ChangeViewMode(ViewMode.Single);
+                        }
+                    };
+
+                    e.PopupMenu.Items.Add(singleView);
+
+                    MenuItem singleContinuousView = new MenuItem();
+                    singleContinuousView.Header = "Single Page Continuous";
+                    singleContinuousView.Click += (o, p) =>
+                    {
+                        if (pdfViewControl != null)
+                        {
+                            pdfViewControl.PDFView?.ChangeViewMode(ViewMode.SingleContinuous);
+                        }
+                    };
+
+                    e.PopupMenu.Items.Add(singleContinuousView);
+
+                    MenuItem doubleView = new MenuItem();
+                    doubleView.Header = "Two Pages";
+                    doubleView.Click += (o, p) =>
+                    {
+                        if (pdfViewControl != null)
+                        {
+                            pdfViewControl.PDFView?.ChangeViewMode(ViewMode.Double);
+                        }
+                    };
+
+                    e.PopupMenu.Items.Add(doubleView);
+
+                    MenuItem doubleContinuousView = new MenuItem();
+                    doubleContinuousView.Header = "Two Pages Continuous";
+                    doubleContinuousView.Click += (o, p) =>
+                    {
+                        if (pdfViewControl != null)
+                        {
+                            pdfViewControl.PDFView?.ChangeViewMode(ViewMode.DoubleContinuous);
+                        }
+                    };
+                    e.PopupMenu.Items.Add(doubleContinuousView);
+                }
+            }
+            else
+            {
+                e.DoCommand();
+            }
+        }
+
+        private void CopyImage_Click(object sender, RoutedEventArgs e)
+        {
+            Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
+
+            if (imageDict != null && imageDict.Count > 0)
+            {
+                foreach (int pageIndex in imageDict.Keys)
+                {
+                    List<Bitmap> imageList = imageDict[pageIndex];
+                    foreach (Bitmap image in imageList)
+                    {
+                        MemoryStream ms = new MemoryStream();
+                        image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
+                        BitmapImage imageData = new BitmapImage();
+                        imageData.BeginInit();
+                        imageData.StreamSource = ms;
+                        imageData.CacheOption = BitmapCacheOption.OnLoad;
+                        imageData.EndInit();
+                        imageData.Freeze();
+                        Clipboard.SetImage(imageData);
+                        break;
+                    }
+                }
+            }
         }
 
-        private void PageEditControlRefreshAnnotList(object sender, EventArgs e)
+        private void ExtraImage_Click(object sender, RoutedEventArgs e)
         {
-            botaBarControl.LoadAnnotationList();
+            System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog();
+            if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                string choosePath = folderDialog.SelectedPath;
+                string openPath = choosePath;
+                Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
+
+                if (imageDict != null && imageDict.Count > 0)
+                {
+                    foreach (int pageIndex in imageDict.Keys)
+                    {
+                        List<Bitmap> imageList = imageDict[pageIndex];
+                        foreach (Bitmap image in imageList)
+                        {
+                            string savePath = System.IO.Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
+                            image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
+                            openPath = savePath;
+                        }
+                    }
+                }
+                Process.Start("explorer", "/select,\"" + openPath + "\"");
+
+            }
+        }
+
+        #endregion
+
+        #region password
+        private void PasswordUI_Canceled(object sender, EventArgs e)
+        {
+            PopupBorder.Visibility = Visibility.Collapsed;
+            PasswordUI.Visibility = Visibility.Collapsed;
+        }
+
+        private void PasswordUI_Closed(object sender, EventArgs e)
+        {
+            PopupBorder.Visibility = Visibility.Collapsed;
+            PasswordUI.Visibility = Visibility.Collapsed;
         }
 
         private void PasswordUI_Confirmed(object sender, string e)
@@ -126,29 +372,347 @@ namespace DocsEditControl
                     PasswordUI.ClearPassword();
                     PasswordUI.Visibility = Visibility.Collapsed;
                     PopupBorder.Visibility = Visibility.Collapsed;
-                    pdfViewer = passwordViewer;
+                    pdfViewControl.PDFView.Document.Release();
+                    pdfViewControl = passwordViewer;
                     LoadDocument();
                 }
                 else
                 {
-                    PasswordUI.SetShowError("Wrong Password", Visibility.Visible);
+                    PasswordUI.SetShowError("error", Visibility.Visible);
                 }
             }
         }
-         
-        private void PasswordUI_Canceled(object sender, EventArgs e)
+
+        #endregion
+
+        #region Expand and collapse Panel
+
+        public void ExpandRightPropertyPanel(UIElement properytPanel, Visibility visible)
+        {
+            PropertyContainer.Width = 260;
+            PropertyContainer.Child = properytPanel;
+            PropertyContainer.Visibility = visible;
+            if (visible == Visibility.Hidden || visible == Visibility.Collapsed)
+            {
+                RightPanelButton.IsChecked = false;
+            }
+        }
+
+        private void ExpandLeftPanel(bool isExpand)
+        {
+            BotaSideTool.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
+            Splitter.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
+            if (isExpand)
+            {
+                BodyGrid.ColumnDefinitions[0].Width = new GridLength(320);
+                BodyGrid.ColumnDefinitions[1].Width = new GridLength(15);
+            }
+            else
+            {
+                BodyGrid.ColumnDefinitions[0].Width = new GridLength(0);
+                BodyGrid.ColumnDefinitions[1].Width = new GridLength(0);
+            }
+        }
+
+        #endregion
+
+        #region UI
+        private void PageInfoBtn_Click(object sender, RoutedEventArgs e)
         {
-            PopupBorder.Visibility = Visibility.Collapsed;
             PasswordUI.Visibility = Visibility.Collapsed;
+            CPDFInfoControl.Visibility = Visibility.Visible;
+            CPDFInfoControl.InitWithPDFViewer(pdfViewControl.PDFView);
+            CPDFInfoControl.CloseInfoEvent -= CPDFInfoControl_CloseInfoEvent;
+            CPDFInfoControl.CloseInfoEvent += CPDFInfoControl_CloseInfoEvent;
+            PopupBorder.Visibility = Visibility.Visible;
         }
 
-        private void PasswordUI_Closed(object sender, EventArgs e)
+        private void CPDFInfoControl_CloseInfoEvent(object sender, EventArgs e)
         {
             PopupBorder.Visibility = Visibility.Collapsed;
-            PasswordUI.Visibility = Visibility.Collapsed;
         }
+
+
+        private void OpenFile()
+        {
+            string filePath = CommonHelper.GetExistedPathOrEmpty();
+            if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
+            {
+                if (pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
+                {
+                    string oldFilePath = pdfViewControl.PDFView.Document.FilePath;
+                    if (oldFilePath.ToLower() == filePath.ToLower())
+                    {
+                        return;
+                    }
+                    else
+                    {
+                        pdfViewControl.PDFView.Document.Release();
+                    }
+                }
+
+                passwordViewer = new PDFViewControl();
+                passwordViewer.PDFView.InitDocument(filePath);
+                if (passwordViewer.PDFView.Document == null)
+                {
+                    MessageBox.Show("Open File Failed");
+                    return;
+                }
+
+                if (passwordViewer.PDFView.Document.IsLocked)
+                {
+                    PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " password encrypted.");
+                    PasswordUI.ClearPassword();
+                    PopupBorder.Visibility = Visibility.Visible;
+                    PasswordUI.Visibility = Visibility.Visible;
+                }
+                else
+                {
+                    pdfViewControl.PDFView.Document.Release();
+                    pdfViewControl = passwordViewer;
+                    LoadDocument();
+                }
+            }
+        }
+
+        private void OpenFile_Click(object sender, RoutedEventArgs e)
+        {
+            OpenFile();
+        }
+
+        private void ControlLeftPanel()
+        {
+            if (LeftToolPanelButton != null)
+            {
+                bool isExpand = LeftToolPanelButton.IsChecked == true;
+                ExpandLeftPanel(isExpand);
+            }
+        }
+
+        private void LeftToolPanelButton_Click(object sender, RoutedEventArgs e)
+        {
+            ControlLeftPanel();
+        }
+
+        private void SaveFileBtn_Click(object sender, RoutedEventArgs e)
+        {
+            SaveFile();
+            pdfViewControl.PDFView.UndoManager.CanSave = false;
+        }
+
+        private void FileInfoCloseBtn_Click(object sender, RoutedEventArgs e)
+        {
+            PopupBorder.Visibility = Visibility.Collapsed;
+        }
+
+
+        private void ExpandSearchBtn_Click(object sender, RoutedEventArgs e)
+        {
+            ExpandLeftPanel(true);
+            LeftToolPanelButton.IsChecked = true;
+            BotaSideTool.SelectBotaTool(BOTATools.Search);
+        }
+
+        private void ControlRightPanel()
+        {
+            if ((bool)ViewSettingBtn.IsChecked)
+            {
+                ViewSettingBtn.IsChecked = false;
+            }
+            if (RightPanelButton != null)
+            {
+                if (RightPanelButton.IsChecked == true)
+                {
+                    ExpandRightPropertyPanel(pdfAnnotationControl, Visibility.Visible);
+                }
+                else
+                {
+                    ExpandRightPropertyPanel(null, Visibility.Collapsed);
+                }
+            }
+        }
+
+        private void RightPanelButton_Click(object sender, RoutedEventArgs e)
+        {
+            ControlRightPanel();
+        }
+
+
+
+        private void ViewSettingBtn_Click(object sender, RoutedEventArgs e)
+        {
+            ShowViewSettings();
+        }
+
+        private double CheckZoomLevel(double zoom, bool IsGrowth)
+        {
+            double standardZoom = 100;
+            if (zoom <= 0.01)
+            {
+                return 0.01;
+            }
+            if (zoom >= 10)
+            {
+                return 10;
+            }
+
+            zoom *= 100;
+            for (int i = 0; i < zoomLevelList.Length - 1; i++)
+            {
+                if (zoom > zoomLevelList[i] && zoom <= zoomLevelList[i + 1] && IsGrowth)
+                {
+                    standardZoom = zoomLevelList[i + 1];
+                    break;
+                }
+                if (zoom >= zoomLevelList[i] && zoom < zoomLevelList[i + 1] && !IsGrowth)
+                {
+                    standardZoom = zoomLevelList[i];
+                    break;
+                }
+            }
+            return standardZoom / 100;
+        }
+
+
+        #endregion
+
+        #region Save file
+
+        /// <summary>
+        /// Save the file to another PDF file.
+        /// </summary>
+        public void SaveAsFile()
+        {
+            {
+                if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
+                {
+                    CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
+                    SaveFileDialog saveDialog = new SaveFileDialog();
+                    saveDialog.Filter = "(*.pdf)|*.pdf";
+                    saveDialog.DefaultExt = ".pdf";
+                    saveDialog.OverwritePrompt = true;
+
+                    if (saveDialog.ShowDialog() == true)
+                    {
+                        pdfDoc.WriteToFilePath(saveDialog.FileName);
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// Save the file in the current path.
+        /// </summary>
+        private void SaveFile()
+        {
+            if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
+            {
+                CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
+                if (pdfDoc.WriteToLoadedPath())
+                {
+                    return;
+                }
+
+                SaveFileDialog saveDialog = new SaveFileDialog();
+                saveDialog.Filter = "(*.pdf)|*.pdf";
+                saveDialog.DefaultExt = ".pdf";
+                saveDialog.OverwritePrompt = true;
+
+                if (saveDialog.ShowDialog() == true)
+                {
+                    pdfDoc.WriteToFilePath(saveDialog.FileName);
+                }
+            }
+        }
+
         #endregion
 
+        #region Selection changed
+
+        private void ViewComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (isFirstLoad)
+            {
+                isFirstLoad = false;
+                return;
+            }
+
+            var item = (sender as ComboBox).SelectedItem as ComboBoxItem;
+            switch (currentMode)
+            {
+                case "Viewer":
+                    break;
+                case "Page Edit":
+                    ToolBarContainer.Visibility = Visibility.Collapsed;
+                    pageEditControl.ExitPageEdit -= PageEditControl_ExitPageEdit;
+                    pageEditControl.PageMoved -= PageEditControl_PageMoved;
+                    CPDFPageEditBarControl.PageEditEvent -= CPDFPageEditBarControl_PageEditEvent;
+                    FloatPageTool.Visibility = Visibility.Visible;
+                    pdfViewControl.PDFView.ReloadDocument();
+                    LeftToolPanelButton.IsEnabled = true;
+                    SearchButton.IsEnabled = true;
+                    RightPanelButton.IsEnabled = true;
+                    ViewSettingBtn.IsEnabled = true;
+                    break;
+                default:
+                    break;
+            }
+            if ((string)item.Content == "Viewer")
+            {
+                ToolBarContainer.Visibility = Visibility.Collapsed;
+                PDFGrid.Child = pdfViewControl;
+            }
+            else if ((string)item.Content == "Page Edit")
+            {
+                ToolBarContainer.Visibility = Visibility.Visible;
+                if (pageEditControl == null)
+                {
+                    pageEditControl = new CPDFPageEditControl();
+                }
+                pageEditControl.ExitPageEdit += PageEditControl_ExitPageEdit;
+                pageEditControl.PageMoved += PageEditControl_PageMoved;
+                CPDFPageEditBarControl.PageEditEvent += CPDFPageEditBarControl_PageEditEvent;
+                pageEditControl.LoadThumbnails(pdfViewControl.PDFView);
+                PDFGrid.Child = pageEditControl;
+                LeftToolPanelButton.IsChecked = false;
+                LeftToolPanelButton.IsEnabled = false;
+                SearchButton.IsEnabled = false;
+                RightPanelButton.IsChecked = false;
+                RightPanelButton.IsEnabled = false;
+                ViewSettingBtn.IsChecked = false;
+                ViewSettingBtn.IsEnabled = false;
+                ExpandLeftPanel(false);
+                ExpandRightPropertyPanel(null, Visibility.Collapsed);
+                FloatPageTool.Visibility = Visibility.Collapsed;
+            }
+            currentMode = (string)item.Content;
+        }
+
+        #endregion
+
+        #region Event handle
+        private void CPDFPageEditBarControl_PageEditEvent(object sender, string e)
+        {
+            pageEditControl.PageEdit(e);
+        }
+
+        private void PageEditControl_ExitPageEdit(object sender, EventArgs e)
+        {
+            ViewComboBox.SelectedIndex = 0;
+        }
+
+        private void UndoManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
+        {
+            OnPropertyChanged(e.PropertyName);
+        }
+        private void PageEditControl_PageMoved(object sender, RoutedEventArgs e)
+        {
+            if (pdfViewControl == null || pdfViewControl.PDFView == null)
+            {
+                return;
+            }
+            BotaSideTool.InitWithPDFViewer(pdfViewControl.PDFView);
+        }
 
         private void PdfViewer_InfoChanged(object sender, KeyValuePair<string, object> e)
         {
@@ -158,20 +722,155 @@ namespace DocsEditControl
             }
         }
 
-        private void PageEditControl_PageMoved(object sender, RoutedEventArgs e)
+        #endregion
+
+        #region Property changed
+
+        protected void OnPropertyChanged([CallerMemberName] string name = null)
+        {
+            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
+        }
+
+        #endregion
+
+        #region Shortcut
+        private void CommandBinding_Executed_Open(object sender, ExecutedRoutedEventArgs e)
         {
-            if (pdfViewer == null || pdfViewer.PDFView == null)
+            OpenFile();
+        }
+
+        private void CommandBinding_Executed_Save(object sender, ExecutedRoutedEventArgs e)
+        {
+            if (CanSave)
             {
-                return;
+                SaveFile();
             }
-            BotaSideTool.InitWithPDFViewer(pdfViewer.PDFView);
         }
 
-        public event PropertyChangedEventHandler PropertyChanged;
+        private void CommandBinding_Executed_SaveAs(object sender, ExecutedRoutedEventArgs e)
+        {
+            SaveAsFile();
+        }
+
+        private void CommandBinding_Executed_ControlLeftPanel(object sender, ExecutedRoutedEventArgs e)
+        {
+            if (currentMode != "Page Edit")
+            {
+                LeftToolPanelButton.IsChecked = !LeftToolPanelButton.IsChecked;
+                ControlLeftPanel();
+            }
+        }
+
+        private void CommandBinding_Executed_ControlRightPanel(object sender, ExecutedRoutedEventArgs e)
+        {
+            if (currentMode != "Page Edit")
+            {
+                RightPanelButton.IsChecked = !RightPanelButton.IsChecked;
+                ControlRightPanel();
+            }
+        }
+
+        private void CommandBinding_Executed_Bookmark(object sender, ExecutedRoutedEventArgs e)
+        {
+            if (currentMode != "Page Edit")
+            {
+                ExpandLeftPanel(true);
+                LeftToolPanelButton.IsChecked = true;
+                BotaSideTool.SelectBotaTool(BOTATools.Bookmark);
+            }
+        }
 
-        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
+        private void CommandBinding_Executed_Outline(object sender, ExecutedRoutedEventArgs e)
         {
-            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+            if (currentMode != "Page Edit")
+            {
+                ExpandLeftPanel(true);
+                LeftToolPanelButton.IsChecked = true;
+                BotaSideTool.SelectBotaTool(BOTATools.Outline);
+            }
         }
+
+        private void CommandBinding_Executed_Thumbnail(object sender, ExecutedRoutedEventArgs e)
+        {
+            if (currentMode != "Page Edit")
+            {
+                ExpandLeftPanel(true);
+                LeftToolPanelButton.IsChecked = true;
+                BotaSideTool.SelectBotaTool(BOTATools.Thumbnail);
+            }
+        }
+
+        private void CommandBinding_Executed_Search(object sender, ExecutedRoutedEventArgs e)
+        {
+            if (currentMode != "Page Edit")
+            {
+                ExpandLeftPanel(true);
+                LeftToolPanelButton.IsChecked = true;
+                BotaSideTool.SelectBotaTool(BOTATools.Search);
+            }
+        }
+
+        private void CommandBinding_Executed_ScaleAdd(object sender, ExecutedRoutedEventArgs e)
+        {
+            double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true);
+            pdfViewControl.PDFView?.Zoom(newZoom);
+        }
+
+        private void CommandBinding_Executed_ScaleSubtract(object sender, ExecutedRoutedEventArgs e)
+        {
+            double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false);
+            pdfViewControl.PDFView?.Zoom(newZoom);
+        }
+
+        private void ShowViewSettings()
+        {
+            if (ViewSettingBtn != null)
+            {
+                if (ViewSettingBtn.IsChecked == true)
+                {
+                    displayPanel = new CPDFDisplaySettingsControl();
+                    displayPanel.InitWithPDFViewer(pdfViewControl.PDFView);
+                    PropertyContainer.Child = displayPanel;
+                    PropertyContainer.Visibility = Visibility.Visible;
+                    if ((bool)RightPanelButton.IsChecked)
+                    {
+                        RightPanelButton.IsChecked = false;
+                    }
+                }
+                else
+                {
+                    PropertyContainer.Child = null;
+                    PropertyContainer.Visibility = Visibility.Collapsed;
+                }
+            }
+        }
+
+        private void CommandBinding_Executed_DisplaySettings(object sender, ExecutedRoutedEventArgs e)
+        {
+            if (currentMode != "Page Edit")
+            {
+                ViewSettingBtn.IsChecked = !ViewSettingBtn.IsChecked;
+                ShowViewSettings();
+            }
+        }
+
+        private void CommandBinding_Executed_DocumentInfo(object sender, ExecutedRoutedEventArgs e)
+        {
+            if (PopupBorder.Visibility != Visibility.Visible)
+            {
+                PasswordUI.Visibility = Visibility.Collapsed;
+                CPDFInfoControl.Visibility = Visibility.Visible;
+                CPDFInfoControl.InitWithPDFViewer(pdfViewControl.PDFView);
+                CPDFInfoControl.CloseInfoEvent -= CPDFInfoControl_CloseInfoEvent;
+                CPDFInfoControl.CloseInfoEvent += CPDFInfoControl_CloseInfoEvent;
+                PopupBorder.Visibility = Visibility.Visible;
+            }
+            else
+            {
+                CPDFInfoControl.Visibility = Visibility.Collapsed;
+                PopupBorder.Visibility = Visibility.Collapsed;
+            }
+        }
+        #endregion
     }
 }