|
@@ -23,7 +23,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
{
|
|
|
#region Property
|
|
|
private bool isFirstLoad = true;
|
|
|
- public PDFViewControl PdfViewControl = new PDFViewControl();
|
|
|
+ public PDFViewControl PDFViewControl = new PDFViewControl();
|
|
|
public CPDFAnnotationControl PDFAnnotationControl = null;
|
|
|
private bool _isActive = false;
|
|
|
public bool IsActive
|
|
@@ -50,9 +50,9 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
- if (PdfViewControl != null && PdfViewControl.PDFView != null)
|
|
|
+ if (PDFViewControl != null && PDFViewControl.PDFView != null)
|
|
|
{
|
|
|
- return PdfViewControl.PDFView.UndoManager.CanUndo;
|
|
|
+ return PDFViewControl.PDFView.UndoManager.CanUndo;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
@@ -62,9 +62,9 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
- if (PdfViewControl != null && PdfViewControl.PDFView != null)
|
|
|
+ if (PDFViewControl != null && PDFViewControl.PDFView != null)
|
|
|
{
|
|
|
- return PdfViewControl.PDFView.UndoManager.CanRedo;
|
|
|
+ return PDFViewControl.PDFView.UndoManager.CanRedo;
|
|
|
}
|
|
|
|
|
|
return false;
|
|
@@ -75,9 +75,9 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
- if (PdfViewControl != null && PdfViewControl.PDFView != null)
|
|
|
+ if (PDFViewControl != null && PDFViewControl.PDFView != null)
|
|
|
{
|
|
|
- return PdfViewControl.PDFView.UndoManager.CanSave;
|
|
|
+ return PDFViewControl.PDFView.UndoManager.CanSave;
|
|
|
}
|
|
|
|
|
|
return false;
|
|
@@ -104,6 +104,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
CPDFAnnotationType.Audio
|
|
|
};
|
|
|
AnnotationBarControl.InitAnnotationBar(annotationProperties);
|
|
|
+ panelState.PropertyChanged -= PanelState_PropertyChanged;
|
|
|
panelState.PropertyChanged += PanelState_PropertyChanged;
|
|
|
}
|
|
|
|
|
@@ -133,8 +134,8 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
#region Init PDFViewer
|
|
|
public void InitWithPDFViewer(CPDFViewer pdfViewer)
|
|
|
{
|
|
|
- PdfViewControl.PDFView = pdfViewer;
|
|
|
- PDFGrid.Child = PdfViewControl;
|
|
|
+ PDFViewControl.PDFView = pdfViewer;
|
|
|
+ PDFGrid.Child = PDFViewControl;
|
|
|
FloatPageTool.InitWithPDFViewer(pdfViewer);
|
|
|
}
|
|
|
|
|
@@ -163,13 +164,13 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- InitialPDFViewControl(PdfViewControl);
|
|
|
- PdfViewControl.PDFView.AnnotCommandHandler += PDFView_AnnotCommandHandler;
|
|
|
+ InitialPDFViewControl(PDFViewControl);
|
|
|
+ PDFViewControl.PDFView.AnnotCommandHandler += PDFView_AnnotCommandHandler;
|
|
|
}
|
|
|
|
|
|
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- PdfViewControl.PDFView.AnnotCommandHandler -= PDFView_AnnotCommandHandler;
|
|
|
+ PDFViewControl.PDFView.AnnotCommandHandler -= PDFView_AnnotCommandHandler;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -198,18 +199,18 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
PDFAnnotationControl.ClearAnnotationBar -= PdfAnnotationControl_ClearAnnotationBar;
|
|
|
PDFAnnotationControl.ClearAnnotationBar += PdfAnnotationControl_ClearAnnotationBar;
|
|
|
- PdfViewControl.PDFView.AnnotEditHandler -= PDFView_AnnotEditHandler;
|
|
|
- PdfViewControl.PDFView.AnnotEditHandler += PDFView_AnnotEditHandler;
|
|
|
- PdfViewControl.PDFView.UndoManager.PropertyChanged -= UndoManager_PropertyChanged;
|
|
|
- PdfViewControl.PDFView.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
|
|
|
- PdfViewControl.PDFView.AnnotActiveHandler -= PDFView_AnnotActiveHandler;
|
|
|
- PdfViewControl.PDFView.AnnotActiveHandler += PDFView_AnnotActiveHandler;
|
|
|
+ PDFViewControl.PDFView.AnnotEditHandler -= PDFView_AnnotEditHandler;
|
|
|
+ PDFViewControl.PDFView.AnnotEditHandler += PDFView_AnnotEditHandler;
|
|
|
+ PDFViewControl.PDFView.UndoManager.PropertyChanged -= UndoManager_PropertyChanged;
|
|
|
+ PDFViewControl.PDFView.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
|
|
|
+ PDFViewControl.PDFView.AnnotActiveHandler -= PDFView_AnnotActiveHandler;
|
|
|
+ PDFViewControl.PDFView.AnnotActiveHandler += PDFView_AnnotActiveHandler;
|
|
|
}
|
|
|
|
|
|
public void UnloadEvent()
|
|
|
{
|
|
|
- PdfViewControl.PDFView.AnnotEditHandler -= PDFView_AnnotEditHandler;
|
|
|
- PdfViewControl.PDFView.AnnotActiveHandler -= PDFView_AnnotActiveHandler;
|
|
|
+ PDFViewControl.PDFView.AnnotEditHandler -= PDFView_AnnotEditHandler;
|
|
|
+ PDFViewControl.PDFView.AnnotActiveHandler -= PDFView_AnnotActiveHandler;
|
|
|
//panelState.PropertyChanged -= PanelState_PropertyChanged;
|
|
|
}
|
|
|
|
|
@@ -294,15 +295,15 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
highLightMenu.Click += (o, p) =>
|
|
|
{
|
|
|
TextHighlightAnnotArgs highLightArgs = new TextHighlightAnnotArgs();
|
|
|
- MouseModes oldMode = PdfViewControl.PDFView.MouseMode;
|
|
|
+ MouseModes oldMode = PDFViewControl.PDFView.MouseMode;
|
|
|
|
|
|
if (PDFAnnotationControl != null)
|
|
|
{
|
|
|
highLightArgs.Color = System.Windows.Media.Colors.Red;
|
|
|
highLightArgs.Transparency = 1;
|
|
|
- PdfViewControl.PDFView.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
- PdfViewControl.PDFView.SetToolParam(highLightArgs);
|
|
|
- PdfViewControl.PDFView.SetMouseMode(oldMode);
|
|
|
+ PDFViewControl.PDFView.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
+ PDFViewControl.PDFView.SetToolParam(highLightArgs);
|
|
|
+ PDFViewControl.PDFView.SetMouseMode(oldMode);
|
|
|
}
|
|
|
|
|
|
};
|
|
@@ -314,15 +315,15 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
underlineMenu.Click += (o, p) =>
|
|
|
{
|
|
|
TextUnderlineAnnotArgs underlineArgs = new TextUnderlineAnnotArgs();
|
|
|
- MouseModes oldMode = PdfViewControl.PDFView.MouseMode;
|
|
|
+ MouseModes oldMode = PDFViewControl.PDFView.MouseMode;
|
|
|
|
|
|
if (PDFAnnotationControl != null)
|
|
|
{
|
|
|
underlineArgs.Color = System.Windows.Media.Colors.Red;
|
|
|
underlineArgs.Transparency = 1;
|
|
|
- PdfViewControl.PDFView.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
- PdfViewControl.PDFView.SetToolParam(underlineArgs);
|
|
|
- PdfViewControl.PDFView.SetMouseMode(oldMode);
|
|
|
+ PDFViewControl.PDFView.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
+ PDFViewControl.PDFView.SetToolParam(underlineArgs);
|
|
|
+ PDFViewControl.PDFView.SetMouseMode(oldMode);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -333,15 +334,15 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
strikeOutMenu.Click += (o, p) =>
|
|
|
{
|
|
|
TextStrikeoutAnnotArgs strikeoutAnnotArgs = new TextStrikeoutAnnotArgs();
|
|
|
- MouseModes oldMode = PdfViewControl.PDFView.MouseMode;
|
|
|
+ MouseModes oldMode = PDFViewControl.PDFView.MouseMode;
|
|
|
|
|
|
if (PDFAnnotationControl != null)
|
|
|
{
|
|
|
strikeoutAnnotArgs.Color = System.Windows.Media.Colors.Red;
|
|
|
strikeoutAnnotArgs.Transparency = 1;
|
|
|
- PdfViewControl.PDFView.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
- PdfViewControl.PDFView.SetToolParam(strikeoutAnnotArgs);
|
|
|
- PdfViewControl.PDFView.SetMouseMode(oldMode);
|
|
|
+ PDFViewControl.PDFView.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
+ PDFViewControl.PDFView.SetToolParam(strikeoutAnnotArgs);
|
|
|
+ PDFViewControl.PDFView.SetMouseMode(oldMode);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -352,15 +353,15 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
SquiggleMenu.Click += (o, p) =>
|
|
|
{
|
|
|
TextSquigglyAnnotArgs squigglyAnnotArgs = new TextSquigglyAnnotArgs();
|
|
|
- MouseModes oldMode = PdfViewControl.PDFView.MouseMode;
|
|
|
+ MouseModes oldMode = PDFViewControl.PDFView.MouseMode;
|
|
|
|
|
|
if (PDFAnnotationControl != null)
|
|
|
{
|
|
|
squigglyAnnotArgs.Color = System.Windows.Media.Colors.Red;
|
|
|
squigglyAnnotArgs.Transparency = 1;
|
|
|
- PdfViewControl.PDFView.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
- PdfViewControl.PDFView.SetToolParam(squigglyAnnotArgs);
|
|
|
- PdfViewControl.PDFView.SetMouseMode(oldMode);
|
|
|
+ PDFViewControl.PDFView.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
+ PDFViewControl.PDFView.SetToolParam(squigglyAnnotArgs);
|
|
|
+ PDFViewControl.PDFView.SetMouseMode(oldMode);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -378,9 +379,9 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
fitWidthMenu.Header = "Automatically Resize";
|
|
|
fitWidthMenu.Click += (o, p) =>
|
|
|
{
|
|
|
- if (PdfViewControl != null)
|
|
|
+ if (PDFViewControl != null)
|
|
|
{
|
|
|
- PdfViewControl.PDFView?.ChangeFitMode(FitMode.FitWidth);
|
|
|
+ PDFViewControl.PDFView?.ChangeFitMode(FitMode.FitWidth);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -390,9 +391,9 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
fitSizeMenu.Header = "Actual Size";
|
|
|
fitSizeMenu.Click += (o, p) =>
|
|
|
{
|
|
|
- if (PdfViewControl != null)
|
|
|
+ if (PDFViewControl != null)
|
|
|
{
|
|
|
- PdfViewControl.PDFView?.ChangeFitMode(FitMode.FitSize);
|
|
|
+ PDFViewControl.PDFView?.ChangeFitMode(FitMode.FitSize);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -402,10 +403,10 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
zoomInMenu.Header = "Zoom In";
|
|
|
zoomInMenu.Click += (o, p) =>
|
|
|
{
|
|
|
- if (PdfViewControl != null)
|
|
|
+ if (PDFViewControl != null)
|
|
|
{
|
|
|
- double newZoom = CheckZoomLevel(PdfViewControl.PDFView.ZoomFactor + 0.01, true);
|
|
|
- PdfViewControl.PDFView?.Zoom(newZoom);
|
|
|
+ double newZoom = CheckZoomLevel(PDFViewControl.PDFView.ZoomFactor + 0.01, true);
|
|
|
+ PDFViewControl.PDFView?.Zoom(newZoom);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -415,10 +416,10 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
zoomOutMenu.Header = "Zoom Out";
|
|
|
zoomOutMenu.Click += (o, p) =>
|
|
|
{
|
|
|
- if (PdfViewControl != null)
|
|
|
+ if (PDFViewControl != null)
|
|
|
{
|
|
|
- double newZoom = CheckZoomLevel(PdfViewControl.PDFView.ZoomFactor - 0.01, false);
|
|
|
- PdfViewControl.PDFView?.Zoom(newZoom);
|
|
|
+ double newZoom = CheckZoomLevel(PDFViewControl.PDFView.ZoomFactor - 0.01, false);
|
|
|
+ PDFViewControl.PDFView?.Zoom(newZoom);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -429,9 +430,9 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
singleView.Header = "Single Page";
|
|
|
singleView.Click += (o, p) =>
|
|
|
{
|
|
|
- if (PdfViewControl != null)
|
|
|
+ if (PDFViewControl != null)
|
|
|
{
|
|
|
- PdfViewControl.PDFView?.ChangeViewMode(ViewMode.Single);
|
|
|
+ PDFViewControl.PDFView?.ChangeViewMode(ViewMode.Single);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -441,9 +442,9 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
singleContinuousView.Header = "Single Page Continuous";
|
|
|
singleContinuousView.Click += (o, p) =>
|
|
|
{
|
|
|
- if (PdfViewControl != null)
|
|
|
+ if (PDFViewControl != null)
|
|
|
{
|
|
|
- PdfViewControl.PDFView?.ChangeViewMode(ViewMode.SingleContinuous);
|
|
|
+ PDFViewControl.PDFView?.ChangeViewMode(ViewMode.SingleContinuous);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -453,9 +454,9 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
doubleView.Header = "Two Pages";
|
|
|
doubleView.Click += (o, p) =>
|
|
|
{
|
|
|
- if (PdfViewControl != null)
|
|
|
+ if (PDFViewControl != null)
|
|
|
{
|
|
|
- PdfViewControl.PDFView?.ChangeViewMode(ViewMode.Double);
|
|
|
+ PDFViewControl.PDFView?.ChangeViewMode(ViewMode.Double);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -465,9 +466,9 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
doubleContinuousView.Header = "Two Pages Continuous";
|
|
|
doubleContinuousView.Click += (o, p) =>
|
|
|
{
|
|
|
- if (PdfViewControl != null)
|
|
|
+ if (PDFViewControl != null)
|
|
|
{
|
|
|
- PdfViewControl.PDFView?.ChangeViewMode(ViewMode.DoubleContinuous);
|
|
|
+ PDFViewControl.PDFView?.ChangeViewMode(ViewMode.DoubleContinuous);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -477,9 +478,9 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
resetFormMenu.Header = "Reset Forms";
|
|
|
resetFormMenu.Click += (o, p) =>
|
|
|
{
|
|
|
- if (PdfViewControl != null)
|
|
|
+ if (PDFViewControl != null)
|
|
|
{
|
|
|
- PdfViewControl.PDFView?.ResetForm(null);
|
|
|
+ PDFViewControl.PDFView?.ResetForm(null);
|
|
|
}
|
|
|
};
|
|
|
e.PopupMenu.Items.Add(new Separator());
|
|
@@ -490,7 +491,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
else if (e.CommandTarget == TargetType.ImageSelection)
|
|
|
{
|
|
|
- if (PdfViewControl != null && PdfViewControl.PDFView != null && PdfViewControl.PDFView.GetSelectImageCount() > 0)
|
|
|
+ if (PDFViewControl != null && PDFViewControl.PDFView != null && PDFViewControl.PDFView.GetSelectImageCount() > 0)
|
|
|
{
|
|
|
e.Handle = true;
|
|
|
e.PopupMenu = new ContextMenu();
|
|
@@ -528,7 +529,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- Dictionary<int, List<Bitmap>> imageDict = PdfViewControl.PDFView?.GetSelectedImages();
|
|
|
+ Dictionary<int, List<Bitmap>> imageDict = PDFViewControl.PDFView?.GetSelectedImages();
|
|
|
|
|
|
if (imageDict != null && imageDict.Count > 0)
|
|
|
{
|
|
@@ -566,7 +567,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
string openPath = choosePath;
|
|
|
try
|
|
|
{
|
|
|
- Dictionary<int, List<Bitmap>> imageDict = PdfViewControl.PDFView?.GetSelectedImages();
|
|
|
+ Dictionary<int, List<Bitmap>> imageDict = PDFViewControl.PDFView?.GetSelectedImages();
|
|
|
|
|
|
if (imageDict != null && imageDict.Count > 0)
|
|
|
{
|
|
@@ -640,17 +641,17 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
private void UndoButton_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- if (PdfViewControl != null && PdfViewControl.PDFView != null)
|
|
|
+ if (PDFViewControl != null && PDFViewControl.PDFView != null)
|
|
|
{
|
|
|
- PdfViewControl.PDFView.UndoManager?.Undo();
|
|
|
+ PDFViewControl.PDFView.UndoManager?.Undo();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void RedoButton_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- if (PdfViewControl != null && PdfViewControl.PDFView != null)
|
|
|
+ if (PDFViewControl != null && PDFViewControl.PDFView != null)
|
|
|
{
|
|
|
- PdfViewControl.PDFView.UndoManager?.Redo();
|
|
|
+ PDFViewControl.PDFView.UndoManager?.Redo();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -705,17 +706,17 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
private void CommandBinding_Executed_Undo(object sender, ExecutedRoutedEventArgs e)
|
|
|
{
|
|
|
- if (PdfViewControl != null && PdfViewControl.PDFView != null && CanUndo)
|
|
|
+ if (PDFViewControl != null && PDFViewControl.PDFView != null && CanUndo)
|
|
|
{
|
|
|
- PdfViewControl.PDFView.UndoManager?.Undo();
|
|
|
+ PDFViewControl.PDFView.UndoManager?.Undo();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void CommandBinding_Executed_Redo(object sender, ExecutedRoutedEventArgs e)
|
|
|
{
|
|
|
- if (PdfViewControl != null && PdfViewControl.PDFView != null && CanRedo)
|
|
|
+ if (PDFViewControl != null && PDFViewControl.PDFView != null && CanRedo)
|
|
|
{
|
|
|
- PdfViewControl.PDFView.UndoManager?.Redo();
|
|
|
+ PDFViewControl.PDFView.UndoManager?.Redo();
|
|
|
}
|
|
|
}
|
|
|
|