|
@@ -19,6 +19,8 @@ using System.Windows.Controls.Primitives;
|
|
|
using System.Windows.Input;
|
|
|
using System.Windows.Media;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
+using ComPDFKit.Tool.DrawTool;
|
|
|
+using ComPDFKitViewer.Helper;
|
|
|
|
|
|
namespace Compdfkit_Tools.Edit
|
|
|
{
|
|
@@ -41,6 +43,33 @@ namespace Compdfkit_Tools.Edit
|
|
|
FlipUI.FlipChanged -= FlipUI_FlipChanged;
|
|
|
RotateUI.RotationChanged += RotateUI_RotationChanged;
|
|
|
FlipUI.FlipChanged += FlipUI_FlipChanged;
|
|
|
+ ToolView.SelectedDataChanged -= ToolView_SelectedDataChanged;
|
|
|
+ ToolView.SelectedDataChanged += ToolView_SelectedDataChanged;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ToolView_SelectedDataChanged(object sender, SelectedAnnotData e)
|
|
|
+ {
|
|
|
+ if (ToolView.GetIsCropMode())
|
|
|
+ {
|
|
|
+ GetImageArea(out CPDFEditImageArea imageArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
+ SelectedRect selectedRect = ToolView.GetSelectedRectForEditAreaObject(imageArea);
|
|
|
+ if (selectedRect != null)
|
|
|
+ {
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(imageArea.GetFrame());
|
|
|
+ double currentZoom = ToolView.GetCPDFViewer().CurrentRenderFrame.ZoomFactor;
|
|
|
+ Rect rect = selectedRect.GetRect();
|
|
|
+ Rect maxRect = selectedRect.GetMaxRect();
|
|
|
+
|
|
|
+ Rect pdfRect = new Rect((rect.X - maxRect.X) / currentZoom, (rect.Y - maxRect.Y) / currentZoom, rect.Width / currentZoom, rect.Height / currentZoom);
|
|
|
+ pdfRect = DpiHelper.StandardRectToPDFRect(pdfRect);
|
|
|
+ CRect newCRect = new CRect((float)pdfRect.Left, (float)pdfRect.Bottom, (float)pdfRect.Right, (float)pdfRect.Top);
|
|
|
+ imageArea.CutWithRect(newCRect);
|
|
|
+
|
|
|
+ SetImageThumb();
|
|
|
+ ToolView.UpdateRender(oldRect, imageArea);
|
|
|
+ editPage.EndEdit();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void PDFImageEditControl_Unloaded(object sender, RoutedEventArgs e)
|
|
@@ -395,6 +424,7 @@ namespace Compdfkit_Tools.Edit
|
|
|
// EditEvent.ClipImage = true;
|
|
|
// EditEvent.UpdatePDFEditByEventArgs();
|
|
|
//}
|
|
|
+ ToolView.SetCropMode(!ToolView.GetIsCropMode());
|
|
|
}
|
|
|
|
|
|
private void OpacityComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|