1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138 |
- using ComPDFKit.PDFAnnotation;
- using ComPDFKitViewer.AnnotEvent;
- using PDF_Master.CustomControl.CompositeControl;
- using PDF_Master.Model.PropertyPanel.AnnotPanel;
- using PDFSettings;
- 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_Master.Model.AnnotPanel
- {
- //属性触发事件的标识
- public enum FontSetModeType
- {
- PresetFontStyes,
- FontFamilys,
- FontSizes,
- FontWeight_Style,
- FontColor,
- TextAlignment
- }
- //设置字体大小、字体内容排版、字体颜色、字体样式、字重
- public class FontBoard : BindableBase
- {
- #region 变量
- protected event EventHandler<FontSetModeType> ChangedValue;
- protected bool IsCanSave = false;
- public List<ComboDataItem> FontFamilyItems { get; protected set; }
- public List<ComboDataItem> FontStyleItems { get; protected set; }
- public List<ComboDataItem> FontSizeItems { get; protected set; }
- public List<ComboDataItem> PresetFontItems { get; protected set; }
- public List<PresetFontItem> PresetFontList = new List<PresetFontItem>();
- public List<string> FontFamily { get; protected set; } = new List<string>
- {
- "Adobe Devanagari",
- "Arial",
- "Arial Black",
- "Arvo",
- "Bahnschrift",
- "Bahnschrift Condensed",
- "Bahnschrift Light Condensed",
- "Bahnschrift Light SemiCondensed",
- "Bahnschrift SemiBold Condensed",
- "Bahnschrift SemiCondensed",
- "Bahnschrift SemiLight",
- "Bahnschrift SemiLight Condensed",
- "Calibri",
- "Cambria",
- "Cambria Math",
- "Candara",
- "Cascadia Code",
- "Cascadia Code SemiLight",
- "Cascadia Mono",
- "Cascadia Mono SemiLight",
- "Comic Sans MS",
- "Consolas",
- "Constantia",
- "Corbel",
- "Courier New",
- "DejaVu Math TeX Gyre",
- "Droid Serif",
- "Ebrima",
- "Franklin Gothic",
- "Gabriola",
- "Gadugi",
- "Georgia",
- "HoloLens MDL2 Assets",
- "Impact",
- "Indie Flower",
- "Ink Free",
- "Javanese Text",
- "Leelawadee UI",
- "Leelawadee UI Semilight",
- "Lobster",
- "Lucida Console",
- "Lucida Sans Unicode",
- "MS Gothic",
- "MS PGothic",
- "MS UI Gothic",
- "MT Extra",
- "MV Boli",
- "Malgun Gothic",
- "Malgun Gothic Semilight",
- "Marlett",
- "Microsoft Himalaya",
- "Microsoft JhengHei",
- "Microsoft JhengHei UI",
- "Microsoft New Tai Lue",
- "Microsoft PhagsPa",
- "Microsoft Sans Serif",
- "Microsoft Tai Le",
- "Microsoft YaHei UI",
- "Microsoft Yi Baiti",
- "MingLiU-ExtB",
- "MingLiU_HKSCS-ExtB",
- "Mongolian Baiti",
- "Myanmar Text",
- "Nirmala UI",
- "Nirmala UI Semilight",
- "Open Sans",
- "PMingLiU-ExtB",
- "Palatino Linotype",
- "Poiret One",
- "Raleway",
- "Roboto",
- "Roboto Condensed",
- "Roboto Slab",
- "Sans Serif Collection",
- "Segoe Fluent Icons",
- "Segoe MDL2 Assets",
- "Segoe Print",
- "Segoe Script",
- "Segoe UI",
- "Segoe UI Black",
- "Segoe UI Emoji",
- "Segoe UI Historic",
- "Segoe UI Semilight",
- "Segoe UI Symbol",
- "Segoe UI Variable Display",
- "Segoe UI Variable Small",
- "Segoe UI Variable Text",
- "SimSun-ExtB",
- "Sitka Banner",
- "Sitka Display",
- "Sitka Heading",
- "Sitka Small",
- "Sitka Subheading",
- "Sitka Text",
- "Sylfaen",
- "Symbol",
- "Tahoma",
- "Times New",
- "Trebuchet MS",
- "Verdana",
- "Webdings",
- "Wingdings",
- "Yu Gothic",
- "Yu Gothic UI",
- "Yu Gothic UI Semilight",
- "ZWAdobeF",
- "等线",
- "仿宋",
- "黑体",
- "楷体",
- "宋体",
- "微软雅黑"
- };
- #endregion 变量
- #region 初始化下拉框或列表默认的数据
- protected void InitBaseVariable()
- {
- InitBase_PresetFontStyles();
- InitBase_FontFamilys();
- InitBase_FontStyles();
- InitBase_FontSize();
- }
- //预设字体大小
- private void InitBase_FontSize()
- {
- FontSizeItems = TextFont.GetFontSize();
- }
- //预设字体样式
- private void InitBase_PresetFontStyles()
- {
- PresetFontItems = new List<ComboDataItem>();
- PresetFontList = TextFont.GetCachePresetFontList();
- foreach (var item in PresetFontList)
- {
- ComboDataItem itemData = new ComboDataItem(item.mTag, item.mTagContent);
- PresetFontItems.Add(itemData);
- }
- }
- //字体
- private void InitBase_FontFamilys()
- {
- FontFamilyItems = TextFont.GetFamily();
- }
- //字重
- private void InitBase_FontStyles()
- {
- FontStyleItems = TextFont.GetFontStyle();
- }
- #endregion 初始化下拉框或列表默认的数据
- #region 属性
- //文字内容对齐
- private string _strtextAlign;
- public string StrTextAlign
- {
- get { return _strtextAlign; }
- set { SetProperty(ref _strtextAlign, value); }
- }
- /// <summary>
- /// 预设样式
- /// </summary>
- private int presetFontSelectedIndex;
- public int PresetFontSelectedIndex
- {
- get { return presetFontSelectedIndex; }
- set
- {
- SetProperty(ref presetFontSelectedIndex, value);
- }
- }
- private ComboDataItem _currentPresetFont=new ComboDataItem("Custom", "Custom");
- public ComboDataItem CurrentPresetFont
- {
- get { return _currentPresetFont; }
- set
- {
- bool isChange = IsEqualStrComboData(_currentPresetFont, value);
- SetProperty(ref _currentPresetFont, value);
- if (isChange)
- {
- ChangedValue?.Invoke(_currentPresetFont.ValueStr, FontSetModeType.PresetFontStyes);
- }
- SetProperty(ref _currentPresetFont, value);
- switch (value.ValueStr.ToString())
- {
- case "Custom":
- PresetFontSelectedIndex = 0;
- break;
- case "H1":
- PresetFontSelectedIndex = 1;
- break;
- case "H2":
- PresetFontSelectedIndex = 2;
- break;
- case "H3":
- PresetFontSelectedIndex = 3;
- break;
- case "B1":
- PresetFontSelectedIndex = 4;
- break;
- case "B2":
- PresetFontSelectedIndex = 5;
- break;
- case "B3":
- PresetFontSelectedIndex = 6;
- break;
- default:
- PresetFontSelectedIndex = 0;
- break;
- }
- }
- }
- #region 字体样式
- //下拉框列表
- private ComboDataItem _currentFontFamily = new ComboDataItem("Arial", "Arial");
- public ComboDataItem CurrentFontFamily
- {
- get { return _currentFontFamily; }
- set
- {
- bool isChange = IsEqualStrComboData(_currentFontFamily, value);
- SetProperty(ref _currentFontFamily, value);
- if (isChange)
- {
- string str= _currentFontFamily.Content;
- if (_currentFontFamily.Content== "Times New Roman")
- {
- str = "Times-Roman";
- }
- ChangedValue?.Invoke(str, FontSetModeType.FontFamilys);
- }
- SetProperty(ref _currentFontFamily, value);
- if (value.Content != null)
- {
- FontFamilySelectedIndex=FontFamilyItems.IndexOf(value);
- }
- else
- {
- FontFamilySelectedIndex = 0;
- }
-
- }
- }
- private int fontFamilySelectedIndex = -1;
- public int FontFamilySelectedIndex
- {
- get { return fontFamilySelectedIndex; }
- set
- {
- SetProperty(ref fontFamilySelectedIndex, value);
- }
- }
- #endregion 字体样式
- #region 字体大小
- private int fontSizeSelectedIndex;
- public int FontSizeSelectedIndex
- {
- get { return fontSizeSelectedIndex; }
- set
- {
- SetProperty(ref fontSizeSelectedIndex, value);
- }
- }
- //下拉框列表:字体大小
- private ComboDataItem _currentFontSize = new ComboDataItem(6);
- public ComboDataItem CurrentFontSize
- {
- get { return _currentFontSize; }
- set
- {
- bool isChange = IsEqualComboData(_currentFontSize, value);
- SetProperty(ref _currentFontSize, value);
- if (isChange && value.Value > 0)
- {
- ChangedValue?.Invoke(_currentFontSize.Value, FontSetModeType.FontSizes);
- }
- SetProperty(ref _currentFontSize, value);
- switch (value.Value)
- {
- case 8:
- FontSizeSelectedIndex = 0;
- break;
- case 9:
- FontSizeSelectedIndex = 1;
- break;
- case 10:
- FontSizeSelectedIndex = 2;
- break;
- case 11:
- FontSizeSelectedIndex = 3;
- break;
- case 12:
- FontSizeSelectedIndex = 4;
- break;
- case 14:
- FontSizeSelectedIndex = 5;
- break;
- case 16:
- FontSizeSelectedIndex = 6;
- break;
- case 18:
- FontSizeSelectedIndex = 7;
- break;
- case 20:
- FontSizeSelectedIndex = 8;
- break;
- case 22:
- FontSizeSelectedIndex = 9;
- break;
- case 24:
- FontSizeSelectedIndex = 10;
- break;
- case 26:
- FontSizeSelectedIndex = 11;
- break;
- case 28:
- FontSizeSelectedIndex = 12;
- break;
- case 36:
- FontSizeSelectedIndex = 13;
- break;
- case 48:
- FontSizeSelectedIndex = 14;
- break;
- case 72:
- FontSizeSelectedIndex = 15;
- break;
- default:
- //FontSizeSelectedIndex = 0;
- //FontSizeSelectedIndex = -1;
- break;
- }
-
- }
- }
- #endregion 字体大小
- //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 int fontStyleSelectedIndex = 0;
- public int FontStyleSelectedIndex
- {
- get { return fontStyleSelectedIndex; }
- set
- {
- SetProperty(ref fontStyleSelectedIndex, value);
- }
- }
- private ComboDataItem _currrentFontWeightStyle = new ComboDataItem("Regular", "Regular");
- public ComboDataItem CurrrentFontWeightStyle
- {
- get { return _currrentFontWeightStyle; }
- set
- {
- bool isChange = IsEqualStrComboData(_currrentFontWeightStyle, value);
- SetProperty(ref _currrentFontWeightStyle, value);
- if (isChange)
- {
- ChangedValue?.Invoke(_currrentFontWeightStyle, FontSetModeType.FontWeight_Style);
- }
- SetProperty(ref _currrentFontWeightStyle, value);
- switch (value.Content.ToString())
- {
- case "Regular":
- FontStyleSelectedIndex = 0;
- break;
- case "Bold":
- FontStyleSelectedIndex = 1;
- break;
- case "Italic":
- FontStyleSelectedIndex = 2;
- break;
- case "Bold Italic":
- FontStyleSelectedIndex = 3;
- break;
- }
- }
- }
- protected void UpdateFontWeight_Style()
- {
- switch (CurrrentFontWeightStyle.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 C_TEXT_ALIGNMENT _textAlignment;
- public C_TEXT_ALIGNMENT TextAlignmentItem
- {
- get { return _textAlignment; }
- set { SetProperty(ref _textAlignment, value); }
- }
- //颜色
- private Brush selectColor = new SolidColorBrush(Colors.Black);
- public Brush SelectColor
- {
- get { return selectColor; }
- set
- {
- SetProperty(ref selectColor, value);
- if (IsCanSave)
- {
- ChangedValue?.Invoke((selectColor as SolidColorBrush).Color, FontSetModeType.FontColor);
- }
- else
- {
- CurrentFontColor = selectColor;
- }
- }
- }
- private Brush _currentFontColor = new SolidColorBrush(Colors.Transparent);
- public Brush CurrentFontColor
- {
- get { return _currentFontColor; }
- set
- {
- SetProperty(ref _currentFontColor, value);
- }
- }
- private bool IsEqualComboData(ComboDataItem oldValue, ComboDataItem newValue)
- {
- if (newValue == null || IsCanSave == false)
- return false;
- if (oldValue != null && newValue != null)
- {
- if (oldValue.Value != newValue.Value)
- return true;
- }
- return false;
- }
- private bool IsEqualStrComboData(ComboDataItem oldValue, ComboDataItem newValue)
- {
- if (newValue == null || string.IsNullOrEmpty(newValue.ValueStr) == true || IsCanSave == false)
- return false;
- if (oldValue != null && newValue != null)
- {
- if (oldValue.ValueStr != newValue.ValueStr)
- return true;
- }
- return false;
- }
- #endregion 属性
- #region 列表选中赋值
- public void GetFontWeights_Style(FontStyle fontStyle, FontWeight fontWeights)
- {
- string strValue = "";
- string strContent = "";
- if (fontStyle == FontStyles.Normal)
- {
- if (fontWeights == FontWeights.Normal)
- {
- strValue = "Regular";
- strContent = "Regular";
- }
- else
- {
- strValue = "Bold";
- strContent = "Bold";
- }
- }
- else
- {
- if (fontWeights == FontWeights.Normal)
- {
- strValue = "Italic";
- strContent = "Italic";
- }
- else
- {
- strValue = "Bold Italic";
- strContent = "Bold Italic";
- }
- }
- CurrrentFontWeightStyle = new ComboDataItem(strValue, strContent);
- UpdateFontWeight_Style();
- }
- protected void GetCurrentFontSize(int size)
- {
- CurrentFontSize = new ComboDataItem(size);
- }
- protected void GetCurrentFontFamily(string fontFamily, string uiStr)
- {
- //SDK捕获到的字体会是Times-Roman
- if (fontFamily == "Times-Roman")
- {
- uiStr = "Times New Roman";
- }
- //WPF的UI字体不包含Helvetica
- if (fontFamily == "Helvetica")
- {
- fontFamily = "Arial";
- uiStr = "Arial";
- }
- CurrentFontFamily = new ComboDataItem(fontFamily, uiStr);
- }
- #endregion 列表选中赋值
- }
- //设置字体大小、字体内容排版、字体颜色、字体样式、字重
- public class FontBoardVm : BindableBase
- {
- #region 变量
- public List<ComboDataItem> FontFamilyItems { get; protected set; }
- public List<ComboDataItem> FontStyleItems { get; protected set; }
- public List<ComboDataItem> FontSizeItems { get; protected set; }
- public List<ComboDataItem> PresetFontItems { get; protected set; }
- public List<PresetFontItem> PresetFontList = new List<PresetFontItem>();
- public FontBoardVm(bool isInitdata)
- {
- if (isInitdata)
- InitBaseVariable();
- }
- #endregion 变量
- #region 初始化下拉框或列表默认的数据
- protected void InitBaseVariable()
- {
- InitBase_PresetFontStyles();
- InitBase_FontFamilys();
- InitBase_FontStyles();
- InitBase_FontSize();
- }
- private void InitBase_FontSize()
- {
- FontSizeItems = TextFont.GetFontSize();
- }
- //预设字体样式
- private void InitBase_PresetFontStyles()
- {
- PresetFontItems = new List<ComboDataItem>();
- PresetFontList = TextFont.GetCachePresetFontList();
- foreach (var item in PresetFontList)
- {
- ComboDataItem itemData = new ComboDataItem(item.mTag, item.mTagContent);
- PresetFontItems.Add(itemData);
- }
- }
- //字体
- private void InitBase_FontFamilys()
- {
- FontFamilyItems = TextFont.GetFamily();
- }
- //字重
- private void InitBase_FontStyles()
- {
- FontStyleItems = TextFont.GetFontStyle();
- }
- #endregion 初始化下拉框或列表默认的数据
- #region 属性
- /// <summary>
- /// 预设样式
- /// </summary>
- private ComboDataItem _currentPresetFont = new ComboDataItem("Custom", "Custom");
- public ComboDataItem CurrentPresetFont
- {
- get { return _currentPresetFont; }
- set
- {
- SetProperty(ref _currentPresetFont, value);
- switch (value.ValueStr.ToString())
- {
- case "Custom":
- PresetFontSelectedIndex = 0;
- break;
- case "H1":
- PresetFontSelectedIndex = 1;
- break;
- case "H2":
- PresetFontSelectedIndex = 2;
- break;
- case "H3":
- PresetFontSelectedIndex = 3;
- break;
- case "B1":
- PresetFontSelectedIndex = 4;
- break;
- case "B2":
- PresetFontSelectedIndex = 5;
- break;
- case "B3":
- PresetFontSelectedIndex = 6;
- break;
- default:
- PresetFontSelectedIndex = 0;
- break;
- }
- }
- }
- private int presetFontSelectedIndex;
- public int PresetFontSelectedIndex
- {
- get { return presetFontSelectedIndex; }
- set
- {
- SetProperty(ref presetFontSelectedIndex, value);
- }
- }
- #region 字体样式
- //下拉框列表
- private ComboDataItem _currentFontFamily = new ComboDataItem("Arial", "Arial");
- public ComboDataItem CurrentFontFamily
- {
- get { return _currentFontFamily; }
- set
- {
- SetProperty(ref _currentFontFamily, value);
- switch (value.Content.ToString())
- {
- case "Courier New":
- FontFamilySelectedIndex = 0;
- break;
- case "Arial":
- FontFamilySelectedIndex = 1;
- break;
- case "Times New Roman":
- FontFamilySelectedIndex = 2;
- break;
- case "Adobe Devanagari":
- FontFamilySelectedIndex = 3;
- break;
- }
- }
- }
- private int fontFamilySelectedIndex;
- public int FontFamilySelectedIndex
- {
- get { return fontFamilySelectedIndex; }
- set
- {
- SetProperty(ref fontFamilySelectedIndex, value);
- }
- }
- #endregion 字体样式
- #region 字体大小
- private int fontSizeSelectedIndex;
- public int FontSizeSelectedIndex
- {
- get { return fontSizeSelectedIndex; }
- set
- {
- SetProperty(ref fontSizeSelectedIndex, value);
- }
- }
- //下拉框列表:字体大小
- private ComboDataItem _currentFontSize = new ComboDataItem(6);
- public ComboDataItem CurrentFontSize
- {
- get { return _currentFontSize; }
- set
- {
- SetProperty(ref _currentFontSize, value);
- switch (value.Value)
- {
- case 8:
- FontSizeSelectedIndex = 0;
- break;
- case 9:
- FontSizeSelectedIndex = 1;
- break;
- case 10:
- FontSizeSelectedIndex = 2;
- break;
- case 11:
- FontSizeSelectedIndex = 3;
- break;
- case 12:
- FontSizeSelectedIndex = 4;
- break;
- case 14:
- FontSizeSelectedIndex = 5;
- break;
- case 16:
- FontSizeSelectedIndex = 6;
- break;
- case 18:
- FontSizeSelectedIndex = 7;
- break;
- case 20:
- FontSizeSelectedIndex = 8;
- break;
- case 22:
- FontSizeSelectedIndex = 9;
- break;
- case 24:
- FontSizeSelectedIndex = 10;
- break;
- case 26:
- FontSizeSelectedIndex = 11;
- break;
- case 28:
- FontSizeSelectedIndex = 12;
- break;
- case 36:
- FontSizeSelectedIndex = 13;
- break;
- case 48:
- FontSizeSelectedIndex = 14;
- break;
- case 72:
- FontSizeSelectedIndex = 15;
- break;
- default:
- //FontSizeSelectedIndex = 0;
- //FontSizeSelectedIndex = -1;
- break;
- }
- }
- }
- #endregion 字体大小
- //FontStyle & FontWeight
- private FontStyle _fontStyleItem;
- public FontStyle FontStyleItem
- {
- get { return _fontStyleItem; }
- set { SetProperty(ref _fontStyleItem, value); }
- }
- private FontWeight _fontWeight;
- public FontWeight FontWeightItem
- {
- get { return _fontWeight; }
- set { SetProperty(ref _fontWeight, value); }
- }
- private int fontStyleSelectedIndex;
- public int FontStyleSelectedIndex
- {
- get { return fontStyleSelectedIndex; }
- set
- {
- SetProperty(ref fontStyleSelectedIndex, value);
- }
- }
- private ComboDataItem _currrentFontWeightStyle = new ComboDataItem("Regular", "Regular");
- public ComboDataItem CurrrentFontWeightStyle
- {
- get { return _currrentFontWeightStyle; }
- set
- {
- SetProperty(ref _currrentFontWeightStyle, value);
- switch (value.Content.ToString())
- {
- case "Regular":
- FontStyleSelectedIndex = 0;
- break;
- case "Bold":
- FontStyleSelectedIndex = 1;
- break;
- case "Italic":
- FontStyleSelectedIndex = 2;
- break;
- case "Bold Italic":
- FontStyleSelectedIndex = 3;
- break;
- }
- }
- }
- public void UpdateFontWeight_Style()
- {
- switch (CurrrentFontWeightStyle.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 string _strtextAlign;
- public string StrTextAlign
- {
- get { return _strtextAlign; }
- set { SetProperty(ref _strtextAlign, value); }
- }
- //颜色
- private Brush _fontColor = new SolidColorBrush(Colors.Black);
- public Brush FontColor
- {
- get { return _fontColor; }
- set { SetProperty(ref _fontColor, value); CurrentFontColor = _fontColor; }
- }
- private Brush _currentFontColor = new SolidColorBrush(Colors.Transparent);
- public Brush CurrentFontColor
- {
- get { return _currentFontColor; }
- set => SetProperty(ref _currentFontColor, value);
- }
- //外部UI引用,判断是否选中左对齐、居中对齐、右对齐,或都不选中
- public string strAglinState { get; private set; }
- //VM赋值
- public void SetStrAglinState(string str)
- {
- strAglinState = str;
- }
- #endregion 属性
- #region 列表选中赋值
- public void GetFontWeights_Style(FontStyle fontStyle, FontWeight fontWeights)
- {
- string strValue = "";
- string strContent = "";
- if (fontStyle == FontStyles.Normal)
- {
- if (fontWeights == FontWeights.Normal)
- {
- strValue = "Regular";
- strContent = "Regular";
- }
- else
- {
- strValue = "Bold";
- strContent = "Bold";
- }
- }
- else
- {
- if (fontWeights == FontWeights.Normal)
- {
- strValue = "Italic";
- strContent = "Italic";
- }
- else
- {
- strValue = "Bold Italic";
- strContent = "Bold Italic";
- }
- }
- CurrrentFontWeightStyle = new ComboDataItem(strValue, strContent);
- UpdateFontWeight_Style();
- }
- public void GetCurrentFontSize(int size)
- {
- CurrentFontSize = new ComboDataItem(size);
- }
- public void GetCurrentFontFamily(string fontFamily, string uiStr)
- {
- if (fontFamily == "Arial")
- {
- fontFamily = "Arial";
- uiStr = "Arial";
- }
- if (fontFamily == "Times-Roman")
- {
- uiStr = "Times New Roman";
- }
- if (fontFamily == "CourierNew")
- {
- uiStr = "Courier New";
- }
- if (fontFamily == "AdobeDevanagari")
- {
- uiStr = "Adobe Devanagari";
- }
- CurrentFontFamily = new ComboDataItem(fontFamily, uiStr);
- }
- public void GetCurrentPresetFont(string presetFont, string uiStr)
- {
- CurrentPresetFont = new ComboDataItem(presetFont, uiStr);
- }
- internal bool GetCurrentPresetFont(FreeTextAnnotArgs annot)
- {
- bool isExist = false;
- //List<PresetFontItem> presetFontItems = TextFont.GetCachePresetFontList();
- foreach (var item in PresetFontList)
- {
- if (annot.FontSize == item.mFontSize && annot.IsBold == (item.mFontWeight==FontWeights.Bold) && annot.IsItalic == (item.mFontStyle==FontStyles.Italic)
- && (annot.FontName == item.mFontFamily.Source || annot.FontName == "Arial" && item.mFontFamily.Source == "Arial")
- )
- {
- if (item.mTag != "Custom")
- {
- CurrentPresetFont = new ComboDataItem(item.mTag, item.mTagContent);
- isExist = true;
- }
- break;
- }
- }
- return isExist;
- }
- #endregion 列表选中赋值
- }
- }
|