|
@@ -1,4 +1,5 @@
|
|
|
using PDF_Office.CustomControl;
|
|
|
+using PDF_Office.Helper;
|
|
|
using PDF_Office.ViewModels.HomePanel;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
@@ -19,25 +20,20 @@ using System.Windows.Shapes;
|
|
|
|
|
|
namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
{
|
|
|
- //public class AToolModule : DependencyObject
|
|
|
- //{
|
|
|
- // public int Id { get; set; }
|
|
|
- // public string Image { get; set; }
|
|
|
- // public string NameInfo { get; set; }
|
|
|
- // public string Name { get; set; }
|
|
|
- //}
|
|
|
|
|
|
/// <summary>
|
|
|
/// ToolbarPage.xaml 的交互逻辑
|
|
|
/// </summary>
|
|
|
- public partial class ToolbarContent : UserControl
|
|
|
+ public partial class PDFToolsContent : UserControl
|
|
|
{
|
|
|
- private MyListBoxItem sourceListItem = null;
|
|
|
- private MyListBoxItem quickSourceListItem = null;
|
|
|
- private MyListBoxItem targetListBoxItem = null;
|
|
|
- private List<ToolBarsViewModel> quickToolbars = null;
|
|
|
- private List<ToolBarsViewModel> allToolbars = null;
|
|
|
- private List<ToolBarsViewModel> moreToolbars = null;
|
|
|
+ private ListItemQuickTool sourceListItem = null;
|
|
|
+ private ListItemQuickTool targetListItem = null;
|
|
|
+ private ListItemQuickTool quickSourceListItem = null;
|
|
|
+
|
|
|
+ private List<QuickToolItem> quickTools = null;
|
|
|
+ private List<QuickToolItem> allTools = null;
|
|
|
+ private List<QuickToolItem> moreTools = null;
|
|
|
+
|
|
|
private string fileName = string.Empty;
|
|
|
private BitmapSource bitmapSource = null;
|
|
|
private bool isMoreCuts = false;
|
|
@@ -46,12 +42,12 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
private Point wrpnlPoint;
|
|
|
private Point mousePoint;
|
|
|
|
|
|
- public ToolbarContent()
|
|
|
+ public PDFToolsContent()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
|
|
|
- quickToolbars = new List<ToolBarsViewModel>();
|
|
|
- allToolbars = new List<ToolBarsViewModel>();
|
|
|
+ quickTools = new List<QuickToolItem>();
|
|
|
+ allTools = new List<QuickToolItem>();
|
|
|
|
|
|
#region ListBox
|
|
|
|
|
@@ -80,20 +76,20 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
|
|
|
for (int i = 0; i < all.Count; i++)
|
|
|
{
|
|
|
- ToolBarsViewModel aToolModule = new ToolBarsViewModel();
|
|
|
+ QuickToolItem aToolModule = new QuickToolItem();
|
|
|
aToolModule.Id = i + 1;
|
|
|
aToolModule.Name = all[i];
|
|
|
aToolModule.Image = path;
|
|
|
- allToolbars.Add(aToolModule);
|
|
|
+ allTools.Add(aToolModule);
|
|
|
}
|
|
|
|
|
|
//取前10个,如果List里面数据少于5个,则返回所有的
|
|
|
- quickToolbars = allToolbars.Take(8).ToList<ToolBarsViewModel>();
|
|
|
- ListShortCuts.ItemsSource = quickToolbars;
|
|
|
+ quickTools = allTools.Take(8).ToList<QuickToolItem>();
|
|
|
+ ListShortCuts.ItemsSource = quickTools;
|
|
|
//对比两个集合,取差值
|
|
|
- moreToolbars = allToolbars.Except(quickToolbars).ToList();
|
|
|
+ moreTools = allTools.Except(quickTools).ToList();
|
|
|
|
|
|
- ListMoreCuts.ItemsSource = moreToolbars;
|
|
|
+ ListMoreCuts.ItemsSource = moreTools;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -115,7 +111,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
sourceImage.Visibility = Visibility.Hidden;
|
|
|
return;
|
|
|
}
|
|
|
- sourceListItem = (MyListBoxItem)Utils.FindVisualParent<ListBoxItem>(result.VisualHit);
|
|
|
+ sourceListItem = (ListItemQuickTool)CommonHelper.FindVisualParent<ListBoxItem>(result.VisualHit);
|
|
|
if (sourceListItem == null || sourceListItem.Content != ListMoreCuts.SelectedItem)
|
|
|
{
|
|
|
return;
|
|
@@ -123,7 +119,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
//获取控件相对于另一控件的坐标
|
|
|
wrpnlPoint = sourceListItem.TranslatePoint(new Point(), this);
|
|
|
|
|
|
- System.Windows.DataObject dataObj = new System.Windows.DataObject(sourceListItem.Content as ToolBarsViewModel);
|
|
|
+ System.Windows.DataObject dataObj = new System.Windows.DataObject(sourceListItem.Content as QuickToolItem);
|
|
|
|
|
|
if (dataObj != null)
|
|
|
{
|
|
@@ -158,9 +154,9 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
|
|
|
private void IsMoreToolbars()
|
|
|
{
|
|
|
- var source = sourceListItem.Content as ToolBarsViewModel;
|
|
|
- if (moreToolbars == null && moreToolbars.Count != 0) return;
|
|
|
- List<ToolBarsViewModel> toolModule = moreToolbars.FindAll(item => item.Name == source.Name);
|
|
|
+ var source = sourceListItem.Content as QuickToolItem;
|
|
|
+ if (moreTools == null && moreTools.Count != 0) return;
|
|
|
+ List<QuickToolItem> toolModule = moreTools.FindAll(item => item.Name == source.Name);
|
|
|
if (toolModule.Count > 0)
|
|
|
{
|
|
|
// 判断文件夹是否存在,不存在则创建
|
|
@@ -187,17 +183,17 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
}
|
|
|
|
|
|
//查找目标数据
|
|
|
- targetListBoxItem = (MyListBoxItem)Utils.FindVisualParent<ListBoxItem>(result.VisualHit);
|
|
|
- if (targetListBoxItem == null)
|
|
|
+ targetListItem = (ListItemQuickTool)CommonHelper.FindVisualParent<ListBoxItem>(result.VisualHit);
|
|
|
+ if (targetListItem == null)
|
|
|
{
|
|
|
WorkingWithAnimation(pos);
|
|
|
return;
|
|
|
}
|
|
|
- var targetAToolModule = targetListBoxItem.Content as ToolBarsViewModel;
|
|
|
- ToolBarsViewModel target = quickToolbars.Find(c => c.Name == targetAToolModule.Name);
|
|
|
+ var targetAToolModule = targetListItem.Content as QuickToolItem;
|
|
|
+ QuickToolItem target = quickTools.Find(c => c.Name == targetAToolModule.Name);
|
|
|
|
|
|
//查找元数据
|
|
|
- var sourceAToolModule = e.Data.GetData(typeof(ToolBarsViewModel)) as ToolBarsViewModel;
|
|
|
+ var sourceAToolModule = e.Data.GetData(typeof(QuickToolItem)) as QuickToolItem;
|
|
|
if (sourceAToolModule == null)
|
|
|
{
|
|
|
sourceImage.Visibility = Visibility.Hidden;
|
|
@@ -221,24 +217,24 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
ModuleExchange(sourceAToolModule, targetAToolModule);
|
|
|
}
|
|
|
|
|
|
- private void ModuleExchange(ToolBarsViewModel sourceAToolModule, ToolBarsViewModel targetAToolModule)
|
|
|
+ private void ModuleExchange(QuickToolItem sourceAToolModule, QuickToolItem targetAToolModule)
|
|
|
{
|
|
|
- if (moreToolbars == null) return;
|
|
|
- ToolBarsViewModel source = moreToolbars.Find(c => c.Name == sourceAToolModule.Name);
|
|
|
+ if (moreTools == null) return;
|
|
|
+ QuickToolItem source = moreTools.Find(c => c.Name == sourceAToolModule.Name);
|
|
|
|
|
|
- int targetIndex = quickToolbars.FindIndex(item => item.Name == targetAToolModule.Name);
|
|
|
+ int targetIndex = quickTools.FindIndex(item => item.Name == targetAToolModule.Name);
|
|
|
if (targetIndex < 0) return;
|
|
|
if (!isMoreCuts)
|
|
|
{
|
|
|
ListMoreCuts.AllowDrop = false;
|
|
|
sourceImage.Visibility = Visibility.Hidden;
|
|
|
- source = quickToolbars.Find(c => c.Name == sourceAToolModule.Name);
|
|
|
+ source = quickTools.Find(c => c.Name == sourceAToolModule.Name);
|
|
|
if (source == null) return;
|
|
|
- int sourceIndex = quickToolbars.FindIndex(item => item.Name == sourceAToolModule.Name);
|
|
|
+ int sourceIndex = quickTools.FindIndex(item => item.Name == sourceAToolModule.Name);
|
|
|
if (sourceIndex < 0) return;
|
|
|
- var temp = quickToolbars[sourceIndex];
|
|
|
- quickToolbars[sourceIndex] = quickToolbars[targetIndex];
|
|
|
- quickToolbars[targetIndex] = temp;
|
|
|
+ var temp = quickTools[sourceIndex];
|
|
|
+ quickTools[sourceIndex] = quickTools[targetIndex];
|
|
|
+ quickTools[targetIndex] = temp;
|
|
|
ListShortCuts.Items.Refresh();
|
|
|
ListBoxCutsWidthChanged(ListShortCuts);
|
|
|
}
|
|
@@ -246,17 +242,17 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
{
|
|
|
if (target == null) return;
|
|
|
if (source == null) return;
|
|
|
- moreToolbars.Remove(source);
|
|
|
- moreToolbars.Insert(0, target);
|
|
|
+ moreTools.Remove(source);
|
|
|
+ moreTools.Insert(0, target);
|
|
|
|
|
|
- quickToolbars.Remove(target);
|
|
|
- quickToolbars.Insert(targetIndex, source);
|
|
|
+ quickTools.Remove(target);
|
|
|
+ quickTools.Insert(targetIndex, source);
|
|
|
|
|
|
ListMoreCuts.Items.Refresh();
|
|
|
ListShortCuts.Items.Refresh();
|
|
|
|
|
|
sourceImage.Visibility = Visibility.Hidden;
|
|
|
- targetListBoxItem.IsOverModular = false;
|
|
|
+ targetListItem.IsOverModular = false;
|
|
|
ListBoxCutsWidthChanged(ListShortCuts);
|
|
|
ListBoxCutsWidthChanged(ListMoreCuts);
|
|
|
}
|
|
@@ -354,7 +350,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
stream.Close();
|
|
|
}
|
|
|
|
|
|
- private ToolBarsViewModel target;
|
|
|
+ private QuickToolItem target;
|
|
|
|
|
|
private void ListBoxShortCuts_DragOver(object sender, DragEventArgs e)
|
|
|
{
|
|
@@ -391,11 +387,11 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
|
|
|
if (!isMoreCuts)
|
|
|
{
|
|
|
- var sourceAToolModule = e.Data.GetData(typeof(ToolBarsViewModel)) as ToolBarsViewModel;
|
|
|
+ var sourceAToolModule = e.Data.GetData(typeof(QuickToolItem)) as QuickToolItem;
|
|
|
if (sourceAToolModule == null) return;
|
|
|
- int sourceIndex = quickToolbars.FindIndex(item => item.Name == sourceAToolModule.Name);
|
|
|
+ int sourceIndex = quickTools.FindIndex(item => item.Name == sourceAToolModule.Name);
|
|
|
//根据index找listbox对应的item
|
|
|
- sourceListItem = (MyListBoxItem)(ListShortCuts.ItemContainerGenerator.ContainerFromIndex(sourceIndex) as FrameworkElement);
|
|
|
+ sourceListItem = (ListItemQuickTool)(ListShortCuts.ItemContainerGenerator.ContainerFromIndex(sourceIndex) as FrameworkElement);
|
|
|
if (sourceListItem == null)
|
|
|
{
|
|
|
return;
|
|
@@ -405,11 +401,11 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- var sourceAToolModule = e.Data.GetData(typeof(ToolBarsViewModel)) as ToolBarsViewModel;
|
|
|
+ var sourceAToolModule = e.Data.GetData(typeof(QuickToolItem)) as QuickToolItem;
|
|
|
if (sourceAToolModule == null) return;
|
|
|
- int sourceIndex = moreToolbars.FindIndex(item => item.Name == sourceAToolModule.Name);
|
|
|
+ int sourceIndex = moreTools.FindIndex(item => item.Name == sourceAToolModule.Name);
|
|
|
//根据index找listbox对应的item
|
|
|
- sourceListItem = (MyListBoxItem)(ListMoreCuts.ItemContainerGenerator.ContainerFromIndex(sourceIndex) as FrameworkElement);
|
|
|
+ sourceListItem = (ListItemQuickTool)(ListMoreCuts.ItemContainerGenerator.ContainerFromIndex(sourceIndex) as FrameworkElement);
|
|
|
if (sourceListItem == null)
|
|
|
{
|
|
|
return;
|
|
@@ -425,16 +421,16 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
}
|
|
|
|
|
|
//查找目标数据
|
|
|
- targetListBoxItem = (MyListBoxItem)Utils.FindVisualParent<ListBoxItem>(result.VisualHit);
|
|
|
+ targetListItem = (ListItemQuickTool)CommonHelper.FindVisualParent<ListBoxItem>(result.VisualHit);
|
|
|
|
|
|
- if (targetListBoxItem == null)
|
|
|
+ if (targetListItem == null)
|
|
|
{
|
|
|
//sourceImage.Visibility = Visibility.Hidden;
|
|
|
return;
|
|
|
}
|
|
|
- var targetAToolModule = targetListBoxItem.Content as ToolBarsViewModel;
|
|
|
+ var targetAToolModule = targetListItem.Content as QuickToolItem;
|
|
|
if (targetAToolModule == null) return;
|
|
|
- target = quickToolbars.Find(c => c.Name == targetAToolModule.Name);
|
|
|
+ target = quickTools.Find(c => c.Name == targetAToolModule.Name);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -460,12 +456,12 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- quickSourceListItem = (MyListBoxItem)Utils.FindVisualParent<ListBoxItem>(result.VisualHit);
|
|
|
+ quickSourceListItem = (ListItemQuickTool)CommonHelper.FindVisualParent<ListBoxItem>(result.VisualHit);
|
|
|
if (quickSourceListItem == null || quickSourceListItem.Content != ListShortCuts.SelectedItem)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- System.Windows.DataObject dataObj = new System.Windows.DataObject(quickSourceListItem.Content as ToolBarsViewModel);
|
|
|
+ System.Windows.DataObject dataObj = new System.Windows.DataObject(quickSourceListItem.Content as QuickToolItem);
|
|
|
|
|
|
if (dataObj != null)
|
|
|
{
|
|
@@ -525,10 +521,10 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
{
|
|
|
|
|
|
var viewItem = listBoxItem.ContentTemplate;
|
|
|
- var myContentPresenter = Utils.FindVisualChild<ContentPresenter>(listBoxItem);
|
|
|
+ var myContentPresenter = CommonHelper.FindVisualChild<ContentPresenter>(listBoxItem);
|
|
|
var obj = viewItem.FindName("data", myContentPresenter);
|
|
|
|
|
|
- var checkNum = obj as HomeToolItem;
|
|
|
+ var checkNum = obj as PDFToolItem;
|
|
|
|
|
|
if (checkNum != null)
|
|
|
{
|