123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- using PDF_Office.CustomControl.CompositeControl;
- using PDF_Office.Model.PropertyPanel.AnnotPanel;
- using Prism.Mvvm;
- 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.PropertyPanel
- {
- //属性触发事件的标识
- public enum FontSetModeType
- {
- PresetFontStyes,
- FontFamilys,
- FontSizes,
- FontWeight_Style,
- FontColor
- }
- public class FontSetMode : BindableBase
- {
- #region 变量
- public event EventHandler<FontSetModeType> ChangedValue;
- public List<ComboDataItem> FontFamilyItems { get; protected set; }
- public List<ComboDataItem> FontStyleItems { get; protected set; }
- public List<ComboDataItem> PresetTextItems { get; protected set; }
- public List<FontStyleItem> FontStyleList = new List<FontStyleItem>();
- #endregion
- #region 初始化下拉框或列表默认的数据
- protected void InitBaseVariable()
- {
- InitBase_PresetFontStyles();
- InitBase_FontFamilys();
- InitBase_FontStyles();
- }
- //预设字体样式
- private void InitBase_PresetFontStyles()
- {
- PresetTextItems = new List<ComboDataItem>();
- FontStyleList = TextFont.GetPresetFontStyle();
- foreach (var item in FontStyleList)
- {
- ComboDataItem itemData = new ComboDataItem(item.mTag, item.mTagContent);
- PresetTextItems.Add(itemData);
- }
- }
- //字体
- private void InitBase_FontFamilys()
- {
- FontFamilyItems = TextFont.GetFamily();
- }
- //字重
- private void InitBase_FontStyles()
- {
- FontStyleItems = TextFont.GetFontStyle();
- }
- #endregion
- #region 属性
- private ComboDataItem _presetTextData;
- public ComboDataItem PresetTextData
- {
- get { return _presetTextData; }
- set
- {
- SetProperty(ref _presetTextData, value);
- if (_presetTextData != null)
- {
- ChangedValue?.Invoke(_presetTextData.ValueStr, FontSetModeType.PresetFontStyes);
- }
- }
- }
- //字体样式
- private ComboDataItem _fontFamilyData;
- public ComboDataItem FontFamilyData
- {
- get { return _fontFamilyData; }
- set
- {
- SetProperty(ref _fontFamilyData, value);
- if(_fontFamilyData != null)
- {
- ChangedValue?.Invoke(_fontFamilyData.ValueStr, FontSetModeType.FontFamilys);
- }
- }
- }
- //字体大小
- private ComboDataItem _fontSizeData = new ComboDataItem(6);
- public ComboDataItem FontSizeData
- {
- get { return _fontSizeData; }
- set
- {
- SetProperty(ref _fontSizeData, value);
- if(_fontSizeData != null)
- {
- ChangedValue?.Invoke(_fontSizeData.Value, FontSetModeType.FontSizes);
- }
- }
- }
- //FontStyle & FontWeight
- private FontStyle _fontStyle;
- public FontStyle FontStyleItem
- {
- get { return _fontStyle; }
- set { SetProperty(ref _fontStyle, value); }
- }
- private FontWeight _fontWeight;
- public FontWeight FontWeightItem
- {
- get { return _fontWeight; }
- set { SetProperty(ref _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)
- {
- if(_fontWeightStyleItem != null)
- {
- ChangedValue?.Invoke(null, FontSetModeType.FontWeight_Style);
- }
- }
- }
- }
- protected void UpdateFontWeight_Style()
- {
- switch (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 Brush selectColor = new SolidColorBrush(Colors.Black);
- public Brush SelectColor
- {
- get { return selectColor; }
- set
- {
- SetProperty(ref selectColor, value);
- ChangedValue?.Invoke((selectColor as SolidColorBrush).Color, FontSetModeType.FontColor);
- }
- }
- #endregion
- }
- }
|