|
@@ -2,6 +2,7 @@
|
|
|
using PDF_Office.Helper;
|
|
|
using PDF_Office.Model.PDFTool;
|
|
|
using PDF_Office.ViewModels.HomePanel;
|
|
|
+using PDF_Office.ViewModels.HomePanel.PDFTools;
|
|
|
using PDFSettings;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
@@ -28,6 +29,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
/// </summary>
|
|
|
public partial class PDFToolsContent : UserControl
|
|
|
{
|
|
|
+ private PDFToolsContentViewModel ViewModel => DataContext as PDFToolsContentViewModel;
|
|
|
private ListItemQuickTool sourceListItem = null;
|
|
|
private ListItemQuickTool targetListItem = null;
|
|
|
private ListItemQuickTool quickSourceListItem = null;
|
|
@@ -74,32 +76,92 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
quickTools = PDFtools.QuickTools;
|
|
|
allTools = PDFtools.AllTools;
|
|
|
moreTools = PDFtools.MoreTools;
|
|
|
- ListShortCuts.ItemsSource = quickTools;
|
|
|
- ListMoreCuts.ItemsSource = moreTools;
|
|
|
-
|
|
|
+ ListShortCutsExpend.ItemsSource = ListShortCuts.ItemsSource = quickTools;
|
|
|
+ ListMoreCutsExpend.ItemsSource = ListMoreCuts.ItemsSource = moreTools;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void Page_Loaded(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
UpdateExptend();
|
|
|
+ if (ViewModel != null)
|
|
|
+ {
|
|
|
+ ViewModel.ExpendToolsHanlder -= ViewModel_ExpendToolsHanlder;
|
|
|
+ ViewModel.ExpendToolsHanlder += ViewModel_ExpendToolsHanlder;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ViewModel_ExpendToolsHanlder(object sender, bool e)
|
|
|
+ {
|
|
|
+ if(e)
|
|
|
+ {
|
|
|
+ ListShortCutsExpend.Items.Refresh();
|
|
|
+ ListMoreCutsExpend.Items.Refresh();
|
|
|
+ ListBoxCutsWidthChanged(ListShortCutsExpend);
|
|
|
+ ListBoxCutsWidthChanged(ListMoreCutsExpend);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ListShortCuts.Items.Refresh();
|
|
|
+ ListMoreCuts.Items.Refresh();
|
|
|
+ ListBoxCutsWidthChanged(ListShortCuts);
|
|
|
+ ListBoxCutsWidthChanged(ListMoreCuts);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private ListBoxEx GetListShortControl()
|
|
|
+ {
|
|
|
+ ListBoxEx ShortEx = null;
|
|
|
+
|
|
|
+ if (ListShortCuts.Visibility == Visibility.Visible)
|
|
|
+ {
|
|
|
+ ShortEx = ListShortCuts;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShortEx = ListShortCutsExpend;
|
|
|
+ }
|
|
|
+
|
|
|
+ return ShortEx;
|
|
|
+ }
|
|
|
+
|
|
|
+ private ListBoxEx GetListMoreControl()
|
|
|
+ {
|
|
|
+ ListBoxEx MoreEx = null;
|
|
|
+
|
|
|
+ if (ListMoreCuts.Visibility == Visibility.Visible)
|
|
|
+ {
|
|
|
+ MoreEx = ListMoreCuts;
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MoreEx = ListMoreCutsExpend;
|
|
|
+ }
|
|
|
+
|
|
|
+ return MoreEx;
|
|
|
}
|
|
|
|
|
|
private void ListBoxMoreCuts_PreviewMouseMove(object sender, MouseEventArgs e)
|
|
|
{
|
|
|
- var pos = e.GetPosition(ListMoreCuts);
|
|
|
+ ListBoxEx MoreEx = GetListMoreControl();
|
|
|
+ if (MoreEx == null) return;
|
|
|
+
|
|
|
+
|
|
|
+ var pos = e.GetPosition(MoreEx);
|
|
|
|
|
|
if (e.LeftButton == MouseButtonState.Pressed)
|
|
|
{
|
|
|
- ListMoreCuts.AllowDrop = true;
|
|
|
+ MoreEx.AllowDrop = true;
|
|
|
|
|
|
- HitTestResult result = VisualTreeHelper.HitTest(ListMoreCuts, pos);
|
|
|
+ HitTestResult result = VisualTreeHelper.HitTest(MoreEx, pos);
|
|
|
if (result == null)
|
|
|
{
|
|
|
sourceImage.Visibility = Visibility.Hidden;
|
|
|
return;
|
|
|
}
|
|
|
sourceListItem = (ListItemQuickTool)CommonHelper.FindVisualParent<ListBoxItem>(result.VisualHit);
|
|
|
- if (sourceListItem == null || sourceListItem.Content != ListMoreCuts.SelectedItem)
|
|
|
+ if (sourceListItem == null || sourceListItem.Content != MoreEx.SelectedItem)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
@@ -122,7 +184,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
ImageDecoding();
|
|
|
|
|
|
isMoreCuts = true;
|
|
|
- DragDrop.DoDragDrop(ListMoreCuts, dataObj, System.Windows.DragDropEffects.Move);
|
|
|
+ DragDrop.DoDragDrop(MoreEx, dataObj, System.Windows.DragDropEffects.Move);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -160,9 +222,12 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
|
|
|
private void ListBoxShortCuts_Drop(object sender, DragEventArgs e)
|
|
|
{
|
|
|
- var pos = e.GetPosition(ListShortCuts);
|
|
|
+ ListBoxEx ShortEx = GetListShortControl();
|
|
|
+ if(ShortEx == null) return;
|
|
|
+
|
|
|
+ var pos = e.GetPosition(ShortEx);
|
|
|
|
|
|
- var result = VisualTreeHelper.HitTest(ListShortCuts, pos);
|
|
|
+ var result = VisualTreeHelper.HitTest(ShortEx, pos);
|
|
|
if (result == null)
|
|
|
{
|
|
|
WorkingWithAnimation(pos);
|
|
@@ -208,12 +273,18 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
{
|
|
|
if (moreTools == null) return;
|
|
|
ToolItem source = moreTools.Find(c => c.Title == sourceAToolModule.Title);
|
|
|
+ ListBoxEx MoreEx = GetListMoreControl();
|
|
|
+ if (MoreEx == null) return;
|
|
|
+
|
|
|
+ ListBoxEx ShortEx = GetListShortControl();
|
|
|
+ if (ShortEx == null) return;
|
|
|
+
|
|
|
|
|
|
int targetIndex = quickTools.FindIndex(item => item.Title == targetAToolModule.Title);
|
|
|
if (targetIndex < 0) return;
|
|
|
if (!isMoreCuts)
|
|
|
{
|
|
|
- ListMoreCuts.AllowDrop = false;
|
|
|
+ MoreEx.AllowDrop = false;
|
|
|
sourceImage.Visibility = Visibility.Hidden;
|
|
|
source = quickTools.Find(c => c.Title == sourceAToolModule.Title);
|
|
|
if (source == null) return;
|
|
@@ -222,8 +293,8 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
var temp = quickTools[sourceIndex];
|
|
|
quickTools[sourceIndex] = quickTools[targetIndex];
|
|
|
quickTools[targetIndex] = temp;
|
|
|
- ListShortCuts.Items.Refresh();
|
|
|
- ListBoxCutsWidthChanged(ListShortCuts);
|
|
|
+ ShortEx.Items.Refresh();
|
|
|
+ ListBoxCutsWidthChanged(ShortEx);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -235,13 +306,13 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
quickTools.Remove(target);
|
|
|
quickTools.Insert(targetIndex, source);
|
|
|
|
|
|
- ListMoreCuts.Items.Refresh();
|
|
|
- ListShortCuts.Items.Refresh();
|
|
|
+ MoreEx.Items.Refresh();
|
|
|
+ ShortEx.Items.Refresh();
|
|
|
|
|
|
sourceImage.Visibility = Visibility.Hidden;
|
|
|
targetListItem.IsOverModular = false;
|
|
|
- ListBoxCutsWidthChanged(ListShortCuts);
|
|
|
- ListBoxCutsWidthChanged(ListMoreCuts);
|
|
|
+ ListBoxCutsWidthChanged(ShortEx);
|
|
|
+ ListBoxCutsWidthChanged(MoreEx);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -341,7 +412,13 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
|
|
|
private void ListBoxShortCuts_DragOver(object sender, DragEventArgs e)
|
|
|
{
|
|
|
- var pos = e.GetPosition(ListShortCuts);
|
|
|
+ ListBoxEx MoreEx = GetListMoreControl();
|
|
|
+ if (MoreEx == null) return;
|
|
|
+
|
|
|
+ ListBoxEx ShortEx = GetListShortControl();
|
|
|
+ if (ShortEx == null) return;
|
|
|
+
|
|
|
+ var pos = e.GetPosition(ShortEx);
|
|
|
Console.WriteLine($"pos:{pos.X} {pos.Y} this.Grid.ActualHeight1 {this.Grid.ActualHeight}");
|
|
|
if (pos.Y < 0)
|
|
|
{
|
|
@@ -378,12 +455,12 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
if (sourceAToolModule == null) return;
|
|
|
int sourceIndex = quickTools.FindIndex(item => item.Title == sourceAToolModule.Title);
|
|
|
//根据index找listbox对应的item
|
|
|
- sourceListItem = (ListItemQuickTool)(ListShortCuts.ItemContainerGenerator.ContainerFromIndex(sourceIndex) as FrameworkElement);
|
|
|
+ sourceListItem = (ListItemQuickTool)(ShortEx.ItemContainerGenerator.ContainerFromIndex(sourceIndex) as FrameworkElement);
|
|
|
if (sourceListItem == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- ListMoreCuts.AllowDrop = false;
|
|
|
+ MoreEx.AllowDrop = false;
|
|
|
sourceImage.Visibility = Visibility.Hidden;
|
|
|
}
|
|
|
else
|
|
@@ -392,7 +469,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
if (sourceAToolModule == null) return;
|
|
|
int sourceIndex = moreTools.FindIndex(item => item.Title == sourceAToolModule.Title);
|
|
|
//根据index找listbox对应的item
|
|
|
- sourceListItem = (ListItemQuickTool)(ListMoreCuts.ItemContainerGenerator.ContainerFromIndex(sourceIndex) as FrameworkElement);
|
|
|
+ sourceListItem = (ListItemQuickTool)(MoreEx.ItemContainerGenerator.ContainerFromIndex(sourceIndex) as FrameworkElement);
|
|
|
if (sourceListItem == null)
|
|
|
{
|
|
|
return;
|
|
@@ -401,7 +478,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
//图片绑定
|
|
|
ImageBinding(pos);
|
|
|
}
|
|
|
- var result = VisualTreeHelper.HitTest(ListShortCuts, pos);
|
|
|
+ var result = VisualTreeHelper.HitTest(ShortEx, pos);
|
|
|
if (result == null)
|
|
|
{
|
|
|
return;
|
|
@@ -436,15 +513,22 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
{
|
|
|
if (e.LeftButton == MouseButtonState.Pressed)
|
|
|
{
|
|
|
- ListMoreCuts.AllowDrop = false;
|
|
|
- var pos = e.GetPosition(ListShortCuts);
|
|
|
- HitTestResult result = VisualTreeHelper.HitTest(ListShortCuts, pos);
|
|
|
+ ListBoxEx MoreEx = GetListMoreControl();
|
|
|
+ if (MoreEx == null) return;
|
|
|
+
|
|
|
+ ListBoxEx ShortEx = GetListShortControl();
|
|
|
+ if (ShortEx == null) return;
|
|
|
+
|
|
|
+
|
|
|
+ MoreEx.AllowDrop = false;
|
|
|
+ var pos = e.GetPosition(ShortEx);
|
|
|
+ HitTestResult result = VisualTreeHelper.HitTest(ShortEx, pos);
|
|
|
if (result == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
quickSourceListItem = (ListItemQuickTool)CommonHelper.FindVisualParent<ListBoxItem>(result.VisualHit);
|
|
|
- if (quickSourceListItem == null || quickSourceListItem.Content != ListShortCuts.SelectedItem)
|
|
|
+ if (quickSourceListItem == null || quickSourceListItem.Content != ShortEx.SelectedItem)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
@@ -453,7 +537,7 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
if (dataObj != null)
|
|
|
{
|
|
|
isMoreCuts = false;
|
|
|
- DragDrop.DoDragDrop(ListShortCuts, dataObj, System.Windows.DragDropEffects.Move);
|
|
|
+ DragDrop.DoDragDrop(ShortEx, dataObj, System.Windows.DragDropEffects.Move);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -497,12 +581,18 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
|
|
|
private void ListBoxShortCuts_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
|
{
|
|
|
- ListBoxCutsWidthChanged(ListShortCuts);
|
|
|
+ ListBoxEx ShortEx = GetListShortControl();
|
|
|
+ if (ShortEx == null) return;
|
|
|
+
|
|
|
+ ListBoxCutsWidthChanged(ShortEx);
|
|
|
}
|
|
|
|
|
|
private void ListBoxMoreCuts_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
|
{
|
|
|
- ListBoxCutsWidthChanged(ListMoreCuts);
|
|
|
+ ListBoxEx MoreEx = GetListMoreControl();
|
|
|
+ if (MoreEx == null) return;
|
|
|
+
|
|
|
+ ListBoxCutsWidthChanged(MoreEx);
|
|
|
}
|
|
|
|
|
|
private void ListBoxCutsWidthChanged(ListBoxEx list)
|
|
@@ -546,15 +636,15 @@ namespace PDF_Office.Views.HomePanel.PDFTools
|
|
|
|
|
|
private void UpdateExptend()
|
|
|
{
|
|
|
- foreach (var item in allTools)
|
|
|
- {
|
|
|
- item.IsShowConciseContent = !(bool)BtnExptend.IsChecked;
|
|
|
- }
|
|
|
-
|
|
|
- foreach (var item in quickTools)
|
|
|
- {
|
|
|
- item.IsShowConciseContent = !(bool)BtnExptend.IsChecked;
|
|
|
- }
|
|
|
+ //foreach (var item in allTools)
|
|
|
+ //{
|
|
|
+ // item.IsShowConciseContent = !(bool)BtnExptend.IsChecked;
|
|
|
+ //}
|
|
|
+
|
|
|
+ //foreach (var item in quickTools)
|
|
|
+ //{
|
|
|
+ // item.IsShowConciseContent = !(bool)BtnExptend.IsChecked;
|
|
|
+ //}
|
|
|
}
|
|
|
|
|
|
//自适应流式布局,以防改需求备用
|