123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949 |
- using ComPDFKitViewer.AnnotEvent;
- using ComPDFKitViewer;
- using Prism.Mvvm;
- using Prism.Regions;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Media;
- using Prism.Commands;
- using System.Windows.Controls;
- using ComPDFKit.PDFAnnotation;
- using PDF_Master.Helper;
- using System.Diagnostics;
- using PDF_Master.Model;
- using PDF_Master.ViewModels.Tools;
- using Microsoft.Office.Interop.Excel;
- using Point = System.Windows.Point;
- using static Dropbox.Api.UsersCommon.AccountType;
- using PDF_Master.Model.AnnotPanel;
- using PDFSettings;
- using PDF_Master.ViewModels.Tools.AnnotManager;
- using Prism.Common;
- using ComPDFKitViewer.PdfViewer;
- using PDF_Master.CustomControl.CompositeControl;
- using Microsoft.Office.Interop.Word;
- using System.Diagnostics.Eventing.Reader;
- using PDF_Master.EventAggregators;
- namespace PDF_Master.ViewModels.FillAndSign.PropertyPanel
- {
- public class ShapFillPropertyViewModel : BindableBase, INavigationAware
- {
- public AnnotAttribEvent AnnotEvent { get; set; }
- private AnnotHandlerEventArgs Annot;
- private AnnotTransfer PropertyPanel;
- private FillAndSignContentViewModel fillAndSignContentViewModel;
- public List<List<Point>> updatapath = new List<List<Point>>();
- private Geometry dataPath = null;
- private bool IsFillAndSign = false;
- private bool IsUpDataCreate = false;
- public string shape = "";
- public string Shape
- {
- get { return shape; }
- set
- {
- SetProperty(ref shape, value);
- }
- }
- public bool _isCreate = false;
- public bool IsCreate
- {
- get {
- if (fillAndSignContentViewModel != null) { if (fillAndSignContentViewModel.PDFViewer.MouseMode != MouseModes.AnnotCreate) { return false; } else { return true; } }
- else { return false; }
- }
- }
- public string shapeType = "";
- public string ShapeType
- {
- get { return shapeType; }
- set
- {
- SetProperty(ref shapeType, value);
- }
- }
- public Geometry DataPath
- {
- get { return dataPath; }
- set
- {
- SetProperty(ref dataPath, value);
- }
- }
- private void InitColorItems()
- {
- }
- private Brush selectColor = new SolidColorBrush(Color.FromArgb(0xff, 0x26, 0x25, 0x29));
- public Brush SelectColor
- {
- get { return selectColor; }
- set
- {
- SetProperty(ref selectColor, value);
- UPDataColor();
- }
- }
- private double fillOpacity = 1;
- public double FillOpacity
- {
- get { return fillOpacity; }
- set
- {
- SetProperty(ref fillOpacity, value);
- //if (!fillAndSignContentViewModel.isFirst)
- //{
- // fillAndSignContentViewModel.FillOpacity = value;
- // //if (FillAndSignContentViewModel.IsEdit)
- // {
- // PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, fillOpacity);
- // }
- // //else
- // {
- // if (IsFillAndSign) { fillAndSignContentViewModel.SetStamp(); }
- // }
- //}
- }
- }
- private bool _hookIsChecked = false;
- public bool HookIsChecked
- {
- get { return _hookIsChecked; }
- set
- {
- SetProperty(ref _hookIsChecked, value);
- }
- }
- private bool _forkIsChecked = false;
- public bool ForkIsChecked
- {
- get { return _forkIsChecked; }
- set
- {
- SetProperty(ref _forkIsChecked, value);
- }
- }
- private bool _rectIsChecked = false;
- public bool RectIsChecked
- {
- get { return _rectIsChecked; }
- set
- {
- SetProperty(ref _rectIsChecked, value);
- }
- }
- private bool _lineIsChecked = false;
- public bool LineIsChecked
- {
- get { return _lineIsChecked; }
- set
- {
- SetProperty(ref _lineIsChecked, value);
- }
- }
- private bool _dotIsChecked = false;
- public bool DotIsChecked
- {
- get { return _dotIsChecked; }
- set
- {
- SetProperty(ref _dotIsChecked, value);
- }
- }
- private bool _isMultiSelected = false;
- public bool IsMultiSelected
- {
- get { return _isMultiSelected; }
- set
- {
- SetProperty(ref _isMultiSelected, value);
- if (value) { ShapeType = "General Properties"; }
- }
- }
- private bool _isSelected = false;
- public bool IsSelected
- {
- get { return _isSelected; }
- set => SetProperty(ref _isSelected, value);
- }
- private double lineWidthMultiple = 1;
- private double lineWidth = 1;
- public double LineWidth
- {
- get { return lineWidth; }
- set
- {
- SetProperty(ref lineWidth, value);
- }
- }
- private Brush _shapeColortColor = new SolidColorBrush(Color.FromArgb(0xff, 0x26, 0x25, 0x29));
- public Brush ShapeColorColor
- {
- get { return _shapeColortColor; }
- set { SetProperty(ref _shapeColortColor, value); }
- }
- List<ColorItem> shapeColorItems = new List<ColorItem>();
- public List<ColorItem> ShapeColorItems
- {
- get { return shapeColorItems; }
- set
- {
- SetProperty(ref shapeColorItems, value);
- }
- }
- private void InitShapeColorList()
- {
- ShapeColorItems = new List<ColorItem>();
- ColorItem colorItem = new ColorItem(Color.FromArgb(0xff, 0xfc, 0x1f, 0x1f), 0);
- ShapeColorItems.Add(colorItem);
- colorItem = new ColorItem(Color.FromArgb(0xff, 0x26, 0x25, 0x29), 1);
- ShapeColorItems.Add(colorItem);
- colorItem = new ColorItem(Color.FromArgb(0xff, 0x29, 0x53, 0x93), 2);
- ShapeColorItems.Add(colorItem);
- colorItem = new ColorItem(Color.FromArgb(0xff, 0x1e, 0x89, 0x56), 3);
- ShapeColorItems.Add(colorItem);
- }
- private DefaultAnnotProperty GetAnnotDefault(AnnotArgsType annotArgsType, string savaKey = "")
- {
- var Annot = SettingHelper.GetAnnotDefaultProperty(annotArgsType, savaKey);
- if (Annot == null)
- {
- Annot = new DefaultAnnotProperty();
- Annot.AnnotToolType = annotArgsType;
- }
- return Annot;
- }
- public DelegateCommand<object> SelectedThickCommand { get; set; }
- public DelegateCommand<object> SelectedColorCommand { get; set; }
- //public DelegateCommand<object> LineStyleCommand { get; set; }
- public DelegateCommand<object> SelectedLineWidthValueCommand { get; set; }
- public DelegateCommand<object> SharpsTypeCommand { get; set; }
- public DelegateCommand<object> ThicknessChangedCommand { get; set; }
- public DelegateCommand<object> SelectedOpacityValueCommand { get; set; }
- public ShapFillPropertyViewModel()
- {
- InitShapeColorList();
- SelectedThickCommand = new DelegateCommand<object>(SelectedThick_Command);
- SelectedColorCommand = new DelegateCommand<object>(SelectedColor_Command);
- SelectedLineWidthValueCommand = new DelegateCommand<object>(SelectedLineWitdh_Command);
- //LineStyleCommand = new DelegateCommand<object>(LineStyle_Command);
- SharpsTypeCommand = new DelegateCommand<object>(SharpsType_Command);
- ThicknessChangedCommand = new DelegateCommand<object>(ThicknessChanged_Command);
- SelectedOpacityValueCommand = new DelegateCommand<object>(SelectedOpacityValue);
- }
- private void InitFillAndSignProperty()
- {
- if (fillAndSignContentViewModel.isFirst)
- {
-
- ShapeColorColor = fillAndSignContentViewModel.SelectColor;
- fillAndSignContentViewModel.SelectColor = ShapeColorColor;
- FillOpacity = fillAndSignContentViewModel.FillOpacity;
- //LineWidth = fillAndSignContentViewModel.LineWidth;
- }
- fillAndSignContentViewModel.isFirst = false;
- }
- private DefaultAnnotProperty GetAnnotDefault(AnnotArgsType annotArgsType)
- {
- var Annot = SettingHelper.GetAnnotDefaultProperty(annotArgsType, "FillAndSign");
- if (Annot == null)
- {
- Annot = new DefaultAnnotProperty();
- Annot.AnnotToolType = annotArgsType;
- }
- return Annot;
- }
- private void SharpsType_Command(object obj)
- {
- if (obj != null)
- {
- var tag = (string)obj;
- SharpsType(tag, obj);
- }
- }
- private void SharpsType(string tag, object obj, bool isFromToolsBtn = false)
- {
- fillAndSignContentViewModel.LineWidthMultiple = 1;
- Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
- lineWidthMultiple = 1;
- //PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Width, 60);
- //PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Height, 60);
- switch (tag)
- {
- case "HookShape":
- var hookShape = new PathGeometry();
- hookShape.AddGeometry(Geometry.Parse("M0.599976 7.0286L5.57775 11.8L13.4 1.40002"));
- DataPath = hookShape;
- //if (FillAndSignContentViewModel.IsEdit)
- {
- PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, LineWidth * fillAndSignContentViewModel.LineWidthMultiple);
- updatapath = fillAndSignContentViewModel.keyShape[tag];
- PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Path, updatapath);
- if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count >= 1)
- {
- foreach (var annot in PropertyPanel.annotlists)
- {
- foreach (var point in fillAndSignContentViewModel.viewContentViewModel.FillAndSign)
- {
- if (annot.PageIndex == point.PageIndex && annot.AnnotIndex == point.AnnotIndex)
- {
- point.Shape = "HookShape";
- }
- }
- }
- }
- }
- //PropertyPanel.UpdateAnnotAAttrib();
- //fillAndSignContentViewModel.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) } };
- //fillAndSignContentViewModel.SetStamp();
- //changeData[AnnotArgsType.AnnotLine] = tag;
- break;
- case "ForkShape":
- var forkShape = new PathGeometry();
- forkShape.AddGeometry(Geometry.Parse("M3.19995 3.20001L12.8 12.8 M12.8 3.20001L3.20005 12.8"));
- DataPath = forkShape;
- // if (FillAndSignContentViewModel.IsEdit)
- {
- PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, LineWidth * fillAndSignContentViewModel.LineWidthMultiple);
- updatapath = fillAndSignContentViewModel.keyShape[tag];
- PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Path, updatapath);
- if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count >= 1)
- {
- foreach (var annot in PropertyPanel.annotlists)
- {
- foreach (var point in fillAndSignContentViewModel.viewContentViewModel.FillAndSign)
- {
- if (annot.PageIndex == point.PageIndex && annot.AnnotIndex == point.AnnotIndex)
- {
- point.Shape = "ForkShape";
- }
- }
- }
- }
- }
- //fillAndSignContentViewModel.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) } };
- //fillAndSignContentViewModel.SetStamp();
- //changeData[AnnotArgsType.AnnotLine] = tag;
- break;
- case "RectShape":
- {
- RectangleGeometry rectPath = new RectangleGeometry();
- rectPath.Rect = new Rect(0, 5, 28, 22);
- DataPath = rectPath;
- //if (FillAndSignContentViewModel.IsEdit)
- {
- PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, LineWidth * fillAndSignContentViewModel.LineWidthMultiple);
- updatapath = fillAndSignContentViewModel.keyShape[tag];
- PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Path, updatapath);
- if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count >= 1)
- {
- foreach (var annot in PropertyPanel.annotlists)
- {
- foreach (var point in fillAndSignContentViewModel.viewContentViewModel.FillAndSign)
- {
- if (annot.PageIndex == point.PageIndex && annot.AnnotIndex == point.AnnotIndex)
- {
- point.Shape = "RectShape";
- }
- }
- }
- }
- }
- //fillAndSignContentViewModel.ShapePoints = new List<List<Point>> { new List<Point> { new Point(0.19995, 5), new Point(28, 5), new Point(28, 27), new Point(0.19995, 27), new Point(0.19995, 5) } };
- //fillAndSignContentViewModel.SetStamp();
- // changeData[AnnotArgsType.AnnotSquare] = tag;
- }
- break;
- case "LineShape":
- {
- var lineShape = new PathGeometry();
- lineShape.AddGeometry(Geometry.Parse(" M0,10L20,10"));
- DataPath = lineShape;
- // if (FillAndSignContentViewModel.IsEdit)
- {
- PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, LineWidth * fillAndSignContentViewModel.LineWidthMultiple);
- updatapath = fillAndSignContentViewModel.keyShape[tag];
- PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Path, updatapath);
- if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count >= 1)
- {
- foreach (var annot in PropertyPanel.annotlists)
- {
- foreach (var point in fillAndSignContentViewModel.viewContentViewModel.FillAndSign)
- {
- if (annot.PageIndex == point.PageIndex && annot.AnnotIndex == point.AnnotIndex)
- {
- point.Shape = "LineShape";
- }
- }
- }
- }
- }
- //fillAndSignContentViewModel.ShapePoints = new List<List<Point>> { new List<Point> { new Point(12.19995, 10), new Point(36, 10) } };
- //fillAndSignContentViewModel.SetStamp();
- //changeData[AnnotArgsType.AnnotLine] = tag;
- }
- break;
- case "DotShape":
- {
- //fillAndSignContentViewModel.LineWidthMultiple = 5;
- EllipseGeometry circlePath = new EllipseGeometry();
- circlePath.RadiusX = 2.4;
- circlePath.RadiusY = 2.4;
- circlePath.Center = new Point(2.4, 2.4);
- DataPath = circlePath;
- // if (FillAndSignContentViewModel.IsEdit)
- {
- lineWidthMultiple = 5;
- updatapath = fillAndSignContentViewModel.keyShape[tag];
- PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, 10);
- PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Path, updatapath);
- if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count >= 1)
- {
- foreach (var annot in PropertyPanel.annotlists)
- {
- foreach (var point in fillAndSignContentViewModel.viewContentViewModel.FillAndSign)
- {
- if (annot.PageIndex == point.PageIndex && annot.AnnotIndex == point.AnnotIndex)
- {
- point.Shape = "DotShape";
- }
- }
- }
- }
- }
- //fillAndSignContentViewModel.ShapePoints = new List<List<Point>> { new List<Point> { new Point(0.19995, 1.19995), new Point(0.19995, -1.19995) }, new List<Point> { new Point(-0.25995, 0.89995), new Point(0.25995, -0.89995) }, new List<Point> { new Point(-1.19995, 0.19995), new Point(0.19995, 1.19995) } };
- //fillAndSignContentViewModel.SetStamp();
- //changeData[AnnotArgsType.AnnotCircle] = tag;
- }
- break;
- }
- //if (isFromToolsBtn == false)
- // PropertyPanel.AnnotTypeChangedInvoke(this, changeData);
- }
- private string UPDateShapeType(string tag)
- {
- switch (tag)
- {
- case "DotShape":
- return "Dot";
- case "LineShape":
- return "Line";
- case "RectShape":
- return "Rectangle";
- case "ForkShape":
- return "Fork";
- case "HookShape":
- return "Hook";
- default:
- return "General Properties";
- }
- }
- private void InitShapesType(string tag)
- {
- ShapeType = UPDateShapeType(tag);
- Trace.WriteLine("ShapeType" + ShapeType);
- fillAndSignContentViewModel.LineWidthMultiple = 1;
- switch (tag)
- {
- case "HookShape":
- var hookShape = new PathGeometry();
- hookShape.AddGeometry(Geometry.Parse("M0.599976 7.0286L5.57775 11.8L13.4 1.40002"));
- DataPath = hookShape;
- break;
- case "ForkShape":
- var forkShape = new PathGeometry();
- forkShape.AddGeometry(Geometry.Parse("M3.19995 3.20001L12.8 12.8 M12.8 3.20001L3.20005 12.8"));
- DataPath = forkShape;
- break;
- case "RectShape":
- {
- RectangleGeometry rectPath = new RectangleGeometry();
- rectPath.Rect = new Rect(0, 5, 28, 22);
- DataPath = rectPath;
- }
- break;
- case "LineShape":
- {
- var lineShape = new PathGeometry();
- lineShape.AddGeometry(Geometry.Parse(" M0,10L20,10"));
-
- DataPath = lineShape;
- }
- break;
- case "DotShape":
- {
- //fillAndSignContentViewModel.LineWidthMultiple = 5;
- //EllipseGeometry circlePath = new EllipseGeometry();
- //circlePath.RadiusX = 2.4;
- //circlePath.RadiusY = 2.4;
- //circlePath.Center = new Point(2.4, 2.4);
- var circlePath = new PathGeometry();
- circlePath.AddGeometry(Geometry.Parse(" M2.4,2.4m-2.4,0a2.4,2.4,0,1,0,4.8,0a2.4,2.4,0,1,0,-4.8,0M2.4,2.4L2.4,4.8M2.4,2.4L4.8,2.4M2.4,2.4L2.4,0M2.4,2.4L0,2.4M2.4,2.4m-1.2,0a1.2,1.2,0,1,0,2.4,0a1.2,1.2,0,1,0,-2.4,0M2.4,2.4m-1.6,0a1.6,1.6,0,1,0,3.2,0a1.6,1.6,0,1,0,-3.2,0"));
- DataPath = circlePath;
- }
- break;
- }
- //if (isFromToolsBtn == false)
- // PropertyPanel.AnnotTypeChangedInvoke(this, changeData);
- }
- private void SelectedThick_Command(object obj)
- {
- if (obj is double)
- {
- var tran = (double)obj;
- //BorderOpacity = tran;
- SelectColor.Opacity = tran;
- //AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, tran);
- //AnnotEvent?.UpdateAnnot();
- }
- }
- private void ThicknessChanged_Command(object obj)
- {
- if (obj != null)
- {
- var item = (ComboBoxItem)obj;
- var content = (string)item.Content;
- if (content != null)
- {
- var intData = int.Parse(content);
- LineWidth = intData;
- UPDataLineWidth();
- }
- }
- }
- private void UPDataLineWidth()
- {
- if (!fillAndSignContentViewModel.isFirst)
- {
-
- //if (FillAndSignContentViewModel.IsEdit)
- {
- if (!fillAndSignContentViewModel.IsClickNull)
- PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, LineWidth * lineWidthMultiple);
- }
- // else
- {
- if (IsFillAndSign&&IsUpDataCreate && IsCreate) { fillAndSignContentViewModel.LineWidth = LineWidth; fillAndSignContentViewModel.SetStamp(); }
- }
- }
- }
- private void UPDataColor()
- {
- if (!fillAndSignContentViewModel.isFirst)
- {
- var newColor = (ShapeColorColor as SolidColorBrush).Color;
- var oldColor = (SelectColor as SolidColorBrush).Color;
- if (newColor.A != oldColor.A || newColor.B != oldColor.B || newColor.R != oldColor.R || newColor.G != oldColor.G)
- {
- ShapeColorColor = SelectColor;
-
- //if (FillAndSignContentViewModel.IsEdit)
- {
- // PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, LineWidth * lineWidthMultiple);
- if (!fillAndSignContentViewModel.IsClickNull)
- PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Color, (selectColor as SolidColorBrush).Color);
- }
- //else
- {
- if (IsFillAndSign&&IsUpDataCreate&&IsCreate) {
- fillAndSignContentViewModel.SelectColor = SelectColor;
- fillAndSignContentViewModel.SetStamp();
- }
- }
- }
- }
- }
- private void UPDataOpacity()
- {
- if (!fillAndSignContentViewModel.isFirst)
- {
-
- //if (FillAndSignContentViewModel.IsEdit)
- {
- if (!fillAndSignContentViewModel.IsClickNull)
- PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, fillOpacity);
- }
- //else
- {
- if (IsFillAndSign&&IsUpDataCreate&&IsCreate) { fillAndSignContentViewModel.FillOpacity = FillOpacity; fillAndSignContentViewModel.SetStamp(); }
- }
- }
- }
- private void SelectedColor_Command(object obj)
- {
- if (obj != null)
- {
- var colorValue = (Color)obj;
- if (colorValue != null)
- {
- SelectColor = new SolidColorBrush(colorValue);
- UPDataColor();
- SelectColor.Opacity = FillOpacity;
- Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
- changeData[AnnotArgsType.AnnotFreehand] = obj;
- //PropertyPanel.DataChangedInvoke(this, changeData);
- }
- }
- }
- private void SelectedLineWitdh_Command(object obj)
- {
- if (obj != null)
- {
- double colorValue = (double)obj;
- UPDataLineWidth();
- }
- }
- private void SelectedOpacityValue(object obj)
- {
- if (obj != null)
- {
- FillOpacity = (double)obj;
- SelectColor.Opacity = FillOpacity;
- UPDataOpacity();
- //AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, FillOpacity);
- //AnnotEvent?.UpdateAnnot();
- Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
- changeData[AnnotArgsType.AnnotFreehand] = FillOpacity;
- //PropertyPanel.DataChangedInvoke(this, changeData);
- }
- }
- private void BindingPDFViewerHandler()
- {
- //来自PDFViewer的响应事件
- if (fillAndSignContentViewModel.PDFViewer != null)
- {
- fillAndSignContentViewModel.PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
- fillAndSignContentViewModel.PDFViewer.AnnotActiveHandler += PDFViewer_AnnotActiveHandler;
- }
- }
- private void UnBindingPDFViewerHandler()
- {
- if (fillAndSignContentViewModel.PDFViewer != null)
- {
- fillAndSignContentViewModel.PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
- }
- }
- private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
- {
- if (e != null) { }
- else
- {
- if (fillAndSignContentViewModel.PDFViewer.MouseMode == MouseModes.AnnotCreate) { IsSelected = true; }
- }
- }
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
- UnBindingPDFViewerHandler();
- }
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
- string shape = "";
- navigationContext.Parameters.TryGetValue<AnnotTransfer>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
- navigationContext.Parameters.TryGetValue<FillAndSignContentViewModel>("FillAndSignContentViewModel", out fillAndSignContentViewModel);
- navigationContext.Parameters.TryGetValue<string>("Shape", out shape);
- bool isFillAndSign = false;
- navigationContext.Parameters.TryGetValue<bool>("IsFillAndSign", out isFillAndSign);
- IsFillAndSign = isFillAndSign;
- InitShapesType(shape);
- InitIsCheck();
- //FillAndSignContentViewModel.IsEdit = false;
- if (PropertyPanel != null)
- {
- AnnotEvent = PropertyPanel.AnnotEvent;
- Annot = PropertyPanel.annot;
- var stampAnnotArgs = Annot as StampAnnotArgs;
- if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count > 1)
- {
- IsMultiSelected = true;
- }
- else
- {
- IsMultiSelected = false;
- }
- IsSelected = !FillAndSignContentViewModel.IsEdit;
- InitFillAndSignProperty();
- if (IsMultiSelected)
- {
- IsAttributeEquals();
- }
- else
- {
- GetAnnotProperty(shape);
- }
- BindingPDFViewerHandler();
- }
- }
- private void InitIsCheck()
- {
- LineIsChecked = false;
- DotIsChecked = false;
- RectIsChecked = false;
- HookIsChecked = false;
- ForkIsChecked = false;
- }
- private List<FreehandAnnotArgs> ConvertLists()
- {
- List<FreehandAnnotArgs> Lists = new List<FreehandAnnotArgs>();
- foreach (var item in PropertyPanel.annotlists)
- {
- var selecteditem = item as FreehandAnnotArgs;
- if (selecteditem != null)
- {
- Lists.Add(selecteditem);
- }
- }
- if (Lists.Count != PropertyPanel.annotlists.Count)
- return null;
- else
- return Lists;
- }
- private void IsAttributeEquals()
- {
- var list = ConvertLists();
- if (list != null)
- {
- var temp = list[0];
- Dictionary<string, bool> isNoEqualsDir = new Dictionary<string, bool>();
- isNoEqualsDir.Add("Color", false);
- isNoEqualsDir.Add("Shape", false);
- string tempShape = "";
- foreach (var point in fillAndSignContentViewModel.viewContentViewModel.FillAndSign)
- {
- if (temp.PageIndex == point.PageIndex && temp.AnnotIndex == point.AnnotIndex)
- {
- tempShape = point.Shape;
- }
- }
- foreach (var item in list)
- {
- if (item == list[0])
- continue;
- //区分图形是否一致,不一致则属性不选中任何图形
- if (isNoEqualsDir["Shape"] == false)
- {
- foreach (var point in fillAndSignContentViewModel.viewContentViewModel.FillAndSign)
- {
- if (item.PageIndex == point.PageIndex && item.AnnotIndex == point.AnnotIndex)
- {
- lineWidthMultiple = 1;
- if (point.Shape != tempShape)
- {
- isNoEqualsDir["Shape"] = true;
- }
- }
- }
- }
- if (isNoEqualsDir["Color"] == false)
- {
- if (temp.InkColor.A != item.InkColor.A || temp.InkColor.R != item.InkColor.R || temp.InkColor.G != item.InkColor.G || temp.InkColor.B != item.InkColor.B)
- {
- ShapeColorColor = new SolidColorBrush(Color.FromArgb(0x01, 0xff, 0xff, 0xff));
- isNoEqualsDir["Color"] = true;
- }
- }
- }
- if (isNoEqualsDir["Shape"] == false)
- {
- if (tempShape == "DotShape")
- {
- ShapeType = "DotShape";
- DotIsChecked = true;
- }
- if (tempShape == "LineShape")
- {
- ShapeType = "LineShape";
- LineIsChecked = true;
- }
- if (tempShape == "HookShape")
- {
- ShapeType = "HookShape";
- HookIsChecked = true;
- }
- if (tempShape == "RectShape")
- {
- ShapeType = "RectShape";
- RectIsChecked = true;
- }
- if (tempShape == "ForkShape")
- {
- ShapeType = "ForkShape";
- ForkIsChecked = true;
- }
- }
- if (isNoEqualsDir["Color"] == false)
- {
- ShapeColorColor = new SolidColorBrush(temp.InkColor);
- }
- }
- }
- private void GetAnnotProperty(string shape)
- {
- if (Annot is FreehandAnnotArgs)
- {
- var annot = Annot as FreehandAnnotArgs;
- if (annot != null)
- {
- try
- {
- foreach (var point in fillAndSignContentViewModel.viewContentViewModel.FillAndSign)
- {
- if (annot.PageIndex == point.PageIndex && annot.AnnotIndex == point.AnnotIndex)
- {
- lineWidthMultiple = 1;
- if (point.Shape == "DotShape")
- {
- DotIsChecked = true;
- lineWidthMultiple = 5;
- LineWidth = annot.LineWidth / 5;
- }
- else { LineWidth = annot.LineWidth; }
- if (point.Shape == "LineShape")
- {
- LineIsChecked = true;
- }
- if (point.Shape == "HookShape")
- {
- HookIsChecked = true;
- }
- if (point.Shape == "RectShape")
- {
- RectIsChecked = true;
- }
- if (point.Shape == "ForkShape")
- {
- ForkIsChecked = true;
- }
- IsUpDataCreate = false;
- SelectColor = new SolidColorBrush(annot.InkColor);
- IsUpDataCreate=true;
- FillOpacity = annot.Transparency;
- InitShapesType(point.Shape);
- Shape = point.Shape;
- }
- }
- }
- catch
- {
-
- }
- }
- }
-
- }
-
-
-
- }
- }
|