|
@@ -1,12 +1,22 @@
|
|
using ComPDFKit.PDFDocument;
|
|
using ComPDFKit.PDFDocument;
|
|
using ComPDFKitViewer.PdfViewer;
|
|
using ComPDFKitViewer.PdfViewer;
|
|
|
|
+using ImTools;
|
|
|
|
+using PDF_Office.Helper;
|
|
using PDF_Office.Model;
|
|
using PDF_Office.Model;
|
|
|
|
+using Prism.Commands;
|
|
using Prism.Mvvm;
|
|
using Prism.Mvvm;
|
|
using Prism.Regions;
|
|
using Prism.Regions;
|
|
using Prism.Services.Dialogs;
|
|
using Prism.Services.Dialogs;
|
|
|
|
+using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows;
|
|
|
|
+using System.Windows.Controls;
|
|
|
|
+using System.Windows.Controls.Primitives;
|
|
|
|
+using System.Windows.Input;
|
|
|
|
+using System.Windows.Media;
|
|
|
|
+using static Dropbox.Api.TeamLog.AdminAlertSeverityEnum;
|
|
|
|
+using static System.Net.Mime.MediaTypeNames;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.BOTA
|
|
namespace PDF_Office.ViewModels.BOTA
|
|
{
|
|
{
|
|
@@ -14,6 +24,11 @@ namespace PDF_Office.ViewModels.BOTA
|
|
{
|
|
{
|
|
#region 属性
|
|
#region 属性
|
|
|
|
|
|
|
|
+ private static string hoverColor = "#D9D9D9";
|
|
|
|
+ private static string defaultColor = "#F2F2F2";
|
|
|
|
+ private static string selectColcr = "#97D7FB";
|
|
|
|
+ private static string borderBackground = "#FFFFFF";
|
|
|
|
+ private static string borderBrush = "#000000";
|
|
private IRegionManager region;
|
|
private IRegionManager region;
|
|
private IDialogService dialogs;
|
|
private IDialogService dialogs;
|
|
public CPDFViewer PDFViewer;
|
|
public CPDFViewer PDFViewer;
|
|
@@ -35,26 +50,216 @@ namespace PDF_Office.ViewModels.BOTA
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private Visibility isEmptyPanelVisibility = Visibility.Visible;
|
|
|
|
|
|
+ private Visibility isEmpty;
|
|
|
|
|
|
public Visibility IsEmptyPanelVisibility
|
|
public Visibility IsEmptyPanelVisibility
|
|
{
|
|
{
|
|
get
|
|
get
|
|
{
|
|
{
|
|
- return isEmptyPanelVisibility;
|
|
|
|
|
|
+ return isEmpty;
|
|
}
|
|
}
|
|
set
|
|
set
|
|
{
|
|
{
|
|
- SetProperty(ref isEmptyPanelVisibility, value);
|
|
|
|
|
|
+ SetProperty(ref isEmpty, value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
#endregion 属性
|
|
#endregion 属性
|
|
|
|
|
|
|
|
+ #region 命令
|
|
|
|
+
|
|
|
|
+ public DelegateCommand<object> MouseClickCommand { get; set; }
|
|
|
|
+ public DelegateCommand<object> MouseEnterCommand { get; set; }
|
|
|
|
+ public DelegateCommand<object> MouseMoveCommand { get; set; }
|
|
|
|
+
|
|
|
|
+ public DelegateCommand<object> LostFocusCommand { get; set; }
|
|
|
|
+
|
|
|
|
+ public DelegateCommand<object> GotFocusCommand { get; set; }
|
|
|
|
+
|
|
|
|
+ public DelegateCommand<object> AddBookmarkCommand { get; set; }
|
|
|
|
+
|
|
|
|
+ #endregion 命令
|
|
|
|
+
|
|
public BookmarkContentViewModel(IRegionManager regionManager, IDialogService dialogService)
|
|
public BookmarkContentViewModel(IRegionManager regionManager, IDialogService dialogService)
|
|
{
|
|
{
|
|
region = regionManager;
|
|
region = regionManager;
|
|
dialogs = dialogService;
|
|
dialogs = dialogService;
|
|
|
|
+
|
|
|
|
+ MouseClickCommand = new DelegateCommand<object>(MouseClickEvent);
|
|
|
|
+ MouseEnterCommand = new DelegateCommand<object>(MouseEnterEvent);
|
|
|
|
+ LostFocusCommand = new DelegateCommand<object>(LostFocusEvent);
|
|
|
|
+ MouseMoveCommand = new DelegateCommand<object>(MouseMoveEvent);
|
|
|
|
+ GotFocusCommand = new DelegateCommand<object>(GotFocusEvent);
|
|
|
|
+ AddBookmarkCommand = new DelegateCommand<object>(AddBookmarkEvent);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void AddBookmarkEvent(object obj)
|
|
|
|
+ {
|
|
|
|
+ int index = PDFViewer.CurrentIndex;
|
|
|
|
+ string mark = string.Format($"第{index}页");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void GotFocusEvent(object obj)
|
|
|
|
+ {
|
|
|
|
+ if (obj is RoutedEventArgs)
|
|
|
|
+ {
|
|
|
|
+ var mouse = (RoutedEventArgs)obj;
|
|
|
|
+ if (mouse.Source is TextBox)
|
|
|
|
+ {
|
|
|
|
+ TextBox textBox = (TextBox)mouse.Source;
|
|
|
|
+ textBox.Select(textBox.Text.Length, 0);
|
|
|
|
+ textBox.SelectAll();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void MouseMoveEvent(object obj)
|
|
|
|
+ {
|
|
|
|
+ //if (obj is MouseEventArgs)
|
|
|
|
+ //{
|
|
|
|
+ // var mouse = (MouseEventArgs)obj;
|
|
|
|
+ // Grid grid = null;
|
|
|
|
+ // if (mouse.Source is TextBox)
|
|
|
|
+ // {
|
|
|
|
+ // TextBox text = (TextBox)mouse.Source;
|
|
|
|
+ // if (text != null)
|
|
|
|
+ // {
|
|
|
|
+ // text.Visibility = Visibility.Collapsed;
|
|
|
|
+ // grid = (text.Parent as StackPanel).Parent as Grid;
|
|
|
|
+ // grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(defaultColor));
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void LostFocusEvent(object obj)
|
|
|
|
+ {
|
|
|
|
+ if (obj is RoutedEventArgs)
|
|
|
|
+ {
|
|
|
|
+ var mouse = (RoutedEventArgs)obj;
|
|
|
|
+ Grid grid = null;
|
|
|
|
+ if (mouse.Source is Grid)
|
|
|
|
+ {
|
|
|
|
+ grid = mouse.Source as Grid;
|
|
|
|
+ if (grid != null)
|
|
|
|
+ {
|
|
|
|
+ TextBlock box = CommonHelper.FindVisualChild<TextBlock>(grid);
|
|
|
|
+ if (box != null)
|
|
|
|
+ {
|
|
|
|
+ box.Visibility = Visibility.Visible;
|
|
|
|
+ }
|
|
|
|
+ grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(defaultColor));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (mouse.Source is TextBox)
|
|
|
|
+ {
|
|
|
|
+ TextBox textBox = (TextBox)mouse.Source;
|
|
|
|
+ if (textBox != null)
|
|
|
|
+ {
|
|
|
|
+ //textBox.Visibility = Visibility.Collapsed;
|
|
|
|
+ grid = (textBox.Parent as StackPanel).Parent as Grid;
|
|
|
|
+ grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(defaultColor));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void MouseEnterEvent(object obj)
|
|
|
|
+ {
|
|
|
|
+ if (obj is MouseEventArgs)
|
|
|
|
+ {
|
|
|
|
+ var mouse = (MouseEventArgs)obj;
|
|
|
|
+ Grid grid = null;
|
|
|
|
+ if (mouse.Source is Grid)
|
|
|
|
+ {
|
|
|
|
+ grid = mouse.Source as Grid;
|
|
|
|
+ if (grid != null)
|
|
|
|
+ {
|
|
|
|
+ TextBlock box = CommonHelper.FindVisualChild<TextBlock>(grid);
|
|
|
|
+ if (box != null)
|
|
|
|
+ {
|
|
|
|
+ //box.Visibility = Visibility.Visible;
|
|
|
|
+ }
|
|
|
|
+ grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(hoverColor));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (mouse.Source is TextBlock)
|
|
|
|
+ {
|
|
|
|
+ TextBlock text = (TextBlock)mouse.Source;
|
|
|
|
+ if (text != null)
|
|
|
|
+ {
|
|
|
|
+ //text.Visibility = Visibility.Visible;
|
|
|
|
+ grid = (text.Parent as StackPanel).Parent as Grid;
|
|
|
|
+ grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(hoverColor));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //if (mouse.Source is TextBox)
|
|
|
|
+ //{
|
|
|
|
+ // TextBox text = (TextBox)mouse.Source;
|
|
|
|
+ // if (text != null)
|
|
|
|
+ // {
|
|
|
|
+ // text.Visibility = Visibility.Collapsed;
|
|
|
|
+ // grid = (text.Parent as StackPanel).Parent as Grid;
|
|
|
|
+ // grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(hoverColor));
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void MouseClickEvent(object obj)
|
|
|
|
+ {
|
|
|
|
+ if (obj is MouseButtonEventArgs)
|
|
|
|
+ {
|
|
|
|
+ var mouse = (MouseButtonEventArgs)obj;
|
|
|
|
+ if (mouse.LeftButton == MouseButtonState.Pressed)
|
|
|
|
+ {
|
|
|
|
+ TextBlock box = null;
|
|
|
|
+ Grid grid = null;
|
|
|
|
+ if (mouse.ClickCount >= 2)
|
|
|
|
+ {
|
|
|
|
+ if (mouse.Source is Grid)
|
|
|
|
+ {
|
|
|
|
+ grid = mouse.Source as Grid;
|
|
|
|
+ //grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(selectColcr));
|
|
|
|
+ if (grid != null)
|
|
|
|
+ {
|
|
|
|
+ box = CommonHelper.FindVisualChild<TextBlock>(grid);
|
|
|
|
+ grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(selectColcr));
|
|
|
|
+ if (box != null)
|
|
|
|
+ {
|
|
|
|
+ box.Visibility = Visibility.Collapsed;
|
|
|
|
+ //TextBox textBox = CommonHelper.FindVisualChild<TextBox>((box.Parent as StackPanel));
|
|
|
|
+ //FocusManager.SetFocusedElement(box.Parent, textBox);
|
|
|
|
+ //Keyboard.Focus(textBox);
|
|
|
|
+ //textBox.IsHitTestVisible = true;
|
|
|
|
+ //textBox.Focus();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (mouse.Source is TextBlock)
|
|
|
|
+ {
|
|
|
|
+ box = (TextBlock)mouse.Source;
|
|
|
|
+ grid = (box.Parent as StackPanel).Parent as Grid;
|
|
|
|
+
|
|
|
|
+ grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(selectColcr));
|
|
|
|
+ if (box != null)
|
|
|
|
+ {
|
|
|
|
+ box.Visibility = Visibility.Collapsed;
|
|
|
|
+ //TextBox textBox = CommonHelper.FindVisualChild<TextBox>((box.Parent as StackPanel));
|
|
|
|
+ //FocusManager.SetFocusedElement(box.Parent, textBox);
|
|
|
|
+ //Keyboard.Focus(textBox);
|
|
|
|
+ //textBox.IsHitTestVisible = true;
|
|
|
|
+ //textBox.Focus();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //MessageBox.Show("dsafa");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
@@ -65,7 +270,7 @@ namespace PDF_Office.ViewModels.BOTA
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- Bookmarklist = new ObservableCollection<CPDFBookmark>(PDFViewer.Document.GetBookmarkList().OrderBy(d => d.Title));
|
|
|
|
|
|
+ list = new ObservableCollection<CPDFBookmark>(PDFViewer.Document.GetBookmarkList().OrderBy(d => d.Title));
|
|
if (Bookmarklist.Count < 1)
|
|
if (Bookmarklist.Count < 1)
|
|
{
|
|
{
|
|
IsEmptyPanelVisibility = Visibility.Visible;
|
|
IsEmptyPanelVisibility = Visibility.Visible;
|
|
@@ -73,7 +278,8 @@ namespace PDF_Office.ViewModels.BOTA
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- isEmptyPanelVisibility = Visibility.Collapsed;
|
|
|
|
|
|
+ IsEmptyPanelVisibility = Visibility.Hidden;
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|