123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- 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_Office.Helper;
- namespace PDF_Office.ViewModels.FillAndSign.PropertyPanel
- {
- public class ShapFillPropertyViewModel : BindableBase, INavigationAware
- {
- private Geometry dataPath = null;
- public Geometry DataPath
- {
- get { return dataPath; }
- set
- {
- SetProperty(ref dataPath, value);
- }
- }
- private Brush selectColor = new SolidColorBrush(Colors.GreenYellow);
- public Brush SelectColor
- {
- get { return selectColor; }
- set
- {
- SetProperty(ref selectColor, value);
- //AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, (selectColor as SolidColorBrush).Color);
- //AnnotEvent?.UpdateAnnot();
- }
- }
- private double fillOpacity = 1;
- public double FillOpacity
- {
- get { return fillOpacity; }
- set
- {
- SetProperty(ref fillOpacity, value);
- }
- }
- private double lineWidth = 1;
- public double LineWidth
- {
- get { return lineWidth; }
- set
- {
- SetProperty(ref lineWidth, value);
- //if (annotType == AnnotArgsType.AnnotLine)
- // AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, lineWidth);
- //else
- // AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, lineWidth);
- //AnnotEvent?.UpdateAnnot();
- }
- }
- public DelegateCommand<object> SelectedThickCommand { get; set; }
- public DelegateCommand<object> SelectedColorCommand { get; set; }
- //public DelegateCommand<object> LineStyleCommand { get; set; }
- public DelegateCommand<object> SharpsTypeCommand { get; set; }
- public DelegateCommand<object> ThicknessChangedCommand { get; set; }
- public DelegateCommand<object> SelectedOpacityValueCommand { get; set; }
- public ShapFillPropertyViewModel()
- {
- SelectedThickCommand = new DelegateCommand<object>(SelectedThick_Command);
- SelectedColorCommand = new DelegateCommand<object>(SelectedColor_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 SharpsType_Command(object obj)
- {
- if (obj != null)
- {
- var tag = (string)obj;
- SharpsType(tag,obj);
- }
- }
- private void SharpsType(string tag, object obj, bool isFromToolsBtn = false)
- {
- Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
- switch (tag)
- {
- case "HookShape":
- var hookShape = new PathGeometry();
- hookShape.AddGeometry(Geometry.Parse("M0.599976 7.0286L5.57775 11.8L13.4 1.40002"));
- DataPath = hookShape;
- 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;
- changeData[AnnotArgsType.AnnotLine] = tag;
- break;
- case "RectShape":
- {
- RectangleGeometry rectPath = new RectangleGeometry();
- rectPath.Rect = new Rect(0, 5, 28, 22);
- DataPath = rectPath;
- changeData[AnnotArgsType.AnnotSquare] = tag;
- }
- break;
- case "LineShape":
- {
- var lineShape = new PathGeometry();
- lineShape.AddGeometry(Geometry.Parse(" M0,10L20,10"));
- DataPath = lineShape;
- changeData[AnnotArgsType.AnnotLine] = tag;
- }
- break;
- case "DotShape":
- {
- EllipseGeometry circlePath = new EllipseGeometry();
- circlePath.RadiusX = 2.4;
- circlePath.RadiusY = 2.4;
- circlePath.Center = new Point(2.4,2.4);
- DataPath = circlePath;
- changeData[AnnotArgsType.AnnotCircle] = tag;
- }
- 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;
- }
- }
- }
- private void SelectedColor_Command(object obj)
- {
- if (obj != null)
- {
- var colorValue = (Color)obj;
- if (colorValue != null)
- {
- SelectColor = new SolidColorBrush(colorValue);
- SelectColor.Opacity = FillOpacity;
- Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
- changeData[AnnotArgsType.AnnotFreehand] = obj;
- //PropertyPanel.DataChangedInvoke(this, changeData);
- }
- }
- }
- private void SelectedOpacityValue(object obj)
- {
- if (obj != null)
- {
- FillOpacity = (double)obj;
- SelectColor.Opacity = FillOpacity;
- //AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, FillOpacity);
- //AnnotEvent?.UpdateAnnot();
- Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
- changeData[AnnotArgsType.AnnotFreehand] = FillOpacity;
- //PropertyPanel.DataChangedInvoke(this, changeData);
- }
- }
-
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
- }
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
- RectangleGeometry rectPath = new RectangleGeometry();
- rectPath.Rect = new Rect(0, 5, 28, 22);
- DataPath = rectPath;
- }
- }
- }
|