|
@@ -1,14 +1,19 @@
|
|
|
-using ComPDFKitViewer.AnnotEvent;
|
|
|
+using ComPDFKit.PDFAnnotation;
|
|
|
+using ComPDFKitViewer.AnnotEvent;
|
|
|
using ComPDFKitViewer.PdfViewer;
|
|
|
+using PDF_Office.CustomControl.CompositeControl;
|
|
|
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;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
+using System.Windows;
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.Form
|
|
@@ -16,40 +21,32 @@ namespace PDF_Office.ViewModels.Form
|
|
|
|
|
|
public class ListBoxPropertyViewModel : FormBaseVM, INavigationAware
|
|
|
{
|
|
|
- #region 属性
|
|
|
+ #region Command变量
|
|
|
+ public DelegateCommand<string> FieldNameTextChangedCommand { get; set; }
|
|
|
+ public DelegateCommand<string> ToolTipTextChangedCommand { get; set; }
|
|
|
|
|
|
- #region 选项
|
|
|
+ //外观
|
|
|
|
|
|
- //排序项目
|
|
|
- private bool _isSortProject = false;
|
|
|
- public bool IsSortProject
|
|
|
- {
|
|
|
- get { return _isSortProject; }
|
|
|
- set { SetProperty(ref _isSortProject, value); }
|
|
|
- }
|
|
|
-
|
|
|
- //多重选择的
|
|
|
- private bool _multipleSelection = false;
|
|
|
- public bool MultipleSelection
|
|
|
- {
|
|
|
- get { return _multipleSelection; }
|
|
|
- set { SetProperty(ref _multipleSelection, value); }
|
|
|
- }
|
|
|
-
|
|
|
- #endregion
|
|
|
-
|
|
|
- #endregion
|
|
|
+ public DelegateCommand<object> ResetColorCommand { get; set; }
|
|
|
+ public DelegateCommand<object> ResetColorCheckedBtnCommand { get; set; }
|
|
|
|
|
|
- #region Command
|
|
|
+ public DelegateCommand<string> FormContentTextChangedCommand { get; set; }
|
|
|
|
|
|
+ public DelegateCommand<object> LineStyleCommand { get; set; }
|
|
|
#endregion
|
|
|
|
|
|
#region 变量
|
|
|
private CPDFViewer PDFViewer;
|
|
|
private WidgetListBoxArgs listBoxArgs;
|
|
|
- public UpdateAttributeHelper AttribEvent;
|
|
|
+ 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
|
|
|
|
|
|
+
|
|
|
#region 初始化
|
|
|
public ListBoxPropertyViewModel()
|
|
|
{
|
|
@@ -60,54 +57,222 @@ namespace PDF_Office.ViewModels.Form
|
|
|
private void InitVariable()
|
|
|
{
|
|
|
|
|
|
- ResetColorOne = new ResetColor()
|
|
|
- {
|
|
|
- BorderColor = new SolidColorBrush(Colors.Transparent),
|
|
|
- FontColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
|
|
|
- FillColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00))
|
|
|
- };
|
|
|
+ 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()
|
|
|
+ {
|
|
|
+ //一般
|
|
|
+ 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
|
|
|
+
|
|
|
+
|
|
|
+ #region 事件
|
|
|
|
|
|
- ResetColorTwo = new ResetColor()
|
|
|
+
|
|
|
+ private void FieldNameTextChanged(string obj)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(obj) == false && IsCurrentWidget == true)
|
|
|
{
|
|
|
- BorderColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
|
|
|
- FontColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
|
|
|
- FillColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00))
|
|
|
- };
|
|
|
+ FieldName = obj;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- ResetColorThree = new ResetColor()
|
|
|
+ private void ToolTipTextChanged(string obj)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(obj) == false && IsCurrentWidget == true)
|
|
|
{
|
|
|
- BorderColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
|
|
|
- FontColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
|
|
|
- FillColor = new SolidColorBrush(Color.FromArgb(0xFF, 0xBD, 0xDF, 0xFD))
|
|
|
- };
|
|
|
+ ToolTipStr = obj;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- ResetColorForth = new ResetColor()
|
|
|
+ private void LineStyleBtnEvent(object obj)
|
|
|
+ {
|
|
|
+ if (obj != null)
|
|
|
{
|
|
|
- BorderColor = new SolidColorBrush(Color.FromArgb(0xFF, 0xff, 0x00, 0x00)),
|
|
|
- FontColor = new SolidColorBrush(Color.FromArgb(0xFF, 0xff, 0x00, 0x00)),
|
|
|
- FillColor = new SolidColorBrush(Colors.Transparent)
|
|
|
- };
|
|
|
+ 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 InitCommand()
|
|
|
+
|
|
|
+ private void FormContentTextChanged(string obj)
|
|
|
{
|
|
|
- //ChangeValueHandler -= ChangeValue;
|
|
|
- //ChangeValueHandler += ChangeValue;
|
|
|
+ if (obj != null && IsCurrentWidget == true)
|
|
|
+ {
|
|
|
+ FormContent = obj;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
|
|
|
+ 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触发事件
|
|
|
|
|
|
- #endregion
|
|
|
+ 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;
|
|
|
+ }
|
|
|
|
|
|
- #region 选项处理
|
|
|
+ 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
|
|
@@ -119,6 +284,8 @@ namespace PDF_Office.ViewModels.Form
|
|
|
public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
|
{
|
|
|
listBoxArgs = null;
|
|
|
+ isCreateWidget = false;
|
|
|
+ IsCurrentWidget = false;
|
|
|
}
|
|
|
|
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
@@ -128,12 +295,12 @@ namespace PDF_Office.ViewModels.Form
|
|
|
navigationContext.Parameters.TryGetValue<UpdateAttributeHelper>(ParameterNames.AnnotEvent, out AttribEvent);
|
|
|
|
|
|
GetWidgeText();
|
|
|
+ UpdataSelectResetColorBtn();
|
|
|
}
|
|
|
|
|
|
private void GetWidgeText()
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
if (listBoxArgs == null)
|
|
|
{
|
|
|
PDFViewer.SetMouseMode(MouseModes.FormEditTool);
|
|
@@ -144,61 +311,77 @@ namespace PDF_Office.ViewModels.Form
|
|
|
listBoxArgs.FontColor = Colors.Black;
|
|
|
listBoxArgs.LineColor = Colors.Black;
|
|
|
listBoxArgs.LineWidth = 1;
|
|
|
- listBoxArgs.FieldName = "ListBox1";
|
|
|
|
|
|
PDFViewer.SetToolParam(listBoxArgs);
|
|
|
+ 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:
|
|
|
+ GetProperty();
|
|
|
|
|
|
- // break;
|
|
|
+ IsCurrentWidget = true;
|
|
|
|
|
|
- // 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;
|
|
|
+ private void GetProperty()
|
|
|
+ {
|
|
|
+ if (listBoxArgs != null)
|
|
|
+ {
|
|
|
+ IsLocked = listBoxArgs.Locked;
|
|
|
+ FieldName = listBoxArgs.FieldName;
|
|
|
+ ToolTipStr = listBoxArgs.Tooltip;
|
|
|
+ IsReadOnly = listBoxArgs.ReadOnly;
|
|
|
+
|
|
|
+ FillColor = listBoxArgs.BgColor;
|
|
|
+ ContentColor = listBoxArgs.FontColor;
|
|
|
+ BorderColor = listBoxArgs.LineColor;
|
|
|
+ BorderThiness = listBoxArgs.LineWidth;
|
|
|
+ BorderStyle = listBoxArgs.BorderStyle;
|
|
|
+
|
|
|
+ string fontWeightStyleStr = "";
|
|
|
+ if (listBoxArgs.FontStyle == FontStyles.Normal)
|
|
|
+ {
|
|
|
+ if (listBoxArgs.FontWeight == FontWeights.Normal)
|
|
|
+ fontWeightStyleStr = "Regular";
|
|
|
+ else
|
|
|
+ fontWeightStyleStr = "Bold";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (listBoxArgs.FontWeight == FontWeights.Normal)
|
|
|
+ fontWeightStyleStr = "Italic";
|
|
|
+ else
|
|
|
+ fontWeightStyleStr = "Bold Italic";
|
|
|
+ }
|
|
|
+ FontWeightStyleItem = new ComboDataItem(fontWeightStyleStr);
|
|
|
+
|
|
|
+ FontFamilyData = new ComboDataItem(listBoxArgs.FontFamily);
|
|
|
+ //避免BorderStyle跟上一个值相同,而没触发更改IsSolid属性
|
|
|
+ if (BorderStyle == C_BORDER_STYLE.BS_SOLID)
|
|
|
+ IsSolid = true;
|
|
|
+ else
|
|
|
+ IsSolid = false;
|
|
|
+ FontSizeData = new ComboDataItem(listBoxArgs.FontSize);
|
|
|
+ if (isCreateWidget == false)
|
|
|
+ {
|
|
|
+ HeightSize = listBoxArgs.Height;
|
|
|
+ WidthSize = listBoxArgs.Width;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- // case FormAttributeType.IsRequiredField:
|
|
|
- // break;
|
|
|
+
|
|
|
|
|
|
- // }
|
|
|
+ //FormContent = listBoxArgs.Text;
|
|
|
+ //IsMultiLine = listBoxArgs.IsMultiLine;
|
|
|
+ //IsScrollText = listBoxArgs.ScrollFlag;
|
|
|
|
|
|
- //}
|
|
|
+ }
|
|
|
+ }
|
|
|
#endregion
|
|
|
}
|
|
|
}
|