|
@@ -42,6 +42,14 @@ using ToolTip = System.Windows.Controls.ToolTip;
|
|
|
using ContentControl = System.Windows.Controls.ContentControl;
|
|
|
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
|
|
using Pen = System.Windows.Media.Pen;
|
|
|
+using PDF_Office.Model.PropertyPanel.AnnotPanel;
|
|
|
+using RadioButton = System.Windows.Controls.RadioButton;
|
|
|
+using Style = System.Windows.Style;
|
|
|
+using PDF_Office.CustomControl;
|
|
|
+using System.Windows.Controls.Primitives;
|
|
|
+using Window = System.Windows.Window;
|
|
|
+using Task = System.Threading.Tasks.Task;
|
|
|
+using Size = System.Windows.Size;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.FillAndSign
|
|
|
{
|
|
@@ -56,24 +64,32 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
public List<List<Point>> ShapePoints = new List<List<Point>>();
|
|
|
private string Shape = "HookShape";
|
|
|
private PopMenu FreeHandAnnotPopMenu;
|
|
|
+ private PopMenu FreeTextAnnotPopMenu;
|
|
|
private PopMenu MultiAnnotPopMenu;
|
|
|
private IRegionManager regions { get; set; }
|
|
|
private Dictionary<string, AnnotArgsType> ToolExpandDict = new Dictionary<string, AnnotArgsType>();
|
|
|
public static bool IsEdit = false;
|
|
|
- public static bool IsSignPoint=false;
|
|
|
+ public static bool IsSignPoint = false;
|
|
|
public Brush SelectColor = new SolidColorBrush(Colors.GreenYellow);
|
|
|
public double FillOpacity = 1;
|
|
|
public double LineWidth = 1;
|
|
|
public double LineWidthMultiple = 1;
|
|
|
|
|
|
- private bool _HookShapeIsCheck=true;
|
|
|
- public bool HookShapeIsCheck {
|
|
|
+ private bool _HookShapeIsCheck = true;
|
|
|
+ public bool HookShapeIsCheck
|
|
|
+ {
|
|
|
get { return _HookShapeIsCheck; }
|
|
|
- set { SetProperty(ref _HookShapeIsCheck,value); }
|
|
|
-
|
|
|
+ set { SetProperty(ref _HookShapeIsCheck, value); }
|
|
|
+
|
|
|
}
|
|
|
#endregion
|
|
|
public DelegateCommand<object> AnnotDefaultValue_MenuCommand { get; set; }
|
|
|
+
|
|
|
+ public DelegateCommand<object> FreeTextFontFamily_MenuCommand { get; set; }
|
|
|
+
|
|
|
+ public DelegateCommand<object> AnnotColorPalette_MenuCommand { get; set; }
|
|
|
+
|
|
|
+ public DelegateCommand<object> FreeTextAglin_MenuCommand { get; set; }
|
|
|
#region Command
|
|
|
public DelegateCommand<RoutedEventArgs> CheckCommand { get; set; }
|
|
|
|
|
@@ -91,9 +107,212 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
ToolExpandDict.Add("Freetext", AnnotArgsType.AnnotFreeText);
|
|
|
InitDictionary();
|
|
|
AnnotDefaultValue_MenuCommand = new DelegateCommand<object>(AnnotDefaultValues_Menu);
|
|
|
+ AnnotColorPalette_MenuCommand = new DelegateCommand<object>(AnnotColorPalette_Menu);
|
|
|
+ FreeTextFontFamily_MenuCommand = new DelegateCommand<object>(FreeTextFontFamily_Menu);
|
|
|
+ FreeTextAglin_MenuCommand = new DelegateCommand<object>(FreeTextAglin_Menu);
|
|
|
InitSelectFreeHandAnnotMenu();
|
|
|
+ InitSelectFreeTextAnnotMenu();
|
|
|
+ }
|
|
|
+ private System.Windows.Controls.Primitives.Popup popup = null;
|
|
|
+ private async void AnnotColorPalette_Menu(object obj)
|
|
|
+ {
|
|
|
+ if (obj as CusMenuItem != null)
|
|
|
+ {
|
|
|
+ var menu = obj as CusMenuItem;
|
|
|
+ var annot = menu.Parameter as AnnotHandlerEventArgs;
|
|
|
+ if (annot != null)
|
|
|
+ {
|
|
|
+ var item = new ColorDropBoxPop();
|
|
|
+ item.DataContext = menu;
|
|
|
+ item.ColorSelected -= AnnotMenu_ColorSelected;
|
|
|
+ item.ColorSelected += AnnotMenu_ColorSelected;
|
|
|
+
|
|
|
+ if (popup == null)
|
|
|
+ popup = new System.Windows.Controls.Primitives.Popup();
|
|
|
+
|
|
|
+ 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.IsOpen)
|
|
|
+ await Task.Delay(20);
|
|
|
+
|
|
|
+ parentWnd.MouseDown -= parentWnd_MouseDown;
|
|
|
+ popup = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void AnnotMenu_ColorSelected(object sender, Color e)
|
|
|
+ {
|
|
|
+ if (sender != null)
|
|
|
+ {
|
|
|
+ var menu = (sender as FrameworkElement).DataContext as CusMenuItem;
|
|
|
+ if (menu == null) return;
|
|
|
+
|
|
|
+ var annot = menu.Parameter as AnnotHandlerEventArgs;
|
|
|
+ if (annot != null)
|
|
|
+ {
|
|
|
+ if (annot is FreehandAnnotArgs || annot is StickyAnnotArgs || annot is LineAnnotArgs)
|
|
|
+ {
|
|
|
+ var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, e);
|
|
|
+ AnnotEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
+ else if (annot is FreeTextAnnotArgs)
|
|
|
+ {
|
|
|
+ var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
|
|
|
+ if (menu.tag.ToString() == "FontColor")
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.FontColor, e);
|
|
|
+ else
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.FillColor, e);
|
|
|
+
|
|
|
+ AnnotEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
+ else if (annot is SquareAnnotArgs || annot is CircleAnnotArgs)
|
|
|
+ {
|
|
|
+ var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
|
|
|
+ if (menu.tag.ToString() == "FillColor")
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.FillColor, e);
|
|
|
+ else
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, e);
|
|
|
+
|
|
|
+ AnnotEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
+ else if (annot is TextHighlightAnnotArgs || annot is TextUnderlineAnnotArgs || annot is TextStrikeoutAnnotArgs)
|
|
|
+ {
|
|
|
+ var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, e);
|
|
|
+ AnnotEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void parentWnd_MouseDown(object sender, MouseButtonEventArgs e)
|
|
|
+ {
|
|
|
+ var ui = Mouse.DirectlyOver as FrameworkElement;
|
|
|
+ if (ui != null)
|
|
|
+ {
|
|
|
+ if (popup != null)
|
|
|
+ {
|
|
|
+ popup.IsOpen = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void FreeTextFontFamily_Menu(object obj)
|
|
|
+ {
|
|
|
+ if (obj as CusMenuItem != null)
|
|
|
+ {
|
|
|
+ var menu = obj as CusMenuItem;
|
|
|
+ var annot = menu.Parameter as AnnotHandlerEventArgs;
|
|
|
+ if (annot != null)
|
|
|
+ {
|
|
|
+ var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.FontFamily, new FontFamily(menu.tag.ToString()));
|
|
|
+ AnnotEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void FreeTextAglin_Menu(object obj)
|
|
|
+ {
|
|
|
+ if (obj as CusMenuItem != null)
|
|
|
+ {
|
|
|
+ var menu = obj as CusMenuItem;
|
|
|
+ var annot = menu.Parameter as AnnotHandlerEventArgs;
|
|
|
+ var tag = menu.control.Tag;
|
|
|
+ if (annot != null && tag != null)
|
|
|
+ {
|
|
|
+ var strTag = tag.ToString();
|
|
|
+
|
|
|
+ var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
|
|
|
+ if (strTag == "Left")
|
|
|
+ {
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Left);
|
|
|
+ }
|
|
|
+ else if (strTag == "Center")
|
|
|
+ {
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Center);
|
|
|
+ }
|
|
|
+ else if (strTag == "Right")
|
|
|
+ {
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Right);
|
|
|
+ }
|
|
|
+ else if (strTag == "Justify")
|
|
|
+ {
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Justify);
|
|
|
+ }
|
|
|
+
|
|
|
+ AnnotEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void AnnotDefaultValues_Menu(object obj)
|
|
|
+ {
|
|
|
+ if (obj as CusMenuItem != null)
|
|
|
+ {
|
|
|
+ var menu = obj as CusMenuItem;
|
|
|
+ var annot = menu.Parameter as AnnotHandlerEventArgs;
|
|
|
+ if (annot != null)
|
|
|
+ {
|
|
|
+ if (annot is FreehandAnnotArgs)
|
|
|
+ {
|
|
|
+ var freeHand = annot as FreehandAnnotArgs;
|
|
|
+ var color = freeHand.InkColor;
|
|
|
+
|
|
|
+ Settings.Default.AppProperties.Annotate.FreeHandColor = color;
|
|
|
+
|
|
|
+ var FreehandDefault = GetAnnotDefault(AnnotArgsType.AnnotFreehand);
|
|
|
+ FreehandDefault.ForgoundColor = color;
|
|
|
+ FreehandDefault.Opacity = freeHand.Transparency;
|
|
|
+ FreehandDefault.Thickness = freeHand.LineWidth;
|
|
|
+
|
|
|
+ var isSolid = AnnotPropertyPanel.IsSolidStyle(freeHand.LineDash);
|
|
|
+ if (isSolid)
|
|
|
+ {
|
|
|
+ FreehandDefault.DashArray = null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ FreehandDefault.DashArray = new List<double>();
|
|
|
+ foreach (var item in freeHand.LineDash.Dashes)
|
|
|
+ {
|
|
|
+ FreehandDefault.DashArray.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SettingHelper.SetAnnotDefaultProperty(FreehandDefault);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private DefaultAnnotProperty GetAnnotDefault(AnnotArgsType annotArgsType)
|
|
|
+ {
|
|
|
+ var Annot = SettingHelper.GetAnnotDefaultProperty(annotArgsType);
|
|
|
+ if (Annot == null)
|
|
|
+ {
|
|
|
+ Annot = new DefaultAnnotProperty();
|
|
|
+ Annot.AnnotToolType = annotArgsType;
|
|
|
+ }
|
|
|
+ return Annot;
|
|
|
}
|
|
|
- private void AnnotDefaultValues_Menu(object e){}
|
|
|
private void CheckedEvent(RoutedEventArgs e)
|
|
|
{
|
|
|
IsEdit = false;
|
|
@@ -151,11 +370,11 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
}
|
|
|
private void InitCheckedEvent(string e)
|
|
|
{
|
|
|
- IsEdit = false;
|
|
|
-
|
|
|
-
|
|
|
- //NavigateToProperty(control.Name);
|
|
|
- //不创建注释,属于注释模板
|
|
|
+ IsEdit = false;
|
|
|
+
|
|
|
+
|
|
|
+ //NavigateToProperty(control.Name);
|
|
|
+ //不创建注释,属于注释模板
|
|
|
bool isTemplateAnnot = false;
|
|
|
bool isSnapshotEdit = false;
|
|
|
AnnotHandlerEventArgs annotArgs = null;
|
|
@@ -208,7 +427,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
private void FindAnnotTypeKey(string tag, ref AnnotHandlerEventArgs annotArgs, bool isRightMenuAdd = false)
|
|
|
{
|
|
|
LineWidthMultiple = 1;
|
|
|
- IsSignPoint=false;
|
|
|
+ IsSignPoint = false;
|
|
|
switch (tag)
|
|
|
{
|
|
|
|
|
@@ -230,13 +449,13 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
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) } };
|
|
|
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 = 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) } };
|
|
|
annotArgs = GetStamp();
|
|
|
break;
|
|
|
case "RbtnLine"://下划线
|
|
@@ -274,7 +493,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
{
|
|
|
StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
|
|
|
|
|
|
- stampAnnotArgs.SetInkData(ShapePoints, LineWidth* LineWidthMultiple, (SelectColor as SolidColorBrush).Color);
|
|
|
+ stampAnnotArgs.SetInkData(ShapePoints, LineWidth * LineWidthMultiple, (SelectColor as SolidColorBrush).Color);
|
|
|
//PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
//PDFViewer.SetToolParam(stampArgs);
|
|
|
//StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
|
|
@@ -311,7 +530,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
public void SetStamp()
|
|
|
{
|
|
|
StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
|
|
|
- stampAnnotArgs.SetInkData(ShapePoints, LineWidth* LineWidthMultiple, (SelectColor as SolidColorBrush).Color);
|
|
|
+ stampAnnotArgs.SetInkData(ShapePoints, LineWidth * LineWidthMultiple, (SelectColor as SolidColorBrush).Color);
|
|
|
//PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
//PDFViewer.SetToolParam(stampArgs);
|
|
|
//StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
|
|
@@ -371,13 +590,13 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
{
|
|
|
|
|
|
Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
|
|
|
- List<AnnotHandlerEventArgs> newSelectedArgs= new List<AnnotHandlerEventArgs>();
|
|
|
+ List<AnnotHandlerEventArgs> newSelectedArgs = new List<AnnotHandlerEventArgs>();
|
|
|
FreehandAnnotArgs freehandArgs = null;
|
|
|
|
|
|
if (selectedArgs == null || selectedArgs.Count == 0)
|
|
|
{
|
|
|
- freehandArgs = new FreehandAnnotArgs();
|
|
|
-
|
|
|
+ freehandArgs = new FreehandAnnotArgs();
|
|
|
+
|
|
|
var annotate = Settings.Default.AppProperties.Annotate;
|
|
|
if (annotate != null)
|
|
|
{
|
|
@@ -387,7 +606,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
{
|
|
|
freehandArgs.InkColor = Color.FromRgb(0x38, 0xE0, 0x2E);
|
|
|
}
|
|
|
- freehandArgs.RawPointList= 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) } };
|
|
|
+ freehandArgs.RawPointList = 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) } };
|
|
|
freehandArgs.Transparency = 1;
|
|
|
freehandArgs.LineWidth = 2;
|
|
|
|
|
@@ -403,7 +622,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
freehandArgs = selectedArgs[0] as FreehandAnnotArgs;
|
|
|
foreach (var item in selectedArgs)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
//if (ListPoint((item as FreehandAnnotArgs).RawPointList, ShapePoints)){
|
|
|
foreach (var point in viewContentViewModel.FillAndSign)
|
|
|
{
|
|
@@ -423,7 +642,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
annotAttribsList[AnnotAttrib.Transparency] = freehandArgs.Transparency;
|
|
|
annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
|
|
|
annotAttribsList[AnnotAttrib.NoteText] = freehandArgs.Content;
|
|
|
- annotAttribsList[AnnotAttrib.Path]= freehandArgs.RawPointList;
|
|
|
+ annotAttribsList[AnnotAttrib.Path] = freehandArgs.RawPointList;
|
|
|
annotAttribsList[AnnotAttrib.Width] = freehandArgs.Width;
|
|
|
annotAttribsList[AnnotAttrib.Height] = freehandArgs.Height;
|
|
|
AddToPropertyPanel("ShapFillProperty", "Freehand", newSelectedArgs, annotAttribsList);
|
|
@@ -462,8 +681,8 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
|
|
|
if (selectedArgs == null || selectedArgs.Count == 0)
|
|
|
{
|
|
|
- freetextArgs = new FreeTextAnnotArgs();
|
|
|
-
|
|
|
+ freetextArgs = new FreeTextAnnotArgs();
|
|
|
+
|
|
|
freetextArgs.Align = TextAlignment.Left;
|
|
|
freetextArgs.BgColor = Colors.Transparent;
|
|
|
freetextArgs.FontFamily = new FontFamily(Settings.Default.AppProperties.Annotate.TextFontFamaily);
|
|
@@ -537,7 +756,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
private void AddToPropertyPanel(string viewContent, string toolTag = null, List<AnnotHandlerEventArgs> annots = null, Dictionary<AnnotAttrib, object> annotAttribsList = null, AnnotAttribEvent annotAttribEvent = null, bool isUpData = false)
|
|
|
{
|
|
|
|
|
|
- if (annots != null&& annots.Count!=0)
|
|
|
+ if (annots != null && annots.Count != 0)
|
|
|
{
|
|
|
propertyPanel.annotlists = annots;
|
|
|
propertyPanel.annot = annots[0];
|
|
@@ -546,11 +765,11 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
else
|
|
|
{
|
|
|
propertyPanel.annotlists = null;
|
|
|
- propertyPanel.annot = null;
|
|
|
-
|
|
|
+ propertyPanel.annot = null;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- if (annotAttribsList != null && annotAttribsList.Count != 0&&annots != null && annots.Count != 0)
|
|
|
+ if (annotAttribsList != null && annotAttribsList.Count != 0 && annots != null && annots.Count != 0)
|
|
|
{
|
|
|
if (annots.Count > 1)
|
|
|
{
|
|
@@ -654,6 +873,114 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
|
|
|
FreeHandAnnotPopMenu = pop;
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 文本
|
|
|
+ /// </summary>
|
|
|
+ private void InitSelectFreeTextAnnotMenu()
|
|
|
+ {
|
|
|
+ var popMenu = new ContextMenu();
|
|
|
+ PopMenu pop = new PopMenu(popMenu);
|
|
|
+ var menuItem = new MenuItem();
|
|
|
+ menuItem.Name = "FreeTextCopy";
|
|
|
+ menuItem.Header = "复制";
|
|
|
+ pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
|
|
|
+
|
|
|
+ menuItem = new MenuItem();
|
|
|
+ menuItem.Name = "FreeTextCut";
|
|
|
+ menuItem.Header = "剪切";
|
|
|
+ pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
|
|
|
+
|
|
|
+ menuItem = new MenuItem();
|
|
|
+ menuItem.Name = "FreeTextPaste";
|
|
|
+ menuItem.Header = "粘贴";
|
|
|
+ pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
|
|
|
+
|
|
|
+ menuItem = new MenuItem();
|
|
|
+ menuItem.Name = "FreeTextDelete";
|
|
|
+ menuItem.Header = "删除";
|
|
|
+ pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
|
|
|
+
|
|
|
+ pop.AddItem(GetSeparator());
|
|
|
+
|
|
|
+ menuItem = new MenuItem();
|
|
|
+ menuItem.Name = "FreeTextColor";
|
|
|
+ menuItem.Header = "字体颜色";
|
|
|
+ menuItem.Tag = "FontColor";
|
|
|
+ pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
|
|
|
+
|
|
|
+ menuItem = new MenuItem();
|
|
|
+ menuItem.Name = "FreeTextColor";
|
|
|
+ menuItem.Header = "填充颜色";
|
|
|
+ menuItem.Tag = "FillColor";
|
|
|
+ pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
|
|
|
+
|
|
|
+ menuItem = new MenuItem();
|
|
|
+ menuItem.Name = "FreeTextFontFamily";
|
|
|
+ menuItem.Header = "字体";
|
|
|
+ pop.AddItem(menuItem);
|
|
|
+
|
|
|
+ var family = TextFont.GetFamily();
|
|
|
+
|
|
|
+ foreach (var item in family)
|
|
|
+ {
|
|
|
+ RadioButton familyRdioBtn = new RadioButton();
|
|
|
+ familyRdioBtn.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
|
|
|
+ familyRdioBtn.Background = new SolidColorBrush(Colors.Transparent);
|
|
|
+ familyRdioBtn.Name = item.ValueStr;
|
|
|
+ familyRdioBtn.Tag = item.ValueStr;
|
|
|
+ familyRdioBtn.GroupName = "FontFamily";
|
|
|
+ familyRdioBtn.Content = item.Content;
|
|
|
+ pop.BindingEvent(pop.AddChild("FreeTextFontFamily", familyRdioBtn), FreeTextFontFamily_MenuCommand);
|
|
|
+ }
|
|
|
+
|
|
|
+ menuItem = new MenuItem();
|
|
|
+ menuItem.Name = "FreeTextAglin";
|
|
|
+ menuItem.Header = "文本对齐";
|
|
|
+ pop.AddItem(menuItem);
|
|
|
+
|
|
|
+ var radioButton = new RadioButton();
|
|
|
+ radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
|
|
|
+ radioButton.Background = new SolidColorBrush(Colors.Transparent);
|
|
|
+ radioButton.Name = "FreeTextAglinLeft";
|
|
|
+ radioButton.Tag = "Left";
|
|
|
+ radioButton.GroupName = "Aglin";
|
|
|
+ radioButton.Content = "左对齐";
|
|
|
+ pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
|
|
|
+
|
|
|
+ radioButton = new RadioButton();
|
|
|
+ radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
|
|
|
+ radioButton.Background = new SolidColorBrush(Colors.Transparent);
|
|
|
+ radioButton.Name = "FreeTextAglinCenter";
|
|
|
+ radioButton.Tag = "Center";
|
|
|
+ radioButton.GroupName = "Aglin";
|
|
|
+ radioButton.Content = "居中对齐";
|
|
|
+ pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
|
|
|
+
|
|
|
+ radioButton = new RadioButton();
|
|
|
+ radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
|
|
|
+ radioButton.Background = new SolidColorBrush(Colors.Transparent);
|
|
|
+ radioButton.Name = "FreeTextAglinRight";
|
|
|
+ radioButton.Tag = "Right";
|
|
|
+ radioButton.GroupName = "Aglin";
|
|
|
+ radioButton.Content = "右对齐";
|
|
|
+ pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
|
|
|
+
|
|
|
+ radioButton = new RadioButton();
|
|
|
+ radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
|
|
|
+ radioButton.Background = new SolidColorBrush(Colors.Transparent);
|
|
|
+ radioButton.Name = "FreeTextAglinJustify";
|
|
|
+ radioButton.Tag = "Justify";
|
|
|
+ radioButton.GroupName = "Aglin";
|
|
|
+ radioButton.Content = "两端对齐";
|
|
|
+ pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
|
|
|
+
|
|
|
+ menuItem = new MenuItem();
|
|
|
+ menuItem.Name = "FreeHandDefault";
|
|
|
+ menuItem.Header = "设置当前属性为默认值";
|
|
|
+ pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
|
|
|
+ FreeTextAnnotPopMenu = pop;
|
|
|
+ }
|
|
|
+
|
|
|
private Separator GetSeparator()
|
|
|
{
|
|
|
Separator separator = new Separator();
|
|
@@ -712,12 +1039,15 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
{
|
|
|
var selectedAnnot = e.AnnotEventArgsList[0];
|
|
|
switch (selectedAnnot.EventType)
|
|
|
- {
|
|
|
-
|
|
|
-
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
case AnnotArgsType.AnnotFreehand:
|
|
|
e.PopupMenu = FreeHandAnnotPopMenu.OpenMenu(selectedAnnot, sender);
|
|
|
break;
|
|
|
+ case AnnotArgsType.AnnotFreeText:
|
|
|
+ e.PopupMenu= FreeTextAnnotPopMenu.OpenMenu(selectedAnnot, sender);
|
|
|
+ break;
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -746,8 +1076,8 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
else
|
|
|
{
|
|
|
if (e.PressOnSelectedText || e.CommandTarget == TargetType.ImageSelection)
|
|
|
- {
|
|
|
-
|
|
|
+ {
|
|
|
+
|
|
|
if (e.PopupMenu != null)
|
|
|
{
|
|
|
e.Handle = true;
|
|
@@ -755,7 +1085,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- e.PopupMenu = ViewerContextMenu(sender);
|
|
|
+ e.PopupMenu = ViewerContextMenu(sender);
|
|
|
if (e.PopupMenu != null)
|
|
|
{
|
|
|
e.Handle = true;
|
|
@@ -845,13 +1175,13 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
}
|
|
|
private ContextMenu ViewerContextMenu(object sender)
|
|
|
{
|
|
|
- ContextMenu contextMenu = App.Current.FindResource("ViewerContextMenu") as ContextMenu;
|
|
|
-
|
|
|
- ViewerContextMenu_Loaded(contextMenu,sender);
|
|
|
+ ContextMenu contextMenu = App.Current.FindResource("ViewerContextMenu") as ContextMenu;
|
|
|
+
|
|
|
+ ViewerContextMenu_Loaded(contextMenu, sender);
|
|
|
return contextMenu;
|
|
|
}
|
|
|
|
|
|
- private void ViewerContextMenu_Loaded(object sender,object e,Visibility visibility =Visibility.Collapsed)
|
|
|
+ private void ViewerContextMenu_Loaded(object sender, object e, Visibility visibility = Visibility.Collapsed)
|
|
|
{
|
|
|
ContextMenu contextMenu = sender as ContextMenu;
|
|
|
if (contextMenu.Items.Count > 0)
|
|
@@ -861,17 +1191,18 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
CPDFBookmark list = PDFViewer.Document.GetBookmarkList().FirstOrDefault(q => q.PageIndex == index);
|
|
|
foreach (var item in contextMenu.Items)
|
|
|
{
|
|
|
- if (item is Separator separator) {
|
|
|
-
|
|
|
- separator.Visibility = visibility;
|
|
|
+ if (item is Separator separator)
|
|
|
+ {
|
|
|
+
|
|
|
+ separator.Visibility = visibility;
|
|
|
}
|
|
|
if (item is MenuItem menuItem1)
|
|
|
- {
|
|
|
- //if (menuItem1.Tag.ToString() == "DisplayAnnot" || menuItem1.Tag.ToString() == "HiddenAnnot")
|
|
|
- //{
|
|
|
- // SetMenuItemVisibility(menuItem1, "DisplayAnnot", "HiddenAnnot", isHiddenAnnot);
|
|
|
- //}
|
|
|
-
|
|
|
+ {
|
|
|
+ //if (menuItem1.Tag.ToString() == "DisplayAnnot" || menuItem1.Tag.ToString() == "HiddenAnnot")
|
|
|
+ //{
|
|
|
+ // SetMenuItemVisibility(menuItem1, "DisplayAnnot", "HiddenAnnot", isHiddenAnnot);
|
|
|
+ //}
|
|
|
+
|
|
|
switch (menuItem1.Tag.ToString())
|
|
|
{
|
|
|
case "Paste":
|
|
@@ -891,53 +1222,53 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
break;
|
|
|
|
|
|
case "AddAnnotation":
|
|
|
- menuItem1.Visibility = visibility;
|
|
|
-
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
case "HiddenAnnot":
|
|
|
- menuItem1.Visibility = visibility;
|
|
|
-
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
case "DisplayAnnot":
|
|
|
- menuItem1.Visibility = visibility;
|
|
|
-
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
case "AddBookMark":
|
|
|
- menuItem1.Visibility = visibility;
|
|
|
-
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
case "DelBookMark":
|
|
|
- menuItem1.Visibility = visibility;
|
|
|
-
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
case "ToolMode":
|
|
|
- menuItem1.Visibility = visibility;
|
|
|
-
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
case "ReadModel":
|
|
|
- menuItem1.Visibility = visibility;
|
|
|
-
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
case "UnReadModel":
|
|
|
- menuItem1.Visibility = visibility;
|
|
|
-
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
case "ViewZoom":
|
|
|
- menuItem1.Visibility = visibility;
|
|
|
-
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
case "PageDisplay":
|
|
|
- menuItem1.Visibility = visibility;
|
|
|
-
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
case "Select":
|
|
@@ -1054,7 +1385,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
//IsAnnotCreateReset:是否为创建注释的状态
|
|
|
if (e.IsAnnotCreateReset == false)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
GetSelectedAnnots(e);
|
|
|
//记录这次选中的注释,之后创建注释会跟随上次选中注释的属性值
|
|
|
//PDFViewer.SetToolParam(annot);
|
|
@@ -1250,11 +1581,11 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
UnBindingPDFViewerHandler();
|
|
|
ContextMenu contextMenu = App.Current.FindResource("ViewerContextMenu") as ContextMenu;
|
|
|
|
|
|
- ViewerContextMenu_Loaded(contextMenu, null,Visibility.Visible);
|
|
|
+ ViewerContextMenu_Loaded(contextMenu, null, Visibility.Visible);
|
|
|
viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
|
|
|
PDFViewer.SetMouseMode(MouseModes.PanTool);
|
|
|
- ShowPropertyPanel(false);
|
|
|
-
|
|
|
+ ShowPropertyPanel(false);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
@@ -1262,7 +1593,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
|
|
|
navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
|
|
|
BindingPDFViewerHandler();
|
|
|
- HookShapeIsCheck=true;
|
|
|
+ HookShapeIsCheck = true;
|
|
|
InitCheckedEvent("RbtnTick");
|
|
|
IsEdit = false;
|
|
|
}
|