Pārlūkot izejas kodu

编辑-文本编辑-支持设置多种字体、单击添加文本,Undo,Rndo刷新属性面板

lvle 1 gadu atpakaļ
vecāks
revīzija
0f092460e1

+ 145 - 39
PDF Office/Model/AnnotPanel/FontBoard.cs

@@ -40,6 +40,122 @@ namespace PDF_Master.Model.AnnotPanel
 
         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 初始化下拉框或列表默认的数据
@@ -164,7 +280,7 @@ namespace PDF_Master.Model.AnnotPanel
         #region 字体样式
 
         //下拉框列表
-        private ComboDataItem _currentFontFamily = new ComboDataItem("Helvetica", "Helvetica");
+        private ComboDataItem _currentFontFamily = new ComboDataItem("Arial", "Arial");
 
         public ComboDataItem CurrentFontFamily
         {
@@ -175,40 +291,18 @@ namespace PDF_Master.Model.AnnotPanel
                 SetProperty(ref _currentFontFamily, value);
                 if (isChange)
                 {
-                    string str= _currentFontFamily.ValueStr;
-                    if (_currentFontFamily.ValueStr== "Times")
+                    string str= _currentFontFamily.Content;
+                    if (_currentFontFamily.Content== "Times New Roman")
                     {
                         str = "Times-Roman";
                     }
-                    else if(_currentFontFamily.ValueStr== "Courier")
-                    {
-                        str = "Courier New";
-                    }
-                    
                     ChangedValue?.Invoke(str, FontSetModeType.FontFamilys);
 
                 }
                 SetProperty(ref _currentFontFamily, value);
                 if (value.Content != null)
                 {
-                    switch (value.Content.ToString())
-                    {
-                        case "Courier New":
-                            FontFamilySelectedIndex = 0;
-                            break;
-
-                        case "Helvetica":
-                        case "Arial":
-                            FontFamilySelectedIndex = 1;
-                            break;
-
-                        case "Times New Roman":
-                            FontFamilySelectedIndex = 2;
-                            break;
-                        default:
-                                FontFamilySelectedIndex = -1;                            
-                            break;
-                    }
+                    FontFamilySelectedIndex=FontFamilyItems.IndexOf(value);
                 }
                 else
                 {
@@ -543,18 +637,16 @@ namespace PDF_Master.Model.AnnotPanel
 
         protected void GetCurrentFontFamily(string fontFamily, string uiStr)
         {
-            if (fontFamily == "Arial")
-            {
-                fontFamily = "Helvetica";
-                uiStr = "Helvetica";
-            }
-            if(fontFamily == "Times-Roman"|| fontFamily == "Times")
+            //SDK捕获到的字体会是Times-Roman
+            if (fontFamily == "Times-Roman")
             {
                 uiStr = "Times New Roman";
             }
-            if(fontFamily == "Courier")
+            //WPF的UI字体不包含Helvetica
+            if (fontFamily == "Helvetica")
             {
-                uiStr = "Courier New";
+                fontFamily = "Arial";
+                uiStr = "Arial";
             }
             CurrentFontFamily = new ComboDataItem(fontFamily, uiStr);
         }
@@ -690,7 +782,7 @@ namespace PDF_Master.Model.AnnotPanel
         #region 字体样式
 
         //下拉框列表
-        private ComboDataItem _currentFontFamily = new ComboDataItem("Helvetica", "Helvetica");
+        private ComboDataItem _currentFontFamily = new ComboDataItem("Arial", "Arial");
 
         public ComboDataItem CurrentFontFamily
         {
@@ -704,7 +796,6 @@ namespace PDF_Master.Model.AnnotPanel
                         FontFamilySelectedIndex = 0;
                         break;
 
-                    case "Helvetica":
                     case "Arial":
                         FontFamilySelectedIndex = 1;
                         break;
@@ -712,6 +803,9 @@ namespace PDF_Master.Model.AnnotPanel
                     case "Times New Roman":
                         FontFamilySelectedIndex = 2;
                         break;
+                    case "Adobe Devanagari":
+                        FontFamilySelectedIndex = 3;
+                        break;
                 }
             }
         }
@@ -994,8 +1088,20 @@ namespace PDF_Master.Model.AnnotPanel
         {
             if (fontFamily == "Arial")
             {
-                fontFamily = "Helvetica";
-                uiStr = "Helvetica";
+                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);
         }
@@ -1012,7 +1118,7 @@ namespace PDF_Master.Model.AnnotPanel
             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 == "Helvetica")
+                    && (annot.FontName == item.mFontFamily.Source || annot.FontName == "Arial" && item.mFontFamily.Source == "Arial")
                     )
                 {
                     if (item.mTag != "Custom")

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

@@ -1,4 +1,5 @@
 using PDF_Master.CustomControl.CompositeControl;
+using PDF_Master.Model.AnnotPanel;
 using PDF_Master.Properties;
 using PDFSettings;
 using System;
@@ -211,7 +212,7 @@ namespace PDF_Master.Model.PropertyPanel.AnnotPanel
             custom.mTagContent = App.MainPageLoader.GetString("PresetTextStyle_Customize");
 
             custom.mFontSize = 24;
-            custom.mFontFamily = new FontFamily("Helvetica");
+            custom.mFontFamily = new FontFamily("Arial");
             custom.mFontStyle = FontStyles.Normal;
             custom.mFontWeight = FontWeights.Normal;
 
@@ -220,7 +221,7 @@ namespace PDF_Master.Model.PropertyPanel.AnnotPanel
             h1.mTagContent = App.MainPageLoader.GetString("PresetTextStyle_H1Title");
 
             h1.mFontSize = 36;
-            h1.mFontFamily = new FontFamily("Helvetica");
+            h1.mFontFamily = new FontFamily("Arial");
             h1.mFontStyle = FontStyles.Normal;
             h1.mFontWeight = FontWeights.Bold;
 
@@ -229,7 +230,7 @@ namespace PDF_Master.Model.PropertyPanel.AnnotPanel
             h2.mTagContent = App.MainPageLoader.GetString("PresetTextStyle_H2Title");
 
             h2.mFontSize = 24;
-            h2.mFontFamily = new FontFamily("Helvetica");
+            h2.mFontFamily = new FontFamily("Arial");
             h2.mFontStyle = FontStyles.Normal;
             h2.mFontWeight = FontWeights.Bold;
 
@@ -238,7 +239,7 @@ namespace PDF_Master.Model.PropertyPanel.AnnotPanel
             h3.mTagContent = App.MainPageLoader.GetString("PresetTextStyle_H3Title");
 
             h3.mFontSize = 18;
-            h3.mFontFamily = new FontFamily("Helvetica");
+            h3.mFontFamily = new FontFamily("Arial");
             h3.mFontStyle = FontStyles.Normal;
             h3.mFontWeight = FontWeights.Bold;
 
@@ -247,7 +248,7 @@ namespace PDF_Master.Model.PropertyPanel.AnnotPanel
             b1.mTagContent = App.MainPageLoader.GetString("PresetTextStyle_B1NormalTextStandard");
 
             b1.mFontSize = 14;
-            b1.mFontFamily = new FontFamily("Helvetica");
+            b1.mFontFamily = new FontFamily("Arial");
             b1.mFontStyle = FontStyles.Normal;
             b1.mFontWeight = FontWeights.Regular;
 
@@ -256,7 +257,7 @@ namespace PDF_Master.Model.PropertyPanel.AnnotPanel
             b2.mTagContent = App.MainPageLoader.GetString("PresetTextStyle_B2NormalTextSmall");
 
             b2.mFontSize = 12;
-            b2.mFontFamily = new FontFamily("Helvetica");
+            b2.mFontFamily = new FontFamily("Arial");
             b2.mFontStyle = FontStyles.Normal;
             b2.mFontWeight = FontWeights.Regular;
 
@@ -265,7 +266,7 @@ namespace PDF_Master.Model.PropertyPanel.AnnotPanel
             b3.mTagContent = App.MainPageLoader.GetString("PresetTextStyle_B3Description");
 
             b3.mFontSize = 11;
-            b3.mFontFamily = new FontFamily("Helvetica");
+            b3.mFontFamily = new FontFamily("Arial");
             b3.mFontStyle = FontStyles.Normal;
             b3.mFontWeight = FontWeights.Regular;
 
@@ -334,16 +335,27 @@ namespace PDF_Master.Model.PropertyPanel.AnnotPanel
         }
 
         public static List<ComboDataItem> GetFamily()
-        {
+        {
+            System.Drawing.Text.InstalledFontCollection objFont = new System.Drawing.Text.InstalledFontCollection();
             var FontFamilyItems = new List<ComboDataItem>();
-            ComboDataItem item = new ComboDataItem("Courier", "Courier New");
-            FontFamilyItems.Add(item);
-            item = new ComboDataItem("Helvetica", "Helvetica");
-            FontFamilyItems.Add(item);
-            item = new ComboDataItem(/*"Times-Roman"*/"Times", "Times New Roman");
-            FontFamilyItems.Add(item);
-
+            ComboDataItem item;
+            FontBoard fontBoard = new FontBoard();
+            foreach (var itemFam in fontBoard.FontFamily)
+            {
+                item = new ComboDataItem(DeleteCharacters(itemFam),itemFam);
+                FontFamilyItems.Add(item);
+
+            }
             return FontFamilyItems;
+
+        }
+
+        public static string DeleteCharacters(string str)
+        {
+            str=str.Replace(" ", string.Empty);
+            str = str.Replace("-", string.Empty);
+            str = str.Replace("_", string.Empty);
+            return str;
         }
 
         public static List<ComboDataItem> GetDateFormats()

+ 5 - 12
PDF Office/ViewModels/PropertyPanel/PDFEdit/TextEditPropertyViewModel.cs

@@ -351,7 +351,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             item.mFontSize = (int)CurrentFontSize.Value;
 
             CurrentPresetFont = new ComboDataItem(item.mTag, item.mTagContent);
-            SelectedPresetFont();
+            //SelectedPresetFont();
             //更改后 保存到本地缓存
             TextFont.SavePresetFontList(PresetFontList);
 
@@ -831,20 +831,13 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             foreach (var item in PresetFontList)
             {
                 string itemmFontFamily = item.mFontFamily.Source;
-                if (item.mFontFamily.Source == "Arial")
-                {
-                    itemmFontFamily = "Helvetica";
-                }
-                if (item.mFontFamily.Source == "Times-Roman" || itemmFontFamily == "Times")
+
+                if (item.mFontFamily.Source == "TimesRoman" )
                 {
                     itemmFontFamily = "Times-Roman";
                 }
-                if (item.mFontFamily.Source == "Courier")
-                {
-                    itemmFontFamily = "Courier New";
-                }
                 if (TextEditEvent.FontSize == item.mFontSize && TextEditEvent.IsBold == (item.mFontWeight == FontWeights.Bold) && TextEditEvent.IsItalic == (item.mFontStyle == FontStyles.Italic)
-                    && (TextEditEvent.FontName == itemmFontFamily || TextEditEvent.FontName == "Arial" && item.mFontFamily.Source == "Helvetica")
+                    && (TextEditEvent.FontName == itemmFontFamily || TextEditEvent.FontName == "Arial")
                     )
                 {
                     if (item.mTag != "Custom")
@@ -865,7 +858,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
 
                 if (TextEditEvent.FontName == ""|| TextEditEvent.FontName == null)
                 {
-                    GetCurrentFontFamily("Helvetica", "Helvetica");
+                    GetCurrentFontFamily("Arial", "Arial");
                 }
                 else
                 {

+ 11 - 1
PDF Office/ViewModels/Tools/TextEditToolContentViewModel.cs

@@ -341,7 +341,13 @@ namespace PDF_Master.ViewModels.Tools
                             }
                         }
                         
+                        else if (PDFViewer.ToolManager != null)
+                        {
+                            PDFViewer.ClearSelectPDFEdit();
+                            AddToPropertyPanel("PropertyPanelContent", null);
+                            PDFViewer.ReloadDocument();
 
+                        }
 
 
 
@@ -657,6 +663,7 @@ namespace PDF_Master.ViewModels.Tools
 
         private void PDFViewer_PDFEditHandler(object sender, List<PDFEditSelectionData> e)
         {
+            PDFViewer.ClearSelectPDFEdit();
             PDFViewer.SelectPDFEdit(e,true);
         }
 
@@ -714,7 +721,10 @@ namespace PDF_Master.ViewModels.Tools
 
             else if(IsTextEdit==true)
             {
-                AddToPropertyPanel("PropertyPanelContent", null);
+                //单击添加文本
+                PDFViewer.ToolManager.EnableClickCreate = true;
+                PDFViewer.ToolManager.ClickCreateWidth = 60;
+                PDFViewer.ToolManager.ClickCreateHeight = 30;
                 AddToPropertyPanel("Text", null);
             }
             else

+ 6 - 12
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -2824,9 +2824,9 @@ namespace PDF_Master.ViewModels
                 //是否取消了水印保存步骤
                 bool flg = false;
                 //删掉Settings.Default.UserDate.isInFreeUseTime == false,没有试用期策略了
-                if ((!App.IsLogin || Settings.Default.UserDate.subscribestatus != 1) && (App.mainWindowViewModel.SelectedItem.DataContext as MainContentViewModel).IsUsedVIP == true)
+                if ((!App.IsLogin || Settings.Default.UserDate.subscribestatus != 1) && ((App.mainWindowViewModel.SelectedItem.DataContext as MainContentViewModel).IsUsedVIP == true||PDFViewer.UndoManager.PDFEditChanged==true))
                 {
-                    DialogParameters value = new DialogParameters();
+                       DialogParameters value = new DialogParameters();
                     value.Add(ParameterNames.ViewContentViewModel, this);
                     if (autosave)
                     {
@@ -3201,7 +3201,7 @@ namespace PDF_Master.ViewModels
             {
                 bool flg = false;
                 //删掉Settings.Default.UserDate.isInFreeUseTime == false,没有试用期策略了
-                if ((!App.IsLogin || Settings.Default.UserDate.subscribestatus != 1) && (App.mainWindowViewModel.SelectedItem.DataContext as MainContentViewModel).IsUsedVIP == true)
+                if ((!App.IsLogin || Settings.Default.UserDate.subscribestatus != 1) && ((App.mainWindowViewModel.SelectedItem.DataContext as MainContentViewModel).IsUsedVIP == true || PDFViewer.UndoManager.PDFEditChanged == true))
                 {
                     DialogParameters value = new DialogParameters();
                     value.Add(ParameterNames.ViewContentViewModel, this);
@@ -3370,7 +3370,8 @@ namespace PDF_Master.ViewModels
             }
             bool flg = false;
             //权益弹窗
-            if ((!App.IsLogin || Settings.Default.UserDate.subscribestatus != 1) && (App.mainWindowViewModel.SelectedItem.DataContext as MainContentViewModel).IsUsedVIP == true)
+            //PDFViewer.UndoManager.PDFEditChanged为是否在编辑中对文档进行了改动
+            if ((!App.IsLogin || Settings.Default.UserDate.subscribestatus != 1) && ((App.mainWindowViewModel.SelectedItem.DataContext as MainContentViewModel).IsUsedVIP == true || PDFViewer.UndoManager.PDFEditChanged == true))
             {
                 DialogParameters value = new DialogParameters();
                 value.Add(ParameterNames.ViewContentViewModel, this);
@@ -3560,14 +3561,7 @@ namespace PDF_Master.ViewModels
 
         private void EnterSelectedBar(string currentBar)
         {
-            if (currentBar == "TabItemEdit")
-            {
-                if (!ServiceHelper.IAPBeforeFunction())
-                {          
-                    isInPageEdit = false;
-                    return;
-                }
-            }
+
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, PDFViewer);
             param.Add(ParameterNames.ViewContentViewModel, this);