瀏覽代碼

PDF工具 - 重新调整PDF工具类

chenrongqian 2 年之前
父節點
當前提交
606c14867e

+ 21 - 0
PDF Office/Model/PDFTool/ToolItem.cs

@@ -0,0 +1,21 @@
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model.PDFTool
+{
+    public class ToolItem : BindableBase
+    {
+        public int Id { get; set; }
+        public string Image { get; set; }
+        public string NameInfo { get; set; }
+        public string Name { get; set; }
+        public ToolItem()
+        {
+
+        }
+    }
+}

+ 1 - 0
PDF Office/PDF Office.csproj

@@ -127,6 +127,7 @@
     </Compile>
     <Compile Include="Model\PageEdit\PageEditItem.cs" />
     <Compile Include="Model\ParameterNames.cs" />
+    <Compile Include="Model\PDFTool\ToolItem.cs" />
     <Compile Include="Model\RegionNames.cs" />
     <Compile Include="CustomControl\SystemControl\TabablzRegionBehavior.cs" />
     <Compile Include="DataConvert\BoolToVisible.cs" />

+ 0 - 11
PDF Office/ViewModels/HomePanel/HomeToolsContentViewModel.cs

@@ -15,15 +15,4 @@ namespace PDF_Office.ViewModels.HomePanel
         }
     }
 
-    public class QuickToolItem : BindableBase
-    {
-        public int Id { get; set; }
-        public string Image { get; set; }
-        public string NameInfo { get; set; }
-        public string Name { get; set; }
-        public QuickToolItem()
-        {
-
-        }
-    }
 }

+ 21 - 20
PDF Office/Views/HomePanel/PDFTools/PDFToolsContent.xaml.cs

@@ -1,5 +1,6 @@
 using PDF_Office.CustomControl;
 using PDF_Office.Helper;
+using PDF_Office.Model.PDFTool;
 using PDF_Office.ViewModels.HomePanel;
 using System;
 using System.Collections.Generic;
@@ -30,9 +31,9 @@ namespace PDF_Office.Views.HomePanel.PDFTools
         private ListItemQuickTool targetListItem = null;
         private ListItemQuickTool quickSourceListItem = null;
 
-        private List<QuickToolItem> quickTools = null;
-        private List<QuickToolItem> allTools = null;
-        private List<QuickToolItem> moreTools = null;
+        private List<ToolItem> quickTools = null;
+        private List<ToolItem> allTools = null;
+        private List<ToolItem> moreTools = null;
 
         private string fileName = string.Empty;
         private BitmapSource bitmapSource = null;
@@ -46,8 +47,8 @@ namespace PDF_Office.Views.HomePanel.PDFTools
         {
             InitializeComponent();
 
-            quickTools = new List<QuickToolItem>();
-            allTools = new List<QuickToolItem>();
+            quickTools = new List<ToolItem>();
+            allTools = new List<ToolItem>();
 
             #region ListBox
 
@@ -76,7 +77,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
 
             for (int i = 0; i < all.Count; i++)
             {
-                QuickToolItem aToolModule = new QuickToolItem();
+                ToolItem aToolModule = new ToolItem();
                 aToolModule.Id = i + 1;
                 aToolModule.Name = all[i];
                 aToolModule.Image = path;
@@ -84,7 +85,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
             }
 
             //取前10个,如果List里面数据少于5个,则返回所有的
-            quickTools = allTools.Take(8).ToList<QuickToolItem>();
+            quickTools = allTools.Take(8).ToList<ToolItem>();
             ListShortCuts.ItemsSource = quickTools;
             //对比两个集合,取差值
             moreTools = allTools.Except(quickTools).ToList();
@@ -119,7 +120,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
                 //获取控件相对于另一控件的坐标
                 wrpnlPoint = sourceListItem.TranslatePoint(new Point(), this);
 
-                System.Windows.DataObject dataObj = new System.Windows.DataObject(sourceListItem.Content as QuickToolItem);
+                System.Windows.DataObject dataObj = new System.Windows.DataObject(sourceListItem.Content as ToolItem);
 
                 if (dataObj != null)
                 {
@@ -154,9 +155,9 @@ namespace PDF_Office.Views.HomePanel.PDFTools
 
         private void IsMoreToolbars()
         {
-            var source = sourceListItem.Content as QuickToolItem;
+            var source = sourceListItem.Content as ToolItem;
             if (moreTools == null && moreTools.Count != 0) return;
-            List<QuickToolItem> toolModule = moreTools.FindAll(item => item.Name == source.Name);
+            List<ToolItem> toolModule = moreTools.FindAll(item => item.Name == source.Name);
             if (toolModule.Count > 0)
             {
                 // 判断文件夹是否存在,不存在则创建
@@ -189,11 +190,11 @@ namespace PDF_Office.Views.HomePanel.PDFTools
                 WorkingWithAnimation(pos);
                 return;
             }
-            var targetAToolModule = targetListItem.Content as QuickToolItem;
-            QuickToolItem target = quickTools.Find(c => c.Name == targetAToolModule.Name);
+            var targetAToolModule = targetListItem.Content as ToolItem;
+            ToolItem target = quickTools.Find(c => c.Name == targetAToolModule.Name);
 
             //查找元数据
-            var sourceAToolModule = e.Data.GetData(typeof(QuickToolItem)) as QuickToolItem;
+            var sourceAToolModule = e.Data.GetData(typeof(ToolItem)) as ToolItem;
             if (sourceAToolModule == null)
             {
                 sourceImage.Visibility = Visibility.Hidden;
@@ -217,10 +218,10 @@ namespace PDF_Office.Views.HomePanel.PDFTools
             ModuleExchange(sourceAToolModule, targetAToolModule);
         }
 
-        private void ModuleExchange(QuickToolItem sourceAToolModule, QuickToolItem targetAToolModule)
+        private void ModuleExchange(ToolItem sourceAToolModule, ToolItem targetAToolModule)
         {
             if (moreTools == null) return;
-            QuickToolItem source = moreTools.Find(c => c.Name == sourceAToolModule.Name);
+            ToolItem source = moreTools.Find(c => c.Name == sourceAToolModule.Name);
 
             int targetIndex = quickTools.FindIndex(item => item.Name == targetAToolModule.Name);
             if (targetIndex < 0) return;
@@ -350,7 +351,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
             stream.Close();
         }
 
-        private QuickToolItem target;
+        private ToolItem target;
 
         private void ListBoxShortCuts_DragOver(object sender, DragEventArgs e)
         {
@@ -387,7 +388,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
 
             if (!isMoreCuts)
             {
-                var sourceAToolModule = e.Data.GetData(typeof(QuickToolItem)) as QuickToolItem;
+                var sourceAToolModule = e.Data.GetData(typeof(ToolItem)) as ToolItem;
                 if (sourceAToolModule == null) return;
                 int sourceIndex = quickTools.FindIndex(item => item.Name == sourceAToolModule.Name);
                 //根据index找listbox对应的item
@@ -401,7 +402,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
             }
             else
             {
-                var sourceAToolModule = e.Data.GetData(typeof(QuickToolItem)) as QuickToolItem;
+                var sourceAToolModule = e.Data.GetData(typeof(ToolItem)) as ToolItem;
                 if (sourceAToolModule == null) return;
                 int sourceIndex = moreTools.FindIndex(item => item.Name == sourceAToolModule.Name);
                 //根据index找listbox对应的item
@@ -428,7 +429,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
                 //sourceImage.Visibility = Visibility.Hidden;
                 return;
             }
-            var targetAToolModule = targetListItem.Content as QuickToolItem;
+            var targetAToolModule = targetListItem.Content as ToolItem;
             if (targetAToolModule == null) return;
             target = quickTools.Find(c => c.Name == targetAToolModule.Name);
         }
@@ -461,7 +462,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
                 {
                     return;
                 }
-                System.Windows.DataObject dataObj = new System.Windows.DataObject(quickSourceListItem.Content as QuickToolItem);
+                System.Windows.DataObject dataObj = new System.Windows.DataObject(quickSourceListItem.Content as ToolItem);
 
                 if (dataObj != null)
                 {

+ 4 - 3
PDF Office/Views/HomePanel/PDFTools/QuickToolsContent.xaml.cs

@@ -1,5 +1,6 @@
 using PDF_Office.CustomControl;
 using PDF_Office.Helper;
+using PDF_Office.Model.PDFTool;
 using PDF_Office.ViewModels.HomePanel;
 using PDF_Office.Views.HomePanel.PDFTools;
 using System.Collections.Generic;
@@ -16,17 +17,17 @@ namespace PDF_Office.Views.HomePanel.PDFTools
     public partial class QuickToolsContent : UserControl
     {
 
-        private List<QuickToolItem> allToolbars = null;
+        private List<ToolItem> allToolbars = null;
         public QuickToolsContent()
         {
             InitializeComponent(); 
-             allToolbars = new List<QuickToolItem>();
+             allToolbars = new List<ToolItem>();
             string path = @"pack://application:,,,/Resources/PromotionIcon/Windows.png";
             List<string> all = new List<string>() { "PDF转Word", "PDF转Excel", "PDF转PPT", "转档PDF", "OCR", "拆分",
             "提取","合并","压缩","图片转PDF","安全", "水印", "页眉页脚","贝茨Bates码","批量处理","打印", "背景","插入","文件对比"};
             for (int i = 0; i < 8; i++)
             {
-                QuickToolItem aToolModule = new QuickToolItem();
+                ToolItem aToolModule = new ToolItem();
                 aToolModule.Id = i + 1;
                 aToolModule.Name = all[i];
                 aToolModule.Image = path;