Bladeren bron

Merge branch 'compdfkit_demo_win_rebuild' of http://git.kdan.cc:8865/Others/kmpdfkit_demo into compdfkit_demo_win_rebuild

# Conflicts:
#	Demo/Examples/Compdfkit_Tools/PDFView/PDFViewControl/PDFViewControl.xaml.cs
zhuyi 9 maanden geleden
bovenliggende
commit
987078330b

+ 30 - 27
Demo/Examples/Compdfkit_Tools/Common/BarControl/CPDFMeasureBarControl.xaml.cs

@@ -275,14 +275,15 @@ namespace Compdfkit_Tools.PDFControl
             //pdfViewer?.ClearSelectAnnots();
             //pdfViewer?.SetMouseMode(MouseModes.AnnotCreate);
             //pdfViewer?.SetToolParam(lineMeasureArgs);
-            //measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_DISTANCE_MEASURE);
-            //measureControl.SetInfoPanelVisble(true, false);
-            //measureControl.SetMeasureScale(CPDFMeasureType.CPDF_DISTANCE_MEASURE,
-            //    string.Format("{0}{1}={2}{3}",
-            //                MeasureSetting.RulerBase,
-            //                MeasureSetting.RulerBaseUnit,
-            //                MeasureSetting.RulerTranslate,
-            //                MeasureSetting.RulerTranslateUnit));
+            measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_DISTANCE_MEASURE);
+            measureControl.SetInfoPanelVisble(true, false);
+            var measureSetting = pdfViewer.PDFViewTool.GetMeasureSetting();
+            measureControl.SetMeasureScale(CPDFMeasureType.CPDF_DISTANCE_MEASURE,
+               string.Format("{0}{1}={2}{3}",
+                   measureSetting.RulerBase,
+                   measureSetting.RulerBaseUnit,
+                   measureSetting.RulerTranslate,
+                   measureSetting.RulerTranslateUnit));
             return lineMeasureParam;
         }
 
@@ -316,17 +317,18 @@ namespace Compdfkit_Tools.PDFControl
             //polyLineMeasureArgs.FontColor = Colors.Red;
             //polyLineMeasureArgs.FontName = "Arial";
             //polyLineMeasureArgs.FontSize = 14;
-            //pdfViewer?.ClearSelectAnnots();
-            //pdfViewer?.SetMouseMode(MouseModes.AnnotCreate);
-            //pdfViewer?.SetToolParam(polyLineMeasureArgs);
-            //measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_PERIMETER_MEASURE);
-            //measureControl.SetInfoPanelVisble(true, false);
-            //measureControl.SetMeasureScale(CPDFMeasureType.CPDF_PERIMETER_MEASURE,
-            //   string.Format("{0}{1}={2}{3}",
-            //               MeasureSetting.RulerBase,
-            //               MeasureSetting.RulerBaseUnit,
-            //               MeasureSetting.RulerTranslate,
-            //               MeasureSetting.RulerTranslateUnit));
+            // pdfViewer?.ClearSelectAnnots();
+            // pdfViewer?.SetMouseMode(MouseModes.AnnotCreate);
+            // pdfViewer?.SetToolParam(polyLineMeasureArgs);
+            measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_PERIMETER_MEASURE);
+            measureControl.SetInfoPanelVisble(true, false);
+            var measureSetting = pdfViewer.PDFViewTool.GetMeasureSetting();
+            measureControl.SetMeasureScale(CPDFMeasureType.CPDF_PERIMETER_MEASURE,
+               string.Format("{0}{1}={2}{3}",
+                   measureSetting.RulerBase,
+                   measureSetting.RulerBaseUnit,
+                   measureSetting.RulerTranslate,
+                   measureSetting.RulerTranslateUnit));
             return polyLineMeasureParam;
         }
 
@@ -364,14 +366,15 @@ namespace Compdfkit_Tools.PDFControl
             //    pdfViewer?.ClearSelectAnnots();
             //    pdfViewer?.SetMouseMode(MouseModes.AnnotCreate);
             //    pdfViewer?.SetToolParam(polygonMeasureArgs);
-            //    measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_AREA_MEASURE);
-            //    measureControl.SetInfoPanelVisble(true, false);
-            //    measureControl.SetMeasureScale(CPDFMeasureType.CPDF_AREA_MEASURE,
-            //      string.Format("{0}{1}={2}{3}",
-            //                  MeasureSetting.RulerBase,
-            //                  MeasureSetting.RulerBaseUnit,
-            //                  MeasureSetting.RulerTranslate,
-            //                  MeasureSetting.RulerTranslateUnit));
+            measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_AREA_MEASURE);
+            measureControl.SetInfoPanelVisble(true, false);
+            var measureSetting = pdfViewer.PDFViewTool.GetMeasureSetting();
+            measureControl.SetMeasureScale(CPDFMeasureType.CPDF_AREA_MEASURE,
+                string.Format("{0}{1}={2}{3}",
+                    measureSetting.RulerBase,
+                    measureSetting.RulerBaseUnit,
+                    measureSetting.RulerTranslate,
+                    measureSetting.RulerTranslateUnit));
             //    return polygonMeasureArgs;
             return polygonMeasureParam;
         }

+ 129 - 10
Demo/Examples/Compdfkit_Tools/DigitalSignature/DigitalSignatureControl/DigitalSignatureControl.xaml.cs

@@ -10,9 +10,12 @@ using System.Windows.Input;
 using System.Windows.Media;
 using Compdfkit_Tools.Helper;
 using ComPDFKit.DigitalSign;
+using ComPDFKit.PDFAnnotation;
 using ComPDFKit.PDFAnnotation.Form;
 using ComPDFKit.Tool;
+using ComPDFKit.Tool.Help;
 using ComPDFKitViewer;
+using ComPDFKitViewer.Widget;
 
 namespace Compdfkit_Tools.PDFControl
 {
@@ -141,10 +144,118 @@ namespace Compdfkit_Tools.PDFControl
             //PDFViewControl.PDFView.AnnotCommandHandler -= PDFView_AnnotCommandHandler;
             //PDFViewControl.PDFView.AnnotCommandHandler += PDFView_AnnotCommandHandler;
             
+            PDFViewControl.PDFViewTool.MouseLeftButtonDownHandler -= PDFViewControl_MouseLeftButtonDownHandler;
+            PDFViewControl.PDFViewTool.MouseLeftButtonDownHandler += PDFViewControl_MouseLeftButtonDownHandler;
+            PDFViewControl.PDFViewTool.MouseRightButtonDownHandler -= PDFViewControl_MouseRightButtonDownHandler;
+            PDFViewControl.PDFViewTool.MouseRightButtonDownHandler += PDFViewControl_MouseRightButtonDownHandler;
+            
             panelState.PropertyChanged -= PanelState_PropertyChanged;
             panelState.PropertyChanged += PanelState_PropertyChanged;
         }
-        
+
+        private void PDFViewControl_MouseRightButtonDownHandler(object sender, MouseEventObject e)
+        {
+            ContextMenu ContextMenu = PDFViewControl.GetRightMenu();
+            if (ContextMenu == null)
+            {
+                ContextMenu = new ContextMenu();
+            }
+            if (PDFViewControl.PDFViewTool.GetViewerModel() == MouseModes.WidgetEditTool && e.annotType== C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET)
+            {
+                BaseWidget baseWidget = PDFViewControl.GetCacheHitTestWidget();
+                if(baseWidget == null)
+                {
+                    return;
+                }
+
+                var widget = baseWidget.GetAnnotData().Annot as CPDFWidget;
+                if (widget == null || widget.WidgetType != C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS)
+                {
+                    return;
+                }
+                var signatureWidget = widget as CPDFSignatureWidget;
+                CPDFSignature sig = signatureWidget.GetSignature(PDFViewControl.GetCPDFViewer().GetDocument());
+                if (signatureWidget.IsSigned() && sig != null && sig?.SignerList.Count > 0)
+                {
+                    MenuItem deleteMenu = new MenuItem()
+                        { Header = LanguageHelper.CommonManager.GetString("Menu_Delete") };
+                    deleteMenu.Click += (o, args) =>
+                    {
+                        PDFViewControl.GetCPDFViewer().GetDocument().RemoveSignature(sig, true);
+                        signatureWidget.ResetForm();
+                        signatureWidget.SetIsLocked(false);
+                        //PDFViewControl.PDFView.ReloadVisibleAnnots();
+                        //PDFViewControl.GetCPDFViewer().UpdateRenderFrame();
+                        PDFViewControl.PDFViewTool.IsDocumentModified = true;
+                        SignatureStatusChanged?.Invoke(this, null);
+                    };
+                    ContextMenu.Items.Add(deleteMenu);
+                }
+                else
+                {
+                    ContextMenu.Items.Add(new MenuItem()
+                        { Header = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
+                    ContextMenu.Items.Add(new MenuItem()
+                        { Header = LanguageHelper.CommonManager.GetString("Menu_Cut"), Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
+                    ContextMenu.Items.Add(new MenuItem()
+                        { Header = LanguageHelper.CommonManager.GetString("Menu_Delete"), Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
+                }
+                
+            }
+            else if(e.hitTestType == MouseHitTestType.Text)
+            {
+                ContextMenu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
+                PDFViewControl.SetRightMenu(ContextMenu);
+            }
+            else
+            {
+                ContextMenu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Paste"), Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
+                PDFViewControl.CreateViewerMenu(sender, ref ContextMenu);
+            }
+
+            PDFViewControl.SetRightMenu(ContextMenu);
+        }
+
+        private void PDFViewControl_MouseLeftButtonDownHandler(object sender, MouseEventObject e)
+        {
+            if (PDFViewControl.PDFViewTool.GetViewerModel() == MouseModes.PanTool && e.annotType== C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET)
+            {
+                BaseWidget baseWidget = PDFViewControl.GetCacheHitTestWidget();
+                if(baseWidget == null)
+                {
+                    return;
+                }
+
+                var widget = baseWidget.GetAnnotData().Annot as CPDFWidget;
+                if (widget == null)
+                {
+                    return;
+                }
+
+                if (widget.WidgetType == C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS)
+                {
+                    var signatureWidget = widget as CPDFSignatureWidget;
+                    CPDFSignature sig = signatureWidget.GetSignature(PDFViewControl.GetCPDFViewer().GetDocument());
+                    if (signatureWidget.IsSigned() && sig != null && sig?.SignerList.Count > 0)
+                    {
+                        ViewSignatureEvent(sender, sig);
+                    }
+                    else
+                    {
+                        Window parentWindow = Window.GetWindow((DependencyObject)sender);
+                        AddCertificationDialog addCertificationControl = new AddCertificationDialog
+                        {
+                            Owner = parentWindow
+                        };
+                        currentSignatureWidget = signatureWidget;
+                        addCertificationControl.FillSignatureEvent -= AddCertificationControl_FillSignatureEvent;
+                        addCertificationControl.FillSignatureEvent += AddCertificationControl_FillSignatureEvent;
+                        addCertificationControl.ShowDialog();
+                    }
+                }
+            }
+        }
+
         /// <summary>
         /// Separately, init PDFView and load undo manager event. Only use for ensuring SaveBtn is enabled after deleting digital signature on Viewer mode.
         /// </summary>
@@ -257,14 +368,22 @@ namespace Compdfkit_Tools.PDFControl
         /// </summary>
         private void CreateSign()
         {
-            //PDFViewControl.PDFView.SetMouseMode(MouseModes.FormEditTool);
-            //WidgetSignArgs signArgs = new WidgetSignArgs
-            //{
-            //    LineWidth = 1,
-            //    LineColor = Colors.Black,
-            //    FieldName = "Signature" + GetTime()
-            //};
-            //PDFViewControl.PDFView.SetToolParam(signArgs);
+            PDFViewControl.PDFToolManager.SetToolType(CPDFToolManager.ToolType.WidgetEdit);
+            PDFViewControl.SetCreateWidgetType(C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS);
+            
+            SignatureParam signatureParam = new SignatureParam
+            {
+                FieldName = "Signature" + GetTime(),
+                CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET,
+                WidgetType = C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS,
+                LineWidth = 1,
+                FontName = "Helvetica",
+                LineColor =new byte[] {0,0,0 },
+                FontColor = new byte[] { 0, 0, 0 },
+                Transparency = 255,
+                HasLineColor = true,
+            };
+            PDFViewControl.SetAnnotParam(signatureParam);
         }
         
         /// <summary>
@@ -342,7 +461,7 @@ namespace Compdfkit_Tools.PDFControl
                 FilePath = e.filePath,
                 Password = e.password,
                 SignatureWidget = currentSignatureWidget,
-                //Document = PDFViewControl.PDFView.Document,
+                Document = PDFViewControl.GetCPDFViewer().GetDocument(),
                 Owner = Window.GetWindow(this)
             };
             fillDigitalSignatureDialog.AfterFillSignature -= FillDigitalSignatureDialog_AfterFillSignature; ;

+ 1 - 1
Demo/Examples/Compdfkit_Tools/DigitalSignature/FillDigitalSignatureControl/FillDigitalSignatureControl.xaml.cs

@@ -117,7 +117,7 @@ namespace Compdfkit_Tools.PDFControl
             tempSignatureConfig.IsDrawLogo = (bool)LogoChk.IsChecked;
             if (tempSignatureConfig.IsDrawLogo)
             {
-                //tempSignatureConfig.LogoBitmap = new Bitmap(logoPath);
+                tempSignatureConfig.LogoData = CommonHelper.ConvertBitmapToByteArray(new Bitmap(logoPath));
             }
             tempSignatureConfig.Content = Text;
             tempSignatureConfig.TextColor = textColor;

+ 8 - 9
Demo/Examples/Compdfkit_Tools/Edit/PDFImageEdit/PDFImageEditControl/PDFImageEditControl.xaml.cs

@@ -35,6 +35,14 @@ namespace Compdfkit_Tools.Edit
             Unloaded += PDFImageEditControl_Unloaded;
         }
 
+        private void PDFImageEditControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            RotateUI.RotationChanged -= RotateUI_RotationChanged;
+            FlipUI.FlipChanged -= FlipUI_FlipChanged;
+            RotateUI.RotationChanged += RotateUI_RotationChanged;
+            FlipUI.FlipChanged += FlipUI_FlipChanged;
+        }
+
         private void PDFImageEditControl_Unloaded(object sender, RoutedEventArgs e)
         {
             RotateUI.RotationChanged -= RotateUI_RotationChanged;
@@ -44,10 +52,6 @@ namespace Compdfkit_Tools.Edit
         public void InitWithPDFViewer(CPDFViewerTool newPDFView)
         {
             ToolView = newPDFView;
-            RotateUI.RotationChanged -= RotateUI_RotationChanged;
-            FlipUI.FlipChanged -= FlipUI_FlipChanged;
-            RotateUI.RotationChanged += RotateUI_RotationChanged;
-            FlipUI.FlipChanged += FlipUI_FlipChanged;
         }
         
         public void SetRotationText(float rotation)
@@ -117,11 +121,6 @@ namespace Compdfkit_Tools.Edit
         //    EditMultiEvents = editEvents;
         //}
 
-        private void PDFImageEditControl_Loaded(object sender, RoutedEventArgs e)
-        {
-
-        }
-
         private void FlipUI_FlipChanged(object sender, bool e)
         {
             GetImageArea(out CPDFEditImageArea imageArea, out CPDFPage pdfPage, out CPDFEditPage editPage);

+ 2 - 2
Demo/Examples/Compdfkit_Tools/Form/FormControl/FormControl.xaml.cs

@@ -136,7 +136,7 @@ namespace Compdfkit_Tools.PDFControl
                 if (baseWidget != null)
                 {
                     CPDFWidget  widget =(baseWidget as CPDFWidget);
-                    switch (widget.WidgeType)
+                    switch (widget.WidgetType)
                     {
                         case C_WIDGET_TYPE.WIDGET_NONE:
                             break;
@@ -178,7 +178,7 @@ namespace Compdfkit_Tools.PDFControl
                 BaseWidget baseWidget = PdfViewControl.GetCacheHitTestWidget();
                 if (baseWidget!=null)
                 {
-                    switch ((baseWidget.GetAnnotData().Annot as CPDFWidget).WidgeType)
+                    switch ((baseWidget.GetAnnotData().Annot as CPDFWidget).WidgetType)
                     {
                         case C_WIDGET_TYPE.WIDGET_PUSHBUTTON:
                         case C_WIDGET_TYPE.WIDGET_COMBOBOX:

+ 1 - 1
Demo/Examples/Compdfkit_Tools/Form/Property/RadioButtonProperty.xaml.cs

@@ -66,7 +66,7 @@ namespace Compdfkit_Tools.PDFControl
             if (annotList != null && annotList.Count > 0)
             {
                 count = annotList.Where(x => x.Type == C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET)
-                    .Cast<CPDFWidget>().Where(x => x.WidgeType == C_WIDGET_TYPE.WIDGET_RADIOBUTTON).Count();
+                    .Cast<CPDFWidget>().Where(x => x.WidgetType == C_WIDGET_TYPE.WIDGET_RADIOBUTTON).Count();
             }
 
             return count>1;

+ 11 - 2
Demo/Examples/Compdfkit_Tools/Measure/MeasureControl.xaml.cs

@@ -20,7 +20,7 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
-
+using ComPDFKitViewer.BaseObject;
 
 
 namespace Compdfkit_Tools.Measure
@@ -104,7 +104,16 @@ namespace Compdfkit_Tools.Measure
         {
             if (e.annotType == C_ANNOTATION_TYPE.C_ANNOTATION_LINE)
             {
-
+                BaseAnnot baseAnnot = PdfViewControl.GetCacheHitTestAnnot();
+                if (baseAnnot != null)
+                {
+                    
+                }
+                
+                // panelState.RightPanel = PanelState.RightPanelState.PropertyPanel;
+                // measurePropertyControl.SetPropertyForMeasureCreate(LineArgs, e);
+                // SetInfoPanelVisble(true, false);
+                // SetMeasureInfoPanel(LineArgs.GetPDFAnnot(), LineArgs);
             }
         }
 

+ 2 - 1
Demo/Examples/Compdfkit_Tools/PDFView/PDFViewControl/PDFViewControl.xaml.cs

@@ -17,6 +17,7 @@ using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
 using Compdfkit_Tools.Helper;
+using ComPDFKit.Tool.DrawTool;
 using static ComPDFKit.Tool.CPDFToolManager;
 using static Compdfkit_Tools.PDFControlUI.CPDFViewModeUI;
 using SplitMode = Compdfkit_Tools.PDFControlUI.CPDFViewModeUI.SplitMode;
@@ -111,7 +112,7 @@ namespace Compdfkit_Tools.PDFControl
 
         }
 
-        private void PDFToolManager_AnnotDefaultEditedHandler(object sender, ComPDFKit.Tool.DrawTool.SelectedAnnotData e)
+        private void PDFToolManager_AnnotDefaultEditedHandler(object sender, SelectedAnnotData e)
         {
             UpdateAnnotFrame();
         }

+ 0 - 3
Demo/Examples/Compdfkit_Tools/PDFView/RegularViewerControl.xaml.cs

@@ -8,11 +8,8 @@ using Compdfkit_Tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI;
 using Compdfkit_Tools.Common;
 using Compdfkit_Tools.Helper;
 using Compdfkit_Tools.PDFControl;
-using ComPDFKit.DigitalSign;
-using ComPDFKit.PDFAnnotation.Form;
 using ComPDFKitViewer;
 using ComPDFKit.Tool;
-using ComPDFKit.PDFAnnotation;
 
 namespace Compdfkit_Tools.PDFView
 {

File diff suppressed because it is too large
+ 3 - 2
Demo/Examples/DigitalSignature/App.xaml.cs


+ 45 - 45
Demo/Examples/DigitalSignature/MainWindow.xaml.cs

@@ -3,7 +3,6 @@ using Compdfkit_Tools.Helper;
 using Compdfkit_Tools.PDFControl;
 using Compdfkit_Tools.PDFView;
 using ComPDFKitViewer;
-using ComPDFKitViewer.PdfViewer;
 using Microsoft.Win32;
 using System;
 using System.Collections.Generic;
@@ -23,6 +22,7 @@ using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
 using ComPDFKit.DigitalSign;
+using ComPDFKit.Tool;
 
 namespace DigitalSignature
 {
@@ -49,7 +49,7 @@ namespace DigitalSignature
         /// <summary>
         /// Whether the save operation can be performed.
         /// </summary>
-        private bool _canSave = false;
+        private bool _canSave = true;
         public bool CanSave
         {
             get => _canSave;
@@ -128,11 +128,11 @@ namespace DigitalSignature
             {
                 filePath = CommonHelper.GetExistedPathOrEmpty();
             }
-            string oldFilePath = pdfViewer.PDFView.Document.FilePath;
+            string oldFilePath = pdfViewer.GetCPDFViewer().GetDocument().FilePath;
 
             if (!string.IsNullOrEmpty(filePath) && regularViewerControl.PdfViewControl != null)
             {
-                if (pdfViewer.PDFView != null && pdfViewer.PDFView.Document != null)
+                if (pdfViewer.GetCPDFViewer() != null && pdfViewer.GetCPDFViewer().GetDocument() != null)
                 {
                     if (oldFilePath.ToLower() == filePath.ToLower())
                     {
@@ -141,14 +141,14 @@ namespace DigitalSignature
                 }
 
                 passwordViewer = new PDFViewControl();
-                passwordViewer.PDFView.InitDocument(filePath);
-                if (passwordViewer.PDFView.Document == null)
+                passwordViewer.InitDocument(filePath);
+                if (passwordViewer.GetCPDFViewer().GetDocument() == null)
                 {
                     MessageBox.Show("Open File Failed");
                     return;
                 }
 
-                if (passwordViewer.PDFView.Document.IsLocked)
+                if (passwordViewer.GetCPDFViewer().GetDocument().IsLocked)
                 {
                     PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " " + LanguageHelper.CommonManager.GetString("Tip_Encrypted"));
                     PasswordUI.ClearPassword();
@@ -157,7 +157,7 @@ namespace DigitalSignature
                 }
                 else
                 {
-                    pdfViewer.PDFView.Document.Release();
+                    pdfViewer.GetCPDFViewer().GetDocument().Release();
                     pdfViewer = passwordViewer;
                     LoadDocument();
                 }
@@ -170,7 +170,7 @@ namespace DigitalSignature
         private void LoadDefaultDocument()
         {
             string defaultFilePath = "ComPDFKit_Signatures_Sample_File.pdf";
-            pdfViewer.PDFView.InitDocument(defaultFilePath);
+            pdfViewer.InitDocument(defaultFilePath);
             LoadDocument();
         }
 
@@ -180,14 +180,14 @@ namespace DigitalSignature
         private void LoadCustomControl()
         {
             regularViewerControl.PdfViewControl = pdfViewer;
-            regularViewerControl.InitWithPDFViewer(pdfViewer.PDFView);
-            regularViewerControl.PdfViewControl.PDFView.SetMouseMode(MouseModes.Viewer);
+            regularViewerControl.InitWithPDFViewer(pdfViewer);
+            regularViewerControl.PdfViewControl.PDFViewTool.SetViewerModel(MouseModes.Viewer);
             regularViewerControl.SetBOTAContainer(null);
             regularViewerControl.SetBOTAContainer(botaBarControl);
             regularViewerControl.SetDisplaySettingsControl(displaySettingsControl);
             PDFGrid.Child = regularViewerControl;
             
-            SignatureHelper.InitEffectiveSignatureList(pdfViewer.PDFView.Document);
+            SignatureHelper.InitEffectiveSignatureList(pdfViewer.GetCPDFViewer().GetDocument());
             digitalSignatureControl.OnCanSaveChanged -= DigitalSignatureControl_OnCanSaveChanged;
             digitalSignatureControl.OnCanSaveChanged += DigitalSignatureControl_OnCanSaveChanged;
             digitalSignatureControl.SignatureStatusChanged -= DigitalSignatureControl_OnSignatureStatusChanged;
@@ -195,8 +195,8 @@ namespace DigitalSignature
             signatureStatusBarControl.OnViewSignatureButtonClicked -= ViewAllSignatures;
             signatureStatusBarControl.OnViewSignatureButtonClicked += ViewAllSignatures;
             
-            SignatureHelper.VerifySignatureList(pdfViewer.PDFView.Document);
-            digitalSignatureControl.LoadUndoManagerEvent(pdfViewer.PDFView);
+            SignatureHelper.VerifySignatureList(pdfViewer.GetCPDFViewer().GetDocument());
+            digitalSignatureControl.LoadUndoManagerEvent(pdfViewer.GetCPDFViewer());
             signatureStatusBarControl.SetStatus(SignatureHelper.SignatureList);
             regularViewerControl.SetSignatureStatusBarControl(signatureStatusBarControl);
         }
@@ -206,18 +206,18 @@ namespace DigitalSignature
         /// </summary>
         private void LoadDocument()
         {
-            if (pdfViewer.PDFView.Document == null)
+            if (pdfViewer.GetCPDFViewer().GetDocument() == null)
             {
                 return;
             }
 
-            pdfViewer.PDFView.Load();
-            pdfViewer.PDFView.SetShowLink(true);
-
-            pdfViewer.PDFView.InfoChanged -= PdfViewer_InfoChanged;
-            pdfViewer.PDFView.InfoChanged += PdfViewer_InfoChanged;
-
-            pdfViewer.PDFView.SetFormFieldHighlight(true);
+            // pdfViewer.PDFView.Load();
+            // pdfViewer.PDFView.SetShowLink(true);
+            //
+            // pdfViewer.PDFView.InfoChanged -= PdfViewer_InfoChanged;
+            // pdfViewer.PDFView.InfoChanged += PdfViewer_InfoChanged;
+            //
+            // pdfViewer.PDFView.SetFormFieldHighlight(true);
             pdfViewer.CustomSignHandle = true;
 
             PasswordUI.Closed -= PasswordUI_Closed;
@@ -227,7 +227,7 @@ namespace DigitalSignature
             PasswordUI.Canceled += PasswordUI_Canceled;
             PasswordUI.Confirmed += PasswordUI_Confirmed;
             ModeComboBox.SelectedIndex = 0;
-            botaBarControl.InitWithPDFViewer(pdfViewer.PDFView);
+            botaBarControl.InitWithPDFViewer(pdfViewer);
             botaBarControl.AddBOTAContent(new []{BOTATools.Thumbnail , BOTATools.Outline , BOTATools.Bookmark , BOTATools.Search , BOTATools.Annotation , BOTATools.Signature});
             botaBarControl.SelectBotaTool(BOTATools.Thumbnail);
             botaBarControl.DeleteSignatureEvent -= BotaControlOnDeleteSignatureEvent;
@@ -237,10 +237,10 @@ namespace DigitalSignature
             botaBarControl.ViewSignatureEvent -= digitalSignatureControl.ViewSignatureEvent;    
             botaBarControl.ViewSignatureEvent += digitalSignatureControl.ViewSignatureEvent;
             
-            displaySettingsControl.InitWithPDFViewer(pdfViewer.PDFView);
+            displaySettingsControl.InitWithPDFViewer(pdfViewer);
             LoadCustomControl();
-            pdfViewer.PDFView.ChangeFitMode(FitMode.FitWidth);
-            CPDFSaclingControl.InitWithPDFViewer(pdfViewer.PDFView);
+            pdfViewer.GetCPDFViewer().SetFitMode(FitMode.FitWidth);
+            CPDFSaclingControl.InitWithPDFViewer(pdfViewer);
             
             panelState.PropertyChanged -= PanelState_PropertyChanged;
             panelState.PropertyChanged += PanelState_PropertyChanged;
@@ -253,10 +253,10 @@ namespace DigitalSignature
         /// <param name="e"></param>
         private void PasswordUI_Confirmed(object sender, string e)
         {
-            if (passwordViewer != null && passwordViewer.PDFView != null && passwordViewer.PDFView.Document != null)
+            if (passwordViewer != null && passwordViewer.GetCPDFViewer() != null && passwordViewer.GetCPDFViewer().GetDocument() != null)
             {
-                passwordViewer.PDFView.Document.UnlockWithPassword(e);
-                if (passwordViewer.PDFView.Document.IsLocked == false)
+                passwordViewer.GetCPDFViewer().GetDocument().UnlockWithPassword(e);
+                if (passwordViewer.GetCPDFViewer().GetDocument().IsLocked == false)
                 {
                     PasswordUI.SetShowError("", Visibility.Collapsed);
                     PasswordUI.ClearPassword();
@@ -338,9 +338,8 @@ namespace DigitalSignature
         /// <param name="e"></param>
         private void BotaControlOnDeleteSignatureEvent(object sender, EventArgs e)
         {
-            pdfViewer.PDFView.UndoManager.CanSave = true;
+            pdfViewer.PDFViewTool.IsDocumentModified = true;
             DigitalSignatureControl_OnSignatureStatusChanged(sender, e);
-            //this.CanSave = true;
         }
         
         /// <summary>
@@ -350,8 +349,8 @@ namespace DigitalSignature
         /// <param name="e"></param>
         private void DigitalSignatureControl_OnSignatureStatusChanged(object sender, EventArgs e)
         {
-            SignatureHelper.InitEffectiveSignatureList(pdfViewer.PDFView.Document);
-            SignatureHelper.VerifySignatureList(pdfViewer.PDFView.Document);
+            SignatureHelper.InitEffectiveSignatureList(pdfViewer.GetCPDFViewer().GetDocument());
+            SignatureHelper.VerifySignatureList(pdfViewer.GetCPDFViewer().GetDocument());
             signatureStatusBarControl.SetStatus(SignatureHelper.SignatureList);
             botaBarControl.LoadSignatureList();
         }
@@ -387,7 +386,7 @@ namespace DigitalSignature
         private void SaveFileBtn_Click(object sender, RoutedEventArgs e)
         {
             SaveFile();
-            pdfViewer.PDFView.UndoManager.CanSave = false;
+            pdfViewer.PDFViewTool.IsDocumentModified = false;
         }
 
         /// <summary>
@@ -429,12 +428,12 @@ namespace DigitalSignature
 
             if (item.Content as string == "Viewer")
             {
-                if (regularViewerControl.PdfViewControl != null && regularViewerControl.PdfViewControl.PDFView != null)
+                if (regularViewerControl.PdfViewControl != null)
                 {
                     PDFGrid.Child = regularViewerControl;
-                    regularViewerControl.PdfViewControl.PDFView.SetMouseMode(MouseModes.Viewer);
+                    regularViewerControl.PdfViewControl.PDFViewTool.SetViewerModel(MouseModes.Viewer);
                     regularViewerControl.PdfViewControl = pdfViewer;
-                    regularViewerControl.InitWithPDFViewer(pdfViewer.PDFView);
+                    regularViewerControl.InitWithPDFViewer(pdfViewer);
                     regularViewerControl.SetBOTAContainer(botaBarControl);
                     regularViewerControl.SetDisplaySettingsControl(displaySettingsControl);
                     regularViewerControl.SetSignatureStatusBarControl(signatureStatusBarControl);
@@ -442,15 +441,16 @@ namespace DigitalSignature
             }
             else if (item.Content as string == "Digital Signature")
             {
-                if (digitalSignatureControl.PDFViewControl != null && digitalSignatureControl.PDFViewControl.PDFView != null)
+                if (digitalSignatureControl.PDFViewControl != null)
                 {
                     PDFGrid.Child = digitalSignatureControl;
-                    digitalSignatureControl.PDFViewControl.PDFView.SetMouseMode(MouseModes.Viewer);
+                    digitalSignatureControl.PDFViewControl.PDFViewTool.SetViewerModel(MouseModes.Viewer);
                     digitalSignatureControl.PDFViewControl = pdfViewer;
-                    digitalSignatureControl.InitWithPDFViewer(pdfViewer.PDFView);
+                    digitalSignatureControl.InitWithPDFViewer(pdfViewer);
                     digitalSignatureControl.SetBOTAContainer(botaBarControl);
                     digitalSignatureControl.SetDisplaySettingsControl(displaySettingsControl);
                     digitalSignatureControl.SetSignatureStatusBarControl(signatureStatusBarControl);
+                    pdfViewer.PDFViewTool.SetViewerModel(MouseModes.PanTool);
                 }
             }
             currentMode = item.Content as string;
@@ -521,7 +521,7 @@ namespace DigitalSignature
         {
             PasswordUI.Visibility = Visibility.Collapsed;
             FileInfoUI.Visibility = Visibility.Visible;
-            FileInfoControl.InitWithPDFViewer(pdfViewer.PDFView);
+            FileInfoControl.InitWithPDFViewer(pdfViewer);
             PopupBorder.Visibility = Visibility.Visible;
 
         }
@@ -593,9 +593,9 @@ namespace DigitalSignature
         public void SaveAsFile()
         {
             {
-                if (pdfViewer != null && pdfViewer.PDFView != null && pdfViewer.PDFView.Document != null)
+                if (pdfViewer != null && pdfViewer.GetCPDFViewer() != null && pdfViewer.GetCPDFViewer().GetDocument() != null)
                 {
-                    CPDFDocument pdfDoc = pdfViewer.PDFView.Document;
+                    CPDFDocument pdfDoc = pdfViewer.GetCPDFViewer().GetDocument();
                     SaveFileDialog saveDialog = new SaveFileDialog();
                     saveDialog.Filter = "(*.pdf)|*.pdf";
                     saveDialog.DefaultExt = ".pdf";
@@ -614,11 +614,11 @@ namespace DigitalSignature
         /// </summary>
         public void SaveFile()
         {
-            if (pdfViewer != null && pdfViewer.PDFView != null && pdfViewer.PDFView.Document != null)
+            if (pdfViewer != null && pdfViewer.GetCPDFViewer() != null && pdfViewer.GetCPDFViewer().GetDocument() != null)
             {
                 try
                 {
-                    CPDFDocument pdfDoc = pdfViewer.PDFView.Document;
+                    CPDFDocument pdfDoc = pdfViewer.GetCPDFViewer().GetDocument();
                     if (pdfDoc.WriteToLoadedPath())
                     {
                         return;

File diff suppressed because it is too large
+ 3 - 2
Demo/Examples/DocsEditor/App.xaml.cs


+ 17 - 3
Demo/Examples/DocsEditor/DocsEditor.csproj

@@ -26,6 +26,7 @@
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <Prefer32bit>false</Prefer32bit>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -35,6 +36,7 @@
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <Prefer32bit>false</Prefer32bit>
   </PropertyGroup>
   <PropertyGroup>
     <ApplicationIcon>ComPDFKit_Logo.ico</ApplicationIcon>
@@ -110,6 +112,18 @@
     <None Include="App.config" />
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\..\..\..\compdfkit_windows\ComPDFKit.Tool\ComPDFKit.Tool.csproj">
+      <Project>{a061ee7a-6704-4bd9-86ee-48ed5df75e2f}</Project>
+      <Name>ComPDFKit.Tool</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\..\compdfkit_windows\ComPDFKit.Viewer\ComPDFKit.Viewer.csproj">
+      <Project>{783263cf-0da3-4095-9df8-2c4a6b3ff908}</Project>
+      <Name>ComPDFKit.Viewer</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\..\compdfkit_windows\ComPDFKit\ComPDFKitCSharp\ComPDFKit.Desk.csproj">
+      <Project>{56e518ad-c126-4b48-9a09-0a64c87020e4}</Project>
+      <Name>ComPDFKit.Desk</Name>
+    </ProjectReference>
     <ProjectReference Include="..\Compdfkit_Tools\Compdfkit_Tools.csproj">
       <Project>{9363bcb1-3a67-446a-8093-5708b86bf418}</Project>
       <Name>Compdfkit_Tools</Name>
@@ -119,10 +133,10 @@
     <Resource Include="ComPDFKit_Logo.ico" />
   </ItemGroup>
   <ItemGroup>
-    <None Include="..\license_key_windows.xml">
-      <Link>license_key_windows.xml</Link>
+    <Content Include="..\..\..\..\x64\ComPDFKit.dll">
+      <Link>x64\ComPDFKit.dll</Link>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
+    </Content>
     <Content Include="..\TestFile\ComPDFKit_Sample_File_Windows.pdf">
       <Link>ComPDFKit_Sample_File_Windows.pdf</Link>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

+ 43 - 259
Demo/Examples/DocsEditor/MainWindow.xaml.cs

@@ -1,6 +1,5 @@
 using Compdfkit_Tools.Helper;
 using Compdfkit_Tools.PDFControl;
-using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer;
 using System;
 using System.Collections.Generic;
@@ -12,11 +11,12 @@ using System.Diagnostics;
 using System.IO;
 using System.Drawing;
 using System.ComponentModel;
+using System.Data;
 using System.Runtime.CompilerServices;
 using ComPDFKit.PDFDocument;
 using Microsoft.Win32;
 using System.Windows.Controls.Primitives;
-using ComPDFKitViewer.PdfViewer; 
+using ComPDFKit.Tool;
 
 namespace DocsEditor
 {
@@ -38,9 +38,9 @@ namespace DocsEditor
         {
             get
             {
-                if (pdfViewControl != null && pdfViewControl.PDFView != null)
+                if (pdfViewControl != null && pdfViewControl.PDFViewTool != null)
                 {
-                    return pdfViewControl.PDFView.UndoManager.CanSave;
+                    return pdfViewControl.PDFViewTool.IsDocumentModified;
                 }
                 return false;
             }
@@ -67,19 +67,17 @@ namespace DocsEditor
             RightPanelButton.IsEnabled = false;
             ViewSettingBtn.IsEnabled = false;
             pdfViewControl = new PDFViewControl();
-            pdfViewControl.PDFView.InitDocument(defaultFilePath);
+            pdfViewControl.InitDocument(defaultFilePath);
             LoadDocument();
         }
 
         private void LoadDocument()
         {
-            if (pdfViewControl.PDFView.Document == null)
+            if (pdfViewControl.PDFToolManager.GetDocument() == null)
             {
                 return;
             }
-            pdfViewControl.PDFView?.SetMouseMode(MouseModes.Viewer);
-            pdfViewControl.PDFView?.Load();
-            pdfViewControl.PDFView?.SetShowLink(true);
+            pdfViewControl.PDFViewTool?.SetViewerModel(MouseModes.Viewer);
             if (ViewComboBox.SelectedIndex == 0)
             {
                 PDFGrid.Child = pdfViewControl;
@@ -99,17 +97,12 @@ namespace DocsEditor
 
                 CPDFPageEditBarControl.PageEditEvent -= CPDFPageEditBarControl_PageEditEvent;
                 CPDFPageEditBarControl.PageEditEvent += CPDFPageEditBarControl_PageEditEvent;
-                pageEditControl.LoadThumbnails(pdfViewControl.PDFView);
+                pageEditControl.LoadThumbnails(pdfViewControl);
+                pageEditControl.viewControl = pdfViewControl;
                 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;
@@ -117,230 +110,21 @@ namespace DocsEditor
             PasswordUI.Canceled += PasswordUI_Canceled;
             PasswordUI.Confirmed += PasswordUI_Confirmed;
 
-            pdfViewControl.PDFView.ChangeFitMode(FitMode.FitWidth);
-            CPDFSaclingControl.InitWithPDFViewer(pdfViewControl.PDFView);
-            CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)));
+            pdfViewControl.PDFViewTool?.GetCPDFViewer().SetFitMode(FitMode.FitWidth);
+            CPDFSaclingControl.InitWithPDFViewer(pdfViewControl);
+            CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewControl.PDFViewTool.GetCPDFViewer().GetZoom() * 100)));
+
 
             ViewSettingBtn.IsChecked = false;
             PropertyContainer.Child = null;
             PropertyContainer.Visibility = Visibility.Collapsed;
-            FloatPageTool.InitWithPDFViewer(pdfViewControl.PDFView);
-            BotaSideTool.InitWithPDFViewer(pdfViewControl.PDFView);
+            FloatPageTool.InitWithPDFViewer(pdfViewControl);
+            BotaSideTool.InitWithPDFViewer(pdfViewControl);
             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 = LanguageHelper.CommonManager.GetString("Menu_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 = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
-                    e.PopupMenu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Cut"), Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
-                    e.PopupMenu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Delete"), Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
-                }
-                else
-                {
-                    e.Handle = true;
-                    e.PopupMenu = new ContextMenu();
-
-                    e.PopupMenu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Paste"), Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
-                    e.PopupMenu.Items.Add(new Separator());
-
-                    MenuItem fitWidthMenu = new MenuItem();
-                    fitWidthMenu.Header = LanguageHelper.CommonManager.GetString("Menu_AutoSize");
-                    fitWidthMenu.Click += (o, p) =>
-                    {
-                        if (pdfViewControl != null)
-                        {
-                            pdfViewControl.PDFView?.ChangeFitMode(FitMode.FitWidth);
-                        }
-                    };
-
-                    e.PopupMenu.Items.Add(fitWidthMenu);
-
-                    MenuItem fitSizeMenu = new MenuItem();
-                    fitSizeMenu.Header = LanguageHelper.CommonManager.GetString("Menu_RealSize");
-                    fitSizeMenu.Click += (o, p) =>
-                    {
-                        if (pdfViewControl != null)
-                        {
-                            pdfViewControl.PDFView?.ChangeFitMode(FitMode.FitSize);
-                        }
-                    };
-
-                    e.PopupMenu.Items.Add(fitSizeMenu);
-
-                    MenuItem zoomInMenu = new MenuItem();
-                    zoomInMenu.Header = LanguageHelper.CommonManager.GetString("Menu_ZoomIn");
-                    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 = LanguageHelper.CommonManager.GetString("Menu_ZoomOut");
-                    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 = LanguageHelper.CommonManager.GetString("Menu_SinglePage");
-                    singleView.Click += (o, p) =>
-                    {
-                        if (pdfViewControl != null)
-                        {
-                            pdfViewControl.PDFView?.ChangeViewMode(ViewMode.Single);
-                        }
-                    };
-
-                    e.PopupMenu.Items.Add(singleView);
-
-                    MenuItem singleContinuousView = new MenuItem();
-                    singleContinuousView.Header = LanguageHelper.CommonManager.GetString("Menu_SingleContinuous");
-                    singleContinuousView.Click += (o, p) =>
-                    {
-                        if (pdfViewControl != null)
-                        {
-                            pdfViewControl.PDFView?.ChangeViewMode(ViewMode.SingleContinuous);
-                        }
-                    };
-
-                    e.PopupMenu.Items.Add(singleContinuousView);
-
-                    MenuItem doubleView = new MenuItem();
-                    doubleView.Header = LanguageHelper.CommonManager.GetString("Menu_DoublePage");
-                    doubleView.Click += (o, p) =>
-                    {
-                        if (pdfViewControl != null)
-                        {
-                            pdfViewControl.PDFView?.ChangeViewMode(ViewMode.Double);
-                        }
-                    };
-
-                    e.PopupMenu.Items.Add(doubleView);
-
-                    MenuItem doubleContinuousView = new MenuItem();
-                    doubleContinuousView.Header = LanguageHelper.CommonManager.GetString("Menu_DoubleContinuous");
-                    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 ExtraImage_Click(object sender, RoutedEventArgs e)
-        {
-            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)
         {
@@ -356,16 +140,16 @@ namespace DocsEditor
 
         private void PasswordUI_Confirmed(object sender, string e)
         {
-            if (passwordViewer != null && passwordViewer.PDFView != null && passwordViewer.PDFView.Document != null)
+            if (passwordViewer != null && passwordViewer.PDFToolManager != null && passwordViewer.PDFToolManager.GetDocument() != null)
             {
-                passwordViewer.PDFView.Document.UnlockWithPassword(e);
-                if (passwordViewer.PDFView.Document.IsLocked == false)
+                passwordViewer.PDFToolManager.GetDocument().UnlockWithPassword(e);
+                if (passwordViewer.PDFToolManager.GetDocument().IsLocked == false)
                 {
                     PasswordUI.SetShowError("", Visibility.Collapsed);
                     PasswordUI.ClearPassword();
                     PasswordUI.Visibility = Visibility.Collapsed;
                     PopupBorder.Visibility = Visibility.Collapsed;
-                    pdfViewControl.PDFView.Document.Release();
+                    pdfViewControl.PDFToolManager.GetDocument().Release();
                     pdfViewControl = passwordViewer;
                     LoadDocument();
                 }
@@ -414,7 +198,7 @@ namespace DocsEditor
         {
             PasswordUI.Visibility = Visibility.Collapsed;
             FileInfoUI.Visibility = Visibility.Visible;
-            FileInfoControl.InitWithPDFViewer(pdfViewControl.PDFView);
+            FileInfoControl.InitWithPDFViewer(pdfViewControl);
             PopupBorder.Visibility = Visibility.Visible;
         }
 
@@ -429,28 +213,28 @@ namespace DocsEditor
             string filePath = CommonHelper.GetExistedPathOrEmpty();
             if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
             {
-                if (pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
+                if (pdfViewControl.PDFToolManager != null && pdfViewControl.PDFToolManager.GetDocument() != null)
                 {
-                    string oldFilePath = pdfViewControl.PDFView.Document.FilePath;
+                    string oldFilePath = pdfViewControl.PDFToolManager.GetDocument().FilePath;
                     if (oldFilePath.ToLower() == filePath.ToLower())
                     {
                         return;
                     }
                     else
                     {
-                        pdfViewControl.PDFView.Document.Release();
+                        pdfViewControl.PDFToolManager.GetDocument().Release();
                     }
                 }
 
                 passwordViewer = new PDFViewControl();
-                passwordViewer.PDFView.InitDocument(filePath);
-                if (passwordViewer.PDFView.Document == null)
+                passwordViewer.InitDocument(filePath);
+                if (passwordViewer.PDFToolManager.GetDocument() == null)
                 {
                     MessageBox.Show("Open File Failed");
                     return;
                 }
 
-                if (passwordViewer.PDFView.Document.IsLocked)
+                if (passwordViewer.PDFToolManager.GetDocument().IsLocked)
                 {
                     PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " " + LanguageHelper.CommonManager.GetString("Tip_Encrypted"));
                     PasswordUI.ClearPassword();
@@ -459,7 +243,7 @@ namespace DocsEditor
                 }
                 else
                 {
-                    pdfViewControl.PDFView.Document.Release();
+                    pdfViewControl.PDFToolManager.GetDocument().Release();
                     pdfViewControl = passwordViewer;
                     LoadDocument();
                 }
@@ -488,7 +272,7 @@ namespace DocsEditor
         private void SaveFileBtn_Click(object sender, RoutedEventArgs e)
         {
             SaveFile();
-            pdfViewControl.PDFView.UndoManager.CanSave = false;
+            pdfViewControl.PDFViewTool.IsDocumentModified = false;
         }
 
         private void FileInfoCloseBtn_Click(object sender, RoutedEventArgs e)
@@ -575,9 +359,9 @@ namespace DocsEditor
         public void SaveAsFile()
         {
             {
-                if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
+                if (pdfViewControl != null && pdfViewControl.PDFToolManager != null && pdfViewControl.PDFToolManager.GetDocument() != null)
                 {
-                    CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
+                    CPDFDocument pdfDoc = pdfViewControl.PDFToolManager.GetDocument();
                     SaveFileDialog saveDialog = new SaveFileDialog();
                     saveDialog.Filter = "(*.pdf)|*.pdf";
                     saveDialog.DefaultExt = ".pdf";
@@ -596,9 +380,9 @@ namespace DocsEditor
         /// </summary>
         private void SaveFile()
         {
-            if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
+            if (pdfViewControl != null && pdfViewControl.PDFToolManager != null && pdfViewControl.PDFToolManager.GetDocument() != null)
             {
-                CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
+                CPDFDocument pdfDoc = pdfViewControl.PDFToolManager.GetDocument();
                 if (pdfDoc.WriteToLoadedPath())
                 {
                     return;
@@ -639,7 +423,7 @@ namespace DocsEditor
                     pageEditControl.PageMoved -= PageEditControl_PageMoved;
                     CPDFPageEditBarControl.PageEditEvent -= CPDFPageEditBarControl_PageEditEvent;
                     FloatPageTool.Visibility = Visibility.Visible;
-                    pdfViewControl.PDFView.ReloadDocument();
+                    //pdfViewControl.PDFView.ReloadDocument();
                     LeftToolPanelButton.IsEnabled = true;
                     SearchButton.IsEnabled = true;
                     RightPanelButton.IsEnabled = true;
@@ -663,7 +447,7 @@ namespace DocsEditor
                 pageEditControl.ExitPageEdit += PageEditControl_ExitPageEdit;
                 pageEditControl.PageMoved += PageEditControl_PageMoved;
                 CPDFPageEditBarControl.PageEditEvent += CPDFPageEditBarControl_PageEditEvent;
-                pageEditControl.LoadThumbnails(pdfViewControl.PDFView);
+                pageEditControl.LoadThumbnails(pdfViewControl);
                 PDFGrid.Child = pageEditControl;
                 LeftToolPanelButton.IsChecked = false;
                 LeftToolPanelButton.IsEnabled = false;
@@ -705,11 +489,11 @@ namespace DocsEditor
         }
         private void PageEditControl_PageMoved(object sender, RoutedEventArgs e)
         {
-            if (pdfViewControl == null || pdfViewControl.PDFView == null)
+            if (pdfViewControl == null)
             {
                 return;
             }
-            BotaSideTool.InitWithPDFViewer(pdfViewControl.PDFView);
+            BotaSideTool.InitWithPDFViewer(pdfViewControl);
         }
 
         private void PdfViewer_InfoChanged(object sender, KeyValuePair<string, object> e)
@@ -810,14 +594,14 @@ namespace DocsEditor
 
         private void CommandBinding_Executed_ScaleAdd(object sender, ExecutedRoutedEventArgs e)
         {
-            double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true);
-            pdfViewControl.PDFView?.Zoom(newZoom);
+            double newZoom = CheckZoomLevel(pdfViewControl.GetCPDFViewer().GetZoom() + 0.01, true);
+            pdfViewControl.GetCPDFViewer().SetZoom(newZoom);
         }
 
         private void CommandBinding_Executed_ScaleSubtract(object sender, ExecutedRoutedEventArgs e)
         {
-            double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false);
-            pdfViewControl.PDFView?.Zoom(newZoom);
+            double newZoom = CheckZoomLevel(pdfViewControl.GetCPDFViewer().GetZoom() - 0.01, false);
+            pdfViewControl.GetCPDFViewer().SetZoom(newZoom);
         }
 
         private void ShowViewSettings()
@@ -827,7 +611,7 @@ namespace DocsEditor
                 if (ViewSettingBtn.IsChecked == true)
                 {
                     displayPanel = new CPDFDisplaySettingsControl();
-                    displayPanel.InitWithPDFViewer(pdfViewControl.PDFView);
+                    displayPanel.InitWithPDFViewer(pdfViewControl);
                     PropertyContainer.Child = displayPanel;
                     PropertyContainer.Visibility = Visibility.Visible;
                     if ((bool)RightPanelButton.IsChecked)
@@ -858,7 +642,7 @@ namespace DocsEditor
             {
                 PasswordUI.Visibility = Visibility.Collapsed;
                 FileInfoUI.Visibility = Visibility.Visible;
-                FileInfoControl.InitWithPDFViewer(pdfViewControl.PDFView);
+                FileInfoControl.InitWithPDFViewer(pdfViewControl);
                 PopupBorder.Visibility = Visibility.Visible;
             }
             else

File diff suppressed because it is too large
+ 3 - 2
Demo/Examples/Forms/App.xaml.cs


+ 15 - 3
Demo/Examples/Forms/Forms.csproj

@@ -92,16 +92,28 @@
     <None Include="packages.config" />
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\..\..\..\compdfkit_windows\ComPDFKit.Tool\ComPDFKit.Tool.csproj">
+      <Project>{a061ee7a-6704-4bd9-86ee-48ed5df75e2f}</Project>
+      <Name>ComPDFKit.Tool</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\..\compdfkit_windows\ComPDFKit.Viewer\ComPDFKit.Viewer.csproj">
+      <Project>{783263cf-0da3-4095-9df8-2c4a6b3ff908}</Project>
+      <Name>ComPDFKit.Viewer</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\..\compdfkit_windows\ComPDFKit\ComPDFKitCSharp\ComPDFKit.Desk.csproj">
+      <Project>{56e518ad-c126-4b48-9a09-0a64c87020e4}</Project>
+      <Name>ComPDFKit.Desk</Name>
+    </ProjectReference>
     <ProjectReference Include="..\Compdfkit_Tools\Compdfkit_Tools.csproj">
       <Project>{9363bcb1-3a67-446a-8093-5708b86bf418}</Project>
       <Name>Compdfkit_Tools</Name>
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
-    <None Include="..\license_key_windows.xml">
-      <Link>license_key_windows.xml</Link>
+    <Content Include="..\..\..\..\x64\ComPDFKit.dll">
+      <Link>x64\ComPDFKit.dll</Link>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
+    </Content>
     <Content Include="..\TestFile\ComPDFKit_Forms_Sample_File.pdf">
       <Link>ComPDFKit_Forms_Sample_File.pdf</Link>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

File diff suppressed because it is too large
+ 4 - 17
Demo/Examples/Measure/App.xaml.cs


+ 44 - 286
Demo/Examples/Measure/MainWindow.xaml.cs

@@ -1,8 +1,6 @@
 using ComPDFKit.PDFDocument;
 using Compdfkit_Tools.Helper;
 using Compdfkit_Tools.PDFControl;
-using ComPDFKitViewer.AnnotEvent;
-using ComPDFKitViewer.PdfViewer;
 using ComPDFKitViewer;
 using Microsoft.Win32;
 using System;
@@ -27,6 +25,7 @@ using System.Windows.Shapes;
 using System.Drawing;
 using Path = System.IO.Path;
 using Compdfkit_Tools.Measure;
+using ComPDFKit.Tool;
 using static Compdfkit_Tools.Helper.PanelState;
 
 namespace Measure
@@ -53,9 +52,9 @@ namespace Measure
         {
             get
             {
-                if (pdfViewControl != null && pdfViewControl.PDFView != null)
+                if (pdfViewControl != null && pdfViewControl.PDFViewTool != null)
                 {
-                    return pdfViewControl.PDFView.UndoManager.CanSave;
+                    return pdfViewControl.PDFViewTool.IsDocumentModified;
                 }
                 return false;
             }
@@ -103,31 +102,19 @@ namespace Measure
         #region Load Document
         private void LoadDocument()
         {
-            if (pdfViewControl.PDFView.Document == null)
+            if (pdfViewControl.GetCPDFViewer().GetDocument() == null)
             {
                 return;
             }
             if(ViewModeBox!=null && ViewModeBox.SelectedIndex==1)
             {
-                pdfViewControl.PDFView?.SetMouseMode(MouseModes.PanTool);
+                pdfViewControl.PDFViewTool?.SetViewerModel(ComPDFKit.Tool.MouseModes.PanTool);
             }
             else
             {
-                pdfViewControl.PDFView?.SetMouseMode(MouseModes.Viewer);
+                pdfViewControl.PDFViewTool?.SetViewerModel(ComPDFKit.Tool.MouseModes.Viewer);
             }
-           
-            pdfViewControl.PDFView?.Load();
-            pdfViewControl.PDFView?.SetShowLink(true);
-
-            pdfViewControl.PDFView.InfoChanged -= PdfViewer_InfoChanged;
-            pdfViewControl.PDFView.InfoChanged += PdfViewer_InfoChanged;
-            pdfViewControl.PDFView.AnnotCommandHandler -= PDFView_AnnotCommandHandler;
-            pdfViewControl.PDFView.AnnotCommandHandler += PDFView_AnnotCommandHandler;
-            pdfViewControl.PDFView.AnnotEditHandler -= PDFView_AnnotEditHandler;
-            pdfViewControl.PDFView.AnnotEditHandler += PDFView_AnnotEditHandler;
-            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;
@@ -135,27 +122,22 @@ namespace Measure
             PasswordUI.Canceled += PasswordUI_Canceled;
             PasswordUI.Confirmed += PasswordUI_Confirmed;
 
-            pdfViewControl.PDFView.ChangeFitMode(FitMode.FitWidth);
-            CPDFSaclingControl.InitWithPDFViewer(pdfViewControl.PDFView);
-            CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)));
+            pdfViewControl.GetCPDFViewer().SetFitMode(FitMode.FitWidth);
+            CPDFSaclingControl.InitWithPDFViewer(pdfViewControl);
+            CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewControl.GetCPDFViewer().GetZoom() * 100)));
 
-            BotaSideTool.InitWithPDFViewer(pdfViewControl.PDFView);
+            BotaSideTool.InitWithPDFViewer(pdfViewControl);
             BotaSideTool.SelectBotaTool(BOTATools.Thumbnail);
             ViewSettingBtn.IsChecked = false;
 
             LoadMeasureRes();
         }
 
-        private void PDFView_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
-        {
-            BotaSideTool.LoadAnnotationList();
-        }
-
         private void LoadDefaultDocument()
         {
             string defaultFilePath = "PDF32000_2008.pdf";
             pdfViewControl = new PDFViewControl();
-            pdfViewControl.PDFView.InitDocument(defaultFilePath);
+            pdfViewControl.InitDocument(defaultFilePath);
             LoadDocument();
         }
         #endregion
@@ -163,10 +145,10 @@ namespace Measure
         #region Password
         private void PasswordUI_Confirmed(object sender, string e)
         {
-            if (passwordViewer != null && passwordViewer.PDFView != null && passwordViewer.PDFView.Document != null)
+            if (passwordViewer != null && passwordViewer.PDFToolManager != null && passwordViewer.PDFToolManager.GetDocument() != null)
             {
-                passwordViewer.PDFView.Document.UnlockWithPassword(e);
-                if (passwordViewer.PDFView.Document.IsLocked == false)
+                passwordViewer.PDFToolManager.GetDocument().UnlockWithPassword(e);
+                if (passwordViewer.PDFToolManager.GetDocument().IsLocked == false)
                 {
                     PasswordUI.SetShowError("", Visibility.Collapsed);
                     PasswordUI.ClearPassword();
@@ -339,8 +321,8 @@ namespace Measure
         {
             if (pdfViewControl != null)
             {
-                double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true);
-                pdfViewControl.PDFView.Zoom(newZoom);
+                double newZoom = CheckZoomLevel(pdfViewControl.GetCPDFViewer().GetZoom() + 0.01, true);
+                pdfViewControl.GetCPDFViewer().SetZoom(newZoom);
             }
         }
 
@@ -348,26 +330,16 @@ namespace Measure
         {
             if (pdfViewControl != null)
             {
-                double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false);
-                pdfViewControl.PDFView.Zoom(newZoom);
+                double newZoom = CheckZoomLevel(pdfViewControl.GetCPDFViewer().GetZoom() - 0.01, false);
+                pdfViewControl.GetCPDFViewer().SetZoom(newZoom);
             }
         }
 
-        private void NextPageBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
-        {
-            pdfViewControl.PDFView?.GoToPage(pdfViewControl.PDFView.CurrentIndex + 1);
-        }
-
-        private void PrevPageBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
-        {
-            pdfViewControl.PDFView?.GoToPage(pdfViewControl.PDFView.CurrentIndex - 1);
-        }
-
         private void PageInfoBtn_Click(object sender, RoutedEventArgs e)
         {
             PasswordUI.Visibility = Visibility.Collapsed;
             FileInfoUI.Visibility = Visibility.Visible;
-            FileInfoControl.InitWithPDFViewer(pdfViewControl.PDFView);
+            FileInfoControl.InitWithPDFViewer(pdfViewControl);
             PopupBorder.Visibility = Visibility.Visible;
         }
 
@@ -385,9 +357,9 @@ namespace Measure
         public void SaveAsFile()
         {
             {
-                if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
+                if (pdfViewControl != null && pdfViewControl.PDFToolManager != null && pdfViewControl.PDFToolManager.GetDocument() != null)
                 {
-                    CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
+                    CPDFDocument pdfDoc = pdfViewControl.PDFToolManager.GetDocument();
                     SaveFileDialog saveDialog = new SaveFileDialog();
                     saveDialog.Filter = "(*.pdf)|*.pdf";
                     saveDialog.DefaultExt = ".pdf";
@@ -403,12 +375,12 @@ namespace Measure
 
         private void SaveFile()
         {
-            if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
+            if (pdfViewControl != null && pdfViewControl.PDFToolManager != null && pdfViewControl.PDFToolManager.GetDocument() != null)
             {
-                CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
+                CPDFDocument pdfDoc = pdfViewControl.PDFToolManager.GetDocument();
                 if (pdfDoc.WriteToLoadedPath())
                 {
-                    pdfViewControl.PDFView.UndoManager.CanSave = false;
+                    pdfViewControl.PDFViewTool.IsDocumentModified = false;
                     return;
                 }
 
@@ -421,7 +393,7 @@ namespace Measure
                 {
                     if (pdfDoc.WriteToFilePath(saveDialog.FileName))
                     {
-                        pdfViewControl.PDFView.UndoManager.CanSave = false;
+                        pdfViewControl.PDFViewTool.IsDocumentModified = false;
                     }
                 }
             }
@@ -432,9 +404,9 @@ namespace Measure
             string filePath = CommonHelper.GetExistedPathOrEmpty();
             if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
             {
-                if (pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
+                if (pdfViewControl.PDFToolManager != null && pdfViewControl.PDFToolManager.GetDocument() != null)
                 {
-                    string oldFilePath = pdfViewControl.PDFView.Document.FilePath;
+                    string oldFilePath = pdfViewControl.PDFToolManager.GetDocument().FilePath;
                     if (oldFilePath.ToLower() == filePath.ToLower())
                     {
                         return;
@@ -442,14 +414,14 @@ namespace Measure
                 }
 
                 passwordViewer = new PDFViewControl();
-                passwordViewer.PDFView.InitDocument(filePath);
-                if (passwordViewer.PDFView.Document == null)
+                passwordViewer.InitDocument(filePath);
+                if (passwordViewer.PDFToolManager.GetDocument() == null)
                 {
                     MessageBox.Show("Open File Failed");
                     return;
                 }
 
-                if (passwordViewer.PDFView.Document.IsLocked)
+                if (passwordViewer.PDFToolManager.GetDocument().IsLocked)
                 {
                     PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " password encrypted.");
                     PasswordUI.ClearPassword();
@@ -476,225 +448,11 @@ namespace Measure
 
         #endregion
 
-        #region Context Menu
-
-        private void ExtraImage_Click(object sender, RoutedEventArgs e)
-        {
-            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 = Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
-                            image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
-                            openPath = savePath;
-                        }
-                    }
-                }
-                Process.Start("explorer", "/select,\"" + openPath + "\"");
-            }
-        }
-
-        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 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
-                {
-                    e.Handle = true;
-                    e.PopupMenu = new ContextMenu();
-                    //if (pdfViewControl.CheckHasForm())
-
-                    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);
-
-                    {
-                        MenuItem resetForms = new MenuItem();
-                        resetForms.Header = "Reset Forms";
-                        resetForms.Click += (o, p) =>
-                        {
-                            if (pdfViewControl != null)
-                            {
-                                pdfViewControl.PDFView?.ResetForm(null);
-                            }
-                        };
-                        e.PopupMenu.Items.Add(new Separator());
-                        e.PopupMenu.Items.Add(resetForms);
-                    }
-                }
-            }
-
-            if (e != null && e.CommandType == CommandType.Copy)
-            {
-                e.DoCommand();
-            }
-        }
-
-        #endregion
-
         #region Close Window
 
         protected override void OnClosing(CancelEventArgs e)
         {
-            if (pdfViewControl.PDFView.UndoManager.CanSave)
+            if (pdfViewControl.PDFViewTool.IsDocumentModified)
             {
                 MessageBoxResult result = MessageBox.Show("Do you want to save your changes before closing the application?", "Message", MessageBoxButton.YesNoCancel);
                 if (result == MessageBoxResult.Yes)
@@ -797,14 +555,14 @@ namespace Measure
         }
         private void CommandBinding_Executed_ScaleAdd(object sender, ExecutedRoutedEventArgs e)
         {
-            double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true);
-            pdfViewControl.PDFView?.Zoom(newZoom);
+            double newZoom = CheckZoomLevel(pdfViewControl.GetCPDFViewer().GetZoom() + 0.01, true);
+            pdfViewControl.GetCPDFViewer().SetZoom(newZoom);
         }
 
         private void CommandBinding_Executed_ScaleSubtract(object sender, ExecutedRoutedEventArgs e)
         {
-            double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false);
-            pdfViewControl.PDFView?.Zoom(newZoom);
+            double newZoom = CheckZoomLevel(pdfViewControl.GetCPDFViewer().GetZoom() - 0.01, false);
+            pdfViewControl.GetCPDFViewer().SetZoom(newZoom);
         }
 
         private void CommandBinding_Executed_DisplaySettings(object sender, ExecutedRoutedEventArgs e)
@@ -819,7 +577,7 @@ namespace Measure
             {
                 PasswordUI.Visibility = Visibility.Collapsed;
                 FileInfoUI.Visibility = Visibility.Visible;
-                FileInfoControl.InitWithPDFViewer(pdfViewControl.PDFView);
+                FileInfoControl.InitWithPDFViewer(pdfViewControl);
                 PopupBorder.Visibility = Visibility.Visible;
             }
             else
@@ -844,8 +602,8 @@ namespace Measure
             PDFGrid.Child = null;
             RightPanelButton.Visibility = Visibility.Visible;
             PDFGrid.Child = measureControl;
-            displayPanel.InitWithPDFViewer(pdfViewControl.PDFView);
-            measureControl.InitWithPDFViewer(pdfViewControl, pdfViewControl.PDFView);
+            displayPanel.InitWithPDFViewer(pdfViewControl);
+            measureControl.InitWithPDFViewer(pdfViewControl);
             measureControl.SetSettingsControl(displayPanel);
             measureControl.ExpandEvent -= MeasureControl_ExpandEvent;
             measureControl.ExpandEvent += MeasureControl_ExpandEvent;
@@ -866,22 +624,22 @@ namespace Measure
                 measureControl.ClearAllToolState();
                 measureControl.ExpandNullRightPropertyPanel(Visibility.Collapsed);
                 RightPanelButton.IsChecked = false;
-                if (pdfViewControl != null && pdfViewControl.PDFView != null)
+                if (pdfViewControl != null && pdfViewControl.PDFViewTool != null)
                 {
-                    pdfViewControl.PDFView.SetMouseMode(MouseModes.Viewer);
+                    pdfViewControl.PDFViewTool.SetViewerModel(MouseModes.Viewer);
                 }
                 RightPanelButton.Visibility = Visibility.Collapsed;
                 measureControl.ClearViewerControl();
                 PDFGrid.Child = pdfViewControl;
                 FloatPageTool.Visibility = Visibility.Visible;
-                FloatPageTool.InitWithPDFViewer(pdfViewControl.PDFView);
+                FloatPageTool.InitWithPDFViewer(pdfViewControl);
             }
             else if ((string)item.Content == "Measurement")
             {
                 LoadMeasureRes();
-                if (pdfViewControl != null && pdfViewControl.PDFView != null)
+                if (pdfViewControl != null && pdfViewControl.PDFViewTool != null)
                 {
-                    pdfViewControl.PDFView.SetMouseMode(MouseModes.PanTool);
+                    pdfViewControl.PDFViewTool.SetViewerModel(MouseModes.PanTool);
                 }
             }
         }

+ 16 - 7
Demo/Examples/Measure/Measure.csproj

@@ -122,20 +122,23 @@
     <None Include="App.config" />
   </ItemGroup>
   <ItemGroup>
-    <ProjectReference Include="..\..\..\..\compdfkit\ComPDFKit\ComPDFKitDesktop\ComPDFKit.Viewer\ComPDFKit.Viewer.csproj">
-      <Project>{18ec356d-8130-49d4-b4e6-ac290e1065b7}</Project>
+    <ProjectReference Include="..\..\..\..\compdfkit_windows\ComPDFKit.Tool\ComPDFKit.Tool.csproj">
+      <Project>{a061ee7a-6704-4bd9-86ee-48ed5df75e2f}</Project>
+      <Name>ComPDFKit.Tool</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\..\compdfkit_windows\ComPDFKit.Viewer\ComPDFKit.Viewer.csproj">
+      <Project>{783263cf-0da3-4095-9df8-2c4a6b3ff908}</Project>
       <Name>ComPDFKit.Viewer</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\..\..\compdfkit_windows\ComPDFKit\ComPDFKitCSharp\ComPDFKit.Desk.csproj">
+      <Project>{56e518ad-c126-4b48-9a09-0a64c87020e4}</Project>
+      <Name>ComPDFKit.Desk</Name>
+    </ProjectReference>
     <ProjectReference Include="..\Compdfkit_Tools\Compdfkit_Tools.csproj">
       <Project>{9363bcb1-3a67-446a-8093-5708b86bf418}</Project>
       <Name>Compdfkit_Tools</Name>
     </ProjectReference>
   </ItemGroup>
-  <ItemGroup>
-    <None Include="license_key_windows.xml">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-    </None>
-  </ItemGroup>
   <ItemGroup>
     <Resource Include="ComPDFKit_Logo.ico" />
   </ItemGroup>
@@ -151,5 +154,11 @@
       <Install>false</Install>
     </BootstrapperPackage>
   </ItemGroup>
+  <ItemGroup>
+    <Content Include="..\..\..\..\x64\ComPDFKit.dll">
+      <Link>x64\ComPDFKit.dll</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>