فهرست منبع

文本 - 优化文本属性设置

chenrongqian@kdanmobile.com 2 سال پیش
والد
کامیت
89b1dde9eb

+ 118 - 15
PDF Office/Model/PropertyPanel/AnnotPanel/FontStyleItem.cs

@@ -1,4 +1,6 @@
 using PDF_Office.CustomControl.CompositeControl;
+using PDF_Office.Properties;
+using PDFSettings;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -9,26 +11,127 @@ using System.Windows.Media;
 
 namespace PDF_Office.Model.PropertyPanel.AnnotPanel
 {
-    #region 自定义文字样式选项
 
-    public class PresetFontItem
+    public class TextFont
     {
-        public string mTag { get; set; }
-
-        public string mTagContent { get; set; }
-        public int mFontSize { get; set; }
-        public FontFamily mFontFamily { get; set; }
-        public FontStyle mFontStyle { get; set; }
-        public FontWeight mFontWeight { get; set; }
+        //获取本地缓存数据
+        public static List<PresetFontItem> GetCachePresetFontList()
+        {
+            List<PresetFontItem> cacheTempList = new List<PresetFontItem>();
+
+            if (Settings.Default.PresetFontList == null)
+                Settings.Default.PresetFontList = new PresetFontList();
+
+            if (Settings.Default.PresetFontList.Count == 0)
+            {
+                cacheTempList = GetPresetFontStyle();
+                foreach(var cacheItem in cacheTempList)
+                {
+                    var newItem = new PresetFontItem();
+                    newItem.mTag = cacheItem.mTag;
+                    newItem.mTagContent = cacheItem.mTagContent;
+                    newItem.mFontStyle = cacheItem.mFontStyle;
+                    newItem.mFontWeight = cacheItem.mFontWeight;
+                    newItem.mFontSize = cacheItem.mFontSize;
+                    Settings.Default.PresetFontList.Add(newItem);
+                }
+
+                Settings.Default.Save();
+            }
+            else
+            {
+                foreach (var item in Settings.Default.PresetFontList)
+                {
+                    var newItem = new PresetFontItem();
+                    newItem.mTag = item.mTag;
+                    newItem.mTagContent = item.mTagContent;
+                    newItem.mFontStyle = item.mFontStyle;
+                    newItem.mFontWeight = item.mFontWeight;
+                    newItem.mFontSize = item.mFontSize;
+                    cacheTempList.Add(newItem);
+                }
+            }
+
+            return cacheTempList;
+        }
 
-    }
+        //保存到本地缓存数据
+        public static void SavePresetFontList(List<PresetFontItem> list)
+        {
+            if (list == null) return;
+
+           if(Settings.Default.PresetFontList == null)
+                Settings.Default.PresetFontList = new PresetFontList();
+
+            bool isCanSave = false;
+            List<PresetFontItem> TempLists = new List<PresetFontItem>();
+
+           foreach (var item in list)
+            {
+                var cacheItem = Settings.Default.PresetFontList.FirstOrDefault(temp => temp.mTag == item.mTag);
+                if (cacheItem != null)
+                {
+                    if(cacheItem.mFontFamily != item.mFontFamily ||
+                       cacheItem.mFontSize != item.mFontSize ||
+                       cacheItem.mFontStyle != item.mFontStyle ||
+                       cacheItem.mFontWeight != item.mFontWeight
+                        )
+                    {
+                        isCanSave = true;
+                        
+                    }
+                    break;
+                }
+                else
+                {
+                    TempLists.Add(item);
+                }
+            }
+
+            foreach(var itemTemp in TempLists)
+            {
+                Settings.Default.PresetFontList.Add(itemTemp);
+            }
+
+            if (isCanSave)
+                Settings.Default.Save();
+        }
 
-    #endregion
+        public static void BackDefaultPresetFontStyle(string tag)
+        {
+            bool isCanSave = false;
+           var list = GetPresetFontStyle();
+            var itemDefault = list.FirstOrDefault(temp => temp.mTag == tag);
+            if (Settings.Default.PresetFontList == null)
+                Settings.Default.PresetFontList = new PresetFontList();
+            if(Settings.Default.PresetFontList.Count == 0)
+            {
+                Settings.Default.PresetFontList.Add(itemDefault);
+                isCanSave = true;
+            }
+            else
+            {
+                foreach (var item in Settings.Default.PresetFontList)
+                {
+                    if (item.mTag == itemDefault.mTag)
+                    {
+                        item.mFontFamily = itemDefault.mFontFamily;
+                        item.mFontWeight = itemDefault.mFontWeight;
+                        item.mFontStyle = itemDefault.mFontStyle;
+                        item.mFontSize = itemDefault.mFontSize;
+                        isCanSave = true;
+                        break;
+                    }
+                }
+            }
+
+            if (isCanSave == true)
+                Settings.Default.Save();
 
+        }
 
-    public class TextFont
-    {
-        public static List<PresetFontItem> GetPresetFontStyle()
+        //获取拟定的预设样式
+        private static List<PresetFontItem> GetPresetFontStyle()
         {
             List<PresetFontItem> fontStyleList = new List<PresetFontItem>();
             PresetFontItem custom = new PresetFontItem();
@@ -53,7 +156,7 @@ namespace PDF_Office.Model.PropertyPanel.AnnotPanel
             h2.mTag = "H2";
             h2.mTagContent = "h2(标准)";
 
-            h2.mFontSize = 1248;
+            h2.mFontSize = 24;
             h2.mFontFamily = new FontFamily("Helvatica");
             h2.mFontStyle = FontStyles.Normal;
             h2.mFontWeight = FontWeights.Bold;

+ 1 - 1
PDF Office/PDF Office.csproj

@@ -497,7 +497,7 @@
     <Compile Include="ViewModels\PropertyPanel\AnnotPanel\SignatureCreateDialogViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\AnnotPanel\SnapshotEditMenuViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\AnnotPanel\StickyNotePropertyViewModel.cs" />
-    <Compile Include="ViewModels\PropertyPanel\FontSetModeVM.cs" />
+    <Compile Include="ViewModels\PropertyPanel\FontBoardVM.cs" />
     <Compile Include="ViewModels\PropertyPanel\PDFEdit\ImageEditPropertyViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\PDFEdit\ImageTextEditPropertyViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\PDFEdit\PDFEditVM.cs" />

+ 12 - 1
PDF Office/Properties/Settings.Designer.cs

@@ -12,7 +12,7 @@ namespace PDF_Office.Properties {
     
     
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.1.0.0")]
     internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
         
         private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -202,5 +202,16 @@ namespace PDF_Office.Properties {
                 this["RedactionsSettings"] = value;
             }
         }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::PDFSettings.PresetFontList PresetFontList {
+            get {
+                return ((global::PDFSettings.PresetFontList)(this["PresetFontList"]));
+            }
+            set {
+                this["PresetFontList"] = value;
+            }
+        }
     }
 }

+ 3 - 0
PDF Office/Properties/Settings.settings

@@ -50,5 +50,8 @@
     <Setting Name="RedactionsSettings" Type="PDFSettings.RedactionSettings" Scope="User">
       <Value Profile="(Default)" />
     </Setting>
+    <Setting Name="PresetFontList" Type="PDFSettings.PresetFontList" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
   </Settings>
 </SettingsFile>

+ 201 - 197
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreetextAnnotPropertyViewModel.cs

@@ -4,6 +4,7 @@ using PDF_Office.CustomControl.CompositeControl;
 using PDF_Office.Model;
 using PDF_Office.Model.PropertyPanel.AnnotPanel;
 using PDF_Office.ViewModels.Tools;
+using PDFSettings;
 using Prism.Commands;
 using Prism.Mvvm;
 using Prism.Regions;
@@ -18,8 +19,15 @@ using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 {
-    public class FreetextAnnotPropertyViewModel : BindableBase, INavigationAware
+    public class FreetextAnnotPropertyViewModel : FontBoard, INavigationAware
     {
+        private bool isSelectedEmpty;
+        public bool IsSelectedEmpty
+        {
+            get { return isSelectedEmpty; }
+            set { SetProperty(ref isSelectedEmpty, value); }
+        }
+
         private double fillOpacity = 1;
         public double FillOpacity
         {
@@ -30,18 +38,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
-        private Brush selectColor = new SolidColorBrush(Colors.Black);
-        public Brush SelectColor
-        {
-            get { return selectColor; }
-            set
-            {
-                SetProperty(ref selectColor, value);
-                AnnotEvent?.UpdateAttrib(AnnotAttrib.FontColor, (selectColor as SolidColorBrush).Color);
-                AnnotEvent?.UpdateAnnot();
-            }
-        }
-
         private Brush fillColor = new SolidColorBrush(Colors.Transparent);
         public Brush FillColor
         {
@@ -54,147 +50,71 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
-        private FontFamily fontFamily = new FontFamily("Courier");
-        public FontFamily TextFontFamily
-        {
-            get { return fontFamily; }
-            set
-            {
-                SetProperty(ref fontFamily, value);
-            }
-        }
-
-        private FontWeight fontWeights = FontWeights.Normal;
-        public FontWeight TextFontWeights
-        {
-            get { return fontWeights; }
-            set
-            {
-                SetProperty(ref fontWeights, value);
-            }
-        }
-
-        private FontStyle fontStyle = FontStyles.Normal;
-        public FontStyle TextFontStyle
-        {
-            get { return fontStyle; }
-            set
-            {
-                SetProperty(ref fontStyle, value);
-            }
-        }
-
-
-        private int fontSize = 24;
-        public int TextFontSize
-        {
-            get { return fontSize; }
-            set
-            {
-                SetProperty(ref fontSize, value);
-            }
-        }
-
-        private List<PresetFontItem> fontStyleList = new List<PresetFontItem>();
-        public List<PresetFontItem> FontStyleList
-        {
-            get { return fontStyleList; }
-            set
-            {
-                SetProperty(ref fontStyleList, value);
-            }
-        }
-
-        private ComboDataItem _presetTextData;
-        public ComboDataItem PresetTextData
-        {
-            get { return _presetTextData; }
-            set
-            {
-                SetProperty(ref _presetTextData, value);
-                if (_presetTextData != null && FontStyleList != null)
-                {
-
-                }
-            }
-        }
-
-        private ComboDataItem _fontSizeData = new ComboDataItem(6);
-        public ComboDataItem FontSizeData
-        {
-            get { return _fontSizeData; }
-            set
-            {
-                SetProperty(ref _fontSizeData, value);
-            }
-        }
-
-        private ComboDataItem _fontFamilyData;
-        public ComboDataItem FontFamilyData
-        {
-            get { return _fontFamilyData; }
-            set
-            {
-                SetProperty(ref _fontFamilyData, value);
-            }
-        }
-
-        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)
-                {
-                    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 FontFamily fontFamily = new FontFamily("Courier");
+        //public FontFamily TextFontFamily
+        //{
+        //    get { return fontFamily; }
+        //    set
+        //    {
+        //        SetProperty(ref fontFamily, value);
+        //    }
+        //}
+
+        //private FontWeight fontWeights = FontWeights.Normal;
+        //public FontWeight TextFontWeights
+        //{
+        //    get { return fontWeights; }
+        //    set
+        //    {
+        //        SetProperty(ref fontWeights, value);
+        //    }
+        //}
+
+        //private FontStyle fontStyle = FontStyles.Normal;
+        //public FontStyle TextFontStyle
+        //{
+        //    get { return fontStyle; }
+        //    set
+        //    {
+        //        SetProperty(ref fontStyle, 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;
+        //            }
                     
-                }
-            }
-        }
-
-
-        public List<ComboDataItem> PresetTextItems { get; private set; }
-        public List<ComboDataItem> FontFamilyItems { get; private set; }
-        public List<ComboDataItem> FontStyleItems { get; private set; }
-
+        //        }
+        //    }
+        //}
         public DelegateCommand<object> SelectedFillOpacityCommand { get; set; }
         public DelegateCommand<object> SelectedFontStyleCommand { get; set; }
         public DelegateCommand<object> SelectedColorCommand { get; set; }
@@ -205,8 +125,11 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         public DelegateCommand<object> TextAlignCheckedCommand { get; set; }
         public DelegateCommand<object> LineModeCheckedCommand { get; set; }
         public DelegateCommand<object> SelectedOpacityValueCommand { get; set; }
-        
 
+        public DelegateCommand CustomFontStyleCommand { get; set; }
+
+        public DelegateCommand ReDefineFontStyleCommand { get; set; }
+        public DelegateCommand RestoreDefaultStyleCommand { get; set; }
 
         public event EventHandler<object> LoadPropertyHandler;
 
@@ -222,6 +145,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             TextAlignCheckedCommand = new DelegateCommand<object>(TextAlignChecked);
             LineModeCheckedCommand = new DelegateCommand<object>(LineMode_Checked);
             SelectedOpacityValueCommand = new DelegateCommand<object>(SelectedOpacityValue);
+
+            CustomFontStyleCommand = new DelegateCommand(CustomFontStyle);
+            ReDefineFontStyleCommand = new DelegateCommand(ReDefineFontStyle);
+            RestoreDefaultStyleCommand = new DelegateCommand(RestoreDefaultStyle);
             InitVariable();
         }
 
@@ -244,13 +171,13 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
         private void InitFontStyles()
         {
-            PresetTextItems = new List<ComboDataItem>();
-            FontStyleList = TextFont.GetPresetFontStyle();
+            PresetFontItems = new List<ComboDataItem>();
+            PresetFontList = TextFont.GetCachePresetFontList();
 
-            foreach (var item in FontStyleList)
+            foreach (var item in PresetFontList)
             {
                 ComboDataItem itemData = new ComboDataItem(item.mTag, item.mTagContent);
-                PresetTextItems.Add(itemData);
+                PresetFontItems.Add(itemData);
             }
         }
 
@@ -299,7 +226,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
         
-
         private void SelectedFontStyle(object obj)
         {
             if (obj != null && (PresetFontItem)obj != null)
@@ -346,7 +272,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 if (content != null)
                 {
                     var intData = int.Parse(content);
-                    TextFontSize = intData;
                     AnnotEvent?.UpdateAttrib(AnnotAttrib.FontSize, intData);
                    
                     AnnotEvent?.UpdateAnnot();
@@ -366,8 +291,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                     {
                         AnnotEvent?.UpdateAttrib(AnnotAttrib.FontStyle, FontStyles.Normal);
                         AnnotEvent?.UpdateAttrib(AnnotAttrib.FontWeight, FontWeights.Normal);
-                        TextFontWeights = FontWeights.Normal;
-                        TextFontStyle = FontStyles.Normal;
+                       // TextFontWeights = FontWeights.Normal;
+                        //TextFontStyle = FontStyles.Normal;
                     }
 
 
@@ -375,8 +300,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                     {
                         AnnotEvent?.UpdateAttrib(AnnotAttrib.FontStyle, FontStyles.Normal);
                         AnnotEvent?.UpdateAttrib(AnnotAttrib.FontWeight, FontWeights.Bold);
-                        TextFontWeights = FontWeights.Bold;
-                        TextFontStyle = FontStyles.Normal;
+                        //TextFontWeights = FontWeights.Bold;
+                       // TextFontStyle = FontStyles.Normal;
                     }
 
 
@@ -384,16 +309,16 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                     {
                         AnnotEvent?.UpdateAttrib(AnnotAttrib.FontStyle, FontStyles.Italic);
                         AnnotEvent?.UpdateAttrib(AnnotAttrib.FontWeight, FontWeights.Normal);
-                        TextFontWeights = FontWeights.Normal;
-                        TextFontStyle = FontStyles.Italic;
+                       // TextFontWeights = FontWeights.Normal;
+                       // TextFontStyle = FontStyles.Italic;
                     }
 
                     if (content == "Bold Italic")
                     {
                         AnnotEvent?.UpdateAttrib(AnnotAttrib.FontStyle, FontStyles.Italic);
                         AnnotEvent?.UpdateAttrib(AnnotAttrib.FontWeight, FontWeights.Bold);
-                        TextFontWeights = FontWeights.Bold;
-                        TextFontStyle = FontStyles.Italic;
+                        //TextFontWeights = FontWeights.Bold;
+                       // TextFontStyle = FontStyles.Italic;
                     }
 
                     AnnotEvent?.UpdateAnnot();
@@ -403,34 +328,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
         private void FontFamilyChanged_Command(object obj)
         {
-            if (obj != null)
-            {
-                if ((int)obj > -1)
-                {
-                    if ((int)obj == 0)
-                    {
-                        AnnotEvent?.UpdateAttrib(AnnotAttrib.FontFamily, new FontFamily("Courier"));
-                        TextFontFamily = new FontFamily("Courier");
-                    }
-                        
-
-                    if ((int)obj == 1)
-                    {
-                        TextFontFamily = new FontFamily("Helvetica");
-                        AnnotEvent?.UpdateAttrib(AnnotAttrib.FontFamily, new FontFamily("Helvetica"));
-                    }
-                       
-
-                    if ((int)obj == 2)
-                    {
-                        TextFontFamily = new FontFamily("Times");
-                        AnnotEvent?.UpdateAttrib(AnnotAttrib.FontFamily, new FontFamily("Times"));
-                    }
-                       
-
-                    AnnotEvent?.UpdateAnnot();
-                }
-            }
 
         }
 
@@ -462,7 +359,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
                     SelectColor = new SolidColorBrush(colorValue);
                     SelectColor.Opacity = FillOpacity;
-
+                    
                     Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
                     changeData[AnnotArgsType.AnnotFreehand] = obj;
                     PropertyPanel.DataChangedInvoke(this, changeData);
@@ -470,6 +367,74 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
+        private void CustomFontStyle()
+        {
+            if (CurrentPresetFont != null)
+            {
+                ContextMenu menu;
+                if (CurrentPresetFont.ValueStr == "custom")
+                {
+                    menu = SelectAnnotContextMenu(false);
+                }
+                else
+                {
+                    menu = SelectAnnotContextMenu(true);
+                }
+
+                if (menu != null)
+                {
+                    menu.IsOpen = true;
+                }
+            }
+
+        }
+
+        private ContextMenu SelectAnnotContextMenu(bool isEnable)
+        {
+            var popMenu = App.Current.FindResource("CustomFontStyleFlyoutMenu") as ContextMenu;
+            if (popMenu != null && popMenu.Items.Count == 2)
+            {
+                //用所选部分重新定义
+                MenuItem menuItem = popMenu.Items[0] as MenuItem;
+                menuItem.IsEnabled = isEnable;
+                menuItem.Command = ReDefineFontStyleCommand;
+                //恢复默认预设样式
+                menuItem = popMenu.Items[1] as MenuItem;
+                menuItem.IsEnabled = isEnable;
+                menuItem.Command = RestoreDefaultStyleCommand;
+            }
+            return popMenu;
+        }
+
+        public List<PresetFontItem> FontStyleList = new List<PresetFontItem>();
+        private void ReDefineFontStyle()
+        {
+            var item = FontStyleList.FirstOrDefault(temp => temp.mTag == CurrentPresetFont.ValueStr);
+
+            if (CurrentFontFamily.ValueStr == "Bold")
+            {
+                item.mFontStyle = FontStyles.Normal;
+                item.mFontWeight = FontWeights.Bold;
+            }
+            else if (CurrentFontFamily.ValueStr == "Regular")
+            {
+                item.mFontStyle = FontStyles.Normal;
+                item.mFontWeight = FontWeights.Normal;
+            }
+            else
+            {
+                item.mFontStyle = FontStyles.Italic;
+                item.mFontWeight = FontWeights.Bold;
+            }
+
+            item.mFontSize = (int)CurrentFontSize.Value;
+        }
+
+        private void RestoreDefaultStyle()
+        {
+            var item = FontStyleList.FirstOrDefault(temp => temp.mTag == CurrentPresetFont.ValueStr);
+        }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -477,6 +442,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
         public void OnNavigatedFrom(NavigationContext navigationContext)
         {
+            IsCanSave = false;
+            ChangedValue -= FontMode_ChangedValue;
         }
 
         public AnnotAttribEvent AnnotEvent { get; set; }
@@ -490,6 +457,43 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 AnnotEvent = PropertyPanel.AnnotEvent;
                 Annot = PropertyPanel.annot as FreeTextAnnotArgs;
                 LoadPropertyHandler?.Invoke(this, Annot);
+                ChangedValue -= FontMode_ChangedValue;
+                ChangedValue += FontMode_ChangedValue;
+                IsCanSave = true;
+            }
+        }
+
+        private void FontMode_ChangedValue(object sender, FontSetModeType e)
+        {
+            if (sender != null)
+            {
+                switch (e)
+                {
+                    case FontSetModeType.PresetFontStyes:
+                        
+                        break;
+                    case FontSetModeType.FontFamilys:
+                      
+                        break;
+                    case FontSetModeType.FontSizes:
+                       
+                        break;
+                    case FontSetModeType.FontWeight_Style:
+                        UpdateFontWeight_Style();
+                    
+                        break;
+                    case FontSetModeType.FontColor:
+                        if (sender is Color == true)
+                        {
+                            AnnotEvent.UpdateAttrib(AnnotAttrib.FontColor, CurrentFontColor);
+                            AnnotEvent.UpdateAnnot();
+                        }
+
+                        break;
+
+                    case FontSetModeType.TextAlignment:
+                        break;
+                }
             }
         }
     }

+ 53 - 39
PDF Office/ViewModels/PropertyPanel/FontSetModeVM.cs

@@ -1,6 +1,7 @@
 using ComPDFKit.PDFAnnotation;
 using PDF_Office.CustomControl.CompositeControl;
 using PDF_Office.Model.PropertyPanel.AnnotPanel;
+using PDFSettings;
 using Prism.Mvvm;
 using System;
 using System.Collections.Generic;
@@ -23,16 +24,18 @@ namespace PDF_Office.ViewModels.PropertyPanel
         TextAlignment
 
     }
-    public class FontSetMode : BindableBase
+
+    //设置字体大小、字体内容排版、字体颜色、字体样式、字重
+    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> PresetTextItems { get; protected set; }
+        public List<ComboDataItem> PresetFontItems { get; protected set; }
 
-        public List<PresetFontItem> FontStyleList = new List<PresetFontItem>();
+        public List<PresetFontItem> PresetFontList = new List<PresetFontItem>();
 
         #endregion
 
@@ -43,16 +46,17 @@ namespace PDF_Office.ViewModels.PropertyPanel
             InitBase_FontFamilys();
             InitBase_FontStyles();
         }
+
         //预设字体样式
         private void InitBase_PresetFontStyles()
         {
-            PresetTextItems = new List<ComboDataItem>();
-            FontStyleList = TextFont.GetPresetFontStyle();
+            PresetFontItems = new List<ComboDataItem>();
+            PresetFontList = TextFont.GetCachePresetFontList();
 
-            foreach (var item in FontStyleList)
+            foreach (var item in PresetFontList)
             {
                 ComboDataItem itemData = new ComboDataItem(item.mTag, item.mTagContent);
-                PresetTextItems.Add(itemData);
+                PresetFontItems.Add(itemData);
             }
 
         }
@@ -71,17 +75,17 @@ namespace PDF_Office.ViewModels.PropertyPanel
 
         #region 属性
 
-        private ComboDataItem _presetTextData;
-        public ComboDataItem PresetTextData
+        private ComboDataItem _currentPresetFont;
+        public ComboDataItem CurrentPresetFont
         {
-            get { return _presetTextData; }
+            get { return _currentPresetFont; }
             set
             {
-                bool isChange = IsEqualStrComboData(_presetTextData, value);
-                SetProperty(ref _presetTextData, value);
+                bool isChange = IsEqualStrComboData(_currentPresetFont, value);
+                SetProperty(ref _currentPresetFont, value);
                 if (isChange)
                 {
-                    ChangedValue?.Invoke(_presetTextData.ValueStr, FontSetModeType.PresetFontStyes);
+                    ChangedValue?.Invoke(_currentPresetFont.ValueStr, FontSetModeType.PresetFontStyes);
                 }
             }
         }
@@ -89,18 +93,18 @@ namespace PDF_Office.ViewModels.PropertyPanel
         #region 字体样式
 
         //下拉框列表
-        private ComboDataItem _fontFamilyData;
-        public ComboDataItem FontFamilyData
+        private ComboDataItem _currentFontFamily;
+        public ComboDataItem CurrentFontFamily
         {
-            get { return _fontFamilyData; }
+            get { return _currentFontFamily; }
             set
             {
-                bool isChange = IsEqualStrComboData(_fontFamilyData, value);
-                SetProperty(ref _fontFamilyData, value);
+                bool isChange = IsEqualStrComboData(_currentFontFamily, value);
+                SetProperty(ref _currentFontFamily, value);
                 if (isChange)
                 {
 
-                    ChangedValue?.Invoke(_fontFamilyData.ValueStr, FontSetModeType.FontFamilys);
+                    ChangedValue?.Invoke(_currentFontFamily.ValueStr, FontSetModeType.FontFamilys);
                 }
             }
         }
@@ -108,20 +112,20 @@ namespace PDF_Office.ViewModels.PropertyPanel
 
         #region 字体大小
         //下拉框列表:字体大小
-        private ComboDataItem _fontSizeData = new ComboDataItem(6);
-        public ComboDataItem FontSizeData
+        private ComboDataItem _currentFontSize = new ComboDataItem(6);
+        public ComboDataItem CurrentFontSize
         {
-            get { return _fontSizeData; }
+            get { return _currentFontSize; }
             set
             {
-                bool isChange = IsEqualComboData(_fontSizeData, value);
+                bool isChange = IsEqualComboData(_currentFontSize, value);
 
                 if(isChange && value.Value > 0)
-                SetProperty(ref _fontSizeData, value);
+                SetProperty(ref _currentFontSize, value);
 
                 if (isChange && value.Value > 0)
                 {
-                    ChangedValue?.Invoke(_fontSizeData.Value, FontSetModeType.FontSizes);
+                    ChangedValue?.Invoke(_currentFontSize.Value, FontSetModeType.FontSizes);
                 }
             }
         }
@@ -145,24 +149,24 @@ namespace PDF_Office.ViewModels.PropertyPanel
             set { SetProperty(ref _fontWeight, value); }
         }
 
-        private ComboDataItem _fontWeightStyleItem;
-        public ComboDataItem FontWeightStyleItem
+        private ComboDataItem _currrentFontWeightStyle;
+        public ComboDataItem CurrrentFontWeightStyle
         {
-            get { return _fontWeightStyleItem; }
+            get { return _currrentFontWeightStyle; }
             set
             {
-                bool isChange = IsEqualStrComboData(_fontWeightStyleItem, value);
-                SetProperty(ref _fontWeightStyleItem, value);
+                bool isChange = IsEqualStrComboData(_currrentFontWeightStyle, value);
+                SetProperty(ref _currrentFontWeightStyle, value);
                 if (isChange)
                 {
-                    ChangedValue?.Invoke(_fontWeightStyleItem, FontSetModeType.FontWeight_Style);
+                    ChangedValue?.Invoke(_currrentFontWeightStyle, FontSetModeType.FontWeight_Style);
                 }
             }
         }
 
         protected void UpdateFontWeight_Style()
         {
-            switch (FontWeightStyleItem.ValueStr)
+            switch (CurrrentFontWeightStyle.ValueStr)
             {
                 case "Regular":
                     FontStyleItem = FontStyles.Normal;
@@ -203,20 +207,20 @@ namespace PDF_Office.ViewModels.PropertyPanel
                 SetProperty(ref selectColor, value);
                 if (IsCanSave)
                 {
+                    CurrentFontColor = (selectColor as SolidColorBrush).Color;
                     ChangedValue?.Invoke((selectColor as SolidColorBrush).Color, FontSetModeType.FontColor);
-                    CurrentColor = (selectColor as SolidColorBrush).Color;
                 }
                     
             }
         }
 
-        private Color currentColor = Colors.Black;
-        public Color CurrentColor
+        private Color _currentFontColor = Colors.Black;
+        public Color CurrentFontColor
         {
-            get { return currentColor; }
+            get { return _currentFontColor; }
             set
             {
-                SetProperty(ref currentColor, value);
+                SetProperty(ref _currentFontColor, value);
             }
         }
 
@@ -249,7 +253,7 @@ namespace PDF_Office.ViewModels.PropertyPanel
 
         #region 列表选中赋值
 
-        protected void SelectedFontWeights_Style(FontStyle fontStyle, FontWeight fontWeights)
+        protected void GetFontWeights_Style(FontStyle fontStyle, FontWeight fontWeights)
         {
             string strValue = "";
             string strContent = "";
@@ -283,9 +287,19 @@ namespace PDF_Office.ViewModels.PropertyPanel
                     
             }
 
-            FontWeightStyleItem = new ComboDataItem(strValue, strContent);
+            CurrrentFontWeightStyle = new ComboDataItem(strValue, strContent);
+        }
+
+
+        protected void GetCurrentFontSize(int size)
+        {
+            CurrentFontSize = new ComboDataItem(size);
         }
 
+        protected void GetCurrentFontFamily(string fontFamily,string uiStr)
+        {
+            CurrentFontFamily = new ComboDataItem(fontFamily, uiStr);
+        }
 
         #endregion
     }

+ 1 - 1
PDF Office/ViewModels/PropertyPanel/PDFEdit/PDFEditVM.cs

@@ -16,7 +16,7 @@ using System.Windows.Media;
 namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
 {
 
-    public class PDFEditVM: FontSetMode
+    public class PDFEditVM: FontBoard
     {
        
         #region 变量

+ 53 - 17
PDF Office/ViewModels/PropertyPanel/PDFEdit/TextEditPropertyViewModel.cs

@@ -5,6 +5,7 @@ using PDF_Office.CustomControl.CompositeControl;
 using PDF_Office.Helper;
 using PDF_Office.Model;
 using PDF_Office.Model.PropertyPanel.AnnotPanel;
+using PDFSettings;
 using Prism.Commands;
 using Prism.Mvvm;
 using Prism.Regions;
@@ -107,20 +108,53 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
 
         private void CustomFontStyle_Click()
         {
-            ContextMenu menu = SelectAnnotContextMenu();
-           if(menu != null)
+            if(CurrentPresetFont != null)
             {
-                menu.IsOpen = true;
+                ContextMenu menu;
+                if (CurrentPresetFont.ValueStr == "custom")
+                {
+                    menu = SelectAnnotContextMenu(false);
+                }
+                else
+                {
+                    menu = SelectAnnotContextMenu(true);
+                }
+               
+                if (menu != null)
+                {
+                    menu.IsOpen = true;
+                }
             }
+            
         }
         private void ReDefineFontStyle()
         {
 
+            var item = PresetFontList.FirstOrDefault(temp => temp.mTag == CurrentPresetFont.ValueStr);
+
+            if (CurrentFontFamily.ValueStr == "Bold")
+            {
+                item.mFontStyle = FontStyles.Normal;
+                item.mFontWeight = FontWeights.Bold;
+            }
+            else if (CurrentFontFamily.ValueStr == "Regular")
+            {
+                item.mFontStyle = FontStyles.Normal;
+                item.mFontWeight = FontWeights.Normal;
+            }
+            else
+            {
+                item.mFontStyle = FontStyles.Italic;
+                item.mFontWeight = FontWeights.Bold;
+            }
+
+            item.mFontSize = (int)CurrentFontSize.Value;
+
         }
 
         private void RestoreDefaultStyle()
         {
-
+            var item = PresetFontList.FirstOrDefault(temp => temp.mTag == CurrentPresetFont.ValueStr);
         }
 
         private void LayoutAlignChecked(object obj)
@@ -390,19 +424,19 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
             }
         }
         
-        private ContextMenu SelectAnnotContextMenu()
+        private ContextMenu SelectAnnotContextMenu(bool isEnable)
         {
             var popMenu = App.Current.FindResource("CustomFontStyleFlyoutMenu") as ContextMenu;
             if (popMenu != null && popMenu.Items.Count == 2)
             {
-                //剪切
+                //用所选部分重新定义
                 MenuItem menuItem = popMenu.Items[0] as MenuItem;
-               // menuItem.CommandTarget = (UIElement)sender;
-                //menuItem.Command = ApplicationCommands.Cut;
-                //复制
+                menuItem.IsEnabled = isEnable;
+                menuItem.Command = ReDefineFontStyleCommand;
+                //恢复默认预设样式
                 menuItem = popMenu.Items[1] as MenuItem;
-                //menuItem.CommandTarget = (UIElement)sender;
-               // menuItem.Command = ApplicationCommands.Copy;
+                menuItem.IsEnabled = isEnable;
+                menuItem.Command = RestoreDefaultStyleCommand;
             }
             return popMenu;
         }
@@ -462,9 +496,9 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
                 switch(e)
                 {
                     case FontSetModeType.PresetFontStyes:
-                        if(FontStyleList != null && sender  is string  == true)
+                        if(PresetFontList != null && sender  is string  == true)
                         {
-                            var item = FontStyleList.FirstOrDefault(temp => temp.mTag == (string)sender);
+                            var item = PresetFontList.FirstOrDefault(temp => temp.mTag == (string)sender);
                             if (item != null && TextEditEvent != null)
                             {
                                 if(TextEditEventList.Count == 1 && IsSelectedEmpty == false)
@@ -539,11 +573,13 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
             if (TextEditEvent != null && TextEditEventList.Count == 1)
             {
                 SelectColor = new SolidColorBrush(TextEditEvent.FontColor);
-                FontSizeData = new ComboDataItem(TextEditEvent.FontSize);
+
+                GetCurrentFontSize((int)TextEditEvent.FontSize);
+
                 if(TextEditEvent.FontFamily != null)
-                FontFamilyData = new ComboDataItem(TextEditEvent.FontFamily.ToString(), TextEditEvent.FontFamily.ToString());
-               
-                SelectedFontWeights_Style(TextEditEvent.FontStyle, TextEditEvent.FontWeight);
+                    GetCurrentFontFamily(TextEditEvent.FontFamily.ToString(), TextEditEvent.FontFamily.ToString());
+                
+                GetFontWeights_Style(TextEditEvent.FontStyle, TextEditEvent.FontWeight);
                 TextAlign = TextEditEvent.TextAlign;
 
 

+ 23 - 34
PDF Office/Views/PropertyPanel/AnnotPanel/FreetextAnnotProperty.xaml

@@ -11,7 +11,7 @@
              prism:ViewModelLocator.AutoWireViewModel="True"
              xmlns:Convert="clr-namespace:PDF_Office.DataConvert"
              xmlns:cus="clr-namespace:PDF_Office.CustomControl"
-             mc:Ignorable="d" 
+             mc:Ignorable="d"
              d:DesignHeight="850" d:DesignWidth="800">
     <UserControl.Resources>
         <ResourceDictionary>
@@ -41,20 +41,6 @@
                     </Setter.Value>
                 </Setter>
             </Style>
-            
-            <ContextMenu x:Key="BtnFlyoutMenu" FontSize="14"
-                        >
-                <ContextMenu.ItemContainerStyle>
-                    <Style TargetType="MenuItem">
-                        <Setter Property="Padding" Value="0,7,0,7"/>
-                        <Setter Property="VerticalContentAlignment" Value="Center"/>
-                    </Style>
-                </ContextMenu.ItemContainerStyle>
-                <MenuItem Name="ChangeStyleMenuItem"  Header="用所选部分重新定义" IsEnabled="True">
-                </MenuItem>
-                <MenuItem Name="BackStyleMenuItem"  Header="恢复默认预设样式" IsEnabled="True">
-                </MenuItem>
-            </ContextMenu>
 
             <DataTemplate x:Key="FontStyleData">
                 <Grid >
@@ -73,10 +59,10 @@
                             Background="{Binding FillColor}">
                         <TextBlock Name="SampleText"
                                    Foreground="{Binding SelectColor}" 
-                                   FontFamily="{Binding TextFontFamily}"
-                                   FontWeight="{Binding TextFontWeights}" 
-                                   FontStyle="{Binding TextFontStyle}"
-                                   FontSize="{Binding TextFontSize}" Opacity="{Binding FillOpacity}"
+                                   FontFamily="{Binding  CurrentFontFamily.ValueStr}"
+                                   FontWeight="{Binding FontWeightItem}" 
+                                   FontStyle="{Binding FontStyleItem}"
+                                   FontSize="{Binding CurrentFontSize.Value}" Opacity="{Binding FillOpacity}"
                                    Text="Sample" HorizontalAlignment="Center" VerticalAlignment="Center">
                         </TextBlock>
                     </Border>
@@ -99,25 +85,28 @@
 
             <Border
                     Height="32"
-                    Margin="0,8,0,18"
+                    Margin="15,8,15,18"
                     BorderBrush="#E2E3E6"
                     BorderThickness="0">
                 <Grid>
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition/>
+                        <ColumnDefinition Width="auto"/>
+                    </Grid.ColumnDefinitions>
                     <CompositeControl:CustomComboControl
                             x:Name="FontTitleBox"
                             Width="188"
                             Height="32"
                             HorizontalAlignment="Left"
                             IsValueContent="True"
-                            ItemSource="{Binding PresetTextItems}"
-                            SelectedItems="{Binding PresetTextData, Mode=TwoWay}" />
+                            ItemSource="{Binding PresetFontItems}"
+                            SelectedItems="{Binding CurrentPresetFont, Mode=TwoWay}" />
 
 
-                    <Button
+                    <Button Grid.Column="1"
                             Width="32"
                             Height="32"
-                            HorizontalAlignment="Right"
-                            ContextMenu="{StaticResource BtnFlyoutMenu}"
+                            HorizontalAlignment="Left" Command="{Binding CustomFontStyleCommand}"
                             Style="{StaticResource btn.sec}">
                         <Path
                                 Width="16"
@@ -128,10 +117,7 @@
                 </Grid>
             </Border>
 
-
-            <TextBlock x:Name="FontText"  FontFamily="Segoe UI Semibold" FontWeight="SemiBold" FontSize="14" LineHeight="20" Margin="12,18,0,0" >Font</TextBlock>
-
-            <StackPanel>
+            <StackPanel Margin="15,0,15,0">
                 <TextBlock
                         Margin="0,0,0,10"
                         Style="{StaticResource PropertyHeaderLv2}"
@@ -143,7 +129,8 @@
                             Height="32"
                             IsValueContent="True"
                             ItemSource="{Binding FontFamilyItems}"
-                            SelectedItems="{Binding FontFamilyData, Mode=TwoWay}" />
+                            IsSelectedEmpty ="{Binding IsSelectedEmpty}"
+                            SelectedItems="{Binding CurrentFontFamily, Mode=TwoWay}" />
 
                     <Grid Margin="0,8">
                         <CompositeControl:CustomComboControl
@@ -153,7 +140,8 @@
                                 HorizontalAlignment="Left"
                                 IsValueContent="True"
                                 ItemSource="{Binding FontStyleItems}"
-                                SelectedItems="{Binding FontWeightStyleItem, Mode=TwoWay}" />
+                                IsSelectedEmpty ="{Binding IsSelectedEmpty}"
+                                SelectedItems="{Binding CurrrentFontWeightStyle, Mode=TwoWay}" />
 
 
                         <CompositeControl:CustomComboControl
@@ -161,7 +149,8 @@
                                 Width="110"
                                 Height="32"
                                 HorizontalAlignment="Right"
-                                SelectedItems="{Binding FontSizeData, Mode=TwoWay}" />
+                                IsSelectedEmpty ="{Binding IsSelectedEmpty}"
+                                SelectedItems="{Binding CurrentFontSize, Mode=TwoWay}" />
                     </Grid>
                     <Grid>
                         <StackPanel Orientation="Horizontal">
@@ -370,7 +359,7 @@
                     </Grid>
                 </StackPanel>
             </StackPanel>
-            <Grid Margin="0,18,0,0">
+            <Grid Margin="15,18,15,0">
                 <Grid.RowDefinitions>
                     <RowDefinition Height="auto"/>
                     <RowDefinition/>
@@ -386,7 +375,7 @@
             </Grid>
 
 
-<!--MVP-->
+<!--MVP不上-->
 
             <TextBlock x:Name="thicknessText" Visibility="Collapsed" FontFamily="Segoe UI Semibold" FontWeight="SemiBold" FontSize="14" LineHeight="20" Margin="12,14,0,0" >Thickness</TextBlock>
 

+ 35 - 7
PDF Office/Views/PropertyPanel/AnnotPanel/FreetextAnnotProperty.xaml.cs

@@ -30,10 +30,10 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
             //FontFamilyBox.SelectionChanged += FontFamilyBox_SelectionChanged;
             //FontStyleBox.SelectionChanged += FontStyleBox_SelectionChanged;
             //FontSizeBox.SelectionChanged += FontSizeBox_SelectionChanged;
-            ThicknessBox.SelectionChanged += ThicknessBox_SelectionChanged; 
+           
             this.Loaded += usercontrol_Loaded;
-            cusColor.SelectedColorHandler += cusColor_SelectedColorHandler;
-           // layerThick.SelectedValueChanged += layerThick_SelectedValue;
+            this.Unloaded += usercontrol_Unloaded;
+            // layerThick.SelectedValueChanged += layerThick_SelectedValue;
         }
 
         private void usercontrol_Loaded(object sender, RoutedEventArgs e)
@@ -42,6 +42,27 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
             FontStyleBox.SelectedIndex = 0;
             FontSizeBox.SelectedIndex = 0;
             ThicknessBox.SelectedIndex = 0;
+            BindingEvent();
+        }
+
+        private void usercontrol_Unloaded(object sender, RoutedEventArgs e)
+        {
+            UnBindingEvent();
+        }
+
+        private void BindingEvent()
+        {
+            UnBindingEvent();
+            ThicknessBox.SelectionChanged += ThicknessBox_SelectionChanged;
+            cusColor.SelectedColorHandler += cusColor_SelectedColorHandler;
+            FontColorBox.SelectedColorHandler += FontColorBox_SelectedColorHandler;
+        }
+
+        private void UnBindingEvent()
+        {
+            ThicknessBox.SelectionChanged -= ThicknessBox_SelectionChanged;
+            cusColor.SelectedColorHandler -= cusColor_SelectedColorHandler;
+            FontColorBox.SelectedColorHandler -= FontColorBox_SelectedColorHandler;
         }
 
         private void ThicknessBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -128,14 +149,21 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
 
         private void FontColorBox_SelectedColorChanged(object sender, Color? e)
         {
-            var data = this.DataContext as FreetextAnnotPropertyViewModel;
-            data.SelectedColorCommand?.Execute(e);
+           
         }
 
         private void cusColor_SelectedColorHandler(object sender, Color e)
         {
-            var data = this.DataContext as FreetextAnnotPropertyViewModel; 
-            data.SelectedFillColorCommand?.Execute(e);
+            var data = this.DataContext as FreetextAnnotPropertyViewModel;
+            if (data != null)
+                data.SelectedFillColorCommand?.Execute(e);
+        }
+
+        private void FontColorBox_SelectedColorHandler(object sender, Color e)
+        {
+            var data = this.DataContext as FreetextAnnotPropertyViewModel;
+            if (data != null)
+                data.SelectedColorCommand?.Execute(e);
         }
 
 

+ 7 - 7
PDF Office/Views/PropertyPanel/PDFEdit/TextEditProperty.xaml

@@ -75,8 +75,8 @@
                                 Name="SampleText"
                                 HorizontalAlignment="Center"
                                 VerticalAlignment="Center"
-                                FontFamily="{Binding FontFamilyData.ValueStr}"
-                                FontSize="{Binding FontSizeData.Value}"
+                                FontFamily="{Binding CurrentFontFamily.ValueStr}"
+                                FontSize="{Binding CurrentFontSize.Value}"
                                 FontStyle="{Binding FontStyleItem}"
                                 FontWeight="{Binding FontWeightItem}"
                                 Foreground="{Binding SelectColor}"
@@ -126,8 +126,8 @@
                             HorizontalAlignment="Left"
                             IsValueContent="True"
                             IsSelectedEmpty ="{Binding IsSelectedEmpty}"
-                            ItemSource="{Binding PresetTextItems}"
-                            SelectedItems="{Binding PresetTextData, Mode=TwoWay}" />
+                            ItemSource="{Binding PresetFontItems}"
+                            SelectedItems="{Binding CurrentPresetFont, Mode=TwoWay}" />
 
                         <Button
                             Width="32"
@@ -156,7 +156,7 @@
                             IsValueContent="True"
                             IsSelectedEmpty ="{Binding IsSelectedEmpty}"
                             ItemSource="{Binding FontFamilyItems}"
-                            SelectedItems="{Binding FontFamilyData, Mode=TwoWay}" />
+                            SelectedItems="{Binding CurrentFontFamily, Mode=TwoWay}" />
 
                         <Grid Margin="0,8">
                             <CompositeControl:CustomComboControl
@@ -167,7 +167,7 @@
                                 IsValueContent="True"
                                 IsSelectedEmpty ="{Binding IsSelectedEmpty}"
                                 ItemSource="{Binding FontStyleItems}"
-                                SelectedItems="{Binding FontWeightStyleItem, Mode=TwoWay}" />
+                                SelectedItems="{Binding CurrrentFontWeightStyle, Mode=TwoWay}" />
 
 
                             <CompositeControl:CustomComboControl
@@ -176,7 +176,7 @@
                                 Height="32"
                                 HorizontalAlignment="Right"
                                 IsSelectedEmpty ="{Binding IsSelectedEmpty}"
-                                SelectedItems="{Binding FontSizeData, Mode=TwoWay}" />
+                                SelectedItems="{Binding CurrentFontSize, Mode=TwoWay}" />
                         </Grid>
                         <Grid>
                             <StackPanel Orientation="Horizontal">

+ 1 - 0
PDFSettings/PDFSettings.csproj

@@ -62,6 +62,7 @@
     <Compile Include="DpiHelpers.cs" />
     <Compile Include="BackgroundTemplateList.cs" />
     <Compile Include="PDFToolsList.cs" />
+    <Compile Include="PresetFontList.cs" />
     <Compile Include="ProductActiveInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="RecentOpenFiles.cs" />

+ 27 - 0
PDFSettings/PresetFontList.cs

@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+
+namespace PDFSettings
+{
+    public class PresetFontList : List<PresetFontItem>
+    {
+
+    }
+
+    public class PresetFontItem
+    {
+        public string mTag { get; set; }
+        public string mTagContent { get; set; }
+        public int mFontSize { get; set; }
+        public FontFamily mFontFamily { get; set; }
+        public FontStyle mFontStyle { get; set; }
+        public FontWeight mFontWeight { get; set; }
+
+    }
+
+}