Procházet zdrojové kódy

Merge branch 'dev' of http://git.kdan.cc:8865/Windows/PDFOffice_Windows_exe into dev

ZhouJieSheng před 2 roky
rodič
revize
d35fd1c1b0

+ 1 - 0
PDF Office/App.xaml

@@ -20,6 +20,7 @@
 
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/PathButtonStyle.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/ContextMenuTextEditStyle.xaml" />
+                <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/ContextMenuStyle.xaml" />
                 <!--  Enable show customctrol's correctly UI in Xaml Designer  -->
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Themes/Generic.xaml" />
             </ResourceDictionary.MergedDictionaries>

binární
PDF Office/ComPDFKit.Viewer.dll


+ 120 - 40
PDF Office/Helper/PDFToolsHelper.cs

@@ -76,7 +76,7 @@ namespace PDF_Office.Helper
         /// </summary>
         public void SetImagePath(string path)
         {
-            toolItem.Image = path;
+            toolItem.FnImg = path;
         }
 
         /// <summary>
@@ -84,8 +84,8 @@ namespace PDF_Office.Helper
         /// </summary>
         public void SetContent(string fnName,string fnInfo)
         {
-            toolItem.Title = fnName;
-            toolItem.TitleInfo = fnInfo;
+            toolItem.FnName = fnName;
+            toolItem.FnInfo = fnInfo;
         }
 
         /// <summary>
@@ -93,8 +93,7 @@ namespace PDF_Office.Helper
         /// </summary>
         public void SetFnType(PDFFnType fnType)
         {
-            toolItem.FnType = (int)fnType;
-            toolItem.strFnType = Enum.GetName(typeof(PDFFnType), fnType);
+            toolItem.FnType = fnType;
         }
 
 
@@ -105,6 +104,8 @@ namespace PDF_Office.Helper
         public List<ToolItem> QuickTools = null;
         public List<ToolItem> MoreTools = null;
         private static PDFToolsHelper pDFToolsHelper;
+
+        public const int QuickToolCount = 8;//快捷工具显示的个数
         public static PDFToolsHelper GetInstance()
         {
             if (pDFToolsHelper == null)
@@ -127,9 +128,10 @@ namespace PDF_Office.Helper
             //Settings.Default.QuickPDFToolsList.Clear();
             //Settings.Default.Save();
             InitAllTools();
-            ContianNewTools();
             InitQuickTools();
             InitMoreTools();
+
+            //  ContianNewTools();
         }
 
         private void InitAllTools()
@@ -258,12 +260,35 @@ namespace PDF_Office.Helper
             AllTools.Add(compareDoc.toolItem);
         }
 
+        /// <summary>
+        /// 检查是否为新增工具
+        /// </summary>
         private void ContianNewTools()
         {
-            Settings.Default.AllPDFToolsList.Clear();
+            var cacheList = Settings.Default.AllPDFToolsList;
             foreach (var item in AllTools)
             {
-                Settings.Default.AllPDFToolsList.Add(item);
+                ToolItem toolItem = null;
+                foreach (var cacheItem in cacheList)
+                {
+                    var strFnTye = Enum.GetName(typeof(PDFFnType), item.FnType);
+                    if (cacheItem.FnTypeStr != strFnTye && cacheItem.IsNewTool == true)
+                    {
+                        toolItem = item;
+                        break;
+                    }
+                }
+
+                if(toolItem != null && toolItem.IsNewTool == true)
+                {
+                    CacheToolItem cacheTool = new CacheToolItem();
+                    cacheTool.IsNewTool = true;
+                    cacheTool.ToolTypeId = toolItem.ToolTypeId;
+                    cacheTool.ToolTypeStr = Enum.GetName(typeof(PDFToolType), toolItem.ToolType);
+                    cacheTool.FnTypeStr = Enum.GetName(typeof(PDFFnType), toolItem.FnType);
+                    Settings.Default.AllPDFToolsList.Add(cacheTool);
+                }
+               
             }
             Settings.Default.Save();
 
@@ -274,66 +299,121 @@ namespace PDF_Office.Helper
         /// </summary>
         private void InitQuickTools()
         {
-            var settingQuickToolslist = Settings.Default.QuickPDFToolsList;
 
-            int quickToolCount = 0;
-            if (settingQuickToolslist != null && settingQuickToolslist.Count > 0)
+            var cacheList = Settings.Default.AllPDFToolsList;
+
+            if (cacheList == null)
+                cacheList = new AllPDFToolsList();
+
+            if(cacheList.Count > 0)
             {
-                foreach (var item in AllTools)
+                int currentCount = 0;
+                foreach (var cacheItem in cacheList)
                 {
-                    if (quickToolCount == 8)
-                        break;
-
-                    var pdfToolItem = settingQuickToolslist.FirstOrDefault(tool => tool.strFnType == item.strFnType);
-                    if (pdfToolItem != null)
+                    if (cacheItem.ToolLayOutType == 1 && currentCount < QuickToolCount)
                     {
-                        quickToolCount++;
-                        pdfToolItem.FnType = item.FnType;
-                        QuickTools.Add(pdfToolItem);
+                        foreach (var allItem in AllTools)
+                        {
+                            if (cacheItem.FnTypeStr == Enum.GetName(typeof(PDFFnType), allItem.FnType))
+                            {
+                                allItem.IsQuickTool = true;
+
+                                var index = QuickTools.FindIndex(t => t.ToolTypeId > allItem.ToolTypeId);
+                                if (index == -1)
+                                {
+                                    allItem.ToolTypeId = cacheItem.ToolTypeId;
+                                    QuickTools.Add(allItem);
+                                }
+                                else
+                                {
+                                    allItem.ToolTypeId = index;
+                                    QuickTools.Insert(index, allItem);
+                                }
+
+                                currentCount++;
+                                break;
+                            }
+                        }
                     }
                 }
 
-                if (quickToolCount < 8 && AllTools.Count > 8)
+            }
+            else
+            {
+                //当所有工具大于等于快捷工具显示的个数时
+                if (AllTools.Count >= QuickToolCount)
                 {
-                    var count = 8 - quickToolCount;
-                    for (int i = count - 1; i < count; i++)
+                    for (int i = 0; i < QuickToolCount; i++)
                     {
+                        AllTools[i].ToolTypeId = i;
+                        AllTools[i].IsQuickTool = true;
                         QuickTools.Add(AllTools[i]);
                     }
                 }
+                else
+                {
+                    for (int i = 0; i < AllTools.Count; i++)
+                    {
+                        AllTools[i].ToolTypeId = i;
+                        AllTools[i].IsQuickTool = true;
+                        QuickTools.Add(AllTools[i]);
+                    }
+                }
+                SaveAllTools();
+
             }
-            else
-            {
-                if (settingQuickToolslist == null)
-                    Settings.Default.QuickPDFToolsList = new QuickPDFToolsList();
 
-                QuickTools = AllTools.Take(8).ToList<ToolItem>();
 
-                foreach(var item in QuickTools)
-                {
-                    Settings.Default.QuickPDFToolsList.Add(item);
-                }
 
-                Settings.Default.Save();
+        }
 
-            }
-                
+        private void SaveAllTools()
+        {
+            var cacheList = Settings.Default.AllPDFToolsList;
 
+            foreach (var item in AllTools)
+            {
+                CacheToolItem cacheItem = new CacheToolItem();
+                cacheItem.ToolLayOutType = (item.IsQuickTool == true ? 1 : 0);
+                cacheItem.IsNewTool = item.IsNewTool;
+                cacheItem.ToolTypeId = item.ToolTypeId;
+                cacheItem.ToolTypeStr = Enum.GetName(typeof(PDFToolType), item.ToolType);
+                cacheItem.FnTypeStr = Enum.GetName(typeof(PDFFnType), item.FnType);
+                cacheList.Add(cacheItem);
+            }
+            Settings.Default.Save();
         }
 
+
         private void InitMoreTools()
         {
-            List<ToolItem> more = new List<ToolItem>();
+            int currentCount = 0;
+            foreach (var allItem in AllTools)
+            {
+                if (allItem.IsQuickTool == false)
+                {
+                    allItem.ToolTypeId = currentCount;
+                    MoreTools.Add(allItem);
+                    currentCount++;
+                }
+            }
+        }
+
+        public void SaveCacheList()
+        {
+            var cacheLists = Settings.Default.AllPDFToolsList;
+            CacheToolItem cacheItem = null;
             foreach (var item in AllTools)
             {
-                var pdfToolItem = QuickTools.FirstOrDefault(tool => tool.strFnType == item.strFnType);
-                if (pdfToolItem == null)
+                cacheItem = cacheLists.Find(t => t.FnTypeStr == Enum.GetName(typeof(PDFFnType), item.FnType));
+                if (cacheItem != null)
                 {
-                    more.Add(item);
+                    cacheItem.ToolTypeId = item.ToolTypeId;
+                    cacheItem.ToolLayOutType = (item.IsQuickTool == true ? 1 : 0);
                 }
             }
 
-            MoreTools = more;
+            Settings.Default.Save();
         }
     }
 

+ 27 - 18
PDF Office/Model/PDFTool/ToolItem.cs

@@ -9,26 +9,35 @@ using System.Threading.Tasks;
 
 namespace PDF_Office.Model.PDFTool
 {
-    public class ToolItem1 : INotifyPropertyChanged
+    public class ToolItem : BindableBase
     {
-        public event PropertyChangedEventHandler PropertyChanged = delegate { };
-
-        private bool _isShowConciseContent = false;
-        public bool IsShowConciseContent
-        {
-            get { return _isShowConciseContent; }
-            set
-            {
-                _isShowConciseContent = value;
-                PropertyChanged(this, new PropertyChangedEventArgs("IsShowConciseContent"));
-            }
-        }
+        /// <summary>
+        /// 是否为新增的工具
+        /// </summary>
         public bool IsNewTool { get; set; }
-        public int Id { get; set; }
-        public PDFToolType Tag { get; set; }
-        public string Image { get; set; }
-        public string TitleInfo { get; set; }
-        public string Title { get; set; }
+        /// <summary>
+        /// 是否为快捷工具
+        /// </summary>
+        public bool IsQuickTool { get; set; }
+        /// <summary>
+        /// 类型:如普通工具、常用工具、付费工具
+        /// </summary>
+        public int ToolTypeId { get; set; }
+        /// <summary>
+        /// 类型:如普通工具、常用工具、付费工具
+        /// </summary>
+        public PDFToolType ToolType { get; set; }
+        /// <summary>
+        /// 功能名称:拆分功能、合并功能、转档功能等
+        /// </summary>
+        public PDFFnType FnType { get; set; }
+
+        #region 显示内容
+
+        public string FnImg { get; set; }
+        public string FnInfo { get; set; }
+        public string FnName { get; set; }
 
+        #endregion
     }
 }

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 19
PDF Office/Styles/ContextMenuTextEditStyle.xaml


+ 103 - 13
PDF Office/ViewModels/BOTA/OutLineControlViewModel.cs

@@ -22,6 +22,7 @@ namespace PDF_Office.ViewModels.BOTA
 {
     class OutLineControlViewModel : BindableBase, INavigationAware
     {
+        private string PageDefaultName = "";
         //缩略图相关全局变量,减少内存申请次数
         private WriteableBitmap WirteBitmap;
         private byte[] bmpData;
@@ -146,13 +147,13 @@ namespace PDF_Office.ViewModels.BOTA
                 return;
             }
             CPDFAction action = outline.Outline.GetAction();
-            //if (action != null && action.ActionType != C_ACTION_TYPE.ACTION_TYPE_UNKNOWN)
-            //    PDFViewer.ProcessAction(action);
-            //else
-            //{
+            if (action != null && action.ActionType != C_ACTION_TYPE.ACTION_TYPE_UNKNOWN)
+                PDFViewer.ProcessAction(action);
+            else
+            {
                 Size size = PDFViewer.Document.GetPageSize(Convert.ToInt32(outline.PageIndex) - 1);
-                PDFViewer.GoToPage(Convert.ToInt32(outline.PageIndex) - 1, new Point(size.Width - outline.PositionX, size.Height - outline.PositionY));
-            //}
+                PDFViewer.GoToPage(Convert.ToInt32(outline.PageIndex) - 1, new Point((size.Width - outline.PositionX)/72.0*96.0, (size.Height - outline.PositionY)/72.0*96.0));
+            }
         }
 
         /// <summary>
@@ -194,38 +195,91 @@ namespace PDF_Office.ViewModels.BOTA
             CPDFDestination info = new CPDFDestination();
             info.PageIndex = textSelectNodes[0].PageIndex;
             Size size = PDFViewer.Document.GetPageSize(textSelectNodes[0].PageIndex);
-            info.Position_X = (float)(size.Width-textSelectNodes[0].StartPoint.X);
-            info.Position_Y = (float)(size.Height-textSelectNodes[0].StartPoint.Y);
+            info.Position_X = (float)(size.Width - textSelectNodes[0].StartPoint.X);
+            info.Position_Y = (float)(size.Height - textSelectNodes[0].StartPoint.Y);
             outline.Outline.SetDestination(PDFViewer.Document, info);
-            PDFViewer.Document.ReleaseOutlineList();
             Updata(false);
         }
 
         /// <summary>
         /// 添加大纲
         /// </summary>
-        public void AddOutLine()
+        public int AddOutLine(OutlineNode outline)
         {
+            int ItemIndex = 0;
             List<TextSelectNode> textSelectNodes = PDFViewer.GetCreateOutLineInfo();
             CPDFDestination info = new CPDFDestination();
+            if (textSelectNodes.Count <= 0)
+            {
+                //SDK出错了
+                return -1;
+            }
             info.PageIndex = textSelectNodes[0].PageIndex;
             info.Position_X = (float)textSelectNodes[0].StartPoint.X;
             info.Position_Y = (float)textSelectNodes[0].StartPoint.Y;
             CPDFOutline dto = null;
+            //当前有选中大纲列表
+            if (outline != null)
+            {
+                CPDFOutline parentoutline = outline.Outline.GetParent();
+                if (parentoutline == null)
+                {
+                    //获取父级失败,直接添加在根节点最下方
+                    PDFViewer.Document.GetOutlineList();
+                    CPDFOutline parent = PDFViewer.Document.GetOutlineRoot();
+                    if (!parent.InsertChildAtIndex(PDFViewer.Document, parent.ChildList.Count, ref dto))
+                    {
+                        //SDK出错了
+                        return -1;
+                    }
+                    ItemIndex = parent.ChildList.Count;
+                }
+                else
+                {
+                    //获取父节点成功,添加在父节点中选中项下方
+                    int index = GetOutlinesIndexFormParent(parentoutline, outline.Outline);
+                    parentoutline.InsertChildAtIndex(PDFViewer.Document, index, ref dto);
+                    ItemIndex = index + 1;
+                }
+            }
+            else
+            {
+                //未选中数据,直接添加在根节点最下方
+                PDFViewer.Document.GetOutlineList();
+                CPDFOutline parent = PDFViewer.Document.GetOutlineRoot();
+                if (!parent.InsertChildAtIndex(PDFViewer.Document, parent.ChildList.Count, ref dto))
+                {
+                    //SDK出错了
+                    return -1;
+                }
+                ItemIndex = parent.ChildList.Count;
+            }
+            ///当前没有选中文字
             if (string.IsNullOrEmpty(textSelectNodes[0].SelectText))
             {
-                dto.SetTitle(textSelectNodes[0].PageIndex.ToString());
+                string addPageName = PageDefaultName + (textSelectNodes[0].PageIndex + 1).ToString();
+                if (!dto.SetTitle(addPageName))
+                {
+                    //SDK出错了
+                    return -1;
+                }
             }
             else
             {
-                dto.SetTitle(textSelectNodes[0].SelectText);
+                string addPageName = PageDefaultName + textSelectNodes[0].SelectText;
+                if (!dto.SetTitle(addPageName))
+                {
+                    //SDK出错了
+                    return -1;
+                }
             }
 
             dto.SetDestination(PDFViewer.Document, info);
-            PDFViewer.Document.ReleaseOutlineList();
             Updata(false);
+            return ItemIndex;
         }
 
+
         /// <summary>
         /// 删除所有大纲
         /// </summary>
@@ -496,6 +550,42 @@ namespace PDF_Office.ViewModels.BOTA
             return null;
         }
 
+        /// <summary>
+        /// 从当前列表中找到对应的OutlineNode对象
+        /// </summary>
+        public OutlineNode FindOutlineFromList(ObservableCollection<OutlineNode> list, OutlineNode outline, int outlineindex)
+        {
+            //如果传入比对数据为null,则返回最后一项
+            if (outline == null)
+            {
+                return list.Last();
+            }
+            int index = list.IndexOf(outline);
+            if (index >= 0)
+            {
+                if (outlineindex <= index)
+                {
+                    return list[index];
+                }
+                else
+                {
+                    return list[outlineindex - 1];
+                }
+            }
+            else
+            {
+                foreach (var item in list)
+                {
+                    OutlineNode node = FindOutlineFromList(item.Chlidlist, outline, outlineindex);
+                    if (node != null)
+                    {
+                        return node;
+                    }
+                }
+            }
+            return null;
+        }
+
         private int GetIndexFromParent(List<CPDFOutline> parentlist, CPDFOutline outline)
         {
             for (int i = 0; i < parentlist.Count; i++)

+ 14 - 0
PDF Office/ViewModels/HomePanel/PDFTools/PDFToolsContentViewModel.cs

@@ -22,11 +22,19 @@ namespace PDF_Office.ViewModels.HomePanel.PDFTools
             set { SetProperty(ref _isExpendTools, value); }
         }
 
+        private bool _isDropTools = false;
+        public bool IsDropTools
+        {
+            get { return _isDropTools; }
+            set { SetProperty(ref _isDropTools, value); }
+        }
+
         #endregion
 
         #region Command and Event
         public DelegateCommand<object> OpenMenuCommand { get; set; }
         public DelegateCommand ExpendCommand { get; set; }
+        public DelegateCommand<object> CustomCommand { get; set; }
 
         public event EventHandler<bool> ExpendToolsHanlder;
 
@@ -41,6 +49,12 @@ namespace PDF_Office.ViewModels.HomePanel.PDFTools
         {
             OpenMenuCommand = new DelegateCommand<object>(OpenMenu);
             ExpendCommand = new DelegateCommand(Expend);
+            CustomCommand = new DelegateCommand<object>(Custom);
+        }
+
+        private void Custom(object obj)
+        {
+            IsDropTools = true;
         }
 
         private void Expend()

+ 3 - 2
PDF Office/ViewModels/HomePanel/PDFTools/QuickToolsContentViewModel.cs

@@ -2,6 +2,7 @@
 using PDF_Office.Helper;
 using PDF_Office.Model;
 using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+using PDF_Office.Model.PDFTool;
 using PDFSettings;
 using Prism.Commands;
 using Prism.Mvvm;
@@ -96,11 +97,11 @@ namespace PDF_Office.ViewModels.HomePanel.PDFTools
             System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
             dlg.Multiselect = false;
             dlg.Filter = "PDF|*.pdf;*.PDF;";
-            if (toolItem.FnType == (int)PDFFnType.Compress || toolItem.FnType == (int)PDFFnType.Security)
+            if (toolItem.FnType == PDFFnType.Compress || toolItem.FnType == PDFFnType.Security)
             {
                 dlg.Multiselect = true;
             }
-            if (toolItem.FnType == (int)PDFFnType.Merge)
+            if (toolItem.FnType == PDFFnType.Merge)
             {
                 dlg.Multiselect = true;
                 dlg.Filter = "Picture|*.png;*.PNG;*.jpg;*.JPG;*bmp;*jpeg;*gif;*tiff;";

+ 22 - 25
PDF Office/ViewModels/PropertyPanel/TextEditPropertyViewModel.cs

@@ -514,11 +514,21 @@ namespace PDF_Office.ViewModels.PropertyPanel
         }
 
 
-
+        private CPDFViewer PDFViewer;
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
 
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            if (PDFViewer != null)
+            {
+                PDFViewer.PDFEditActiveHandler -= PDFViewer_PDFEditActiveHandler;
+                PDFViewer.PDFEditActiveHandler += PDFViewer_PDFEditActiveHandler;
+
+                PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
+                PDFViewer.PDFEditCommandHandler += PDFViewer_PDFEditCommandHandler;
+
+            }
         }
 
         public bool IsNavigationTarget(NavigationContext navigationContext)
@@ -526,25 +536,17 @@ namespace PDF_Office.ViewModels.PropertyPanel
             return true;
         }
 
-        private CPDFViewer PDFViewer;
+       
         public void OnNavigatedFrom(NavigationContext navigationContext)
         {
-            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
-            if(PDFViewer != null)
-            {
-                PDFViewer.PDFEditActiveHandler -= PDFViewer_PDFEditActiveHandler;
-                PDFViewer.PDFEditActiveHandler += PDFViewer_PDFEditActiveHandler; 
-
-                PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
-                PDFViewer.PDFEditCommandHandler += PDFViewer_PDFEditCommandHandler;
-                
-            }
         }
 
         private void PDFViewer_PDFEditCommandHandler(object sender, PDFEditCommand e)
         {
            
             ContextMenu popMenu = null;
+            if (e == null)
+                return;
 
             switch (e.CommandType)
             {
@@ -553,12 +555,12 @@ namespace PDF_Office.ViewModels.PropertyPanel
                     if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.None)
                     {
                         popMenu = App.Current.FindResource("NoneMenu") as ContextMenu;
-                        if(popMenu != null && popMenu.Items.Count == 4)
+                        if(popMenu != null && popMenu.Items.Count == 3)
                         {
                             //复制
                             MenuItem menuItem = popMenu.Items[0] as MenuItem;
                             menuItem.CommandTarget = (UIElement)sender;
-                            menuItem.Command = ApplicationCommands.Copy;
+                            menuItem.Command = ApplicationCommands.Paste;
                             //添加文本
                             menuItem = popMenu.Items[1] as MenuItem;
                             menuItem.CommandTarget = (UIElement)sender;
@@ -567,11 +569,6 @@ namespace PDF_Office.ViewModels.PropertyPanel
                              menuItem = popMenu.Items[2] as MenuItem;
                             menuItem.CommandTarget = (UIElement)sender;
                             menuItem.Command = AddImgCommand;
-                            //删除
-                            menuItem = popMenu.Items[3] as MenuItem;
-                            menuItem.CommandTarget = (UIElement)sender;
-                            menuItem.Command = ApplicationCommands.Delete;
-
                             e.PopupMenu = popMenu;
                             if (e.PopupMenu != null)
                             {
@@ -582,7 +579,7 @@ namespace PDF_Office.ViewModels.PropertyPanel
                     else if(e.EditType == ComPDFKit.PDFPage.CPDFEditType.EditImage)
                     {
                         popMenu = App.Current.FindResource("SelectImgMenu") as ContextMenu;
-                        if (popMenu != null && popMenu.Items.Count == 8)
+                        if (popMenu != null && popMenu.Items.Count == 7)
                         {
                             //复制
                             MenuItem menuItem = popMenu.Items[0] as MenuItem;
@@ -611,11 +608,7 @@ namespace PDF_Office.ViewModels.PropertyPanel
                             //导出
                             menuItem = popMenu.Items[6] as MenuItem;
                             menuItem.CommandTarget = (UIElement)sender;
-                            menuItem.Command = ExportImgCommand;
-                            //排列
-                            menuItem = popMenu.Items[7] as MenuItem;
-                            menuItem.CommandTarget = (UIElement)sender;
-                            menuItem.Command = ApplicationCommands.Cut;
+                            menuItem.Command =ExportImgCommand;
                             e.PopupMenu = popMenu;
                             if (e.PopupMenu != null)
                             {
@@ -623,6 +616,10 @@ namespace PDF_Office.ViewModels.PropertyPanel
                             }
                         }
                     }
+                    else if(e.EditType == ComPDFKit.PDFPage.CPDFEditType.EditText)
+                    {
+                     //   e.SelectText
+                    }
 
             break;
 

+ 8 - 7
PDF Office/ViewModels/Tools/TextEditToolContentViewModel.cs

@@ -71,9 +71,15 @@ namespace PDF_Office.ViewModels.Tools
 
         }
 
+        private CPDFViewer PDFViewer;
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            if (PDFViewer != null)
+            {
+
 
+            }
         }
 
         public bool IsNavigationTarget(NavigationContext navigationContext)
@@ -81,15 +87,10 @@ namespace PDF_Office.ViewModels.Tools
             return true;
         }
 
-        private CPDFViewer PDFViewer;
+      
         public void OnNavigatedFrom(NavigationContext navigationContext)
         {
-            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
-            if (PDFViewer != null)
-            {
-             
-
-            }
+          
         }
 
     }

+ 4 - 8
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -510,15 +510,11 @@ namespace PDF_Office.ViewModels
         {
             if(currentBar == "TabItemEdit")
             {
-                IsPropertyOpen = true;
-                if (IsPropertyOpen == true)
+                if (PDFViewer != null)
                 {
-                    if(PDFViewer != null)
-                    {
-                        PDFViewer.SetMouseMode(MouseModes.PDFEdit);
-                        SelectedPrpoertyPanel("TextEditProperty", null);
-                    }
-                   
+                    PDFViewer.SetMouseMode(MouseModes.PDFEdit);
+                    SelectedPrpoertyPanel("TextEditProperty", null);
+                    IsPropertyOpen = true;
                 }
             }
             else

+ 10 - 8
PDF Office/Views/BOTA/OutLineControl.xaml

@@ -27,13 +27,15 @@
                     VerticalAlignment="Center" FontSize="18" FontWeight="SemiBold" Text="Outline" />
             <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                 <customcontrol:PathButton
+            x:Name="BtnAdd"
+            Click="BtnAdd_Click"
             Height="24" Width="24"  IconHeight="20"  IconWidth="20" 
             Icon="{StaticResource Ic_AddButtonPath}"  IconFill="Red"
             IconPress="{StaticResource Ic_AddButtonPath}" IconPressFill="#C04CF8"
             IconMouseOver="{StaticResource Ic_AddButtonPath}" IconMouseOverFill="#C04CF8" />
                 <customcontrol:PathButton
-                    x:Name="BtnMore"
-                    Click="BtnMore_Click"
+            x:Name="BtnMore"
+            Click="BtnMore_Click"
             Height="24" Width="24"  IconHeight="20"  IconWidth="20" 
             Icon="{StaticResource Ic_MoreButtonPath}"  IconFill="Red"
             IconPress="{StaticResource Ic_MoreButtonPath}" IconPressFill="#C04CF8"
@@ -74,7 +76,7 @@
         <Grid Grid.Row="1"
                DragOver="Grid_DragOver"
               DragLeave="Grid_DragLeave">
-            <TreeView x:Name="OutlineView" Grid.Row="1" ItemsSource="{Binding Outlinelist}"
+            <TreeView x:Name="OutlineView" Grid.Row="1" ItemsSource="{Binding Outlinelist}" 
                 BorderThickness="0" AllowDrop="True"
                 VirtualizingPanel.ScrollUnit="Pixel"
                 Drop="OutlineView_Drop"
@@ -83,14 +85,14 @@
                 PreviewMouseDoubleClick="OutlineView_PreviewMouseDoubleClick"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                 <TreeView.ItemTemplate>
-                    <HierarchicalDataTemplate  DataType="{x:Type model:OutlineNode}" ItemsSource="{Binding Path=Chlidlist}">
+                    <HierarchicalDataTemplate   DataType="{x:Type model:OutlineNode}" ItemsSource="{Binding Path=Chlidlist}">
                         <Grid>
                             <Grid.ContextMenu>
                                 <ContextMenu>
-                                    <MenuItem Header="添加条目"/>
-                                    <MenuItem Header="添加子条目"/>
-                                    <MenuItem Header="添加上一级条目" IsEnabled="{Binding CanAddParent}"/>
-                                    
+                                    <MenuItem x:Name="AddMenu" Click="AddMenu_Click" Header="添加条目"/>
+                                    <MenuItem x:Name="AddChlidMenu" Click="AddChlidMenu_Click"  Header="添加子条目"/>
+                                    <MenuItem x:Name="AddParentMenu" Click="AddParentMenu_Click" Header="添加上一级条目" IsEnabled="{Binding CanAddParent}"/>
+
                                     <MenuItem x:Name="DeleteMenu" Click="DeleteMenu_Click" Header="删除"/>
 
                                     <MenuItem x:Name="RenameMenu" Click="RenameMenu_Click" Header="重命名"/>

+ 40 - 2
PDF Office/Views/BOTA/OutLineControl.xaml.cs

@@ -35,6 +35,7 @@ namespace PDF_Office.Views.BOTA
         /// 需要重命名的Item的DataContext
         /// </summary>
         private OutlineNode ReNameOutlineNode = null;
+        bool IsReName = false;
         public OutLineControl()
         {
             InitializeComponent();
@@ -48,7 +49,7 @@ namespace PDF_Office.Views.BOTA
         }
         private void OutlineView_PreviewMouseMove(object sender, MouseEventArgs e)
         {
-            if (e.LeftButton == MouseButtonState.Pressed)
+            if (e.LeftButton == MouseButtonState.Pressed && !IsReName)
             {
                 var pos = e.GetPosition(OutlineView);
                 HitTestResult result = VisualTreeHelper.HitTest(OutlineView, pos);
@@ -154,6 +155,7 @@ namespace PDF_Office.Views.BOTA
             {
                 return;
             }
+
             OutlineNode viewitem = tree.SelectedItem as OutlineNode;
             if (viewitem == null)
             {
@@ -234,6 +236,7 @@ namespace PDF_Office.Views.BOTA
                 }
                 ReNameText.Focus();
                 ReNameText.SelectAll();
+                IsReName = true;
             }
         }
 
@@ -242,12 +245,14 @@ namespace PDF_Office.Views.BOTA
             TextBox newdto = e.OriginalSource as TextBox;
             if (newdto == null)
             {
+                IsReName = false;
                 return;
             }
             string newtitle = string.IsNullOrEmpty(newdto.Text) ? "" : newdto.Text;
             Grid senderdto = sender as Grid;
             if (senderdto == null)
             {
+                IsReName = false;
                 return;
             }
             senderdto.Visibility = Visibility.Collapsed;
@@ -258,18 +263,20 @@ namespace PDF_Office.Views.BOTA
                 {
                     if (newtitle == result.Title)
                     {
+                        IsReName = false;
                         return;
                     }
                     (DataContext as OutLineControlViewModel).SetTitle(result, newtitle);
                 }
                 (DataContext as OutLineControlViewModel).Updata(false);
             }
+            IsReName = false;
         }
 
         private void ToolTip_Opened(object sender, RoutedEventArgs e)
         {
             CustomImageControl imageControl = CommonHelper.FindVisualChild<CustomImageControl>(sender as ToolTip);
-           
+
             OutlineNode outline = imageControl.DataContext as OutlineNode;
             if (outline == null || string.IsNullOrEmpty(outline.PageIndex))
             {
@@ -363,5 +370,36 @@ namespace PDF_Office.Views.BOTA
                 (DataContext as OutLineControlViewModel).ChangeOutLineDestination((sender as MenuItem).DataContext as OutlineNode);
             }
         }
+
+        private void BtnAdd_Click(object sender, RoutedEventArgs e)
+        {
+            int ItemIndex = (DataContext as OutLineControlViewModel).AddOutLine(OutlineView.SelectedItem as OutlineNode);
+            OutlineView.UpdateLayout();
+            OutlineNode node = (DataContext as OutLineControlViewModel).FindOutlineFromList((DataContext as OutLineControlViewModel).Outlinelist, OutlineView.SelectedItem as OutlineNode, ItemIndex);
+            node.IsSelected = true;
+            ReNameOutlineNode = node;
+            node.IsReName = Visibility.Collapsed;
+        }
+
+        private void AddMenu_Click(object sender, RoutedEventArgs e)
+        {
+            ((sender as MenuItem).DataContext as OutlineNode).IsSelected = true;
+            int ItemIndex = (DataContext as OutLineControlViewModel).AddOutLine((sender as MenuItem).DataContext as OutlineNode);
+            OutlineView.UpdateLayout();
+            OutlineNode node = (DataContext as OutLineControlViewModel).FindOutlineFromList((DataContext as OutLineControlViewModel).Outlinelist, OutlineView.SelectedItem as OutlineNode, ItemIndex);
+            node.IsSelected = true;
+            ReNameOutlineNode = node;
+            node.IsReName = Visibility.Collapsed;
+        }
+
+        private void AddParentMenu_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void AddChlidMenu_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
     }
 }

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

@@ -22,16 +22,16 @@
                         <RowDefinition Height="auto"></RowDefinition>
                         <RowDefinition Height="*"></RowDefinition>
                     </Grid.RowDefinitions>
-                    <Image VerticalAlignment="Top" Source="{Binding Image}" HorizontalAlignment="Center" Width="28" Height="28" Margin="5,10,5,5" />
+                    <Image VerticalAlignment="Top" Source="{Binding FnImg}" HorizontalAlignment="Center" Width="28" Height="28" Margin="5,10,5,5" />
 
-                    <TextBlock  Name="TxbTitle" Grid.Column="1" Text="{Binding Title}" 
+                    <TextBlock  Name="TxbTitle" Grid.Column="1" Text="{Binding FnName}" 
                                     FontSize="14" FontWeight="SemiBold" Foreground="Black"
                                     VerticalAlignment="Top" Margin="0,15,0,0"></TextBlock>
 
 
                     <StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1"  Margin="6,0,6,0">
                         <Grid>
-                            <TextBlock Name="ToolInfoBlock" Text="{Binding TitleInfo}"
+                            <TextBlock Name="ToolInfoBlock" Text="{Binding FnInfo}"
                                        Foreground="#666666" LineHeight="16"  FontSize="12"  TextWrapping="Wrap" VerticalAlignment="Center" Margin="0,8,0,0"></TextBlock>
                         </Grid>
 

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

@@ -18,8 +18,8 @@
                     <ColumnDefinition Width="*"/>
                 </Grid.ColumnDefinitions>
                 <Grid x:Name="GridToolMaskConcise" Grid.ColumnSpan="2" Background="#477EDE" Visibility="Collapsed"/>
-                <Image VerticalAlignment="Top" Source="{Binding Image}" HorizontalAlignment="Center" Width="28" Height="28" Margin="5,10,5,5" />
-                <TextBlock  Name="TxbTitleConcise" Grid.Column="1" Text="{Binding Title}" FontSize="14" FontWeight="SemiBold" VerticalAlignment="Top" Margin="0,15,0,0"></TextBlock>
+                <Image VerticalAlignment="Top" Source="{Binding FnImg}" HorizontalAlignment="Center" Width="28" Height="28" Margin="5,10,5,5" />
+                <TextBlock  Name="TxbTitleConcise" Grid.Column="1" Text="{Binding FnName}" FontSize="14" FontWeight="SemiBold" VerticalAlignment="Top" Margin="0,15,0,0"></TextBlock>
             </Grid>
         </Border>
         

+ 42 - 2
PDF Office/Views/HomePanel/PDFTools/PDFToolsContent.xaml

@@ -66,15 +66,17 @@
             HorizontalAlignment="Right"
             VerticalAlignment="Top"
             Orientation="Horizontal"
-            Visibility="Visible">
+            Visibility="{Binding IsDropTools,Converter={StaticResource InvertBoolToVisibleConvert}}">
 
                     <Button
-                x:Name="BtnCustom"
+                x:Name="BtnCustom" Tag="Custom"
                 Width="68"
                 Height="28"
                 Margin="0,0,0,0"
                 Background="#FFFFFF"
                 Content="Custom"
+                Command="{Binding CustomCommand}"
+                CommandParameter="{Binding ElementName=BtnCustom,Path=Tag}"        
                 Click="BtnTools_Click"
                >
 
@@ -91,6 +93,44 @@
                     </Button>
 
                 </StackPanel>
+
+
+                <StackPanel
+            x:Name="PnlDropToolsUIBtns" Grid.ColumnSpan="2"
+            Grid.Column="0" 
+            Margin="0,0,12,0"
+            HorizontalAlignment="Right"
+            VerticalAlignment="Top"
+            Orientation="Horizontal"
+            Visibility="{Binding IsDropTools,Converter={StaticResource BoolToVisibilityConverter}}">
+
+                    <Button
+                x:Name="BtnCancel" Tag="Cancel"
+                Width="68"
+                Height="28"
+                Margin="0,0,0,0"
+                Background="#FFFFFF"
+                Content="Cancel"
+                CommandParameter="{Binding ElementName=BtnCustom,Path=Tag}"           
+                Click="BtnTools_Click"
+               >
+
+                    </Button>
+
+                    <Button  Tag="Apply"
+                x:Name="BtnApply"
+                Width="28"
+                Height="28"
+                Margin="12,0,0,0"
+                 Background="#FFFFFF" BorderThickness="0" Content="Apply"
+                Command="{Binding OpenMenuCommand}" CommandParameter="{Binding ElementName=BtnMore}"
+               >
+                    </Button>
+
+                </StackPanel>
+
+
+
             </Grid>
            
             <TextBlock Text="首页快捷工具" Margin="0,16,0,0" FontSize="14" FontFamily="PingFang SC"/> 

+ 27 - 10
PDF Office/Views/HomePanel/PDFTools/PDFToolsContent.xaml.cs

@@ -205,7 +205,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
         {
             var source = sourceListItem.Content as ToolItem;
             if (moreTools == null && moreTools.Count != 0) return;
-            List<ToolItem> toolModule = moreTools.FindAll(item => item.Title == source.Title);
+            List<ToolItem> toolModule = moreTools.FindAll(item => item.FnName == source.FnName);
             if (toolModule.Count > 0)
             {
                 // 判断文件夹是否存在,不存在则创建
@@ -214,7 +214,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
                 {
                     folder.Create();
                 }
-                fileName = System.IO.Path.Combine(folder.FullName, $"{source.Title}.png");
+                fileName = System.IO.Path.Combine(folder.FullName, $"{source.FnName}.png");
 
                 SaveToPng(sourceListItem, fileName);
             }
@@ -242,7 +242,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
                 return;
             }
             var targetAToolModule = targetListItem.Content as ToolItem;
-            ToolItem target = quickTools.Find(c => c.Title == targetAToolModule.Title);
+            ToolItem target = quickTools.Find(c => c.FnName == targetAToolModule.FnName);
 
             //查找元数据
             var sourceAToolModule = e.Data.GetData(typeof(ToolItem)) as ToolItem;
@@ -272,7 +272,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
         private void ModuleExchange(ToolItem sourceAToolModule, ToolItem targetAToolModule)
         {
             if (moreTools == null) return;
-            ToolItem source = moreTools.Find(c => c.Title == sourceAToolModule.Title);
+            ToolItem source = moreTools.Find(c => c.FnName == sourceAToolModule.FnName);
             ListBoxEx MoreEx = GetListMoreControl();
             if (MoreEx == null) return;
 
@@ -280,19 +280,25 @@ namespace PDF_Office.Views.HomePanel.PDFTools
             if (ShortEx == null) return;
 
 
-            int targetIndex = quickTools.FindIndex(item => item.Title == targetAToolModule.Title);
+            int targetIndex = quickTools.FindIndex(item => item.FnName == targetAToolModule.FnName);
             if (targetIndex < 0) return;
             if (!isMoreCuts)
             {
                 MoreEx.AllowDrop = false;
                 sourceImage.Visibility = Visibility.Hidden;
-                source = quickTools.Find(c => c.Title == sourceAToolModule.Title);
+                source = quickTools.Find(c => c.FnName == sourceAToolModule.FnName);
                 if (source == null) return;
-                int sourceIndex = quickTools.FindIndex(item => item.Title == sourceAToolModule.Title);
+                int sourceIndex = quickTools.FindIndex(item => item.FnName == sourceAToolModule.FnName);
                 if (sourceIndex < 0) return;
                 var temp = quickTools[sourceIndex];
                 quickTools[sourceIndex] = quickTools[targetIndex];
                 quickTools[targetIndex] = temp;
+
+                var sourceId = source.ToolTypeId;
+                var targetId = target.ToolTypeId;
+                source.ToolTypeId = targetId;
+                target.ToolTypeId = sourceId;
+
                 ShortEx.Items.Refresh();
                 ListBoxCutsWidthChanged(ShortEx);
             }
@@ -306,6 +312,13 @@ namespace PDF_Office.Views.HomePanel.PDFTools
                 quickTools.Remove(target);
                 quickTools.Insert(targetIndex, source);
 
+                source.IsQuickTool = true;
+                target.IsQuickTool = false;
+
+                var targetId = target.ToolTypeId;
+                source.ToolTypeId = targetId;
+                target.ToolTypeId = 0;//移到第一个位置
+
                 MoreEx.Items.Refresh();
                 ShortEx.Items.Refresh(); 
 
@@ -314,8 +327,12 @@ namespace PDF_Office.Views.HomePanel.PDFTools
                 ListBoxCutsWidthChanged(ShortEx);
                 ListBoxCutsWidthChanged(MoreEx);
             }
+
+            if (PDFtools != null)
+                PDFtools.SaveCacheList();
         }
 
+
         private void WorkingWithAnimation(Point pos)
         {
             sourceImage.Visibility = Visibility.Hidden;
@@ -453,7 +470,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
             {
                 var sourceAToolModule = e.Data.GetData(typeof(ToolItem)) as ToolItem;
                 if (sourceAToolModule == null) return;
-                int sourceIndex = quickTools.FindIndex(item => item.Title == sourceAToolModule.Title);
+                int sourceIndex = quickTools.FindIndex(item => item.FnName == sourceAToolModule.FnName);
                 //根据index找listbox对应的item
                 sourceListItem = (ListItemQuickTool)(ShortEx.ItemContainerGenerator.ContainerFromIndex(sourceIndex) as FrameworkElement);
                 if (sourceListItem == null)
@@ -467,7 +484,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
             {
                 var sourceAToolModule = e.Data.GetData(typeof(ToolItem)) as ToolItem;
                 if (sourceAToolModule == null) return;
-                int sourceIndex = moreTools.FindIndex(item => item.Title == sourceAToolModule.Title);
+                int sourceIndex = moreTools.FindIndex(item => item.FnName == sourceAToolModule.FnName);
                 //根据index找listbox对应的item
                 sourceListItem = (ListItemQuickTool)(MoreEx.ItemContainerGenerator.ContainerFromIndex(sourceIndex) as FrameworkElement);
                 if (sourceListItem == null)
@@ -494,7 +511,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
             }
             var targetAToolModule = targetListItem.Content as ToolItem;
             if (targetAToolModule == null) return;
-            target = quickTools.Find(c => c.Title == targetAToolModule.Title);
+            target = quickTools.Find(c => c.FnName == targetAToolModule.FnName);
         }
 
         /// <summary>

+ 16 - 51
PDFSettings/PDFToolsList.cs

@@ -10,7 +10,7 @@ namespace PDFSettings
     /// <summary>
     /// 所有工具列表
     /// </summary>
-    public class AllPDFToolsList : List<ToolItem>
+    public class AllPDFToolsList : List<CacheToolItem>
     {
 
     }
@@ -18,74 +18,39 @@ namespace PDFSettings
     /// <summary>
     /// 快捷工具列表
     /// </summary>
-    public class QuickPDFToolsList : List<ToolItem>
+    public class QuickPDFToolsList : List<CacheToolItem>
     {
 
     }
 
-    public class ToolItem : INotifyPropertyChanged
+    public class CacheToolItem 
     {
-        public event PropertyChangedEventHandler PropertyChanged = delegate { };
-        private bool _isShowConciseContent = false;
-        /// <summary>
-        /// PDF工具集合UI是否显示为只有标题和图标的内容
-        /// </summary>
-        public bool IsShowConciseContent
-        {
-            get { return _isShowConciseContent; }
-            set
-            {
-                _isShowConciseContent = value;
-                PropertyChanged(this, new PropertyChangedEventArgs("IsShowConciseContent"));
-            }
-        }
-
         #region 重要属性
-
-
         /// <summary>
-        /// 是否为新增工具
+        /// 是否为新增工具功能
         /// </summary>
-        public bool IsNew { get; set; }
-
-        #region 工具类型
-
+        public bool IsNewTool { get; set; }
         /// <summary>
-        /// 排序的PDF工具类型:优势工具、常用工具、付费工具等
+        /// 是否为快捷工具;值0为更多工具、值1为快捷工具
+        /// Todo:使用int类型,是因为考虑将来是否会有新需求,除了快捷工具、更多工具外,可能存在以其他布局分类的PDF工具;预留更多的int值以便于缓存数据
         /// </summary>
-        public int ToolType { get; set; }
-        /// <summary>
-        /// 某类型PDF工具的排序Id号
-        /// </summary>
-        public string strToolType { get; set; }
-        #endregion
+        public int ToolLayOutType { get; set; }
 
-
-        #region 功能
         /// <summary>
-        /// PDF工具某功能的枚举值:用来标识功能
+        /// 显示排序号:根据id号递增的方式进行排列顺序
         /// </summary>
-        public int FnType { get; set; }
-        /// <summary>
-        /// 功能名称:拆分功能、合并功能、转档功能等
-        /// </summary>
-        public string strFnType { get; set; }
-        #endregion
+        public int ToolTypeId { get; set; }
 
-        #region 显示内容
         /// <summary>
-        /// 图标路径
+        /// 类型:如普通工具、常用工具、付费工具
         /// </summary>
-        public string Image { get; set; }
-        /// <summary>
-        /// 功能说明内容
-        /// </summary>
-        public string TitleInfo { get; set; }
+        public string ToolTypeStr { get; set; }
+
         /// <summary>
-        /// 功能标题
+        /// 功能名称:拆分功能、合并功能、转档功能等
+        /// Todo:考虑到后续便于迭代PDF工具功能,不能使用int类型进行识别所需的功能,因为int类型会灵活变化,以至于不方便修改增加删除功能;
         /// </summary>
-        public string Title { get; set; }
-        #endregion
+        public string FnTypeStr { get; set; }
 
         #endregion