|
@@ -1,4 +1,5 @@
|
|
|
using ComPDFKit.PDFAnnotation;
|
|
|
+using ComPDFKitViewer;
|
|
|
using ComPDFKitViewer.AnnotEvent;
|
|
|
using ComPDFKitViewer.PdfViewer;
|
|
|
using PDF_Office.CustomControl.CompositeControl;
|
|
@@ -10,6 +11,8 @@ using Prism.Regions;
|
|
|
using Prism.Services.Dialogs;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Collections.ObjectModel;
|
|
|
+using System.Collections.Specialized;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
@@ -32,6 +35,16 @@ namespace PDF_Office.ViewModels.Form
|
|
|
public DelegateCommand<string> FormContentTextChangedCommand { get; set; }
|
|
|
|
|
|
public DelegateCommand<object> LineStyleCommand { get; set; }
|
|
|
+ //选项
|
|
|
+ public DelegateCommand<object> AddOptionCommand { get; set; }
|
|
|
+ public DelegateCommand<object> RemoveOptionCommand { get; set; }
|
|
|
+ public DelegateCommand<object> UpItemOptionCommand { get; set; }
|
|
|
+ public DelegateCommand<object> DownItemOptionCommand { get; set; }
|
|
|
+ public DelegateCommand<string> OptionKeyTextChangedCommand { get; set; }
|
|
|
+
|
|
|
+ public DelegateCommand<string> OptionKeyValueTextChangedCommand { get; set; }
|
|
|
+ public DelegateCommand<object> OptionSelectionChangedCommand { get; set; }
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region 变量
|
|
@@ -42,6 +55,7 @@ namespace PDF_Office.ViewModels.Form
|
|
|
public List<ComboDataItem> FontFamilyItems { get; private set; }
|
|
|
public List<ComboDataItem> FontStyleItems { get; private set; }
|
|
|
public List<ComboDataItem> AglinmentItems { get; private set; }
|
|
|
+ public ObservableCollection<ComboDataItem> OptionItems { get; private set; }
|
|
|
|
|
|
#endregion
|
|
|
|
|
@@ -58,8 +72,21 @@ namespace PDF_Office.ViewModels.Form
|
|
|
InitFontFamilyComboBox();
|
|
|
InitFontStyleComboBox();
|
|
|
InitAglinmentItemsComboBox();
|
|
|
+ InitOptionItems();
|
|
|
}
|
|
|
|
|
|
+ private void InitOptionItems()
|
|
|
+ {
|
|
|
+ OptionItems = new ObservableCollection<ComboDataItem>();
|
|
|
+ OptionItems.CollectionChanged -= OptionItems_CollectionChanged;
|
|
|
+ OptionItems.CollectionChanged += OptionItems_CollectionChanged;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OptionItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
|
|
+ {
|
|
|
+ if(OptionItems.Count == 0)
|
|
|
+ IsRemoveOption = false;
|
|
|
+ }
|
|
|
|
|
|
private void InitAllResetColor()
|
|
|
{
|
|
@@ -79,7 +106,7 @@ namespace PDF_Office.ViewModels.Form
|
|
|
FontFamilyItems.Add(item);
|
|
|
item = new ComboDataItem("Helvetica", "Helvetica");
|
|
|
FontFamilyItems.Add(item);
|
|
|
- item = new ComboDataItem("Times Roman", "Times New Roman");
|
|
|
+ item = new ComboDataItem("Times", "Times New Roman");
|
|
|
FontFamilyItems.Add(item);
|
|
|
}
|
|
|
|
|
@@ -120,6 +147,13 @@ namespace PDF_Office.ViewModels.Form
|
|
|
|
|
|
//选项
|
|
|
FormContentTextChangedCommand = new DelegateCommand<string>(FormContentTextChanged);
|
|
|
+ AddOptionCommand = new DelegateCommand<object>(AddOption);
|
|
|
+ RemoveOptionCommand = new DelegateCommand<object>(RemoveOption);
|
|
|
+ UpItemOptionCommand = new DelegateCommand<object>(UpItemOption);
|
|
|
+ DownItemOptionCommand = new DelegateCommand<object>(DownItemOption);
|
|
|
+ OptionKeyTextChangedCommand = new DelegateCommand<string>(OptionKeyTextChanged);
|
|
|
+ OptionKeyValueTextChangedCommand = new DelegateCommand<string>(OptionKeyValueTextChanged);
|
|
|
+ OptionSelectionChangedCommand = new DelegateCommand<object>(OptionSelectionChanged);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
@@ -171,6 +205,142 @@ namespace PDF_Office.ViewModels.Form
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void OptionKeyValueTextChanged(string obj)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(obj) == false && IsCurrentWidget == true)
|
|
|
+ {
|
|
|
+ OptionKeyValue = obj;
|
|
|
+ }
|
|
|
+ UpdateIsInputOption();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OptionKeyTextChanged(string obj)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(obj) == false && IsCurrentWidget == true)
|
|
|
+ {
|
|
|
+ OptionKey = obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ UpdateIsInputOption();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OptionSelectionChanged(object obj)
|
|
|
+ {
|
|
|
+ if(obj != null && obj is int == true)
|
|
|
+ {
|
|
|
+ UpdateAllOptionBtn((int)obj);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //刷新所有Option有关的按钮状态
|
|
|
+ private void UpdateAllOptionBtn(int SelectedIndex)
|
|
|
+ {
|
|
|
+ var count = OptionItems.Count;
|
|
|
+ if (SelectedIndex <= -1)
|
|
|
+ {
|
|
|
+ IsDownOption = false;
|
|
|
+ IsUpOption = false;
|
|
|
+ IsRemoveOption = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ IsRemoveOption = true;
|
|
|
+ IsUpOption = SelectedIndex == 0 ? false : true;
|
|
|
+ IsDownOption = (SelectedIndex == count - 1)?false:true;
|
|
|
+ }
|
|
|
+ OptionSelectedIndex = SelectedIndex;
|
|
|
+ }
|
|
|
+
|
|
|
+ //Option是否可输入内容
|
|
|
+ private void UpdateIsInputOption()
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(OptionKeyValue) || string.IsNullOrEmpty(OptionKey))
|
|
|
+ {
|
|
|
+ IsInputOption = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ foreach (var item in OptionItems)
|
|
|
+ {
|
|
|
+ if (item.ValueStr == OptionKeyValue || item.Content == OptionKey)
|
|
|
+ {
|
|
|
+ IsInputOption = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ IsInputOption = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //新增Option项
|
|
|
+ private void AddOption(object obj)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(OptionKey) || string.IsNullOrEmpty(OptionKeyValue))
|
|
|
+ return;
|
|
|
+
|
|
|
+ var item = new ComboDataItem(OptionKeyValue,OptionKey);
|
|
|
+ OptionItems.Add(item);
|
|
|
+ OptionsList[item.Content] = item.ValueStr;
|
|
|
+ ChangeValue(AnnotAttrib.ListOptions, OptionsList);
|
|
|
+ OptionKey = "";
|
|
|
+ OptionKeyValue = "";
|
|
|
+ UpdateAllOptionBtn(OptionSelectedIndex);
|
|
|
+ }
|
|
|
+ //移除Option项
|
|
|
+ private void RemoveOption(object obj)
|
|
|
+ {
|
|
|
+ if(obj != null)
|
|
|
+ {
|
|
|
+ var item = (ComboDataItem)obj;
|
|
|
+ OptionsList.Remove(item.Content);
|
|
|
+ OptionItems.Remove(item);
|
|
|
+ ChangeValue(AnnotAttrib.ListOptions, OptionsList);
|
|
|
+ UpdateAllOptionBtn(-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //向下移项
|
|
|
+ private void DownItemOption(object obj)
|
|
|
+ {
|
|
|
+ if(obj != null)
|
|
|
+ {
|
|
|
+ var item = (ComboDataItem)obj;
|
|
|
+ var index = OptionItems.IndexOf(item);
|
|
|
+ if(index < OptionItems.Count - 1)
|
|
|
+ {
|
|
|
+ OptionItems.Move(index, index + 1);
|
|
|
+ UpdateAllOptionBtn(index + 1);
|
|
|
+ OptionsList.Clear();
|
|
|
+ foreach(var itemOption in OptionItems)
|
|
|
+ {
|
|
|
+ OptionsList[itemOption.Content] = itemOption.ValueStr;
|
|
|
+ }
|
|
|
+ ChangeValue(AnnotAttrib.ListOptions, OptionsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //向上移项
|
|
|
+ private void UpItemOption(object obj)
|
|
|
+ {
|
|
|
+ if (obj != null)
|
|
|
+ {
|
|
|
+ var item = (ComboDataItem)obj;
|
|
|
+ var index = OptionItems.IndexOf(item);
|
|
|
+ if (index > 0)
|
|
|
+ {
|
|
|
+ OptionItems.Move(index, index - 1);
|
|
|
+ UpdateAllOptionBtn(index - 1);
|
|
|
+ OptionsList.Clear();
|
|
|
+ foreach (var itemOption in OptionItems)
|
|
|
+ {
|
|
|
+ OptionsList[itemOption.Content] = itemOption.ValueStr;
|
|
|
+ }
|
|
|
+ ChangeValue(AnnotAttrib.ListOptions, OptionsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private void ResetColorCheckedBtn(object obj)
|
|
|
{
|
|
@@ -282,8 +452,7 @@ namespace PDF_Office.ViewModels.Form
|
|
|
public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
|
{
|
|
|
comboBoxArgs = null;
|
|
|
- isCreateWidget = false;
|
|
|
- IsCurrentWidget = false;
|
|
|
+ ClearVMData();
|
|
|
}
|
|
|
|
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
@@ -291,6 +460,7 @@ namespace PDF_Office.ViewModels.Form
|
|
|
navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
|
|
|
navigationContext.Parameters.TryGetValue<WidgetComboBoxArgs>("WidgetArgs", out comboBoxArgs);
|
|
|
navigationContext.Parameters.TryGetValue<UpdateAttributeHelper>(ParameterNames.AnnotEvent, out AttribEvent);
|
|
|
+ OptionsList = new Dictionary<string, string>();
|
|
|
GetWidgeText();
|
|
|
UpdataSelectResetColorBtn();
|
|
|
}
|
|
@@ -370,11 +540,14 @@ namespace PDF_Office.ViewModels.Form
|
|
|
HeightSize = comboBoxArgs.Height;
|
|
|
WidthSize = comboBoxArgs.Width;
|
|
|
}
|
|
|
-
|
|
|
- //FormContent = listBoxArgs.Text;
|
|
|
- //IsMultiLine = listBoxArgs.IsMultiLine;
|
|
|
- //IsScrollText = listBoxArgs.ScrollFlag;
|
|
|
-
|
|
|
+ OptionsList = comboBoxArgs.ListOptions;
|
|
|
+ OptionItems.Clear();
|
|
|
+ foreach (string key in OptionsList.Keys)
|
|
|
+ {
|
|
|
+ var item = new ComboDataItem(OptionsList[key], key);
|
|
|
+ OptionItems.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
#endregion
|