Browse Source

compdfkit(win) - 五合一模块 - Docs Editcor&多页签&密码文档

liuaoran 1 year ago
parent
commit
0c9b4f76ff
26 changed files with 805 additions and 91 deletions
  1. 0 1
      Demo/Examples/Compdfkit_Tools/Common/BarControl/CPDFPageEditBarControl.xaml
  2. 2 1
      Demo/Examples/Compdfkit_Tools/Common/BarControl/CPDFPageEditBarControl.xaml.cs
  3. 7 0
      Demo/Examples/Compdfkit_Tools/Compdfkit_Tools.csproj
  4. 7 10
      Demo/Examples/Compdfkit_Tools/Form/FormControl/FormControl.xaml.cs
  5. 3 14
      Demo/Examples/Compdfkit_Tools/PageEdit/PDFPageEdit/CPDFPageEditControl.xaml.cs
  6. 1 1
      Demo/Examples/Compdfkit_Tools/PageEdit/PageEditControl/PageEditControl.xaml
  7. 17 0
      Demo/Examples/Compdfkit_Tools/PageEdit/PageEditControl/PageEditControl.xaml.cs
  8. 0 1
      Demo/Examples/DocsEditControl/MainWindow.xaml
  9. 0 1
      Demo/Examples/DocsEditor/App.xaml.cs
  10. 0 1
      Demo/Examples/DocsEditor/MainWindow.xaml
  11. 1 0
      Demo/Examples/DocsEditor/MainWindow.xaml.cs
  12. 42 0
      Demo/Examples/Examlpes.sln
  13. 0 1
      Demo/Examples/FormViewControl/MainWindow.xaml.cs
  14. 0 1
      Demo/Examples/Forms/App.xaml.cs
  15. 1 2
      Demo/Examples/PDFViewer/App.xaml
  16. 0 2
      Demo/Examples/PDFViewer/MainPage.xaml.cs
  17. 0 1
      Demo/Examples/PDFViewer/MainWindow.xaml
  18. 4 1
      Demo/Examples/PDFViewer_new/App.xaml
  19. 3 1
      Demo/Examples/PDFViewer_new/App.xaml.cs
  20. BIN
      Demo/Examples/PDFViewer_new/Dragablz.dll
  21. 6 5
      Demo/Examples/PDFViewer_new/MainPage.xaml
  22. 60 35
      Demo/Examples/PDFViewer_new/MainPage.xaml.cs
  23. 254 2
      Demo/Examples/PDFViewer_new/MainWindow.xaml
  24. 386 2
      Demo/Examples/PDFViewer_new/MainWindow.xaml.cs
  25. 10 5
      Demo/Examples/PDFViewer_new/PDFViewer_new.csproj
  26. 1 3
      Demo/Examples/Samples/LicenseKey.cs

+ 0 - 1
Demo/Examples/Compdfkit_Tools/Common/BarControl/CPDFPageEditBarControl.xaml

@@ -5,7 +5,6 @@
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:Compdfkit_Tools.PDFControl"
              mc:Ignorable="d" 
-             Loaded="UserControl_Loaded"
              d:DesignHeight="40" d:DesignWidth="1280">
     <UserControl.Resources>
         <ResourceDictionary>

+ 2 - 1
Demo/Examples/Compdfkit_Tools/Common/BarControl/CPDFPageEditBarControl.xaml.cs

@@ -49,9 +49,10 @@ namespace Compdfkit_Tools.PDFControl
         public CPDFPageEditBarControl()
         {
             InitializeComponent();
+            CreateButton();
         }
 
-        private void UserControl_Loaded(object sender, RoutedEventArgs e)
+        private void CreateButton()
         {
             foreach (KeyValuePair<string, string> data in ButtonDict)
             {

+ 7 - 0
Demo/Examples/Compdfkit_Tools/Compdfkit_Tools.csproj

@@ -258,6 +258,9 @@
     <Compile Include="Form\Property\TextFieldProperty.xaml.cs">
       <DependentUpon>TextFieldProperty.xaml</DependentUpon>
     </Compile>
+    <Compile Include="PageEdit\PageEditControl\PageEditControl.xaml.cs">
+      <DependentUpon>PageEditControl.xaml</DependentUpon>
+    </Compile>
     <Compile Include="PageEdit\PDFPageEdit\CPDFPageEditControl.xaml.cs">
       <DependentUpon>CPDFPageEditControl.xaml</DependentUpon>
     </Compile>
@@ -677,6 +680,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="PageEdit\PageEditControl\PageEditControl.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="PageEdit\PDFPageEdit\CPDFPageEditControl.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 7 - 10
Demo/Examples/Compdfkit_Tools/Form/FormControl/FormControl.xaml.cs

@@ -58,24 +58,21 @@ namespace Compdfkit_Tools.PDFControl
                     return PdfViewControl.PDFView.UndoManager.CanRedo;
                 }
 
-                return false;
+                return false; 
             }
         }
 
-        private bool CanSave
+        private bool _canSave = false;
+        public bool CanSave
         {
-            get
+            get => _canSave;
+            set
             {
-                if (PdfViewControl != null && PdfViewControl.PDFView != null)
-                {
-                    return PdfViewControl.PDFView.UndoManager.CanSave;
-                }
-
-                return false;
+                _canSave = value;
+                OnPropertyChanged();
             }
         }
 
-
         public event EventHandler<bool> OnCanSaveChanged;
         public event EventHandler OnAnnotEditHandler;
 

+ 3 - 14
Demo/Examples/Compdfkit_Tools/PageEdit/PDFPageEdit/CPDFPageEditControl.xaml.cs

@@ -90,7 +90,6 @@ namespace Compdfkit_Tools.PDFControl
         //When the first half is displayed, the index obtained is the actual index value
         //When the second half is displayed, the obtained index needs add 1
         //private bool isFrontHalf = false;
-
         private bool isDraging = false;
 
         //Whether the file is being dragged in from the outside
@@ -105,7 +104,6 @@ namespace Compdfkit_Tools.PDFControl
         //When zooming
         public event RoutedEventHandler ChangedZoomFactor;
 
-
         private bool isFirstScrollChange = true;
         private bool isFirstSizeChange = true;
         public string SelectedItemsRange
@@ -267,6 +265,7 @@ namespace Compdfkit_Tools.PDFControl
                 Debug.WriteLine(ex.ToString());
             }
         }
+
         private void UserControl_Loaded(object sender, RoutedEventArgs e)
         {
             PageEditListBox.Focus();
@@ -578,7 +577,7 @@ namespace Compdfkit_Tools.PDFControl
                         pdfViewer.UndoManager.CanSave = true;
                         pdfViewer.ReloadDocument();
                         PageEditListBox.ScrollIntoView(PageEditListBox.SelectedItem as ListBoxItem);
-                        PageMoved.Invoke(this, new RoutedEventArgs());
+                        PageMoved?.Invoke(this, new RoutedEventArgs());
                         dragDoc.Release();
                     }
                     else
@@ -931,16 +930,6 @@ namespace Compdfkit_Tools.PDFControl
             ExitPageEdit?.Invoke(this, new EventArgs());
         }
 
-        private void InsertBlank_Click(object sender, RoutedEventArgs e)
-        {
-            var send = sender as MenuItem;
-        }
-
-        private void Replace_Click(object sender, RoutedEventArgs e)
-        {
-            DoReplace();
-        }
-
         public void Copy_Click(object sender, RoutedEventArgs e)
         {
             DoCopy();
@@ -1441,7 +1430,7 @@ namespace Compdfkit_Tools.PDFControl
             pdfViewer.UndoManager.CanSave = true;
 
             ItemsInViewHitTest();
-            this.PageMoved.Invoke(this, new RoutedEventArgs());
+            this.PageMoved?.Invoke(this, new RoutedEventArgs());
             UpdateSortedPageNum(sourceindex, targetindex);
         }
          

+ 1 - 1
Demo/Examples/Compdfkit_Tools/PageEdit/PageEditControl/PageEditControl.xaml

@@ -11,7 +11,7 @@
             <RowDefinition Height="auto"></RowDefinition>
             <RowDefinition></RowDefinition>
         </Grid.RowDefinitions>
-        <Border x:Name="ToolBarContainer" Height="45" Visibility="Collapsed"  BorderThickness="1" BorderBrush="#1A000000" Background="#F2F3F5">
+        <Border x:Name="ToolBarContainer" Height="45" Visibility="Visible"  BorderThickness="1" BorderBrush="#1A000000" Background="#F2F3F5">
             <cpdftools:CPDFPageEditBarControl x:Name="CPDFPageEditBarControl" Height="44"/>
         </Border>
         <cpdftools:CPDFPageEditControl x:Name="pageEditControl" Grid.Row="1"></cpdftools:CPDFPageEditControl>

+ 17 - 0
Demo/Examples/Compdfkit_Tools/PageEdit/PageEditControl/PageEditControl.xaml.cs

@@ -32,6 +32,7 @@ namespace Compdfkit_Tools.PDFControl
 
         //When the order or total number of pages changes
         public event RoutedEventHandler PageMoved;
+        public event EventHandler ExitPageEdit;
 
         public event EventHandler<bool> OnCanSaveChanged;
         public event EventHandler OnAnnotEditHandler;
@@ -44,6 +45,22 @@ namespace Compdfkit_Tools.PDFControl
             this.DataContext = this;
             pageEditControl.PageMoved -= PageEditControl_PageMoved;
             pageEditControl.PageMoved += PageEditControl_PageMoved;
+
+            CPDFPageEditBarControl.PageEditEvent -= CPDFPageEditBarControl_PageEditEvent;
+            CPDFPageEditBarControl.PageEditEvent += CPDFPageEditBarControl_PageEditEvent;
+
+            pageEditControl.ExitPageEdit -= PageEditControl_ExitPageEdit;
+            pageEditControl.ExitPageEdit += PageEditControl_ExitPageEdit;
+        }
+
+        private void PageEditControl_ExitPageEdit(object sender, EventArgs e)
+        {
+            this.ExitPageEdit?.Invoke(this, EventArgs.Empty);
+        }
+
+        private void CPDFPageEditBarControl_PageEditEvent(object sender, string e)
+        {
+            pageEditControl.PageEdit(e);
         }
 
         private void PageEditControl_PageMoved(object sender, RoutedEventArgs e)

+ 0 - 1
Demo/Examples/DocsEditControl/MainWindow.xaml

@@ -122,7 +122,6 @@
                     </ComboBox>
 
                     <StackPanel Orientation="Horizontal" Grid.Column="2">
-
                         <Button BorderThickness="0" Width="40" Height="40" Style="{StaticResource LightButtonStyle}" Background="Transparent">
                             <Button.Content>
                                 <Path Fill="#43474D">

+ 0 - 1
Demo/Examples/DocsEditor/App.xaml.cs

@@ -43,7 +43,6 @@ namespace DocsEditor
         private static bool LicenseVerify()
         {
             bool result = false;
-
             result = CPDFSDKVerifier.LoadNativeLibrary();
             if (!result)
                 return false;

+ 0 - 1
Demo/Examples/DocsEditor/MainWindow.xaml

@@ -4,7 +4,6 @@
         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:local="clr-namespace:DocsEditor"
         xmlns:cpdfcommon="clr-namespace:Compdfkit_Tools.Common;assembly=Compdfkit_Tools"
         mc:Ignorable="d"
         Title="Docs Editor_ComPDFKit V1.9.1" Height="450" Width="800">

+ 1 - 0
Demo/Examples/DocsEditor/MainWindow.xaml.cs

@@ -691,6 +691,7 @@ namespace DocsEditor
         {
             OnPropertyChanged(e.PropertyName);
         }
+
         private void PageEditControl_PageMoved(object sender, RoutedEventArgs e)
         {
             if (pdfViewControl == null || pdfViewControl.PDFView == null)

+ 42 - 0
Demo/Examples/Examlpes.sln

@@ -72,6 +72,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormViewControl", "FormView
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ContentEditorViewControl", "ContentEditorViewControl\ContentEditorViewControl.csproj", "{05219D39-7AFF-48F0-93B9-178BC88D4D98}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocsEditControl", "DocsEditControl\DocsEditControl.csproj", "{D3003B68-0D1E-47B2-84CA-D6B749BABC74}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComPDFKit.Viewer", "..\..\..\compdfkit\ComPDFKit\ComPDFKitDesktop\ComPDFKit.Viewer\ComPDFKit.Viewer.csproj", "{18EC356D-8130-49D4-B4E6-AC290E1065B7}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComPDFKit.Desk", "..\..\..\compdfkit\ComPDFKit\ComPDFKitCSharp\ComPDFKit.Desk.csproj", "{56E518AD-C126-4B48-9A09-0A64C87020E4}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -451,6 +457,42 @@ Global
 		{05219D39-7AFF-48F0-93B9-178BC88D4D98}.Release|x64.Build.0 = Release|Any CPU
 		{05219D39-7AFF-48F0-93B9-178BC88D4D98}.Release|x86.ActiveCfg = Release|Any CPU
 		{05219D39-7AFF-48F0-93B9-178BC88D4D98}.Release|x86.Build.0 = Release|Any CPU
+		{D3003B68-0D1E-47B2-84CA-D6B749BABC74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{D3003B68-0D1E-47B2-84CA-D6B749BABC74}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{D3003B68-0D1E-47B2-84CA-D6B749BABC74}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{D3003B68-0D1E-47B2-84CA-D6B749BABC74}.Debug|x64.Build.0 = Debug|Any CPU
+		{D3003B68-0D1E-47B2-84CA-D6B749BABC74}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{D3003B68-0D1E-47B2-84CA-D6B749BABC74}.Debug|x86.Build.0 = Debug|Any CPU
+		{D3003B68-0D1E-47B2-84CA-D6B749BABC74}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{D3003B68-0D1E-47B2-84CA-D6B749BABC74}.Release|Any CPU.Build.0 = Release|Any CPU
+		{D3003B68-0D1E-47B2-84CA-D6B749BABC74}.Release|x64.ActiveCfg = Release|Any CPU
+		{D3003B68-0D1E-47B2-84CA-D6B749BABC74}.Release|x64.Build.0 = Release|Any CPU
+		{D3003B68-0D1E-47B2-84CA-D6B749BABC74}.Release|x86.ActiveCfg = Release|Any CPU
+		{D3003B68-0D1E-47B2-84CA-D6B749BABC74}.Release|x86.Build.0 = Release|Any CPU
+		{18EC356D-8130-49D4-B4E6-AC290E1065B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{18EC356D-8130-49D4-B4E6-AC290E1065B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{18EC356D-8130-49D4-B4E6-AC290E1065B7}.Debug|x64.ActiveCfg = Debug|x64
+		{18EC356D-8130-49D4-B4E6-AC290E1065B7}.Debug|x64.Build.0 = Debug|x64
+		{18EC356D-8130-49D4-B4E6-AC290E1065B7}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{18EC356D-8130-49D4-B4E6-AC290E1065B7}.Debug|x86.Build.0 = Debug|Any CPU
+		{18EC356D-8130-49D4-B4E6-AC290E1065B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{18EC356D-8130-49D4-B4E6-AC290E1065B7}.Release|Any CPU.Build.0 = Release|Any CPU
+		{18EC356D-8130-49D4-B4E6-AC290E1065B7}.Release|x64.ActiveCfg = Release|x64
+		{18EC356D-8130-49D4-B4E6-AC290E1065B7}.Release|x64.Build.0 = Release|x64
+		{18EC356D-8130-49D4-B4E6-AC290E1065B7}.Release|x86.ActiveCfg = Release|Any CPU
+		{18EC356D-8130-49D4-B4E6-AC290E1065B7}.Release|x86.Build.0 = Release|Any CPU
+		{56E518AD-C126-4B48-9A09-0A64C87020E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{56E518AD-C126-4B48-9A09-0A64C87020E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{56E518AD-C126-4B48-9A09-0A64C87020E4}.Debug|x64.ActiveCfg = Debug|x64
+		{56E518AD-C126-4B48-9A09-0A64C87020E4}.Debug|x64.Build.0 = Debug|x64
+		{56E518AD-C126-4B48-9A09-0A64C87020E4}.Debug|x86.ActiveCfg = Debug|x86
+		{56E518AD-C126-4B48-9A09-0A64C87020E4}.Debug|x86.Build.0 = Debug|x86
+		{56E518AD-C126-4B48-9A09-0A64C87020E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{56E518AD-C126-4B48-9A09-0A64C87020E4}.Release|Any CPU.Build.0 = Release|Any CPU
+		{56E518AD-C126-4B48-9A09-0A64C87020E4}.Release|x64.ActiveCfg = Release|x64
+		{56E518AD-C126-4B48-9A09-0A64C87020E4}.Release|x64.Build.0 = Release|x64
+		{56E518AD-C126-4B48-9A09-0A64C87020E4}.Release|x86.ActiveCfg = Release|x86
+		{56E518AD-C126-4B48-9A09-0A64C87020E4}.Release|x86.Build.0 = Release|x86
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 0 - 1
Demo/Examples/FormViewControl/MainWindow.xaml.cs

@@ -108,7 +108,6 @@ namespace FormViewControl
         #endregion
         
         #region Password
-
         private void PasswordUI_Confirmed(object sender, string e)
         {
             if (passwordViewer != null && passwordViewer.PDFView != null && passwordViewer.PDFView.Document != null)

+ 0 - 1
Demo/Examples/Forms/App.xaml.cs

@@ -29,7 +29,6 @@ namespace Forms
                 secret = node.Attributes["secret"].Value;
             }
         }
-
     }
 
     public partial class App : Application

+ 1 - 2
Demo/Examples/PDFViewer/App.xaml

@@ -1,7 +1,6 @@
 <Application x:Class="PDFViewer.App"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:local="clr-namespace:compdfkit"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
              xmlns:common="clr-namespace:Compdfkit_Tools.Common;assembly=Compdfkit_Tools"
              StartupUri="MainWindow.xaml">
     <Application.Resources>

+ 0 - 2
Demo/Examples/PDFViewer/MainPage.xaml.cs

@@ -120,12 +120,10 @@ namespace PDFViewer
 
         public void SetPDFViewer(PDFViewControl newPdfViewer)
         {
-
             if (newPdfViewer != null)
             {
                 pdfViewControl = newPdfViewer;
             }
-
         }
 
         private void CPDFTitleBarControl_Loaded(object sender, RoutedEventArgs e)

+ 0 - 1
Demo/Examples/PDFViewer/MainWindow.xaml

@@ -4,7 +4,6 @@
         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:cpdfcommon="clr-namespace:Compdfkit_Tools.Common;assembly=Compdfkit_Tools"
         mc:Ignorable="d"   
         SnapsToDevicePixels="True" 

+ 4 - 1
Demo/Examples/PDFViewer_new/App.xaml

@@ -2,8 +2,11 @@
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:local="clr-namespace:PDFViewer_new"
+              xmlns:cpdfcommon="clr-namespace:Compdfkit_Tools.Common;assembly=Compdfkit_Tools"
              StartupUri="MainWindow.xaml">
     <Application.Resources>
-         
+        <cpdfcommon:WindowStateToThicknessConverter x:Key="WindowStateToThicknessConverter"></cpdfcommon:WindowStateToThicknessConverter>
+        <cpdfcommon:CaptionHeightConverter x:Key="CaptionHeightConverter"></cpdfcommon:CaptionHeightConverter>
+        <cpdfcommon:WindowStateToPathConverter x:Key="WindowStateToPathConverter"></cpdfcommon:WindowStateToPathConverter>
     </Application.Resources>
 </Application>

+ 3 - 1
Demo/Examples/PDFViewer_new/App.xaml.cs

@@ -17,7 +17,6 @@ namespace PDFViewer_new
         public string secret = string.Empty;
         public SDKLicenseHelper()
         {
-
             string sdkLicensePath = "license_key_win.xml";
             Assembly assembly = Assembly.GetExecutingAssembly();
             XmlDocument xmlDocument = new XmlDocument();
@@ -37,6 +36,9 @@ namespace PDFViewer_new
     /// </summary>
     public partial class App: Application
     {
+        static public bool DefaultPDFLoaded = false;
+        public static List<string> OpenedFilePathList = new List<string>();
+
         protected override void OnStartup(StartupEventArgs e)
         {
             string str = this.GetType().Assembly.Location;

BIN
Demo/Examples/PDFViewer_new/Dragablz.dll


+ 6 - 5
Demo/Examples/PDFViewer_new/MainPage.xaml

@@ -7,7 +7,7 @@
              xmlns:cpdftools="clr-namespace:Compdfkit_Tools.PDFControl;assembly=Compdfkit_Tools"
              xmlns:cpdfcommon="clr-namespace:Compdfkit_Tools.Common;assembly=Compdfkit_Tools"
              mc:Ignorable="d" 
-             Loaded="MainWindow_Loaded"
+             Loaded="MainPage_Loaded"
              d:DesignHeight="720" d:DesignWidth="1080">
     <UserControl.Resources>
         <ResourceDictionary>
@@ -18,7 +18,7 @@
             </ResourceDictionary.MergedDictionaries>
         </ResourceDictionary>
     </UserControl.Resources>
-    <Grid>
+    <Grid> 
         <Grid>
             <Grid.RowDefinitions>
                 <RowDefinition Height="Auto"></RowDefinition>
@@ -124,6 +124,7 @@
                     <ComboBoxItem Tag="Annotation">Annotation</ComboBoxItem>
                     <ComboBoxItem Tag="Form">Form</ComboBoxItem>
                     <ComboBoxItem Tag="Content Editor">Content Editor</ComboBoxItem>
+                    <ComboBoxItem Tag="Docs Editor">Docs Editor</ComboBoxItem>
                 </ComboBox>
 
                 <StackPanel Orientation="Horizontal" Grid.Column="2">
@@ -206,7 +207,7 @@
                     <ColumnDefinition Width="auto"></ColumnDefinition>
                 </Grid.ColumnDefinitions>
                 <Grid>
-                    
+
                 </Grid>
                 <GridSplitter  Name="Splitter" Grid.Column="1" Width="15" ResizeBehavior="PreviousAndNext" Visibility="Collapsed">
                     <GridSplitter.Template>
@@ -240,8 +241,8 @@
                 </Grid>
             </Grid>
         </Grid>
-        
-        <Border Name="PopupBorder" Background="#A0000000" Visibility="Collapsed">
+
+        <Border Name="PopupBorder" Background="#A0000000" Visibility="Collapsed" Grid.ColumnSpan="2">
             <Grid>
                 <Grid Name="FileInfoUI"  Width="422" Height="680" HorizontalAlignment="Center" VerticalAlignment="Center" Background="White" Visibility="Collapsed">
                     <Grid.ColumnDefinitions>

+ 60 - 35
Demo/Examples/PDFViewer_new/MainPage.xaml.cs

@@ -1,27 +1,16 @@
 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.Controls.Primitives;
-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 Compdfkit_Tools.Helper;
 using Compdfkit_Tools.PDFControl;
 using Compdfkit_Tools.PDFView;
 using ComPDFKit.PDFDocument;
 using ComPDFKit.PDFPage;
 using ComPDFKitViewer;
-using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
 using Microsoft.Win32;
 
@@ -36,9 +25,13 @@ namespace PDFViewer_new
         private AnnotationControl annotationControl = new AnnotationControl();
         private FormControl formControl = new FormControl();
         private ContentEditControl contentEditControl = new ContentEditControl();
+        private PageEditControl pageEditControl = new PageEditControl();
         private CPDFBOTABarControl botaBarControl = new CPDFBOTABarControl();
         private CPDFDisplaySettingsControl displaySettingsControl = new CPDFDisplaySettingsControl();
 
+        public event Func<string[], bool> CheckExistBeforeOpenFileEvent;
+        public event EventHandler FileChangeEvent;
+
         private PanelState panelState = PanelState.GetInstance();
 
         private bool _canSave = false;
@@ -47,7 +40,7 @@ namespace PDFViewer_new
             get => _canSave;
             set
             {
-               _canSave = value;
+                _canSave = value;
                 OnPropertyChanged();
             }
         }
@@ -96,16 +89,19 @@ namespace PDFViewer_new
         }
 
         #region Load document
-        private void LoadDefaultDocument()
+
+        public void InitWithFilePath(string filePath)
         {
-            string defaultFilePath = "PDF32000_2008.pdf";
-            pdfViewer.PDFView.InitDocument(defaultFilePath);
-            LoadDocument();
-            PDFGrid.Child = regularViewerControl;
+            pdfViewer = new PDFViewControl();
+            pdfViewer.PDFView.InitDocument(filePath);
         }
 
         private void LoadDocument()
         {
+            if (pdfViewer.PDFView.Document == null)
+            {
+                return;
+            }
             pdfViewer.PDFView.Load();
             pdfViewer.PDFView.SetShowLink(true);
 
@@ -122,6 +118,9 @@ namespace PDFViewer_new
 
             pdfViewer.PDFView.ChangeFitMode(FitMode.FitWidth);
             CPDFSaclingControl.InitWithPDFViewer(pdfViewer.PDFView);
+            ModeComboBox.SelectedIndex = 0;
+            regularViewerControl.IsActive = true;
+
             CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.PDFView.ZoomFactor * 100)));
 
             ViewSettingBtn.IsChecked = false;
@@ -132,7 +131,6 @@ namespace PDFViewer_new
             LoadCustomControl();
             panelState.PropertyChanged -= PanelState_PropertyChanged;
             panelState.PropertyChanged += PanelState_PropertyChanged;
-            ModeComboBox.SelectedIndex = 0;
         }
 
         private void PanelState_PropertyChanged(object sender, PropertyChangedEventArgs e)
@@ -171,6 +169,7 @@ namespace PDFViewer_new
                     PopupBorder.Visibility = Visibility.Collapsed;
                     pdfViewer = passwordViewer;
                     LoadDocument();
+                    FileChangeEvent?.Invoke(null, EventArgs.Empty);
                 }
                 else
                 {
@@ -201,15 +200,15 @@ namespace PDFViewer_new
             regularViewerControl.OnCanSaveChanged += FormControlOnCanSaveChanged;
             regularViewerControl.InitWithPDFViewer(pdfViewer.PDFView);
             regularViewerControl.PdfViewControl.PDFView.SetMouseMode(MouseModes.AnnotCreate);
+            regularViewerControl.SetBOTAContainer(null);
             regularViewerControl.SetBOTAContainer(botaBarControl);
             regularViewerControl.SetDisplaySettingsControl(displaySettingsControl);
             PDFGrid.Child = regularViewerControl;
         }
 
-        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
+        private void MainPage_Loaded(object sender, RoutedEventArgs e)
         {
-            pdfViewer = new PDFViewControl();
-            LoadDefaultDocument();
+             LoadDocument();
         }
         #endregion
 
@@ -236,17 +235,23 @@ namespace PDFViewer_new
         private void OpenFile()
         {
             string filePath = CommonHelper.GetFilePathOrEmpty();
+            string oldFilePath = pdfViewer.PDFView.Document.FilePath;
+
             if (!string.IsNullOrEmpty(filePath) && regularViewerControl.PdfViewControl != null)
             {
                 if (pdfViewer.PDFView != null && pdfViewer.PDFView.Document != null)
                 {
-                    string oldFilePath = pdfViewer.PDFView.Document.FilePath;
                     if (oldFilePath.ToLower() == filePath.ToLower())
                     {
                         return;
                     }
                 }
 
+                if ((bool)CheckExistBeforeOpenFileEvent?.Invoke(new string[] { filePath, oldFilePath }))
+                {
+                    return;
+                }
+
                 passwordViewer = new PDFViewControl();
                 passwordViewer.PDFView.InitDocument(filePath);
                 if (passwordViewer.PDFView.Document == null)
@@ -265,7 +270,7 @@ namespace PDFViewer_new
                 else
                 {
                     pdfViewer = passwordViewer;
-                    LoadDocument();
+                    FileChangeEvent?.Invoke(null, EventArgs.Empty);
                 }
             }
         }
@@ -301,7 +306,7 @@ namespace PDFViewer_new
             }
             else if (currentMode == "Form")
             {
-                formControl.ClearViewerControl(); 
+                formControl.ClearViewerControl();
                 formControl.UnloadEvent();
                 formControl.ClearViewerControl();
                 formControl.IsActive = false;
@@ -311,8 +316,12 @@ namespace PDFViewer_new
                 contentEditControl.ClearViewerControl();
                 contentEditControl.IsActive = false;
             }
+            else if (currentMode == "Docs Editor")
+            {
+                pageEditControl.ExitPageEdit -= PageEditControl_ExitPageEdit;
+            }
 
-            if ((string)item.Content == "Viewer")
+            if (item.Content as string == "Viewer")
             {
                 regularViewerControl.IsActive = true;
                 if (regularViewerControl.PdfViewControl != null && regularViewerControl.PdfViewControl.PDFView != null)
@@ -327,7 +336,7 @@ namespace PDFViewer_new
                     regularViewerControl.SetDisplaySettingsControl(displaySettingsControl);
                 }
             }
-            else if ((string)item.Content == "Annotation")
+            else if (item.Content as string == "Annotation")
             {
                 annotationControl.IsActive = true;
                 annotationControl.SetToolBarContainerVisibility(Visibility.Visible);
@@ -346,7 +355,7 @@ namespace PDFViewer_new
                     annotationControl.SetDisplaySettingsControl(displaySettingsControl);
                 }
             }
-            else if ((string)item.Content == "Form")
+            else if (item.Content as string == "Form")
             {
                 formControl.IsActive = true;
                 formControl.SetToolBarContainerVisibility(Visibility.Visible);
@@ -365,7 +374,7 @@ namespace PDFViewer_new
                     formControl.SetDisplaySettingsControl(displaySettingsControl);
                 }
             }
-            else if ((string)item.Content == "Content Editor")
+            else if (item.Content as string == "Content Editor")
             {
                 contentEditControl.IsActive = true;
                 if (contentEditControl.pdfContentEditControl != null && contentEditControl.PdfViewControl.PDFView != null)
@@ -375,9 +384,8 @@ namespace PDFViewer_new
                     pdfViewer.PDFView?.SetMouseMode(MouseModes.PDFEdit);
                     pdfViewer.PDFView?.ReloadDocument();
 
-                    //pdfViewer.PDFView.PDFEditActiveHandler += PDFView_PDFEditActiveHandler;
                     pdfViewer.PDFView?.SetSplitMode(SplitMode.None);
-                    
+
                     PDFGrid.Child = contentEditControl;
                     contentEditControl.PdfViewControl.PDFView.SetMouseMode(MouseModes.PDFEdit);
                     contentEditControl.PdfViewControl = pdfViewer;
@@ -385,13 +393,23 @@ namespace PDFViewer_new
                     contentEditControl.OnCanSaveChanged -= FormControlOnCanSaveChanged;
                     contentEditControl.OnCanSaveChanged += FormControlOnCanSaveChanged;
                     contentEditControl.SetBOTAContainer(botaBarControl);
-                    
                 }
             }
-            currentMode = (string)item.Content;
+            else if (item.Content as string == "Docs Editor")
+            {
+                pageEditControl.PDFViewControl = pdfViewer;
+                pageEditControl.ExitPageEdit += PageEditControl_ExitPageEdit;
+                PDFGrid.Child = pageEditControl;
+            }
+            currentMode = item.Content as string;
             RightToolPanelButtonIsChecked = false;
         }
 
+        private void PageEditControl_ExitPageEdit(object sender, EventArgs e)
+        {
+            ModeComboBox.SelectedIndex = 0;
+        }
+
         private void PageInfoBtn_Click(object sender, RoutedEventArgs e)
         {
             PasswordUI.Visibility = Visibility.Collapsed;
@@ -401,8 +419,7 @@ namespace PDFViewer_new
         }
 
         private void ViewSettingBtn_Click(object sender, RoutedEventArgs e)
-        {
-            //ShowViewSettings();
+        { 
             panelState.RightPanel =
                ((sender as ToggleButton).IsChecked == true) ?
                PanelState.RightPanelState.ViewSettings : PanelState.RightPanelState.None;
@@ -469,7 +486,7 @@ namespace PDFViewer_new
         /// <summary>
         /// Save the file in the current path.
         /// </summary>
-        private void SaveFile()
+        public void SaveFile()
         {
             if (pdfViewer != null && pdfViewer.PDFView != null && pdfViewer.PDFView.Document != null)
             {
@@ -509,6 +526,14 @@ namespace PDFViewer_new
         {
             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
         }
+
+        internal void SetPDFViewer(PDFViewControl newPdfViewer)
+        {
+            if (newPdfViewer != null)
+            {
+                pdfViewer = newPdfViewer;
+            }
+        }
     }
 
 }

+ 254 - 2
Demo/Examples/PDFViewer_new/MainWindow.xaml

@@ -1,12 +1,264 @@
 <Window x:Class="PDFViewer_new.MainWindow"
+        x:Name="Window"
+        
         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:local="clr-namespace:PDFViewer_new"
         mc:Ignorable="d"
-        Title="MainWindow" Height="450" Width="800">
+        SnapsToDevicePixels="True" 
+        xmlns:cpdfcommon="clr-namespace:Compdfkit_Tools.Common;assembly=Compdfkit_Tools"
+        xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
+        BorderThickness="{Binding RelativeSource={RelativeSource Mode=Self},Path=WindowState,Converter={StaticResource WindowStateToThicknessConverter}}"
+        Title="ComPDFKit V1.9.1" Height="450" Width="800">
+    <WindowChrome.WindowChrome>
+        <WindowChrome 
+            CornerRadius="8"
+            NonClientFrameEdges="Left,Bottom,Right"
+            UseAeroCaptionButtons="False"
+            ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}">
+            <WindowChrome.CaptionHeight>
+                <MultiBinding Converter="{StaticResource CaptionHeightConverter}">
+                    <Binding ElementName="TitleBarGrid" Path="ActualHeight"/>
+                    <Binding ElementName="Window" Path="BorderThickness.Top"/>
+                </MultiBinding>
+            </WindowChrome.CaptionHeight>
+        </WindowChrome>
+    </WindowChrome.WindowChrome>
+
+    <Window.Resources>
+        <ControlTemplate x:Key="CloseFileButton" TargetType="{x:Type ButtonBase}">
+            <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
+                                BorderBrush="{TemplateBinding Border.BorderBrush}"
+                                Background="{TemplateBinding Panel.Background}"
+                                Name="border"
+                                SnapsToDevicePixels="True">
+                <Path Name="content" VerticalAlignment="Center" HorizontalAlignment="Center" Fill="#666666">
+                    <Path.RenderTransform>
+                        <TransformGroup>
+                            <TranslateTransform X="8" Y="-8"/>
+                            <RotateTransform Angle="45"/>
+                            <TranslateTransform X="-4" Y="-5"/>
+                        </TransformGroup>
+                    </Path.RenderTransform>
+                    <Path.Data>
+                        M9.48528137,2.98528137 L9.48428137,8.48428137 L14.9852814,8.48528137 L14.9852814,9.48528137 L9.48428137,9.48428137 L9.48528137,14.9852814 L8.48528137,14.9852814 
+                        L8.48428137,9.48428137 L2.98528137,9.48528137 L2.98528137,8.48528137 L8.48428137,8.48428137 L8.48528137,2.98528137 L9.48528137,2.98528137 Z
+                    </Path.Data>
+                </Path>
+            </Border>
+            <ControlTemplate.Triggers>
+                <Trigger Property="Button.IsDefaulted" Value="True">
+                    <Setter Property="Path.Fill"  TargetName="content" Value="#666666" />
+                </Trigger>
+                <Trigger Property="UIElement.IsMouseOver"  Value="True">
+                    <Setter Property="Path.Fill" TargetName="content" Value="#333333" />
+                </Trigger>
+                <Trigger Property="ButtonBase.IsPressed" Value="True">
+                    <Setter Property="Path.Fill" TargetName="content"  Value="#000000" />
+                </Trigger>
+            </ControlTemplate.Triggers>
+        </ControlTemplate>
+
+        <ControlTemplate x:Key="AddFileButton" TargetType="{x:Type ButtonBase}">
+            <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
+                                BorderBrush="{TemplateBinding Border.BorderBrush}"
+                                Background="{TemplateBinding Panel.Background}"
+                                Name="border"
+                                SnapsToDevicePixels="True">
+                <Path Name="content" VerticalAlignment="Center" HorizontalAlignment="Center" Fill="#FFFFFF">
+                    <Path.RenderTransform>
+                        <TransformGroup>
+                            <TranslateTransform X="-2" Y="-2"/>
+                        </TransformGroup>
+                    </Path.RenderTransform>
+                    <Path.Data>
+                        M9.48528137,2.98528137 L9.48428137,8.48428137 L14.9852814,8.48528137 L14.9852814,9.48528137 L9.48428137,9.48428137 L9.48528137,14.9852814 L8.48528137,14.9852814 
+                        L8.48428137,9.48428137 L2.98528137,9.48528137 L2.98528137,8.48528137 L8.48428137,8.48428137 L8.48528137,2.98528137 L9.48528137,2.98528137 Z
+                    </Path.Data>
+                </Path>
+            </Border>
+            <ControlTemplate.Triggers>
+                <Trigger Property="Button.IsDefaulted" Value="True">
+                    <Setter Property="Path.Fill" TargetName="content" Value="#666666" />
+                </Trigger>
+                <Trigger Property="UIElement.IsMouseOver"  Value="True">
+                    <Setter Property="Path.Fill" TargetName="content" Value="#333333" />
+                </Trigger>
+                <Trigger Property="ButtonBase.IsPressed" Value="True">
+                    <Setter Property="Path.Fill" TargetName="content" Value="#000000" />
+                </Trigger>
+            </ControlTemplate.Triggers>
+        </ControlTemplate>
+
+        <Style x:Key="DragablzItemStyle" TargetType="{x:Type dragablz:DragablzItem}">
+            <Setter Property="Template">
+                <Setter.Value>
+                    <ControlTemplate TargetType="dragablz:DragablzItem">
+                        <Grid x:Name="templateRoot">
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition Width="*" />
+                                <ColumnDefinition Width="auto" />
+                            </Grid.ColumnDefinitions>
+                            <Border  x:Name="Title"  Width="184"  Height="32"  Margin="10,4,0,0" BorderBrush="#A0A2AE" BorderThickness="1,1,1,0" CornerRadius="3,3,0,0">
+                                <Grid Background="Transparent">
+                                    <Grid.ColumnDefinitions>
+                                        <ColumnDefinition Width="auto" />
+                                        <ColumnDefinition Width="*" MinWidth="10" />
+                                        <ColumnDefinition Width="auto" />
+                                    </Grid.ColumnDefinitions>
+                                    <TextBlock  x:Name="TextTitle"  MaxWidth="145"  Margin="8,4,0,4"  FontFamily="Segoe UI,Microsoft YaHei"  Text="{Binding FileName}"  TextTrimming="WordEllipsis" />
+                                    <Thumb  x:Name="PART_Thumb"  Grid.ColumnSpan="2"  HorizontalAlignment="Stretch"  VerticalContentAlignment="Stretch" Background="Transparent"  FontFamily="Segoe UI,Microsoft YaHei"  ToolTip="{Binding FileName}">
+                                        <Thumb.Template>
+                                            <ControlTemplate>
+                                                <Grid Background="Transparent" />
+                                            </ControlTemplate>
+                                        </Thumb.Template>
+                                    </Thumb>
+                                    <TextBlock  x:Name="ChangeIcon"  Grid.Column="1" Width="5" Margin="3,4,2,0" HorizontalAlignment="Left" VerticalAlignment="Top" IsHitTestVisible="False"  Text="*" Visibility="{Binding FileChanged}" />
+
+                                    <Button x:Name="CloseFileButton" Grid.Column="2"  Width="16" Height="16"  Margin="0,4,8,4" Background="Transparent"  BorderThickness="0" Template="{StaticResource CloseFileButton}"  Click="CloseFileButton_Click"></Button>
+                                </Grid>
+                            </Border>
+                        </Grid>
+                        <ControlTemplate.Triggers>
+                            <Trigger Property="IsSelected" Value="True">
+                                <Setter TargetName="Title" Property="Background" Value="#FFFFFF" />
+                                <Setter TargetName="Title" Property="BorderThickness" Value="1,1,1,0" />
+                                <Setter TargetName="TextTitle" Property="Foreground" Value="Black" />
+                                <Setter TargetName="ChangeIcon" Property="Foreground" Value="Black" />
+                            </Trigger>
+                            <Trigger Property="IsSelected" Value="False">
+                                <Setter TargetName="Title" Property="Background" Value="TransParent" />
+                                <Setter TargetName="Title" Property="BorderThickness" Value="1,1,1,0" />
+                                <Setter TargetName="TextTitle" Property="Foreground" Value="White" />
+                                <Setter TargetName="ChangeIcon" Property="Foreground" Value="white" />
+                            </Trigger>
+                            <MultiDataTrigger>
+                                <MultiDataTrigger.Conditions>
+                                    <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false" />
+                                    <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true" />
+                                </MultiDataTrigger.Conditions>
+                                <Setter TargetName="Title" Property="Background" Value="#0D000000" />
+                                <Setter TargetName="TextTitle" Property="Foreground" Value="black" />
+                                <Setter TargetName="ChangeIcon" Property="Foreground" Value="black" />
+                            </MultiDataTrigger>
+                        </ControlTemplate.Triggers>
+                    </ControlTemplate>
+                </Setter.Value>
+            </Setter>
+        </Style>
+        <Style x:Key="TitleBarButtonStyle" TargetType="Button">
+            <Setter Property="Foreground" Value="#FFFFFF" />
+            <Setter Property="Padding" Value="0" />
+            <Setter Property="Margin" Value="0" />
+            <Setter Property="VerticalAlignment" Value="Top" />
+            <Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
+            <Setter Property="IsTabStop" Value="False" />
+            <Setter Property="Width" Value="36" />
+            <Setter Property="Height" Value="30" />
+            <Setter Property="Template">
+                <Setter.Value>
+                    <ControlTemplate TargetType="{x:Type Button}">
+                        <Border x:Name="border"
+                                Background="Transparent"
+                                BorderThickness="0"
+                                SnapsToDevicePixels="True">
+                            <ContentPresenter x:Name="contentPresenter"
+                                Margin="0"
+                                HorizontalAlignment="Center"
+                                VerticalAlignment="Center"
+                                Focusable="False"
+                                RecognizesAccessKey="True" />
+                        </Border>
+                        <ControlTemplate.Triggers>
+                            <Trigger Property="IsMouseOver" Value="true">
+                                <Setter TargetName="border" Property="Background" Value="#1AE9E9E9" />
+                            </Trigger>
+                            <Trigger Property="IsPressed" Value="true">
+                                <Setter TargetName="border" Property="Background" Value="#1AEDEDED" />
+                            </Trigger>
+                        </ControlTemplate.Triggers>
+                    </ControlTemplate>
+                </Setter.Value>
+            </Setter>
+        </Style>
+
+        <Style x:Key="TitleBarCloseButtonStyle" BasedOn="{StaticResource TitleBarButtonStyle}" TargetType="Button">
+            <Setter Property="Template">
+                <Setter.Value>
+                    <ControlTemplate TargetType="{x:Type Button}">
+                        <Border x:Name="border"
+                                Background="Transparent"
+                                BorderThickness="0"
+                                SnapsToDevicePixels="True">
+                            <ContentPresenter x:Name="contentPresenter"
+                                Margin="0"
+                                HorizontalAlignment="Center"
+                                VerticalAlignment="Center"
+                                Focusable="False"
+                                RecognizesAccessKey="True" />
+                        </Border>
+                        <ControlTemplate.Triggers>
+                            <Trigger Property="IsMouseOver" Value="true">
+                                <Setter TargetName="border" Property="Background" Value="#C42B1C" />
+                            </Trigger>
+                            <Trigger Property="IsPressed" Value="true">
+                                <Setter TargetName="border" Property="Background" Value="#C84031" />
+                            </Trigger>
+                        </ControlTemplate.Triggers>
+                    </ControlTemplate>
+                </Setter.Value>
+            </Setter>
+        </Style>
+    </Window.Resources>
     <Grid>
-        <local:MainPage></local:MainPage>
+        <Grid Background="#273C62" Margin="0,-1,0,0">
+            <dragablz:TabablzControl Name="TabControl" ItemContainerStyle="{StaticResource DragablzItemStyle}" WindowChrome.IsHitTestVisibleInChrome="True">
+                <dragablz:TabablzControl.InterTabController>
+                    <dragablz:InterTabController />
+                </dragablz:TabablzControl.InterTabController>
+                <dragablz:TabablzControl.HeaderSuffixContent>
+                    <Grid Name="TitleBarGrid" MinHeight="32">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="auto"></ColumnDefinition>
+                            <ColumnDefinition Width="*"></ColumnDefinition>
+                            <ColumnDefinition Width="auto"></ColumnDefinition>
+                        </Grid.ColumnDefinitions>
+                        <Button  x:Name="addBtn" Width="16"  Height="16"  Margin="9,7,0,5"  HorizontalAlignment="Left" Background="Transparent"  BorderThickness="0" 
+                             Click="DefaultAddButton_Click"  Template="{StaticResource AddFileButton}"></Button>
+                        <Grid Grid.Column="2" HorizontalAlignment="Right">
+                            <StackPanel Orientation="Horizontal" Margin="0,-2,0,0">
+                                <Button x:Name="MinimizeButton" Style="{StaticResource TitleBarButtonStyle}" Width="36" Height="32" Click="MinimizeButton_Click">
+                                    <Path Width="36" Height="32"
+                                        Data="M 13,15 H 23"
+                                        Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
+                                        StrokeThickness="1" />
+                                </Button>
+                                <Button x:Name="MaximizeRestoreButton" Style="{StaticResource TitleBarButtonStyle}" Width="36" Height="32" Click="MaximizeRestoreButton_Click">
+                                    <Path Width="36" Height="32"
+                      Data="{Binding ElementName=Window, Path=WindowState, Converter={StaticResource WindowStateToPathConverter}}"
+                      Stroke="{Binding Path=Foreground,RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
+                      StrokeThickness="1" />
+                                </Button>
+                                <Button x:Name="CloseButton" Style="{StaticResource TitleBarCloseButtonStyle}" Width="36" Height="32" Click="CloseButton_Click">
+                                    <Path Width="36" Height="32"
+                                        Data="M 13,11 22,20 M 13,20 22,11"
+                                        Stroke="{Binding Path=Foreground,RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
+                                        StrokeThickness="1" />
+                                </Button>
+                            </StackPanel>
+                        </Grid>
+                    </Grid>
+                </dragablz:TabablzControl.HeaderSuffixContent>
+
+            </dragablz:TabablzControl>
+        </Grid>
+
+        <Border Name="PopupBorder" Background="#A0000000" Visibility="Collapsed">
+            <cpdfcommon:PasswordDialog x:Name="PasswordUI" Visibility="Collapsed"></cpdfcommon:PasswordDialog>
+        </Border>
     </Grid>
+
 </Window>

+ 386 - 2
Demo/Examples/PDFViewer_new/MainWindow.xaml.cs

@@ -1,4 +1,6 @@
-using System;
+using Compdfkit_Tools.PDFControl;
+
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -11,7 +13,11 @@ using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
-using System.Windows.Shapes;
+using System.IO;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+using Dragablz;
+using Compdfkit_Tools.Helper;
 
 namespace PDFViewer_new
 {
@@ -20,9 +26,387 @@ namespace PDFViewer_new
     /// </summary>
     public partial class MainWindow : Window
     {
+        #region Property
+        private PDFViewControl passwordViewer;
+        private PDFViewControl pdfViewControl = new PDFViewControl();
+        private string[] oldAndNewFilePath;
+
+        #endregion
+
         public MainWindow()
         {
             InitializeComponent();
+            Loaded += MainWindow_Loaded; ;
+
+        }
+
+        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
+        {
+            PasswordUI.Closed -= PasswordUI_Closed;
+            PasswordUI.Canceled -= PasswordUI_Canceled;
+            PasswordUI.Confirmed -= PasswordUI_Confirmed;
+            PasswordUI.Confirmed += PasswordUI_Confirmed;
+            PasswordUI.Canceled += PasswordUI_Canceled;
+            PasswordUI.Closed += PasswordUI_Closed;
+
+            if (App.DefaultPDFLoaded == false)
+            {
+                LoadDefaultDocument();
+                App.DefaultPDFLoaded = true;
+            }
+        }
+
+        private void LoadDefaultDocument()
+        {
+            string defaultFilePath = "PDF32000_2008.pdf";
+            TabControlLoadDocument(defaultFilePath);
+        }
+
+
+        private void TabControlLoadDocument(string filePath)
+        {
+            if (App.OpenedFilePathList.Contains(filePath))
+            {
+                for (int i = 0; i < App.Current.Windows.Count; i++)
+                {
+                    MainWindow win = App.Current.Windows[i] as MainWindow;
+                    if (win != null)
+                    {
+                        var items = win.TabControl.Items;
+
+                        foreach (TabItemExt item in items)
+                        {
+                            if (item.Tag.ToString().ToLower() == filePath.ToLower())
+                            {
+                                win.Activate();
+                                item.IsSelected = true;
+                                return;
+                            }
+                        }
+                    }
+                }
+            }
+
+            TabItemExt tabItem = new TabItemExt();
+            MainPage viewPage = new MainPage();
+
+            viewPage.CheckExistBeforeOpenFileEvent -= ViewPage_CheckExistBeforeOpenFileEvent;
+            viewPage.FileChangeEvent -= ViewPage_FileChangeEvent;
+            viewPage.CheckExistBeforeOpenFileEvent += ViewPage_CheckExistBeforeOpenFileEvent;
+            viewPage.FileChangeEvent += ViewPage_FileChangeEvent;
+
+            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
+            {
+                viewPage.InitWithFilePath(filePath);
+                tabItem.Content = viewPage;
+                tabItem.IsSelected = true;
+                tabItem.FileName = Path.GetFileName(filePath);
+                tabItem.Tag = filePath;
+
+                App.OpenedFilePathList.Add(filePath);
+                TabControl.Items.Add(tabItem);
+            }
+        }
+
+        private void PasswordUI_Closed(object sender, EventArgs e)
+        {
+            PopupBorder.Visibility = Visibility.Collapsed;
+            PasswordUI.Visibility = Visibility.Collapsed;
+        }
+
+        private void PasswordUI_Canceled(object sender, EventArgs e)
+        {
+            PopupBorder.Visibility = Visibility.Collapsed;
+            PasswordUI.Visibility = Visibility.Collapsed;
+        }
+
+        private void PasswordUI_Confirmed(object sender, string e)
+        {
+            if (passwordViewer != null && passwordViewer.PDFView != null && passwordViewer.PDFView.Document != null)
+            {
+                passwordViewer.PDFView.Document.UnlockWithPassword(e);
+                if (passwordViewer.PDFView.Document.IsLocked == false)
+                {
+                    PasswordUI.SetShowError("", Visibility.Collapsed);
+                    PasswordUI.ClearPassword();
+                    PasswordUI.Visibility = Visibility.Collapsed;
+                    PopupBorder.Visibility = Visibility.Collapsed;
+                    pdfViewControl = passwordViewer;
+
+                    string filePath = passwordViewer.PDFView.Document.FilePath;
+                    TabItemExt tabItem = new TabItemExt();
+                    MainPage viewPage = new MainPage();
+
+                    tabItem.Content = viewPage;
+                    tabItem.IsSelected = true;
+                    tabItem.FileName = Path.GetFileName(filePath);
+                    tabItem.Tag = filePath;
+
+                    viewPage.SetPDFViewer(pdfViewControl);
+                    App.OpenedFilePathList.Add(filePath);
+
+                    TabControl.Items.Add(tabItem);
+                }
+                else
+                {
+                    PasswordUI.SetShowError("error", Visibility.Visible);
+                }
+            }
+
+        }
+
+
+        private void ViewPage_FileChangeEvent(object sender, EventArgs e)
+        {
+            for (int i = 0; i < App.Current.Windows.Count; i++)
+            {
+                MainWindow win = App.Current.Windows[i] as MainWindow;
+                if (win != null)
+                {
+                    var items = win.TabControl.Items;
+
+                    foreach (TabItemExt item in items)
+                    {
+                        if (item.Tag.ToString().ToLower() == oldAndNewFilePath[1].ToLower())
+                        {
+                            item.IsSelected = true;
+                            item.FileName = Path.GetFileName(oldAndNewFilePath[0]);
+                            item.IsSelected = true;
+                            item.Tag = oldAndNewFilePath[0];
+                        }
+                    }
+                }
+            }
+
+            for (int i = 0; i < App.OpenedFilePathList.Count; i++)
+            {
+                if (oldAndNewFilePath[1].ToLower() == App.OpenedFilePathList[i].ToLower())
+                {
+                    App.OpenedFilePathList[i] = oldAndNewFilePath[0];
+                    break;
+                }
+            }
+        }
+
+        private bool ViewPage_CheckExistBeforeOpenFileEvent(string[] arg)
+        {
+
+            if (App.OpenedFilePathList.Contains(arg[0]))
+            {
+                for (int i = 0; i < App.Current.Windows.Count; i++)
+                {
+                    MainWindow win = App.Current.Windows[i] as MainWindow;
+                    if (win != null)
+                    {
+                        var items = win.TabControl.Items;
+
+                        foreach (TabItemExt item in items)
+                        {
+                            if (item.Tag.ToString().ToLower() == arg[0].ToLower())
+                            {
+                                win.Activate();
+                                item.IsSelected = true;
+                                return true;
+                            }
+                        }
+                    }
+                }
+            }
+            oldAndNewFilePath = arg;
+            return false;
+        }
+
+        public class TabItemExt : TabItem, INotifyPropertyChanged
+        {
+            public event PropertyChangedEventHandler PropertyChanged;
+            private string _fileName;
+            public string FileName
+            {
+                get
+                {
+                    return _fileName;
+                }
+                set
+                {
+                    if (_fileName != value)
+                    {
+                        _fileName = value;
+                        OnPropertyChanged();
+                    }
+                }
+            }
+
+            private Visibility _fileChanged = Visibility.Hidden;
+
+            public Visibility FileChanged
+            {
+                get
+                {
+                    return _fileChanged;
+                }
+                set
+                {
+                    if (_fileChanged != value)
+                    {
+                        _fileChanged = value;
+                        OnPropertyChanged();
+                    }
+                }
+            }
+
+            public void OnPropertyChanged([CallerMemberName] string name = null)
+            {
+                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
+            }
+        }
+
+        private DragablzItem FindParentDragablzItem(DependencyObject element)
+        {
+            while (element != null && !(element is DragablzItem))
+            {
+                element = VisualTreeHelper.GetParent(element);
+            }
+
+            return element as DragablzItem;
+        }
+
+        private TabControl FindParentTabControl(DependencyObject element)
+        {
+            while (element != null && !(element is TabControl))
+            {
+                element = VisualTreeHelper.GetParent(element);
+            }
+
+            return element as TabControl;
+        }
+
+        private void CloseFileButton_Click(object sender, RoutedEventArgs e)
+        {
+            var button = sender as Button;
+            var dragablzItem = FindParentDragablzItem(button);
+            var tabControl = FindParentTabControl(dragablzItem);
+            MainPage mainPage = (dragablzItem.Content as TabItemExt).Content as MainPage;
+
+            if (mainPage.CanSave)
+            {
+                string fileName = (dragablzItem.Content as TabItemExt).FileName;
+                var message = string.Format("Do you want to save the changes in {0}?", fileName);
+                var result = MessageBox.Show(message, "Alert", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
+
+                if (result == MessageBoxResult.Yes)
+                {
+                    mainPage.SaveFile();
+                    App.OpenedFilePathList.Remove((dragablzItem.Content as TabItemExt).Tag.ToString());
+                    tabControl.Items.Remove(dragablzItem.Content);
+
+                }
+                else if (result == MessageBoxResult.No)
+                {
+                    App.OpenedFilePathList.Remove((dragablzItem.Content as TabItemExt).Tag.ToString());
+                    tabControl.Items.Remove(dragablzItem.Content);
+                }
+                else
+                {
+
+                }
+            }
+            else
+            {
+                App.OpenedFilePathList.Remove((dragablzItem.Content as TabItemExt).Tag.ToString());
+                tabControl.Items.Remove(dragablzItem.Content);
+            }
+
+            if (tabControl.Items.Count == 0)
+            {
+                SystemCommands.CloseWindow(this);
+            }
+        }
+
+        private void DefaultAddButton_Click(object sender, RoutedEventArgs e)
+        {
+            string filePath = CommonHelper.GetFilePathOrEmpty();
+            if (filePath != string.Empty)
+            {
+                TabControlLoadDocument(filePath);
+            }
+        }
+
+        private void MinimizeButton_Click(object sender, RoutedEventArgs e)
+        {
+            SystemCommands.MinimizeWindow(this);
+        }
+
+        private void MaximizeRestoreButton_Click(object sender, RoutedEventArgs e)
+        {
+            if (this.WindowState == WindowState.Maximized)
+            {
+                SystemCommands.RestoreWindow(this);
+            }
+            else
+            {
+                SystemCommands.MaximizeWindow(this);
+            }
+        }
+
+        private void CloseButton_Click(object sender, RoutedEventArgs e)
+        {
+            int count = TabControl.Items.Count;
+            while (count > 0)
+            {
+                TabItemExt item = TabControl.Items[0] as TabItemExt;
+
+                MainPage mainPage = item.Content as MainPage;
+                if (mainPage.CanSave)
+                {
+                    string fileName = item.FileName;
+                    var message = string.Format("Do you want to save the changes in {0}?", fileName);
+                    var result = MessageBox.Show(message, "Alert", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
+
+                    if (result == MessageBoxResult.Yes)
+                    {
+                        mainPage.SaveFile();
+                        App.OpenedFilePathList.Remove(item.Tag.ToString());
+                        TabControl.Items.Remove(item);
+                        count--;
+                    }
+                    else if (result == MessageBoxResult.No)
+                    {
+                        App.OpenedFilePathList.Remove(item.Tag.ToString());
+                        TabControl.Items.Remove(item);
+                        count--;
+                    }
+                    else
+                    {
+                        break;
+                    }
+                }
+                else
+                {
+                    App.OpenedFilePathList.Remove(item.Tag.ToString());
+                    TabControl.Items.Remove(item);
+                    count--;
+                }
+            }
+
+            if (count == 0)
+            {
+                SystemCommands.CloseWindow(this);
+            }
         }
     }
 }

+ 10 - 5
Demo/Examples/PDFViewer_new/PDFViewer_new.csproj

@@ -39,11 +39,8 @@
     <Prefer32bit>false</Prefer32bit>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="ComPDFKit.Desk, Version=1.9.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <HintPath>..\packages\ComPDFKit.NetFramework.1.9.0\lib\ComPDFKit.Desk.dll</HintPath>
-    </Reference>
-    <Reference Include="ComPDFKit.Viewer, Version=1.9.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <HintPath>..\packages\ComPDFKit.NetFramework.1.9.0\lib\ComPDFKit.Viewer.dll</HintPath>
+    <Reference Include="Dragablz">
+      <HintPath>.\Dragablz.dll</HintPath>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Data" />
@@ -113,6 +110,14 @@
     <None Include="App.config" />
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\..\..\..\compdfkit\ComPDFKit\ComPDFKitCSharp\ComPDFKit.Desk.csproj">
+      <Project>{56e518ad-c126-4b48-9a09-0a64c87020e4}</Project>
+      <Name>ComPDFKit.Desk</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\..\compdfkit\ComPDFKit\ComPDFKitDesktop\ComPDFKit.Viewer\ComPDFKit.Viewer.csproj">
+      <Project>{18ec356d-8130-49d4-b4e6-ac290e1065b7}</Project>
+      <Name>ComPDFKit.Viewer</Name>
+    </ProjectReference>
     <ProjectReference Include="..\Compdfkit_Tools\Compdfkit_Tools.csproj">
       <Project>{9363bcb1-3a67-446a-8093-5708b86bf418}</Project>
       <Name>Compdfkit_Tools</Name>

+ 1 - 3
Demo/Examples/Samples/LicenseKey.cs

@@ -21,9 +21,7 @@ public class SDKLicenseHelper
 
     public static bool LicenseVerify()
     {
-        bool result = false;
-
-        result = CPDFSDKVerifier.LoadNativeLibrary();
+        bool result = CPDFSDKVerifier.LoadNativeLibrary();
         if (!result)
             return false;