Przeglądaj źródła

PDF工具 - 添加本地缓存数据类

chenrongqian 2 lat temu
rodzic
commit
07ab905c2e

+ 7 - 0
PDF Office/App.xaml.cs

@@ -94,6 +94,13 @@ namespace PDF_Office
 
             if (Settings.Default.AppProperties == null)
                 Settings.Default.AppProperties = new PDFSettings.APPSettingProperties();
+
+            if (Settings.Default.AllPDFToolsList == null)
+                Settings.Default.AllPDFToolsList = new PDFSettings.AllPDFToolsList();
+
+            if (Settings.Default.QuickPDFToolsList == null)
+                Settings.Default.QuickPDFToolsList = new PDFSettings.QuickPDFToolsList();
+
         }
 
         /// <summary>

+ 17 - 1
PDF Office/Helper/PDFToolsHelper.cs

@@ -1,4 +1,6 @@
 using PDF_Office.Model.PDFTool;
+using PDF_Office.Properties;
+using PDFSettings;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -68,6 +70,19 @@ namespace PDF_Office.Helper
             AddToolItem(PDFToolType.Batch, path, "批量处理", "Batch convert, compress, secure, watermark PDFs.");
             AddToolItem(PDFToolType.Background, path, "背景", "Batch convert, compress, secure, watermark PDFs.");
             AddToolItem(PDFToolType.CompareDoc, path, "文件对比", "Batch convert, compress, secure, watermark PDFs.");
+
+           
+        }
+
+        private void ContianNewTools()
+        {
+            if (Settings.Default.AllPDFToolsList != null)
+            {
+                foreach(var item in AllTools)
+                {
+                    Settings.Default.AllPDFToolsList.FirstOrDefault(tool => tool.Tag == item.Tag);
+                }
+            }
         }
 
         private void AddToolItem(PDFToolType toolType, string imgPath,string title,string titleInfo,int id = 0)
@@ -75,7 +90,8 @@ namespace PDF_Office.Helper
             ToolItem toolItem = new ToolItem();
 
             toolItem.Id = id;
-            toolItem.Tag = toolType;
+            toolItem.Tag = (int)toolType;
+            toolItem.TagStr = Enum.GetName(typeof(PDFToolType), toolType);
             toolItem.Image = imgPath;
             toolItem.Title = title;
             toolItem.TitleInfo = titleInfo;

+ 11 - 1
PDF Office/Model/PDFTool/ToolItem.cs

@@ -8,8 +8,18 @@ using System.Threading.Tasks;
 
 namespace PDF_Office.Model.PDFTool
 {
-    public class ToolItem : BindableBase
+    public class ToolItem1 : BindableBase
     {
+        private bool _isShowConciseContent = false;
+        public bool IsShowConciseContent
+        {
+            get { return _isShowConciseContent; }
+            set
+            {
+                SetProperty(ref _isShowConciseContent, value);
+            }
+        }
+        public bool IsNewTool { get; set; }
         public int Id { get; set; }
         public PDFToolType Tag { get; set; }
         public string Image { get; set; }

+ 22 - 0
PDF Office/Properties/Settings.Designer.cs

@@ -55,5 +55,27 @@ namespace PDF_Office.Properties {
                 this["AppProperties"] = value;
             }
         }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::PDFSettings.AllPDFToolsList AllPDFToolsList {
+            get {
+                return ((global::PDFSettings.AllPDFToolsList)(this["AllPDFToolsList"]));
+            }
+            set {
+                this["AllPDFToolsList"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::PDFSettings.QuickPDFToolsList QuickPDFToolsList {
+            get {
+                return ((global::PDFSettings.QuickPDFToolsList)(this["QuickPDFToolsList"]));
+            }
+            set {
+                this["QuickPDFToolsList"] = value;
+            }
+        }
     }
 }

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

@@ -11,5 +11,11 @@
     <Setting Name="AppProperties" Type="PDFSettings.APPSettingProperties" Scope="User">
       <Value Profile="(Default)" />
     </Setting>
+    <Setting Name="AllPDFToolsList" Type="PDFSettings.AllPDFToolsList" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
+    <Setting Name="QuickPDFToolsList" Type="PDFSettings.QuickPDFToolsList" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
   </Settings>
 </SettingsFile>

+ 4 - 3
PDF Office/ViewModels/HomePanel/HomeGuidContentViewModel.cs

@@ -6,6 +6,7 @@ using PDF_Office.Model;
 using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
 using PDF_Office.Model.PDFTool;
 using PDF_Office.Views.HomePanel.PDFTools;
+using PDFSettings;
 using Prism.Commands;
 using Prism.Mvvm;
 using Prism.Services.Dialogs;
@@ -37,11 +38,11 @@ namespace PDF_Office.ViewModels.HomePanel
             System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
             dlg.Multiselect = false;
             dlg.Filter = "PDF|*.pdf;*.PDF;";
-            if (toolItem.Tag == PDFToolType.Compress || toolItem.Tag == PDFToolType.Security)
+            if (toolItem.Tag == (int)PDFToolType.Compress || toolItem.Tag == (int)PDFToolType.Security)
             {
                 dlg.Multiselect = true;
             }
-                if (toolItem.Tag == PDFToolType.Merge)
+                if (toolItem.Tag == (int)PDFToolType.Merge)
             {
                 dlg.Multiselect = true;
                 dlg.Filter = "Picture|*.png;*.PNG;*.jpg;*.JPG;*bmp;*jpeg;*gif;*tiff;";
@@ -50,7 +51,7 @@ namespace PDF_Office.ViewModels.HomePanel
             {
                 CPDFViewer viewer = new CPDFViewer();
                 
-                switch (toolItem.Tag)
+                switch ((PDFToolType)toolItem.Tag)
                 {
                     case PDFToolType.Split:
                         

+ 3 - 3
PDF Office/Views/HomePanel/PDFTools/PDFToolItem.xaml

@@ -6,7 +6,6 @@
              xmlns:local="clr-namespace:PDF_Office.Views.HomePanel"
              xmlns:convert="clr-namespace:PDF_Office.DataConvert"
              mc:Ignorable="d" 
-             x:Name="usercontrol"
              d:DesignHeight="450" d:DesignWidth="800">
     <UserControl.Resources>
         <convert:BoolToVisible x:Key="boolToVisible"/>
@@ -15,7 +14,7 @@
     <Grid  Margin="1,1,1,1">
 
         <Border x:Name="BorderExtend" Height="108"  CornerRadius="8" Background="White" BorderThickness="2" 
-                Visibility="{Binding ElementName=usercontrol,Path=IsShowConciseContent,Converter={StaticResource invertBoolToVisibleConvert}}">
+                Visibility="{Binding IsShowConciseContent,Converter={StaticResource invertBoolToVisibleConvert}}">
 
             <Grid  Background="Transparent" MouseEnter="Border_MouseEnter" MouseLeave="Border_MouseLeave">
                 <Grid Margin="10">
@@ -45,7 +44,8 @@
             </Grid>
         </Border>
 
-        <Border x:Name="BorderConcise" Height="64"  CornerRadius="8" Background="White" BorderThickness="2" BorderBrush="#04000000" Visibility="{Binding ElementName=usercontrol,Path=IsShowConciseContent,Converter={StaticResource boolToVisible}}">
+        <Border x:Name="BorderConcise" Height="64"  CornerRadius="8" Background="White" BorderThickness="2" BorderBrush="#04000000" 
+                Visibility="{Binding IsShowConciseContent,Converter={StaticResource boolToVisible}}">
             <Grid Background="Transparent" MouseEnter="Border_MouseEnter" MouseLeave="Border_MouseLeave">
                 <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="auto"/>

+ 0 - 18
PDF Office/Views/HomePanel/PDFTools/PDFToolItem.xaml.cs

@@ -179,23 +179,5 @@ namespace PDF_Office.Views.HomePanel.PDFTools
         }
         public static readonly DependencyProperty ToolInfoProperty = DependencyProperty.Register("ToolInfo", typeof(string), typeof(PDFToolItem), new PropertyMetadata(string.Empty));
 
-
-        /// <summary>
-        /// 是否收缩UI
-        /// </summary>
-        public bool IsShowConciseContent
-        {
-            get
-            {
-                return (bool)GetValue(IsShowConciseContentProperty);
-            }
-            set
-            {
-                SetValue(IsShowConciseContentProperty, value);
-            }
-        }
-        public static readonly DependencyProperty IsShowConciseContentProperty = DependencyProperty.Register("IsShowConciseContent", typeof(bool), typeof(PDFToolItem), new PropertyMetadata(false));
-
-
     }
 }

+ 7 - 11
PDF Office/Views/HomePanel/PDFTools/PDFToolsContent.xaml

@@ -14,6 +14,7 @@
         <ResourceDictionary>
             <ResourceDictionary.MergedDictionaries>
                 <ResourceDictionary Source="../../../Styles/CustomListItemStyle.xaml"/>
+                <ResourceDictionary Source="../../../Styles/CustomBtnStyle.xaml"/>
             </ResourceDictionary.MergedDictionaries>
             <converter:BoolToVisible x:Key="BoolToVisibilityConverter" />
 
@@ -73,17 +74,12 @@
 
                     </Button>
 
-
-                    <Button
-                x:Name="BtnMore"
-                Width="28"
-                Height="28"
-                Margin="12,0,0,0"
-                 Background="#FFFFFF" BorderThickness="0" Content="..."
-                Click="BtnMore_Click"
-               >
-                    </Button>
-
+                    <customControl:CustomIconToggleBtn x:Name="BtnExptend"  Click="BtnExptend_Click"
+                                                        Style="{StaticResource ToggleBtnViewModeStyle}"
+                                                       >
+                        <TextBlock Text="展开"/>
+                    </customControl:CustomIconToggleBtn>
+                    
                 </StackPanel>
             </Grid>
            

+ 28 - 38
PDF Office/Views/HomePanel/PDFTools/PDFToolsContent.xaml.cs

@@ -2,6 +2,7 @@
 using PDF_Office.Helper;
 using PDF_Office.Model.PDFTool;
 using PDF_Office.ViewModels.HomePanel;
+using PDFSettings;
 using System;
 using System.Collections.Generic;
 using System.IO;
@@ -496,34 +497,34 @@ namespace PDF_Office.Views.HomePanel.PDFTools
             }
         }
 
-        /// <summary>
-        /// 扩展收缩UI
-        /// </summary>
-        /// <param name="IsShowConciseContent">是否收缩</param>
-        private void ShowToolsUI(ListBoxEx list,bool IsShowConciseContent)
-        {
-            foreach (var item in list.Items)
-            {
+        ///// <summary>
+        ///// 扩展收缩UI
+        ///// </summary>
+        ///// <param name="IsShowConciseContent">是否收缩</param>
+        //private void ShowToolsUI(ListBoxEx list,bool IsShowConciseContent)
+        //{
+        //    foreach (var item in list.Items)
+        //    {
 
-                var listBoxItem = list.ItemContainerGenerator.ContainerFromItem(item) as ListBoxItem;
-                if (listBoxItem != null)
-                {
+        //        var listBoxItem = list.ItemContainerGenerator.ContainerFromItem(item) as ListBoxItem;
+        //        if (listBoxItem != null)
+        //        {
 
-                    var viewItem = listBoxItem.ContentTemplate;
-                    var myContentPresenter = CommonHelper.FindVisualChild<ContentPresenter>(listBoxItem);
-                    var obj = viewItem.FindName("data", myContentPresenter);
+        //            var viewItem = listBoxItem.ContentTemplate;
+        //            var myContentPresenter = CommonHelper.FindVisualChild<ContentPresenter>(listBoxItem);
+        //            var obj = viewItem.FindName("data", myContentPresenter);
 
-                    var checkNum = obj as PDFToolItem;
+        //            var checkNum = obj as PDFToolItem;
 
-                    if (checkNum != null)
-                    {
-                        checkNum.IsShowConciseContent = IsShowConciseContent;
-                    }
+        //            if (checkNum != null)
+        //            {
+        //                checkNum.IsShowConciseContent = IsShowConciseContent;
+        //            }
 
-                }
-            }
+        //        }
+        //    }
 
-        }
+        //}
 
 
         private void ListBoxShortCuts_SizeChanged(object sender, SizeChangedEventArgs e)
@@ -566,27 +567,16 @@ namespace PDF_Office.Views.HomePanel.PDFTools
 
         private void BtnTools_Click(object sender, RoutedEventArgs e)
         {
-
+           
         }
 
-        bool isExtend = false;
-        private void BtnMore_Click(object sender, RoutedEventArgs e)
+
+        private void BtnExptend_Click(object sender, RoutedEventArgs e)
         {
-            if(isExtend)
-            {
-                isExtend = false;
-                ShowToolsUI(ListShortCuts, false);
-                ShowToolsUI(ListMoreCuts, false);
-            }
-            else
+            foreach (var item in allTools)
             {
-                isExtend = true;
-                ShowToolsUI(ListShortCuts, true);
-                ShowToolsUI(ListMoreCuts, true);
+                item.IsShowConciseContent = (bool)BtnExptend.IsChecked;
             }
-           
-           
-
         }
 
 

+ 16 - 15
PDF Office/Views/HomePanel/PDFTools/QuickToolsContent.xaml.cs

@@ -3,6 +3,7 @@ using PDF_Office.Helper;
 using PDF_Office.Model.PDFTool;
 using PDF_Office.ViewModels.HomePanel;
 using PDF_Office.Views.HomePanel.PDFTools;
+using PDFSettings;
 using System.Collections.Generic;
 using System.Windows;
 using System.Windows.Controls;
@@ -46,26 +47,26 @@ namespace PDF_Office.Views.HomePanel.PDFTools
         /// <param name="IsShowConciseContent">是否收缩</param>
         private void ShowToolsUI(bool IsShowConciseContent)
         {
-            foreach (var item in ListBoxToolBars.Items)
-            {
+            //foreach (var item in ListBoxToolBars.Items)
+            //{
                
-                var listBoxItem = ListBoxToolBars.ItemContainerGenerator.ContainerFromItem(item) as ListBoxItem;
-                if (listBoxItem != null)
-                {
+            //    var listBoxItem = ListBoxToolBars.ItemContainerGenerator.ContainerFromItem(item) as ListBoxItem;
+            //    if (listBoxItem != null)
+            //    {
                    
-                    var viewItem = listBoxItem.ContentTemplate;
-                    var myContentPresenter = CommonHelper.FindVisualChild<ContentPresenter>(listBoxItem);
-                    var obj = viewItem.FindName("data", myContentPresenter);
+            //        var viewItem = listBoxItem.ContentTemplate;
+            //        var myContentPresenter = CommonHelper.FindVisualChild<ContentPresenter>(listBoxItem);
+            //        var obj = viewItem.FindName("data", myContentPresenter);
 
-                    var checkNum = obj as PDFToolItem;
+            //        var checkNum = obj as PDFToolItem;
 
-                    if (checkNum != null)
-                    {
-                        checkNum.IsShowConciseContent = IsShowConciseContent;
-                    }
+            //        if (checkNum != null)
+            //        {
+            //            checkNum.IsShowConciseContent = IsShowConciseContent;
+            //        }
 
-                }
-            }
+            //    }
+            //}
             
         }
 

+ 1 - 0
PDFSettings/PDFSettings.csproj

@@ -61,6 +61,7 @@
     <Compile Include="DialogCounter.cs" />
     <Compile Include="DpiHelpers.cs" />
     <Compile Include="PDFBackgroundList.cs" />
+    <Compile Include="PDFToolsList.cs" />
     <Compile Include="ProductActiveInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="RecentOpenFiles.cs" />

+ 33 - 0
PDFSettings/PDFToolsList.cs

@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDFSettings
+{
+
+    public class AllPDFToolsList : List<ToolItem>
+    {
+
+    }
+
+    public class QuickPDFToolsList : List<ToolItem>
+    {
+
+    }
+
+    public class ToolItem
+    {
+        public bool IsShowConciseContent { get; set; }
+        public bool IsNewTool { get; set; }
+        public int Id { get; set; }
+        public int Tag { get; set; }
+        public string TagStr { get; set; }
+        public string Image { get; set; }
+        public string TitleInfo { get; set; }
+        public string Title { get; set; }
+
+    }
+
+}