123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482 |
- using ComPDFKitViewer;
- using PDF_Master.Model.From;
- using Prism.Mvvm;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Media;
- using System.Windows;
- using PDF_Master.CustomControl.CompositeControl;
- using ComPDFKit.PDFAnnotation;
- using PDF_Master.Helper;
- namespace PDF_Master.ViewModels.Form
- {
- public class FormBaseVM : BindableBase
- {
- #region 变量
- public UpdateAttributeHelper AttribEvent;
- public bool IsCurrentWidget = false;
- public bool isCreateWidget = false;
- #endregion
- #region 一般
- //名称
- private string _fieldName;
- public string FieldName
- {
- get { return _fieldName; }
- set { SetProperty(ref _fieldName, value); ChangeValue(AnnotAttrib.FieldName, value); }
- }
- //提示
- private string _toolTipStr;
- public string ToolTipStr
- {
- get { return _toolTipStr; }
- set { SetProperty(ref _toolTipStr, value); ChangeValue(AnnotAttrib.Tooltip, value); }
- }
- //表单域
- private FormFieldType _formField;
- public FormFieldType FormField
- {
- get { return _formField; }
- set { SetProperty(ref _formField, value); ChangeValue(AnnotAttrib.FormField, value); }
- }
- //只读
- public bool _isReadOnly = false;
- public bool IsReadOnly
- {
- get { return _isReadOnly; }
- set { SetProperty(ref _isReadOnly, value); ChangeValue(AnnotAttrib.ReadOnly, value); }
- }
- //必填
- public bool _isRequiredField = false;
- public bool IsRequiredField
- {
- get { return _isRequiredField; }
- set { SetProperty(ref _isRequiredField, value); ChangeValue(AnnotAttrib.IsRequired, value); }
- }
- //锁定
- public bool _isLocked = false;
- public bool IsLocked
- {
- get { return _isLocked; }
- set { SetProperty(ref _isLocked, value); ChangeValue(AnnotAttrib.Locked, value); }
- }
- #endregion
- #region 外观
- #region 四个选项:颜色样式
- private ResetColor _resetColorOne = new ResetColor();
- public ResetColor ResetColorOne
- {
- get { return _resetColorOne; }
- set { SetProperty(ref _resetColorOne, value); }
- }
- private ResetColor _resetColorTwo = new ResetColor();
- public ResetColor ResetColorTwo
- {
- get { return _resetColorTwo; }
- set { SetProperty(ref _resetColorTwo, value); }
- }
- private ResetColor _resetColorThree = new ResetColor();
- public ResetColor ResetColorThree
- {
- get { return _resetColorThree; }
- set { SetProperty(ref _resetColorThree, value); }
- }
- private ResetColor _resetColorForth = new ResetColor();
- public ResetColor ResetColorForth
- {
- get { return _resetColorForth; }
- set { SetProperty(ref _resetColorForth, value); }
- }
- #endregion
- //边框颜色
- private Color _borderColor = Colors.Transparent;
- public Color BorderColor
- {
- get { return _borderColor; }
- set { SetProperty(ref _borderColor, value); ChangeValue(AnnotAttrib.Color, value); }
- }
- //内容颜色
- private Color _contentColor = Colors.Transparent;
- public Color ContentColor
- {
- get { return _contentColor; }
- set { SetProperty(ref _contentColor, value); ChangeValue(AnnotAttrib.FontColor, value); }
- }
- //填充颜色
- private Color _fillColor = Colors.Transparent;
- public Color FillColor
- {
- get { return _fillColor; }
- set { SetProperty(ref _fillColor, value); ChangeValue(AnnotAttrib.FillColor, value); }
- }
- //边框大小
- private double _borderThiness = 0;
- public double BorderThiness
- {
- get { return _borderThiness; }
- set { SetProperty(ref _borderThiness, value); ChangeValue(AnnotAttrib.Thickness, value); }
- }
- //是否为实线条
- private bool _isSolid = true;
- public bool IsSolid
- {
- get { return _isSolid; }
- set { SetProperty(ref _isSolid, value); }
- }
- //线条样式
- private ComPDFKit.PDFAnnotation.C_BORDER_STYLE _borderStyle = ComPDFKit.PDFAnnotation.C_BORDER_STYLE.BS_SOLID;
- public ComPDFKit.PDFAnnotation.C_BORDER_STYLE BorderStyle
- {
- get { return _borderStyle; }
- set {
- SetProperty(ref _borderStyle, value);
- if (value == ComPDFKit.PDFAnnotation.C_BORDER_STYLE.BS_SOLID)
- IsSolid = true;
- else
- IsSolid = false;
- ChangeValue(AnnotAttrib.LineStyle, value);
- }
- }
- private ComboDataItem _fontFamilyData;
- public ComboDataItem FontFamilyData
- {
- get { return _fontFamilyData; }
- set
- {
- SetProperty(ref _fontFamilyData, value);
- ChangeValue(AnnotAttrib.FontFamily, _fontFamilyData.ValueStr);
- }
- }
- private FontStyle _fontStyle;
- public FontStyle FontStyleItem
- {
- get { return _fontStyle; }
- set { SetProperty(ref _fontStyle, value); ChangeValue(AnnotAttrib.FontStyle, value); }
- }
- private FontWeight _fontWeight;
- public FontWeight FontWeightItem
- {
- get { return _fontWeight; }
- set { SetProperty(ref _fontWeight, value); ChangeValue(AnnotAttrib.FontWeight, value); }
- }
- private ComboDataItem _fontWeightStyleItem;
- public ComboDataItem FontWeightStyleItem
- {
- get { return _fontWeightStyleItem; }
- set { SetProperty(ref _fontWeightStyleItem, value);
- if (_fontWeightStyleItem.ValueStr != null && string.IsNullOrEmpty((string)_fontWeightStyleItem.ValueStr) == false)
- {
- switch ((string)_fontWeightStyleItem.ValueStr)
- {
- case "Regular":
- FontStyleItem = FontStyles.Normal;
- FontWeightItem = FontWeights.Normal;
- break;
- case "Bold":
- FontStyleItem = FontStyles.Normal;
- FontWeightItem = FontWeights.Bold;
- break;
- case "Italic":
- FontStyleItem = FontStyles.Italic;
- FontWeightItem = FontWeights.Normal;
- break;
- case "Bold Italic":
- FontStyleItem = FontStyles.Italic;
- FontWeightItem = FontWeights.Bold;
- break;
- }
- }
- }
- }
- private ComboDataItem _fontSizeData = new ComboDataItem(6);
- public ComboDataItem FontSizeData
- {
- get { return _fontSizeData; }
- set { SetProperty(ref _fontSizeData, value);
- if(_fontSizeData != null)
- ChangeValue(AnnotAttrib.FontSize, (int)_fontSizeData.Value); }
- }
- //宽大小
- private double _widthSize = 150;
- public double WidthSize
- {
- get { return _widthSize; }
- set { SetProperty(ref _widthSize, value); if (isNoUpdateValue == false) ChangeValue(AnnotAttrib.Width, value); }
- }
- //高大小
- private double _heightSize = 22;
- public double HeightSize
- {
- get { return _heightSize; }
- set { SetProperty(ref _heightSize, value);if (isNoUpdateValue == false) ChangeValue(AnnotAttrib.Height, value); }
- }
- private bool isNoUpdateValue = false;
- public void SetSizeNoUpdateValue(double width, double height)
- {
- isNoUpdateValue = true;
- WidthSize = width;
- HeightSize = height;
- isNoUpdateValue = false;
- }
- #endregion
- #region 选项
- private C_TEXT_ALIGNMENT _textAlignment;
- public C_TEXT_ALIGNMENT TextAlignmentItem
- {
- get { return _textAlignment; }
- set { SetProperty(ref _textAlignment, value); ChangeValue(AnnotAttrib.TextAlign, value); }
- }
- private ComboDataItem _fextAlignmentData = new ComboDataItem("Left", "Left");
- public ComboDataItem TextAlignmentData
- {
- get { return _fextAlignmentData; }
- set
- {
- SetProperty(ref _fextAlignmentData, value);
- if (_fextAlignmentData != null && string.IsNullOrEmpty(_fextAlignmentData.ValueStr) == false)
- {
- switch(_fextAlignmentData.ValueStr)
- {
- case "Left":
- TextAlignmentItem = C_TEXT_ALIGNMENT.ALIGNMENT_LEFT;
- break;
- case "Center":
- TextAlignmentItem = C_TEXT_ALIGNMENT.ALIGNMENT_CENTER;
- break;
- case "Right":
- TextAlignmentItem = C_TEXT_ALIGNMENT.ALIGNMENT_RIGHT;
- break;
- }
- }
-
- }
- }
- //内容
- private string _content;
- public string FormContent
- {
- get { return _content; }
- set { SetProperty(ref _content, value); ChangeValue(AnnotAttrib.Text, value); }
- }
- //默认值
- private string _defaultValue;
- public string DefaultValue
- {
- get { return _defaultValue; }
- set { SetProperty(ref _defaultValue, value); }
- }
- //多行
- private bool _isMultiline = false;
- public bool IsMultiLine
- {
- get { return _isMultiline; }
- set { SetProperty(ref _isMultiline, value); ChangeValue(AnnotAttrib.IsMutilLine, value); }
- }
- //滚动显示长文本
- private bool _isScrollText = false;
- public bool IsScrollText
- {
- get { return _isScrollText; }
- set { SetProperty(ref _isScrollText, value); ChangeValue(AnnotAttrib.ScrollFlag, value); }
- }
- //下拉框Form,
- private bool _isDefaultCheckBox = false;
- public bool IsDefaultCheckBox
- {
- get { return _isDefaultCheckBox; }
- set { SetProperty(ref _isDefaultCheckBox, value); ChangeValue(AnnotAttrib.IsChecked, value); }
- }
- //复选框的导出值
- private string _exportedValues;
- public string ExportedValues
- {
- get { return _exportedValues; }
- set { SetProperty(ref _exportedValues, value); ChangeValue(AnnotAttrib.ExportValue, value); }
- }
- //单选框Form,
- private bool _isDefaultRadioBox = false;
- public bool IsDefaultRadioBox
- {
- get { return _isDefaultRadioBox; }
- set { SetProperty(ref _isDefaultRadioBox, value); ChangeValue(AnnotAttrib.IsChecked, value); }
- }
- //复选框的导出值
- private string _radioMemberName;
- public string RadioMemberName
- {
- get { return _radioMemberName; }
- set { SetProperty(ref _radioMemberName, value); ChangeValue(AnnotAttrib.RadioMemberName, value); }
- }
- //Option
- //是否可以输入内容
- private bool _isInputOption = false;
- public bool IsInputOption
- {
- get { return _isInputOption; }
- set { SetProperty(ref _isInputOption, value); }
- }
- private bool _isUpOption = false;
- public bool IsUpOption
- {
- get { return _isUpOption; }
- set{ SetProperty(ref _isUpOption, value); }
- }
- private bool _isDownOption = false;
- public bool IsDownOption
- {
- get { return _isDownOption; }
- set { SetProperty(ref _isDownOption, value); }
- }
- private bool _isRemoveOption = false;
- public bool IsRemoveOption
- {
- get { return _isRemoveOption; }
- set { SetProperty(ref _isRemoveOption, value); }
- }
- public int OptionSelectedIndex = -1;
- private string _optionKey;
- public string OptionKey
- {
- get { return _optionKey; }
- set { SetProperty(ref _optionKey, value); }
- }
- private string _optionKeyValue;
- public string OptionKeyValue
- {
- get { return _optionKeyValue; }
- set { SetProperty(ref _optionKeyValue, value); }
- }
- private Dictionary<string, string> _optionsList;
- public Dictionary<string, string> OptionsList
- {
- get { return _optionsList; }
- set { SetProperty(ref _optionsList, value); }
- }
- #endregion
- public void ChangeValue(AnnotAttrib annotAttrib,object obj)
- {
-
- if(AttribEvent != null && IsCurrentWidget && AttribEvent.IsCreateForm() == false)
- {
- AttribEvent.UpdateAttrib(annotAttrib, obj);
- AttribEvent.UpdateAnnot();
- }
- }
- #region
- public ResetColor InitResetColor(Color border, Color font, Color fill)
- {
- return new ResetColor()
- {
- BorderColor = new SolidColorBrush(border),
- FontColor = new SolidColorBrush(font),
- FillColor = new SolidColorBrush(fill)
- };
- }
- //退出或切换属性面板,清除数据
- public void ClearVMData()
- {
- isCreateWidget = false;
- IsCurrentWidget = false;
- OptionsList = null;
- IsRemoveOption = false;
- IsInputOption = false;
- IsUpOption = false;
- IsDownOption = false;
- OptionSelectedIndex = -1;
- OptionKey = "";
- OptionKeyValue = "";
- }
- #endregion
- }
- public class ResetColor : BindableBase
- {
- private SolidColorBrush _borderColor;
- public SolidColorBrush BorderColor
- {
- get { return _borderColor; }
- set { SetProperty(ref _borderColor, value); }
- }
- private SolidColorBrush _fontColor;
- public SolidColorBrush FontColor
- {
- get { return _fontColor; }
- set { SetProperty(ref _fontColor, value); }
- }
- private SolidColorBrush _fillColor;
- public SolidColorBrush FillColor
- {
- get { return _fillColor; }
- set { SetProperty(ref _fillColor, value); }
- }
- }
- }
|