|
@@ -164,8 +164,6 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- //PDFViewControl.PDFView.AnnotCommandHandler -= PDFView_AnnotCommandHandler;
|
|
|
- //PDFViewControl.PDFView.WidgetClickHandler -= PDFView_WidgetClickHandler;
|
|
|
PDFViewControl.MouseRightButtonDownHandler -= PDFViewControl_MouseRightButtonDownHandler;
|
|
|
}
|
|
|
|
|
@@ -378,346 +376,6 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
- //#region Context menu
|
|
|
-
|
|
|
- //private void PDFView_AnnotCommandHandler(object sender, AnnotCommandArgs e)
|
|
|
- //{
|
|
|
- // switch (e.CommandType)
|
|
|
- // {
|
|
|
- // case CommandType.Context:
|
|
|
- // e.Handle = true;
|
|
|
- // if (e.CommandTarget == TargetType.Annot)
|
|
|
- // {
|
|
|
- // e.Handle = true;
|
|
|
- // e.PopupMenu = new ContextMenu();
|
|
|
- // if (e.PressOnLink && AnnotationBarControl.CurrentMode == "Link")
|
|
|
- // {
|
|
|
- // e.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
|
|
|
- // MenuItem propertyMenu = new MenuItem();
|
|
|
- // propertyMenu = new MenuItem();
|
|
|
- // propertyMenu.Header = "Edit";
|
|
|
- // WeakEventManager<MenuItem, RoutedEventArgs>.AddHandler(propertyMenu, "Click", EditLink_Click);
|
|
|
- // propertyMenu.CommandParameter = e;
|
|
|
- // e.PopupMenu.Items.Add(propertyMenu);
|
|
|
- // }
|
|
|
- // else if (e.PressOnAnnot)
|
|
|
- // {
|
|
|
- // e.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
|
|
|
- // e.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
|
|
|
- // e.PopupMenu.Items.Add(new MenuItem() { Header = "Cut", Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
|
|
|
- // }
|
|
|
- // else if (e.PressOnMedia || e.PressOnSound)
|
|
|
- // {
|
|
|
- // e.Handle = true;
|
|
|
- // e.PopupMenu.Items.Add(new MenuItem() { Header = "Play", Command = MediaCommands.Play, CommandTarget = (UIElement)sender, CommandParameter = e });
|
|
|
- // e.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
|
|
|
- // }
|
|
|
- // else if (e.PressOnSelectedText)
|
|
|
- // {
|
|
|
- // e.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
|
|
|
- // MenuItem highLightMenu = new MenuItem();
|
|
|
- // highLightMenu.Header = "HighLight";
|
|
|
- // highLightMenu.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // TextHighlightAnnotArgs highLightArgs = new TextHighlightAnnotArgs();
|
|
|
- // 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);
|
|
|
- // }
|
|
|
-
|
|
|
- // };
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(highLightMenu);
|
|
|
-
|
|
|
- // MenuItem underlineMenu = new MenuItem();
|
|
|
- // underlineMenu.Header = "UnderLine";
|
|
|
- // underlineMenu.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // TextUnderlineAnnotArgs underlineArgs = new TextUnderlineAnnotArgs();
|
|
|
- // 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);
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(underlineMenu);
|
|
|
-
|
|
|
- // MenuItem strikeOutMenu = new MenuItem();
|
|
|
- // strikeOutMenu.Header = "StrikeOut";
|
|
|
- // strikeOutMenu.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // TextStrikeoutAnnotArgs strikeoutAnnotArgs = new TextStrikeoutAnnotArgs();
|
|
|
- // 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);
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(strikeOutMenu);
|
|
|
-
|
|
|
- // MenuItem SquiggleMenu = new MenuItem();
|
|
|
- // SquiggleMenu.Header = "Squiggle";
|
|
|
- // SquiggleMenu.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // TextSquigglyAnnotArgs squigglyAnnotArgs = new TextSquigglyAnnotArgs();
|
|
|
- // 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);
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(SquiggleMenu);
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // e.Handle = true;
|
|
|
- // e.PopupMenu = new ContextMenu();
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
|
|
|
- // e.PopupMenu.Items.Add(new Separator());
|
|
|
-
|
|
|
- // MenuItem fitWidthMenu = new MenuItem();
|
|
|
- // fitWidthMenu.Header = "Automatically Resize";
|
|
|
- // fitWidthMenu.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // if (PDFViewControl != null)
|
|
|
- // {
|
|
|
- // PDFViewControl.PDFView?.ChangeFitMode(FitMode.FitWidth);
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(fitWidthMenu);
|
|
|
-
|
|
|
- // MenuItem fitSizeMenu = new MenuItem();
|
|
|
- // fitSizeMenu.Header = "Actual Size";
|
|
|
- // fitSizeMenu.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // if (PDFViewControl != null)
|
|
|
- // {
|
|
|
- // PDFViewControl.PDFView?.ChangeFitMode(FitMode.FitSize);
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(fitSizeMenu);
|
|
|
-
|
|
|
- // MenuItem zoomInMenu = new MenuItem();
|
|
|
- // zoomInMenu.Header = "Zoom In";
|
|
|
- // zoomInMenu.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // if (PDFViewControl != null)
|
|
|
- // {
|
|
|
- // double newZoom = CheckZoomLevel(PDFViewControl.PDFView.ZoomFactor + 0.01, true);
|
|
|
- // PDFViewControl.PDFView?.Zoom(newZoom);
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(zoomInMenu);
|
|
|
-
|
|
|
- // MenuItem zoomOutMenu = new MenuItem();
|
|
|
- // zoomOutMenu.Header = "Zoom Out";
|
|
|
- // zoomOutMenu.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // if (PDFViewControl != null)
|
|
|
- // {
|
|
|
- // double newZoom = CheckZoomLevel(PDFViewControl.PDFView.ZoomFactor - 0.01, false);
|
|
|
- // PDFViewControl.PDFView?.Zoom(newZoom);
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(zoomOutMenu);
|
|
|
- // e.PopupMenu.Items.Add(new Separator());
|
|
|
-
|
|
|
- // MenuItem singleView = new MenuItem();
|
|
|
- // singleView.Header = "Single Page";
|
|
|
- // singleView.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // if (PDFViewControl != null)
|
|
|
- // {
|
|
|
- // PDFViewControl.PDFView?.ChangeViewMode(ViewMode.Single);
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(singleView);
|
|
|
-
|
|
|
- // MenuItem singleContinuousView = new MenuItem();
|
|
|
- // singleContinuousView.Header = "Single Page Continuous";
|
|
|
- // singleContinuousView.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // if (PDFViewControl != null)
|
|
|
- // {
|
|
|
- // PDFViewControl.PDFView?.ChangeViewMode(ViewMode.SingleContinuous);
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(singleContinuousView);
|
|
|
-
|
|
|
- // MenuItem doubleView = new MenuItem();
|
|
|
- // doubleView.Header = "Two Pages";
|
|
|
- // doubleView.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // if (PDFViewControl != null)
|
|
|
- // {
|
|
|
- // PDFViewControl.PDFView?.ChangeViewMode(ViewMode.Double);
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(doubleView);
|
|
|
-
|
|
|
- // MenuItem doubleContinuousView = new MenuItem();
|
|
|
- // doubleContinuousView.Header = "Two Pages Continuous";
|
|
|
- // doubleContinuousView.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // if (PDFViewControl != null)
|
|
|
- // {
|
|
|
- // PDFViewControl.PDFView?.ChangeViewMode(ViewMode.DoubleContinuous);
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(doubleContinuousView);
|
|
|
-
|
|
|
- // MenuItem resetFormMenu = new MenuItem();
|
|
|
- // resetFormMenu.Header = "Reset Forms";
|
|
|
- // resetFormMenu.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // if (PDFViewControl != null)
|
|
|
- // {
|
|
|
- // PDFViewControl.PDFView?.ResetForm(null);
|
|
|
- // }
|
|
|
- // };
|
|
|
- // e.PopupMenu.Items.Add(new Separator());
|
|
|
- // e.PopupMenu.Items.Add(resetFormMenu);
|
|
|
-
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // 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);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // break;
|
|
|
- // case CommandType.Copy:
|
|
|
- // e.DoCommand();
|
|
|
- // break;
|
|
|
- // case CommandType.Cut:
|
|
|
- // case CommandType.Paste:
|
|
|
- // case CommandType.Delete:
|
|
|
- // e.DoCommand();
|
|
|
- // break;
|
|
|
- // default:
|
|
|
- // break;
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
- //private void CopyImage_Click(object sender, RoutedEventArgs e)
|
|
|
- //{
|
|
|
- // try
|
|
|
- // {
|
|
|
- // 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;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // catch (Exception ex)
|
|
|
- // {
|
|
|
-
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
- //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;
|
|
|
- // try
|
|
|
- // {
|
|
|
- // 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 + "\"");
|
|
|
- // }
|
|
|
- // catch (Exception ex)
|
|
|
- // {
|
|
|
-
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
- //#endregion
|
|
|
-
|
|
|
#region UI
|
|
|
|
|
|
private double CheckZoomLevel(double zoom, bool IsGrowth)
|
|
@@ -796,7 +454,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
private void UndoManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
|
{
|
|
|
OnPropertyChanged(e.PropertyName);
|
|
|
- if (e.PropertyName == "CanSave")
|
|
|
+ if (e.PropertyName == "CanUndo" || e.PropertyName == "CanRedo")
|
|
|
{
|
|
|
OnCanSaveChanged?.Invoke(this, CanSave);
|
|
|
}
|