|
@@ -54,6 +54,7 @@ using System.Windows.Markup;
|
|
|
using Prism.Services.Dialogs;
|
|
|
using PDF_Master.ViewModels.Tools.AnnotManager;
|
|
|
using PDF_Master.Model.FillAndSign;
|
|
|
+using System.Windows.Shapes;
|
|
|
|
|
|
namespace PDF_Master.ViewModels.FillAndSign
|
|
|
{
|
|
@@ -94,6 +95,25 @@ namespace PDF_Master.ViewModels.FillAndSign
|
|
|
get { return _HookShapeIsCheck; }
|
|
|
set { SetProperty(ref _HookShapeIsCheck, value); }
|
|
|
|
|
|
+ }
|
|
|
+ public Dictionary<string, List<List<Point>>> keyShape = new Dictionary<string, List<List<Point>>>();
|
|
|
+
|
|
|
+ private void InitkeyShape()
|
|
|
+ {
|
|
|
+
|
|
|
+ keyShape["HookShape"] = new List<List<Point>> { new List<Point> { new Point(2 ,12.2028), new Point(9.77817 ,19.981), new Point(22.5061 ,2.30333) } };
|
|
|
+ keyShape["ForkShape"] = new List<List<Point>> { new List<Point> { new Point(5,5), new Point(23,23) }, new List<Point> { new Point(23, 5), new Point( 5,23) } };
|
|
|
+ keyShape["RectShape"] = new List<List<Point>> { new List<Point> { new Point(1.40002, 1.40002), new Point(20, 1.40002) }, new List<Point> { new Point(20, 1.40002), new Point(20, 20) }, new List<Point> { new Point(20, 20), new Point(1.40002, 20) }, new List<Point> { new Point(1.40002, 20), new Point(1.40002, 1.40002) } };
|
|
|
+ keyShape["LineShape"] = new List<List<Point>> { new List<Point> { new Point(3.19995, 14) ,new Point(25.127, 14) } };
|
|
|
+ keyShape["DotShape"] = new List<List<Point>> { new List<Point> { new Point(3.19995, 3.19995), new Point(3.19995, 3.19995) } };
|
|
|
+
|
|
|
+
|
|
|
+ //keyShape["HookShape"] = new List<List<Point>> { new List<Point> { new Point(0.599976, 7.0286), new Point(5.57775, 11.8), new Point(13.4, 1.40002) } };
|
|
|
+ //keyShape["ForkShape"] = new List<List<Point>> { new List<Point> { new Point(3.19995, 3.20001), new Point(12.8, 12.8) }, new List<Point> { new Point(12.8, 3.20001), new Point(3.20005, 12.8) } };
|
|
|
+ //keyShape["RectShape"] = new List<List<Point>> { new List<Point> { new Point(5, 5), new Point(28, 5) }, new List<Point> { new Point(28, 5), new Point(28, 27) }, new List<Point> { new Point(28, 27), new Point(5, 27) }, new List<Point> { new Point(5, 27), new Point(5, 5) } };
|
|
|
+ //keyShape["LineShape"] = new List<List<Point>> { new List<Point> { new Point(3.19995, 3.20001), new Point(28, 3.20001) } };
|
|
|
+ //keyShape["DotShape"] = new List<List<Point>> { new List<Point> { new Point(3.19995, 3.19995), new Point(3.19995, 3.19995) } };
|
|
|
+
|
|
|
}
|
|
|
#endregion
|
|
|
public DelegateCommand<object> AnnotDefaultValue_MenuCommand { get; set; }
|
|
@@ -111,6 +131,7 @@ namespace PDF_Master.ViewModels.FillAndSign
|
|
|
/// </summary>
|
|
|
public Dictionary<string, string> btnToProperty = new Dictionary<string, string>();
|
|
|
|
|
|
+
|
|
|
private IDialogService dialogs;
|
|
|
#endregion
|
|
|
string Unicode = "";
|
|
@@ -125,6 +146,7 @@ namespace PDF_Master.ViewModels.FillAndSign
|
|
|
CheckCommand = new DelegateCommand<object>(CheckedEvent);
|
|
|
ToolExpandDict.Add("Freetext", AnnotArgsType.AnnotFreeText);
|
|
|
InitDictionary();
|
|
|
+ InitkeyShape();
|
|
|
AnnotDefaultValue_MenuCommand = new DelegateCommand<object>(AnnotDefaultValues_Menu);
|
|
|
AnnotColorPalette_MenuCommand = new DelegateCommand<object>(AnnotColorPalette_Menu);
|
|
|
FreeTextFontFamily_MenuCommand = new DelegateCommand<object>(FreeTextFontFamily_Menu);
|
|
@@ -144,6 +166,10 @@ namespace PDF_Master.ViewModels.FillAndSign
|
|
|
|
|
|
private void FromFillAndSign(FillAndSigntEventArgs obj)
|
|
|
{
|
|
|
+ if (viewContentViewModel.CurrentBar != "TabItemAnnotation")
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (obj != null)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(obj.Action) == false)
|
|
@@ -557,29 +583,29 @@ namespace PDF_Master.ViewModels.FillAndSign
|
|
|
break;
|
|
|
case "RbtnTick"://勾
|
|
|
Shape = "HookShape";
|
|
|
- ShapePoints = new List<List<Point>> { new List<Point> { new Point(0.599976, 7.0286), new Point(5.57775, 11.8), new Point(13.4, 1.40002) } };
|
|
|
+ ShapePoints = keyShape[Shape];
|
|
|
annotArgs = GetStamp();
|
|
|
break;
|
|
|
case "RbtnFork"://叉
|
|
|
Shape = "ForkShape";
|
|
|
|
|
|
- ShapePoints = new List<List<Point>> { new List<Point> { new Point(3.19995, 3.20001), new Point(12.8, 12.8) }, new List<Point> { new Point(12.8, 3.20001), new Point(3.20005, 12.8) } };
|
|
|
+ ShapePoints = keyShape[Shape];
|
|
|
annotArgs = GetStamp();
|
|
|
break;
|
|
|
case "RbtnRectangle"://矩形
|
|
|
Shape = "RectShape";
|
|
|
- ShapePoints = new List<List<Point>> { new List<Point> { new Point(5, 5), new Point(28, 5) }, new List<Point> { new Point(28, 5), new Point(28, 27) }, new List<Point> { new Point(28, 27), new Point(5, 27) }, new List<Point> { new Point(5, 27), new Point(5, 5) } };
|
|
|
+ ShapePoints = keyShape[Shape];
|
|
|
annotArgs = GetStamp();
|
|
|
break;
|
|
|
case "RbtnLine"://下划线
|
|
|
Shape = "LineShape";
|
|
|
- ShapePoints = new List<List<Point>> { new List<Point> { new Point(3.19995, 3.20001), new Point(28, 3.20001) } };
|
|
|
+ ShapePoints = keyShape[Shape];
|
|
|
annotArgs = GetStamp();
|
|
|
break;
|
|
|
case "RbtnPoint":
|
|
|
IsSignPoint = true;
|
|
|
Shape = "DotShape";
|
|
|
- ShapePoints = new List<List<Point>> { new List<Point> { new Point(3.19995, 3.19995), new Point(3.19995, 3.19995) } };
|
|
|
+ ShapePoints = keyShape[Shape];
|
|
|
LineWidthMultiple = 5;
|
|
|
annotArgs = GetStamp();
|
|
|
break;
|
|
@@ -898,51 +924,53 @@ namespace PDF_Master.ViewModels.FillAndSign
|
|
|
|
|
|
foreach (var itemAnnot in annots)
|
|
|
{
|
|
|
- for (int j = 0; j < viewContentViewModel.FillAndSign.Count; j++)
|
|
|
- {
|
|
|
- //annotAttribsList = itemAnnot.GetAnnotAttrib();
|
|
|
- //annotAttribsList[AnnotAttrib.Width] = (itemAnnot as FreehandAnnotArgs).Width;
|
|
|
- //annotAttribsList[AnnotAttrib.Height] = (itemAnnot as FreehandAnnotArgs).Height;
|
|
|
- if (viewContentViewModel.FillAndSign[j].PageIndex == itemAnnot.PageIndex && viewContentViewModel.FillAndSign[j].AnnotIndex == itemAnnot.AnnotIndex)
|
|
|
- {
|
|
|
- FreehandAnnotArgs freehandArgs = null;
|
|
|
- freehandArgs = itemAnnot as FreehandAnnotArgs;
|
|
|
- annotAttribsList = itemAnnot.GetAnnotAttrib();
|
|
|
- annotAttribsList[AnnotAttrib.Color] = freehandArgs.InkColor;
|
|
|
- annotAttribsList[AnnotAttrib.Transparency] = freehandArgs.Transparency;
|
|
|
- annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
|
|
|
- annotAttribsList[AnnotAttrib.NoteText] = freehandArgs.Content;
|
|
|
- annotAttribsList[AnnotAttrib.Path] = freehandArgs.RawPointList;
|
|
|
- annotAttribsList[AnnotAttrib.Width] = freehandArgs.Width;
|
|
|
- annotAttribsList[AnnotAttrib.Height] = freehandArgs.Height;
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
+ //for (int j = 0; j < viewContentViewModel.FillAndSign.Count; j++)
|
|
|
+ //{
|
|
|
+ // //annotAttribsList = itemAnnot.GetAnnotAttrib();
|
|
|
+ // //annotAttribsList[AnnotAttrib.Width] = (itemAnnot as FreehandAnnotArgs).Width;
|
|
|
+ // //annotAttribsList[AnnotAttrib.Height] = (itemAnnot as FreehandAnnotArgs).Height;
|
|
|
+ // if (viewContentViewModel.FillAndSign[j].PageIndex == itemAnnot.PageIndex && viewContentViewModel.FillAndSign[j].AnnotIndex == itemAnnot.AnnotIndex)
|
|
|
+ // {
|
|
|
+ // FreehandAnnotArgs freehandArgs = null;
|
|
|
+ // freehandArgs = itemAnnot as FreehandAnnotArgs;
|
|
|
+ // annotAttribsList = itemAnnot.GetAnnotAttrib();
|
|
|
+ // annotAttribsList[AnnotAttrib.Color] = freehandArgs.InkColor;
|
|
|
+ // annotAttribsList[AnnotAttrib.Transparency] = freehandArgs.Transparency;
|
|
|
+ // annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
|
|
|
+ // annotAttribsList[AnnotAttrib.NoteText] = freehandArgs.Content;
|
|
|
+ // annotAttribsList[AnnotAttrib.Path] = freehandArgs.RawPointList;
|
|
|
+ // annotAttribsList[AnnotAttrib.Width] = freehandArgs.Width;
|
|
|
+ // annotAttribsList[AnnotAttrib.Height] = freehandArgs.Height;
|
|
|
+
|
|
|
+ // }
|
|
|
+ //}
|
|
|
var eventitem = AnnotAttribEvent.GetAnnotAttribEvent(itemAnnot, annotAttribsList);
|
|
|
- propertyPanel.AnnotEvent.ClearChangeAttribute();
|
|
|
+ eventitem.ClearChangeAttribute();
|
|
|
propertyPanel.AnnotEvents.Add(eventitem);
|
|
|
|
|
|
}
|
|
|
- }
|
|
|
- for (int j = 0; j < viewContentViewModel.FillAndSign.Count; j++)
|
|
|
- {
|
|
|
-
|
|
|
- if (viewContentViewModel.FillAndSign[j].PageIndex == annots[0].PageIndex && viewContentViewModel.FillAndSign[j].AnnotIndex == annots[0].AnnotIndex)
|
|
|
- {
|
|
|
- FreehandAnnotArgs freehandArgs = null;
|
|
|
- freehandArgs = annots[0] as FreehandAnnotArgs;
|
|
|
- annotAttribsList = annots[0].GetAnnotAttrib();
|
|
|
- annotAttribsList[AnnotAttrib.Color] = freehandArgs.InkColor;
|
|
|
- annotAttribsList[AnnotAttrib.Transparency] = freehandArgs.Transparency;
|
|
|
- annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
|
|
|
- annotAttribsList[AnnotAttrib.NoteText] = freehandArgs.Content;
|
|
|
- annotAttribsList[AnnotAttrib.Path] = freehandArgs.RawPointList;
|
|
|
- annotAttribsList[AnnotAttrib.Width] = freehandArgs.Width;
|
|
|
- annotAttribsList[AnnotAttrib.Height] = freehandArgs.Height;
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annots[0], annotAttribsList);
|
|
|
+ }
|
|
|
+ //for (int j = 0; j < viewContentViewModel.FillAndSign.Count; j++)
|
|
|
+ //{
|
|
|
+
|
|
|
+ // //if (viewContentViewModel.FillAndSign[j].PageIndex == annots[0].PageIndex && viewContentViewModel.FillAndSign[j].AnnotIndex == annots[0].AnnotIndex)
|
|
|
+ // //{
|
|
|
+ // // FreehandAnnotArgs freehandArgs = null;
|
|
|
+ // // freehandArgs = annots[0] as FreehandAnnotArgs;
|
|
|
+ // // annotAttribsList = annots[0].GetAnnotAttrib();
|
|
|
+ // // annotAttribsList[AnnotAttrib.Color] = freehandArgs.InkColor;
|
|
|
+ // // annotAttribsList[AnnotAttrib.Transparency] = freehandArgs.Transparency;
|
|
|
+ // // annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
|
|
|
+ // // annotAttribsList[AnnotAttrib.NoteText] = freehandArgs.Content;
|
|
|
+ // // annotAttribsList[AnnotAttrib.Path] = freehandArgs.RawPointList;
|
|
|
+ // // annotAttribsList[AnnotAttrib.Width] = freehandArgs.Width;
|
|
|
+ // // annotAttribsList[AnnotAttrib.Height] = freehandArgs.Height;
|
|
|
+
|
|
|
+ // //}
|
|
|
+ //}
|
|
|
+ var eventitem1 = AnnotAttribEvent.GetAnnotAttribEvent(annots[0], annotAttribsList);
|
|
|
+ eventitem1.ClearChangeAttribute();
|
|
|
+ propertyPanel.AnnotEvent = eventitem1;
|
|
|
if (annots[0] is LinkAnnotArgs && annotAttribEvent != null)
|
|
|
{
|
|
|
propertyPanel.AnnotEvent = annotAttribEvent;
|
|
@@ -1282,7 +1310,7 @@ namespace PDF_Master.ViewModels.FillAndSign
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void PDFViewer_AnnotHoverHandler(object sender, AnnotHoverData e)
|
|
|
+ private async void PDFViewer_AnnotHoverHandler(object sender, AnnotHoverData e)
|
|
|
{
|
|
|
if (e != null && e.DrawContext != null)
|
|
|
{
|
|
@@ -1293,38 +1321,51 @@ namespace PDF_Master.ViewModels.FillAndSign
|
|
|
e.PaintRect.Height + 4);
|
|
|
Pen hoverPen = new Pen(new SolidColorBrush(Color.FromArgb(0xff, 0x11, 0x8A, 0xff)), 1);
|
|
|
hoverPen.DashStyle = DashStyles.Dash;
|
|
|
- e.DrawContext?.DrawRectangle(null, hoverPen, hoverRect);
|
|
|
-
|
|
|
- //Todo:目前ComPDFKit.Viewer没有e.Annot参数
|
|
|
- //便签,显示ToolTip内容
|
|
|
- //if (e.Annot != null && e.Annot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_TEXT)
|
|
|
- //{
|
|
|
- // if (PDFViewer.ToolTip == null)
|
|
|
- // {
|
|
|
- // var content = e.Annot.GetContent();
|
|
|
- // if (string.IsNullOrEmpty(content) == false)
|
|
|
- // {
|
|
|
- // ToolTip TipChild = new ToolTip();
|
|
|
- // TipChild.Style = App.Current.Resources["FlowToolTip"] as Style;
|
|
|
- // TipChild.MaxWidth = 246;
|
|
|
- // TipChild.Content = content;
|
|
|
- // TipChild.Visibility = Visibility.Visible;
|
|
|
- // TipChild.IsOpen = true;
|
|
|
- // TipChild.Placement = PlacementMode.Right;
|
|
|
- // var rec = e.Annot.GetRect();
|
|
|
- // TipChild.PlacementRectangle = new Rect(rec.left, rec.top, rec.right, rec.bottom);
|
|
|
- // TipChild.PlacementTarget = PDFViewer.Parent as ContentControl;
|
|
|
- // TipChild.Placement = PlacementMode.MousePoint;
|
|
|
- // PDFViewer.ToolTip = TipChild;
|
|
|
- // oldRect = hoverRect;
|
|
|
- // PDFViewer.MouseMove -= PDFViewer_MouseMove;
|
|
|
- // PDFViewer.MouseMove += PDFViewer_MouseMove;
|
|
|
- // return;
|
|
|
- // }
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
- //}
|
|
|
+ e.DrawContext?.DrawRectangle(null, hoverPen, hoverRect);
|
|
|
+
|
|
|
+ ////Todo: 目前ComPDFKit.Viewer没有e.Annot参数
|
|
|
+ ////便签,显示ToolTip内容
|
|
|
+ // if (e.Annot != null && e.Annot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_INK)
|
|
|
+ // {
|
|
|
+
|
|
|
+ // {
|
|
|
+
|
|
|
+ // var item = new ColorDropBoxPop();
|
|
|
+ // //item.DataContext = (sender as Ellipse).DataContext;
|
|
|
+ // item.ColorSelected -= AnnotMenu_ColorSelected;
|
|
|
+ // item.ColorSelected += AnnotMenu_ColorSelected;
|
|
|
+
|
|
|
+ // if (popup == null)
|
|
|
+ // { popup = new System.Windows.Controls.Primitives.Popup(); }
|
|
|
+ // else { popup.IsOpen = false; }
|
|
|
+
|
|
|
+ // ContentControl window = null;
|
|
|
+ // if (PDFViewer.Parent as ContentControl != null)
|
|
|
+ // window = PDFViewer.Parent as ContentControl;
|
|
|
+ // else
|
|
|
+ // window = App.Current.MainWindow;
|
|
|
+
|
|
|
+ // popup.Child = item;
|
|
|
+ // popup.PlacementRectangle = new Rect(Mouse.GetPosition(window), new Size(item.Width, item.Height));
|
|
|
+ // popup.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
|
|
|
+ // popup.PlacementTarget = window;
|
|
|
+ // popup.IsOpen = true;
|
|
|
+
|
|
|
+ // Window parentWnd = Window.GetWindow(App.Current.MainWindow);
|
|
|
+ // if (parentWnd != null)
|
|
|
+ // {
|
|
|
+ // parentWnd.MouseDown -= parentWnd_MouseDown;
|
|
|
+ // parentWnd.MouseDown += parentWnd_MouseDown;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // while (popup!= null && popup.IsOpen)
|
|
|
+ // await Task.Delay(20);
|
|
|
+
|
|
|
+ // parentWnd.MouseDown -= parentWnd_MouseDown;
|
|
|
+ // popup = null;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
CloseAnnotToolTip();
|