|
@@ -1,49 +1,48 @@
|
|
-using ComPDFKitViewer.AnnotEvent;
|
|
|
|
|
|
+using ComPDFKit.PDFAnnotation;
|
|
|
|
+using ComPDFKitViewer.AnnotEvent;
|
|
using ComPDFKitViewer.PdfViewer;
|
|
using ComPDFKitViewer.PdfViewer;
|
|
|
|
+using PDF_Office.CustomControl.CompositeControl;
|
|
|
|
+using PDF_Office.Helper;
|
|
using PDF_Office.Model;
|
|
using PDF_Office.Model;
|
|
|
|
+using Prism.Commands;
|
|
using Prism.Mvvm;
|
|
using Prism.Mvvm;
|
|
using Prism.Regions;
|
|
using Prism.Regions;
|
|
|
|
+using Prism.Services.Dialogs;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
|
|
+using System.Windows;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.Form
|
|
namespace PDF_Office.ViewModels.Form
|
|
{
|
|
{
|
|
public class ButtonPropertyViewModel : FormBaseVM, INavigationAware
|
|
public class ButtonPropertyViewModel : FormBaseVM, INavigationAware
|
|
{
|
|
{
|
|
- #region 属性
|
|
|
|
|
|
|
|
- #region 选项
|
|
|
|
- //标签
|
|
|
|
- private string _labelContent;
|
|
|
|
- public string LabelContent
|
|
|
|
- {
|
|
|
|
- get { return _labelContent; }
|
|
|
|
- set { SetProperty(ref _labelContent, value); }
|
|
|
|
- }
|
|
|
|
|
|
+ #region Command变量
|
|
|
|
+ public DelegateCommand<string> FieldNameTextChangedCommand { get; set; }
|
|
|
|
+ public DelegateCommand<string> ToolTipTextChangedCommand { get; set; }
|
|
|
|
|
|
- private string _emailContent;
|
|
|
|
- public string EmailContent
|
|
|
|
- {
|
|
|
|
- get { return _emailContent; }
|
|
|
|
- set { SetProperty(ref _emailContent, value); }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- #endregion
|
|
|
|
|
|
+ //外观
|
|
|
|
+ public DelegateCommand<object> ResetColorCommand { get; set; }
|
|
|
|
+ public DelegateCommand<object> ResetColorCheckedBtnCommand { get; set; }
|
|
|
|
|
|
|
|
+ public DelegateCommand<string> FormContentTextChangedCommand { get; set; }
|
|
|
|
|
|
- #endregion
|
|
|
|
-
|
|
|
|
- #region Command
|
|
|
|
-
|
|
|
|
|
|
+ public DelegateCommand<object> LineStyleCommand { get; set; }
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
#region 变量
|
|
#region 变量
|
|
private CPDFViewer PDFViewer;
|
|
private CPDFViewer PDFViewer;
|
|
private WidgetPushButtonArgs pushButtonArgs;
|
|
private WidgetPushButtonArgs pushButtonArgs;
|
|
|
|
+ private IDialogService dialogs;
|
|
|
|
+ public event EventHandler<int> SelectResetColorBtnHandler;
|
|
|
|
+ public List<ComboDataItem> FontFamilyItems { get; private set; }
|
|
|
|
+ public List<ComboDataItem> FontStyleItems { get; private set; }
|
|
|
|
+ public List<ComboDataItem> AglinmentItems { get; private set; }
|
|
|
|
+
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
#region 初始化
|
|
#region 初始化
|
|
@@ -55,29 +54,222 @@ namespace PDF_Office.ViewModels.Form
|
|
|
|
|
|
private void InitVariable()
|
|
private void InitVariable()
|
|
{
|
|
{
|
|
|
|
+ InitAllResetColor();
|
|
|
|
+ InitFontFamilyComboBox();
|
|
|
|
+ InitFontStyleComboBox();
|
|
|
|
+ InitAglinmentItemsComboBox();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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 InitFontFamilyComboBox()
|
|
|
|
+ {
|
|
|
|
+ FontFamilyItems = new List<ComboDataItem>();
|
|
|
|
+ ComboDataItem item = new ComboDataItem("Courier", "Courier New");
|
|
|
|
+ FontFamilyItems.Add(item);
|
|
|
|
+ item = new ComboDataItem("Helvetica", "Helvetica");
|
|
|
|
+ FontFamilyItems.Add(item);
|
|
|
|
+ item = new ComboDataItem("Times Roman", "Times New Roman");
|
|
|
|
+ FontFamilyItems.Add(item);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void InitFontStyleComboBox()
|
|
|
|
+ {
|
|
|
|
+ FontStyleItems = new List<ComboDataItem>();
|
|
|
|
+ ComboDataItem item = new ComboDataItem("Regular", "Regular");
|
|
|
|
+ FontStyleItems.Add(item);
|
|
|
|
+ item = new ComboDataItem("Bold", "Bold");
|
|
|
|
+ FontStyleItems.Add(item);
|
|
|
|
+ item = new ComboDataItem("Italic", "Italic");
|
|
|
|
+ FontStyleItems.Add(item);
|
|
|
|
+
|
|
|
|
+ item = new ComboDataItem("Bold Italic", "Bold Italic");
|
|
|
|
+ FontStyleItems.Add(item);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void InitAglinmentItemsComboBox()
|
|
|
|
+ {
|
|
|
|
+ AglinmentItems = new List<ComboDataItem>();
|
|
|
|
+ ComboDataItem item = new ComboDataItem("Left", "Left");
|
|
|
|
+ AglinmentItems.Add(item);
|
|
|
|
+ item = new ComboDataItem("Center", "Center");
|
|
|
|
+ AglinmentItems.Add(item);
|
|
|
|
+ item = new ComboDataItem("Right", "Right");
|
|
|
|
+ AglinmentItems.Add(item);
|
|
|
|
+ }
|
|
private void InitCommand()
|
|
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);
|
|
|
|
+
|
|
|
|
+ //选项
|
|
|
|
+ FormContentTextChangedCommand = new DelegateCommand<string>(FormContentTextChanged);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
- #region 一般处理
|
|
|
|
|
|
+ #region 事件
|
|
|
|
|
|
- #endregion
|
|
|
|
|
|
|
|
- #region 外观处理
|
|
|
|
|
|
+ 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 FormContentTextChanged(string obj)
|
|
|
|
+ {
|
|
|
|
+ if (obj != null && IsCurrentWidget == true)
|
|
|
|
+ {
|
|
|
|
+ FormContent = 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;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
#endregion
|
|
#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
|
|
#endregion
|
|
|
|
|
|
#region Navegation
|
|
#region Navegation
|
|
@@ -89,22 +281,26 @@ namespace PDF_Office.ViewModels.Form
|
|
public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
{
|
|
{
|
|
pushButtonArgs = null;
|
|
pushButtonArgs = null;
|
|
|
|
+ isCreateWidget = false;
|
|
|
|
+ IsCurrentWidget = false;
|
|
}
|
|
}
|
|
|
|
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
{
|
|
{
|
|
navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
|
|
navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
|
|
navigationContext.Parameters.TryGetValue<WidgetPushButtonArgs>("WidgetArgs", out pushButtonArgs);
|
|
navigationContext.Parameters.TryGetValue<WidgetPushButtonArgs>("WidgetArgs", out pushButtonArgs);
|
|
|
|
+ navigationContext.Parameters.TryGetValue<UpdateAttributeHelper>(ParameterNames.AnnotEvent, out AttribEvent);
|
|
|
|
|
|
GetWidgeText();
|
|
GetWidgeText();
|
|
- GetProperty();
|
|
|
|
|
|
+ UpdataSelectResetColorBtn();
|
|
}
|
|
}
|
|
|
|
|
|
private void GetWidgeText()
|
|
private void GetWidgeText()
|
|
{
|
|
{
|
|
- PDFViewer.SetMouseMode(MouseModes.FormEditTool);
|
|
|
|
|
|
+
|
|
if (pushButtonArgs == null)
|
|
if (pushButtonArgs == null)
|
|
{
|
|
{
|
|
|
|
+ PDFViewer.SetMouseMode(MouseModes.FormEditTool);
|
|
WidgetPushButtonArgs pushButtonArgs = new WidgetPushButtonArgs();
|
|
WidgetPushButtonArgs pushButtonArgs = new WidgetPushButtonArgs();
|
|
pushButtonArgs.BgColor = Colors.White;
|
|
pushButtonArgs.BgColor = Colors.White;
|
|
pushButtonArgs.FontFamily = "Courier New";
|
|
pushButtonArgs.FontFamily = "Courier New";
|
|
@@ -120,60 +316,69 @@ namespace PDF_Office.ViewModels.Form
|
|
|
|
|
|
this.pushButtonArgs = pushButtonArgs;
|
|
this.pushButtonArgs = pushButtonArgs;
|
|
PDFViewer.SetToolParam(pushButtonArgs);
|
|
PDFViewer.SetToolParam(pushButtonArgs);
|
|
|
|
+ isCreateWidget = true;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
PDFViewer.SetToolParam(new AnnotHandlerEventArgs());
|
|
PDFViewer.SetToolParam(new AnnotHandlerEventArgs());
|
|
|
|
+ isCreateWidget = false;
|
|
}
|
|
}
|
|
|
|
+ GetProperty();
|
|
|
|
+
|
|
|
|
+ IsCurrentWidget = true;
|
|
}
|
|
}
|
|
|
|
|
|
private void GetProperty()
|
|
private void GetProperty()
|
|
{
|
|
{
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //更改基类公共属性后,触发的事件
|
|
|
|
- //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;
|
|
|
|
-
|
|
|
|
- // case FormAttributeType.HeightSize:
|
|
|
|
- // break;
|
|
|
|
-
|
|
|
|
- // case FormAttributeType.BorderThiness:
|
|
|
|
- // break;
|
|
|
|
-
|
|
|
|
- // case FormAttributeType.BorderColor:
|
|
|
|
- // break;
|
|
|
|
-
|
|
|
|
- // case FormAttributeType.ContentColor:
|
|
|
|
- // break;
|
|
|
|
-
|
|
|
|
- // case FormAttributeType.IsReadOnly:
|
|
|
|
- // break;
|
|
|
|
-
|
|
|
|
- // case FormAttributeType.WidthSize:
|
|
|
|
- // break;
|
|
|
|
-
|
|
|
|
- // case FormAttributeType.IsRequiredField:
|
|
|
|
- // break;
|
|
|
|
-
|
|
|
|
- // }
|
|
|
|
|
|
+ if (pushButtonArgs != null)
|
|
|
|
+ {
|
|
|
|
+ IsLocked = pushButtonArgs.Locked;
|
|
|
|
+ FieldName = pushButtonArgs.FieldName;
|
|
|
|
+ ToolTipStr = pushButtonArgs.Tooltip;
|
|
|
|
+ IsReadOnly = pushButtonArgs.ReadOnly;
|
|
|
|
+
|
|
|
|
+ FillColor = pushButtonArgs.BgColor;
|
|
|
|
+ ContentColor = pushButtonArgs.FontColor;
|
|
|
|
+ BorderColor = pushButtonArgs.LineColor;
|
|
|
|
+ BorderThiness = pushButtonArgs.LineWidth;
|
|
|
|
+ BorderStyle = pushButtonArgs.BorderStyle;
|
|
|
|
+
|
|
|
|
+ string fontWeightStyleStr = "";
|
|
|
|
+ if (pushButtonArgs.FontStyle == FontStyles.Normal)
|
|
|
|
+ {
|
|
|
|
+ if (pushButtonArgs.FontWeight == FontWeights.Normal)
|
|
|
|
+ fontWeightStyleStr = "Regular";
|
|
|
|
+ else
|
|
|
|
+ fontWeightStyleStr = "Bold";
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (pushButtonArgs.FontWeight == FontWeights.Normal)
|
|
|
|
+ fontWeightStyleStr = "Italic";
|
|
|
|
+ else
|
|
|
|
+ fontWeightStyleStr = "Bold Italic";
|
|
|
|
+ }
|
|
|
|
+ FontWeightStyleItem = new ComboDataItem(fontWeightStyleStr);
|
|
|
|
+
|
|
|
|
+ FontFamilyData = new ComboDataItem(pushButtonArgs.FontFamily);
|
|
|
|
+ //避免BorderStyle跟上一个值相同,而没触发更改IsSolid属性
|
|
|
|
+ if (BorderStyle == C_BORDER_STYLE.BS_SOLID)
|
|
|
|
+ IsSolid = true;
|
|
|
|
+ else
|
|
|
|
+ IsSolid = false;
|
|
|
|
+ FontSizeData = new ComboDataItem(pushButtonArgs.FontSize);
|
|
|
|
+ if (isCreateWidget == false)
|
|
|
|
+ {
|
|
|
|
+ HeightSize = pushButtonArgs.Height;
|
|
|
|
+ WidthSize = pushButtonArgs.Width;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //FormContent = listBoxArgs.Text;
|
|
|
|
+ //IsMultiLine = listBoxArgs.IsMultiLine;
|
|
|
|
+ //IsScrollText = listBoxArgs.ScrollFlag;
|
|
|
|
|
|
- //}
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
#endregion
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
}
|