Jelajahi Sumber

缓存 - 本地缓存颜色列表数据

chenrongqian@kdanmobile.com 2 tahun lalu
induk
melakukan
ead11fe8fc

+ 29 - 2
PDF Office/Helper/SettingHelper.cs

@@ -150,7 +150,8 @@ namespace PDF_Office.Helper
             catch { }
         }
 
-        public static DefaultAnnotProperty GetAnnotDefaultProperty(AnnotArgsType annotToolType,string saveKey="")
+        #region 缓存注释属性
+        public static DefaultAnnotProperty GetAnnotDefaultProperty(AnnotArgsType annotToolType, string saveKey = "")
         {
             if (Settings.Default.DefautAnnotProperties != null)
             {
@@ -162,7 +163,6 @@ namespace PDF_Office.Helper
             }
             return null;
         }
-
         public static void SetAnnotDefaultProperty(DefaultAnnotProperty annotProperty)
         {
             if (Settings.Default.DefautAnnotProperties == null)
@@ -172,6 +172,33 @@ namespace PDF_Office.Helper
             Settings.Default.DefautAnnotProperties.SetAnnotProperty(annotProperty);
             Settings.Default.Save();
         }
+
+        #endregion 缓存注释属性
+
+
+        #region 缓存颜色列表
+
+        public static void SetColorSelector(ColorSelectorItem selectorItem)
+        {
+            if (Settings.Default.ColorSelectors == null)
+            {
+                Settings.Default.ColorSelectors = new ColorSelectorList();
+            }
+            Settings.Default.ColorSelectors.SetColorSelector(selectorItem);
+            Settings.Default.Save();
+        }
+
+        public static ColorSelectorItem GetColorSelectorItem(ColorSelectorType selectorType,int Index)
+        {
+            if (Settings.Default.ColorSelectors != null)
+            {
+                return Settings.Default.ColorSelectors.GetColorSelector(selectorType, Index);
+            }
+            return null;
+        }
+
+        #endregion 缓存颜色列表
+
         private static string KeyAlaphabet = "0123456789ABCDEFGHIGKLMNOPQRSTUVWXYZ";
         public static char NumberToChar(int num)
         {

+ 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())));
@@ -225,5 +225,16 @@ namespace PDF_Office.Properties {
                 this["UpdateSettings"] = value;
             }
         }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::PDFSettings.ColorSelectorList ColorSelectors {
+            get {
+                return ((global::PDFSettings.ColorSelectorList)(this["ColorSelectors"]));
+            }
+            set {
+                this["ColorSelectors"] = value;
+            }
+        }
     }
 }

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

@@ -56,5 +56,8 @@
     <Setting Name="UpdateSettings" Type="System.Boolean" Scope="User">
       <Value Profile="(Default)">True</Value>
     </Setting>
+    <Setting Name="ColorSelectors" Type="PDFSettings.ColorSelectorList" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
   </Settings>
 </SettingsFile>

+ 52 - 0
PDFSettings/ColorSelectorList.cs

@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media;
+
+namespace PDFSettings
+{
+    public class ColorSelectorList : List<ColorSelectorItem>
+    {
+        public ColorSelectorItem GetColorSelector(ColorSelectorType selectorType, int Index)
+        {
+            if (selectorType != ColorSelectorType.None)
+                return this.AsEnumerable().Where(x => x.SelectorType == selectorType && x.Index == Index).FirstOrDefault();
+            else
+                return null;
+        }
+
+        public void SetColorSelector(ColorSelectorItem selectorItem)
+        {
+            if (selectorItem.SelectorType == ColorSelectorType.None)
+                return;
+
+            ColorSelectorItem[] deleteArray = new ColorSelectorItem[0];
+
+            deleteArray = this.AsEnumerable().Where(x => (x.SelectorType == selectorItem.SelectorType) && (x.Index == selectorItem.Index)).ToArray();
+
+            foreach (ColorSelectorItem deleteProperty in deleteArray)
+            {
+                this.Remove(deleteProperty);
+            }
+
+            this.Add(selectorItem);
+        }
+    }
+    public class ColorSelectorItem : EventArgs
+    {
+        public int Index = 0;
+        public bool IsChangedColor = false;
+        public ColorSelectorType SelectorType = ColorSelectorType.Highlight;
+        public Color color = Color.FromArgb(0xFF, 0xFF, 0xC7, 0x00);
+    }
+    public enum ColorSelectorType
+    {
+        None,
+        Highlight,
+        Border,
+        Fill,
+        Sticky
+    }
+}

+ 1 - 0
PDFSettings/PDFSettings.csproj

@@ -56,6 +56,7 @@
   <ItemGroup>
     <Compile Include="APPSettingProperties.cs" />
     <Compile Include="BatesHeaderFooterTemplateList.cs" />
+    <Compile Include="ColorSelectorList.cs" />
     <Compile Include="CustomStampList.cs" />
     <Compile Include="DefaultAnnotProperty.cs" />
     <Compile Include="DialogCounter.cs" />