|
@@ -1,8 +1,12 @@
|
|
|
-using ComPDFKitViewer.AnnotEvent;
|
|
|
+using ComPDFKit.PDFAnnotation;
|
|
|
+using ComPDFKitViewer.AnnotEvent;
|
|
|
using ComPDFKitViewer.PdfViewer;
|
|
|
+using PDF_Office.Helper;
|
|
|
using PDF_Office.Model;
|
|
|
+using Prism.Commands;
|
|
|
using Prism.Mvvm;
|
|
|
using Prism.Regions;
|
|
|
+using Prism.Services.Dialogs;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
@@ -14,17 +18,27 @@ namespace PDF_Office.ViewModels.Form
|
|
|
{
|
|
|
public class SignPropertyViewModel : FormBaseVM, INavigationAware
|
|
|
{
|
|
|
- #region 属性
|
|
|
-
|
|
|
- #endregion
|
|
|
|
|
|
#region Command
|
|
|
+ public DelegateCommand<string> FieldNameTextChangedCommand { get; set; }
|
|
|
+ public DelegateCommand<string> ToolTipTextChangedCommand { get; set; }
|
|
|
+
|
|
|
+ //外观
|
|
|
+
|
|
|
+ public DelegateCommand<object> ResetColorCommand { get; set; }
|
|
|
+ public DelegateCommand<object> ResetColorCheckedBtnCommand { get; set; }
|
|
|
+
|
|
|
+ public DelegateCommand<string> ExportedValuesTextChangedCommand { get; set; }
|
|
|
|
|
|
+ public DelegateCommand<object> LineStyleCommand { get; set; }
|
|
|
#endregion
|
|
|
|
|
|
#region 变量
|
|
|
+
|
|
|
private CPDFViewer PDFViewer;
|
|
|
private WidgetSignArgs signArgs;
|
|
|
+ private IDialogService dialogs;
|
|
|
+ public event EventHandler<int> SelectResetColorBtnHandler;
|
|
|
#endregion
|
|
|
|
|
|
#region 初始化
|
|
@@ -36,28 +50,182 @@ namespace PDF_Office.ViewModels.Form
|
|
|
|
|
|
private void InitVariable()
|
|
|
{
|
|
|
+ InitAllResetColor();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void InitAllResetColor()
|
|
|
+ {
|
|
|
+ ResetColorOne = InitResetColor(Colors.Transparent, Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
|
|
|
+
|
|
|
+ ResetColorTwo = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
|
|
|
|
|
|
+ ResetColorThree = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
|
|
|
+
|
|
|
+ ResetColorForth = InitResetColor(Color.FromArgb(0xFF, 0xff, 0x00, 0x00), Color.FromArgb(0xFF, 0xff, 0x00, 0x00), Colors.Transparent);
|
|
|
}
|
|
|
|
|
|
private void InitCommand()
|
|
|
{
|
|
|
- //ChangeValueHandler -= ChangeValue;
|
|
|
- //ChangeValueHandler += ChangeValue;
|
|
|
+ //一般
|
|
|
+ FieldNameTextChangedCommand = new DelegateCommand<string>(FieldNameTextChanged);
|
|
|
+ ToolTipTextChangedCommand = new DelegateCommand<string>(ToolTipTextChanged);
|
|
|
+ //外观
|
|
|
+ ResetColorCheckedBtnCommand = new DelegateCommand<object>(ResetColorCheckedBtn);
|
|
|
+ ResetColorCommand = new DelegateCommand<object>(ResetColorEvent);
|
|
|
+ LineStyleCommand = new DelegateCommand<object>(LineStyleBtnEvent);
|
|
|
+
|
|
|
+ //选项
|
|
|
+ ExportedValuesTextChangedCommand = new DelegateCommand<string>(ExportedValuesTextChanged);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
+ #region 事件
|
|
|
|
|
|
- #region 一般处理
|
|
|
|
|
|
- #endregion
|
|
|
+ private void FieldNameTextChanged(string obj)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(obj) == false && IsCurrentWidget == true)
|
|
|
+ {
|
|
|
+ FieldName = obj;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ToolTipTextChanged(string obj)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(obj) == false && IsCurrentWidget == true)
|
|
|
+ {
|
|
|
+ ToolTipStr = obj;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void LineStyleBtnEvent(object obj)
|
|
|
+ {
|
|
|
+ if (obj != null)
|
|
|
+ {
|
|
|
+ switch ((string)obj)
|
|
|
+ {
|
|
|
+ case "Solid":
|
|
|
+ BorderStyle = ComPDFKit.PDFAnnotation.C_BORDER_STYLE.BS_SOLID;
|
|
|
+ break;
|
|
|
+ case "Dotted":
|
|
|
+ BorderStyle = ComPDFKit.PDFAnnotation.C_BORDER_STYLE.BS_DASHDED;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void ExportedValuesTextChanged(string obj)
|
|
|
+ {
|
|
|
+ if (obj != null && IsCurrentWidget == true)
|
|
|
+ {
|
|
|
+ ExportedValues = obj;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void ResetColorCheckedBtn(object obj)
|
|
|
+ {
|
|
|
+ if (obj != null)
|
|
|
+ {
|
|
|
+ var str = obj as string;
|
|
|
+ if (str != null)
|
|
|
+ {
|
|
|
+ switch (str)
|
|
|
+ {
|
|
|
+ case "One":
|
|
|
+ BorderColor = ResetColorOne.BorderColor.Color;
|
|
|
+ ContentColor = ResetColorOne.FontColor.Color;
|
|
|
+ FillColor = ResetColorOne.FillColor.Color;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "Two":
|
|
|
+ BorderColor = ResetColorTwo.BorderColor.Color;
|
|
|
+ ContentColor = ResetColorTwo.FontColor.Color;
|
|
|
+ FillColor = ResetColorTwo.FillColor.Color;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "Three":
|
|
|
+ BorderColor = ResetColorThree.BorderColor.Color;
|
|
|
+ ContentColor = ResetColorThree.FontColor.Color;
|
|
|
+ FillColor = ResetColorThree.FillColor.Color;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "Forth":
|
|
|
+ BorderColor = ResetColorForth.BorderColor.Color;
|
|
|
+ ContentColor = ResetColorForth.FontColor.Color;
|
|
|
+ FillColor = ResetColorForth.FillColor.Color;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ResetColorEvent(object obj)
|
|
|
+ {
|
|
|
+ bool result = true;
|
|
|
+ DialogParameters value = new DialogParameters();
|
|
|
+ value.Add(ParameterNames.PDFViewer, PDFViewer);
|
|
|
+ dialogs.ShowDialog(DialogNames.EditPresetColorsDialog, value, e =>
|
|
|
+ {
|
|
|
+ if (e.Result != ButtonResult.OK)
|
|
|
+ {
|
|
|
+ result = false;
|
|
|
+ }
|
|
|
+ EditPresetColorsDialogViewModel DialogVM = e.Parameters.GetValue<EditPresetColorsDialogViewModel>(ParameterNames.DataModel);
|
|
|
+ if (DialogVM != null)
|
|
|
+ {
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (!result)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- #region 外观处理
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
- #region 选项处理
|
|
|
+ #region 外部XAML触发事件
|
|
|
+
|
|
|
+ private void UpdataSelectResetColorBtn()
|
|
|
+ {
|
|
|
+ int result = 0;
|
|
|
+ if (UpdataSelectResetColor(ResetColorOne))
|
|
|
+ {
|
|
|
+ result = 1;
|
|
|
+ }
|
|
|
+ else if (UpdataSelectResetColor(ResetColorTwo))
|
|
|
+ {
|
|
|
+ result = 2;
|
|
|
+ }
|
|
|
+ else if (UpdataSelectResetColor(ResetColorThree))
|
|
|
+ {
|
|
|
+ result = 3;
|
|
|
+ }
|
|
|
+ else if (UpdataSelectResetColor(ResetColorForth))
|
|
|
+ {
|
|
|
+ result = 4;
|
|
|
+ }
|
|
|
+
|
|
|
+ SelectResetColorBtnHandler?.Invoke(null, result);
|
|
|
+ }
|
|
|
|
|
|
+ private bool UpdataSelectResetColor(ResetColor reset)
|
|
|
+ {
|
|
|
+ if (reset.FillColor.Color == FillColor &&
|
|
|
+ reset.FontColor.Color == ContentColor &&
|
|
|
+ reset.BorderColor.Color == BorderColor
|
|
|
+ )
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
#region Navegation
|
|
@@ -69,76 +237,71 @@ namespace PDF_Office.ViewModels.Form
|
|
|
public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
|
{
|
|
|
signArgs = null;
|
|
|
+ isCreateWidget = false;
|
|
|
+ IsCurrentWidget = false;
|
|
|
}
|
|
|
|
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
|
{
|
|
|
navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
|
|
|
navigationContext.Parameters.TryGetValue<WidgetSignArgs>("WidgetArgs", out signArgs);
|
|
|
+ navigationContext.Parameters.TryGetValue<UpdateAttributeHelper>(ParameterNames.AnnotEvent, out AttribEvent);
|
|
|
|
|
|
GetWidgeText();
|
|
|
+ UpdataSelectResetColorBtn();
|
|
|
}
|
|
|
|
|
|
private void GetWidgeText()
|
|
|
{
|
|
|
- PDFViewer.SetMouseMode(MouseModes.FormEditTool);
|
|
|
+
|
|
|
|
|
|
if (signArgs == null)
|
|
|
{
|
|
|
+ PDFViewer.SetMouseMode(MouseModes.FormEditTool);
|
|
|
signArgs = new WidgetSignArgs();
|
|
|
signArgs.LineWidth = 1;
|
|
|
signArgs.LineColor = Colors.Black;
|
|
|
PDFViewer.SetToolParam(signArgs);
|
|
|
+ isCreateWidget = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
PDFViewer.SetToolParam(new AnnotHandlerEventArgs());
|
|
|
+ isCreateWidget = false;
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- //更改基类公共属性后,触发的事件
|
|
|
- //private void ChangeValue(object sender, FormAttributeType e)
|
|
|
- //{
|
|
|
- // switch (e)
|
|
|
- // {
|
|
|
- // case FormAttributeType.Name:
|
|
|
- // break;
|
|
|
-
|
|
|
- // case FormAttributeType.ToolTip:
|
|
|
-
|
|
|
- // break;
|
|
|
-
|
|
|
- // case FormAttributeType.IsSolid:
|
|
|
- // break;
|
|
|
-
|
|
|
- // case FormAttributeType.IsLocked:
|
|
|
- // break;
|
|
|
+ GetProperty();
|
|
|
|
|
|
- // case FormAttributeType.HeightSize:
|
|
|
- // break;
|
|
|
+ IsCurrentWidget = true;
|
|
|
|
|
|
- // case FormAttributeType.BorderThiness:
|
|
|
- // break;
|
|
|
-
|
|
|
- // case FormAttributeType.BorderColor:
|
|
|
- // break;
|
|
|
-
|
|
|
- // case FormAttributeType.ContentColor:
|
|
|
- // break;
|
|
|
-
|
|
|
- // case FormAttributeType.IsReadOnly:
|
|
|
- // break;
|
|
|
-
|
|
|
- // case FormAttributeType.WidthSize:
|
|
|
- // break;
|
|
|
+ }
|
|
|
|
|
|
- // case FormAttributeType.IsRequiredField:
|
|
|
- // break;
|
|
|
|
|
|
- // }
|
|
|
+ private void GetProperty()
|
|
|
+ {
|
|
|
+ if (signArgs != null)
|
|
|
+ {
|
|
|
+ IsLocked = signArgs.Locked;
|
|
|
+ FieldName = signArgs.FieldName;
|
|
|
+ ToolTipStr = signArgs.Tooltip;
|
|
|
+ IsReadOnly = signArgs.ReadOnly;
|
|
|
+ IsRequiredField = signArgs.IsRequired;
|
|
|
+
|
|
|
+ FillColor = signArgs.BgColor;
|
|
|
+ ContentColor = signArgs.FontColor;
|
|
|
+ BorderColor = signArgs.LineColor;
|
|
|
+ BorderThiness = signArgs.LineWidth;
|
|
|
+ BorderStyle = signArgs.BorderStyle;
|
|
|
+ //ExportedValues = signArgs.ExportValue;
|
|
|
+ //避免BorderStyle跟上一个值相同,而没触发更改IsSolid属性
|
|
|
+ if (BorderStyle == C_BORDER_STYLE.BS_SOLID)
|
|
|
+ IsSolid = true;
|
|
|
+ else
|
|
|
+ IsSolid = false;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //}
|
|
|
#endregion
|
|
|
}
|
|
|
}
|