فهرست منبع

编辑 -获取预设字体,需要做处理,有些字体带空格,不做处理无法识别

OYXH\oyxh 1 سال پیش
والد
کامیت
96ce0fa30e
2فایلهای تغییر یافته به همراه75 افزوده شده و 19 حذف شده
  1. 63 7
      PDF Office/ViewModels/PropertyPanel/PDFEdit/TextEditPropertyViewModel.cs
  2. 12 12
      PDFSettings/DefaultEditProperty.cs

+ 63 - 7
PDF Office/ViewModels/PropertyPanel/PDFEdit/TextEditPropertyViewModel.cs

@@ -181,7 +181,11 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
 
                         if (item.mFontFamily != null)
                         {
-                            GetCurrentFontFamily(item.mFontFamily.ToString(), item.mFontFamily.ToString());
+                            //GetCurrentFontFamily(item.mFontFamily.ToString(), item.mFontFamily.ToString());
+                            if (GetCurrentFontFamily(item) == false)
+                            {
+                                GetCurrentFontFamily(item.mFontFamily.ToString(), item.mFontFamily.ToString());
+                            }
                         }
                         GetFontWeights_Style(item.mFontStyle, item.mFontWeight);
                         //CurrentFontSize = new ComboDataItem(TextEditEvent.FontSize);
@@ -193,6 +197,26 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             }
         }
 
+        /// <summary>
+        /// 编辑 获取预设字体,需要做处理,有些字体带空格,不做处理无法识别
+        /// </summary>
+        /// <param name="item"></param>
+        /// <returns></returns>
+        private bool GetCurrentFontFamily(PresetFontItem item)
+        {
+            DefaultEditProperty defaultEdit = SettingHelper.GetPDFEditDefaultProperty(CPDFEditType.EditText);
+            if (defaultEdit != null && defaultEdit.SystemFontNameList != null)
+            {
+                List<string> itemq = defaultEdit.SystemFontNameList.FindAll(p => p.Replace(" ", "").Equals(item.mFontFamily.ToString()));
+                if (itemq != null && itemq.Count > 0)
+                {
+                    GetCurrentFontFamily(item.mFontFamily.ToString(), itemq[0]);
+                    return true;
+                }
+            }
+            return false;
+        }
+
         /// <summary>
         /// 自定义文字样式
         /// </summary>
@@ -400,7 +424,11 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
                         currentItem.mFontWeight = defaulItem.mFontWeight;
                         currentItem.mFontFamily = defaulItem.mFontFamily;
                         currentItem.mFontSize = defaulItem.mFontSize;
-                        GetCurrentFontFamily(currentItem.mFontFamily.ToString(), currentItem.mFontFamily.ToString());
+                        //GetCurrentFontFamily(currentItem.mFontFamily.ToString(), currentItem.mFontFamily.ToString());
+                        if (GetCurrentFontFamily(currentItem) == false)
+                        {
+                            GetCurrentFontFamily(currentItem.mFontFamily.ToString(), currentItem.mFontFamily.ToString());
+                        }
                         GetCurrentFontSize(currentItem.mFontSize);
                         GetFontWeights_Style(currentItem.mFontStyle, currentItem.mFontWeight);
                         CurrentPresetFont = new ComboDataItem(defaulItem.mTag, defaulItem.mTagContent);
@@ -723,7 +751,11 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
                         FontStyleItem = FontStyles.Normal;
                         FontWeightItem = FontWeights.Normal;
 
-                        GetCurrentFontFamily(currentItem.mFontFamily.ToString(), currentItem.mFontFamily.ToString());
+                        //GetCurrentFontFamily(currentItem.mFontFamily.ToString(), currentItem.mFontFamily.ToString());
+                        if (GetCurrentFontFamily(currentItem) == false)
+                        {
+                            GetCurrentFontFamily(currentItem.mFontFamily.ToString(), currentItem.mFontFamily.ToString());
+                        }
                         GetCurrentFontSize(currentItem.mFontSize);
                         GetFontWeights_Style(currentItem.mFontStyle, currentItem.mFontWeight);
                         SelectedPresetFont();
@@ -854,11 +886,19 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
         //获取文本参数
         private void GetPDFEdit()
         {
+            DefaultEditProperty defaultEdit = SettingHelper.GetPDFEditDefaultProperty(CPDFEditType.EditText);
             if (!App.IsGetTextFamily)
             {
                 if (TextEditEvent.SystemFontNameList.Count > 0)
                 {
                     EditHelper.FontFamily = TextEditEvent.SystemFontNameList;
+
+                    if (defaultEdit != null)
+                    {
+                        defaultEdit.SystemFontNameList = TextEditEvent.SystemFontNameList;
+                        SettingHelper.SetPDFEditProperty(defaultEdit);
+                        Settings.Default.Save();
+                    }
                     App.IsGetTextFamily = true;
                 }
                 InitBase_FontFamilys();
@@ -882,9 +922,17 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
                 {
                     itemmFontFamily = "Times-Roman";
                 }
+                if (defaultEdit != null && defaultEdit.SystemFontNameList != null)
+                {
+                    List<string> itemq = defaultEdit.SystemFontNameList.FindAll(p => p.Replace(" ", "").Equals(item.mFontFamily.ToString()));
+                    if (itemq != null && itemq.Count > 0)
+                    {
+                        itemmFontFamily = itemq[0];
+                    }
+                }
                 if (TextEditEvent.FontSize == item.mFontSize && TextEditEvent.IsBold == (item.mFontWeight == FontWeights.Bold) && TextEditEvent.IsItalic == (item.mFontStyle == FontStyles.Italic)
-                    && (TextEditEvent.FontName == itemmFontFamily || TextEditEvent.FontName == "Arial")
-                    )
+            && (TextEditEvent.FontName == itemmFontFamily || TextEditEvent.FontName == "Arial")
+            )
                 {
                     if (item.mTag != "Custom")
                     {
@@ -908,7 +956,12 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
                 }
                 else
                 {
-                    GetCurrentFontFamily(TextEditEvent.FontName, TextEditEvent.FontName);
+                    GetCurrentFontFamily(TextEditEvent.FontName.Replace(" ", ""), TextEditEvent.FontName);
+                    //List<ComboDataItem> itemq = FontFamilyItems.FindAll(p => p.ValueStr == currentItem.mFontFamily.ToString());
+                    //if (itemq != null && itemq.Count > 0)
+                    //{
+                    //    GetCurrentFontFamily(TextEditEvent.FontName, itemq[0].Content);
+                    //}
                 }
                 GetFontWeights_Style(TextEditEvent.IsItalic ? FontStyles.Italic : FontStyles.Normal, TextEditEvent.IsBold ? FontWeights.Bold : FontWeights.Normal);
             }
@@ -926,7 +979,10 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
                             GetCurrentFontSize(item.mFontSize);
                             if (item.mFontFamily != null)
                             {
-                                GetCurrentFontFamily(item.mFontFamily.ToString(), item.mFontFamily.ToString());
+                                if (GetCurrentFontFamily(item) == false)
+                                {
+                                    GetCurrentFontFamily(item.mFontFamily.ToString(), item.mFontFamily.ToString());
+                                }
                             }
                             GetFontWeights_Style(TextEditEvent.IsItalic ? FontStyles.Italic : FontStyles.Normal, TextEditEvent.IsBold ? FontWeights.Bold : FontWeights.Normal);
                         }

+ 12 - 12
PDFSettings/DefaultEditProperty.cs

@@ -12,20 +12,20 @@ namespace PDFSettings
 {
     public class DefaultEditProperty
     {
-        public bool IsItalic { get; set; } 
+        public bool IsItalic { get; set; }
         public bool ClipImage { get; set; }
-        public bool HorizontalMirror { get; set; } 
-        public bool VerticalMirror { get; set; } 
-        public List<string> SystemFontNameList { get; }
-        public int Transparency { get; set; } 
-        public bool IsBold { get; set; } 
-        public string ReplaceImagePath { get; set; } 
-        public string FontName { get; set; } 
+        public bool HorizontalMirror { get; set; }
+        public bool VerticalMirror { get; set; }
+        public List<string> SystemFontNameList { get; set; }
+        public int Transparency { get; set; }
+        public bool IsBold { get; set; }
+        public string ReplaceImagePath { get; set; }
+        public string FontName { get; set; }
         public TextAlignType TextAlign { get; set; }
-        public Color FontColor { get; set; } 
-        public bool AutoBlock { get; set; } 
-        public double FontSize { get; set; } 
-        public CPDFEditType EditType { get; set; } 
+        public Color FontColor { get; set; }
+        public bool AutoBlock { get; set; }
+        public double FontSize { get; set; }
+        public CPDFEditType EditType { get; set; }
         public int Rotate { get; set; } = 0;
         public string SaveKey;