|
@@ -57,7 +57,7 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
- private CPDFViewer PDFViewer;
|
|
|
|
|
|
+ public CPDFViewer PDFViewer;
|
|
|
|
|
|
private ViewContentViewModel viewContentViewModel;
|
|
private ViewContentViewModel viewContentViewModel;
|
|
|
|
|
|
@@ -140,14 +140,16 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
set
|
|
set
|
|
{
|
|
{
|
|
SetProperty(ref listSelecedIndex, value);
|
|
SetProperty(ref listSelecedIndex, value);
|
|
- //显示页面范围选择控件
|
|
|
|
- TbPageRangeVisibility = Visibility.Visible;
|
|
|
|
- TbPageRange = (ListSelectedIndex + 1).ToString();
|
|
|
|
- TxtPageInputVisibility = Visibility.Collapsed;
|
|
|
|
- if (IsBOTAThumb == Visibility.Visible && PDFViewer != null)
|
|
|
|
|
|
+ if (!IsSelectFormSelf&&value>=0)
|
|
{
|
|
{
|
|
- PDFViewer.GoToPage(listSelecedIndex);
|
|
|
|
|
|
+ //显示页面范围选择控件
|
|
|
|
+ TxtPageInputVisibility = Visibility.Visible;
|
|
|
|
+ TbPageRange = (ListSelectedIndex + 1).ToString();
|
|
}
|
|
}
|
|
|
|
+ //if (IsBOTAThumb == Visibility.Visible && PDFViewer != null)
|
|
|
|
+ //{
|
|
|
|
+ // PDFViewer.GoToPage(listSelecedIndex);
|
|
|
|
+ //}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -175,10 +177,11 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
set
|
|
set
|
|
{
|
|
{
|
|
SetProperty(ref comboxSelectIndex, value);
|
|
SetProperty(ref comboxSelectIndex, value);
|
|
|
|
+ //隐藏tb页面范围显示控件
|
|
|
|
+ TxtPageInputVisibility = Visibility.Collapsed;
|
|
//选中指定的页面范围
|
|
//选中指定的页面范围
|
|
SuitPageRange(comboxSelectIndex);
|
|
SuitPageRange(comboxSelectIndex);
|
|
- //隐藏tb页面范围显示控件
|
|
|
|
- TbPageRangeVisibility = Visibility.Collapsed;
|
|
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -210,10 +213,6 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
set
|
|
set
|
|
{
|
|
{
|
|
SetProperty(ref tbPageRange, value);
|
|
SetProperty(ref tbPageRange, value);
|
|
- if (string.IsNullOrEmpty(TbPageRange))
|
|
|
|
- {
|
|
|
|
- TbPageRange = "请输入范围";
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -347,6 +346,11 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
//选中的页面集合
|
|
//选中的页面集合
|
|
private List<int> selectedPageList = new List<int>();
|
|
private List<int> selectedPageList = new List<int>();
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 是否是下拉框选项改变引起的选项变更事件
|
|
|
|
+ /// </summary>
|
|
|
|
+ private bool IsSelectFormSelf = false;
|
|
|
|
+
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
@@ -358,16 +362,6 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
/// </summary>
|
|
/// </summary>
|
|
public DelegateCommand<object> PreviewKeyDown { get; set; }
|
|
public DelegateCommand<object> PreviewKeyDown { get; set; }
|
|
|
|
|
|
- /// <summary>
|
|
|
|
- /// 响应键盘回车事件
|
|
|
|
- /// </summary>
|
|
|
|
- public DelegateCommand<object> KeyDown { get; set; }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- ///文本框失去焦点事件
|
|
|
|
- /// </summary>
|
|
|
|
- public DelegateCommand<object> LostFocusCommand { get; set; }
|
|
|
|
-
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 粘贴
|
|
/// 粘贴
|
|
@@ -445,6 +439,8 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
public DelegateCommand ShowPageSizeCommand { get; set; }
|
|
public DelegateCommand ShowPageSizeCommand { get; set; }
|
|
|
|
|
|
public DelegateCommand ClearSelectedCommand { get; set; }
|
|
public DelegateCommand ClearSelectedCommand { get; set; }
|
|
|
|
+
|
|
|
|
+
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
public PageEditContentViewModel(IDialogService dialogService, IEventAggregator eventAggregator)
|
|
public PageEditContentViewModel(IDialogService dialogService, IEventAggregator eventAggregator)
|
|
@@ -459,8 +455,6 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
//绑定命令
|
|
//绑定命令
|
|
SelectionChangedCommand = new DelegateCommand<object>(SelectionChangedEvent);
|
|
SelectionChangedCommand = new DelegateCommand<object>(SelectionChangedEvent);
|
|
PreviewKeyDown = new DelegateCommand<object>(PreviewKeyDownEvent);
|
|
PreviewKeyDown = new DelegateCommand<object>(PreviewKeyDownEvent);
|
|
- KeyDown = new DelegateCommand<object>(KeyDownEvent);
|
|
|
|
- LostFocusCommand = new DelegateCommand<object>(lostfocus);
|
|
|
|
|
|
|
|
SplitCommand = new DelegateCommand(SplitCommandEvent);
|
|
SplitCommand = new DelegateCommand(SplitCommandEvent);
|
|
InsertCommand = new DelegateCommand<object>(InsertCommandEvent);
|
|
InsertCommand = new DelegateCommand<object>(InsertCommandEvent);
|
|
@@ -814,10 +808,6 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
PageEditItems.Insert(preiIndex, targetitem);
|
|
PageEditItems.Insert(preiIndex, targetitem);
|
|
PageEditItems.Insert(laterIndex, sourceitem);
|
|
PageEditItems.Insert(laterIndex, sourceitem);
|
|
|
|
|
|
- //PageEditItems.Remove(targetitem);
|
|
|
|
- //PageEditItems.Insert(laterIndex, sourceitem);
|
|
|
|
- //PageEditItems.Remove(sourceitem);
|
|
|
|
- //PageEditItems.Insert(preiIndex, targetitem);
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -924,11 +914,16 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
/// <param name="e"></param>
|
|
/// <param name="e"></param>
|
|
private void SelectionChangedEvent(object e)
|
|
private void SelectionChangedEvent(object e)
|
|
{
|
|
{
|
|
|
|
+ if (IsSelectFormSelf)
|
|
|
|
+ {
|
|
|
|
+ //避免频繁的触发该事件
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
var args = e as SelectionChangedEventArgs;
|
|
var args = e as SelectionChangedEventArgs;
|
|
//下下策 从UI控件获取所有选项的集合
|
|
//下下策 从UI控件获取所有选项的集合
|
|
var listbox = args.OriginalSource as ListBox;
|
|
var listbox = args.OriginalSource as ListBox;
|
|
|
|
|
|
- if (TbPageRangeVisibility == Visibility.Visible && args != null)
|
|
|
|
|
|
+ if (TxtPageInputVisibility == Visibility.Visible && args != null)
|
|
{
|
|
{
|
|
selectedPageList = new List<int>();
|
|
selectedPageList = new List<int>();
|
|
for (int i = 0; i < listbox.SelectedItems.Count; i++)
|
|
for (int i = 0; i < listbox.SelectedItems.Count; i++)
|
|
@@ -994,28 +989,18 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ //枚举 过滤所有不合理的输入
|
|
if (args.Key != Key.Enter && args.Key != Key.Back && args.Key != Key.OemComma && args.Key != Key.OemMinus && args.Key != Key.Subtract && !((args.Key >= Key.D0 && args.Key <= Key.D9) || (args.Key >= Key.NumPad0 && args.Key <= Key.NumPad9)))
|
|
if (args.Key != Key.Enter && args.Key != Key.Back && args.Key != Key.OemComma && args.Key != Key.OemMinus && args.Key != Key.Subtract && !((args.Key >= Key.D0 && args.Key <= Key.D9) || (args.Key >= Key.NumPad0 && args.Key <= Key.NumPad9)))
|
|
{
|
|
{
|
|
args.Handled = true;
|
|
args.Handled = true;
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- /// <summary>
|
|
|
|
- /// 响应回车确认事件
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="e"></param>
|
|
|
|
- private void KeyDownEvent(object e)
|
|
|
|
- {
|
|
|
|
- var args = e as KeyEventArgs;
|
|
|
|
- if (args == null)
|
|
|
|
- {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
if (args.Key == Key.Enter)
|
|
if (args.Key == Key.Enter)
|
|
{
|
|
{
|
|
List<int> TargetPageIndexs = new List<int>();
|
|
List<int> TargetPageIndexs = new List<int>();
|
|
var result = CommonHelper.GetPagesInRange(ref TargetPageIndexs, (args.OriginalSource as TextBox).Text, PDFViewer.Document.PageCount, new char[] { ',', ',' }, new char[] { '-' });
|
|
var result = CommonHelper.GetPagesInRange(ref TargetPageIndexs, (args.OriginalSource as TextBox).Text, PDFViewer.Document.PageCount, new char[] { ',', ',' }, new char[] { '-' });
|
|
- if (!result && ComboxSelectIndex == 5)
|
|
|
|
|
|
+ if (!result)
|
|
{
|
|
{
|
|
AlertsMessage alertsMessage = new AlertsMessage();
|
|
AlertsMessage alertsMessage = new AlertsMessage();
|
|
alertsMessage.ShowDialog("", "请输入有效范围", "OK");
|
|
alertsMessage.ShowDialog("", "请输入有效范围", "OK");
|
|
@@ -1040,7 +1025,7 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
/// 失去焦点后选中页面
|
|
/// 失去焦点后选中页面
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
/// <param name="obj"></param>
|
|
- private void lostfocus(object obj)
|
|
|
|
|
|
+ public void lostfocus(object obj)
|
|
{
|
|
{
|
|
var args = obj as RoutedEventArgs;
|
|
var args = obj as RoutedEventArgs;
|
|
if (args == null || (args.OriginalSource as TextBox) == null)
|
|
if (args == null || (args.OriginalSource as TextBox) == null)
|
|
@@ -2059,7 +2044,7 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
/// 选中目标页面范围的页面
|
|
/// 选中目标页面范围的页面
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="index">页面范围选中项索引</param>
|
|
/// <param name="index">页面范围选中项索引</param>
|
|
- private void SuitPageRange(int index)
|
|
|
|
|
|
+ private async void SuitPageRange(int index)
|
|
{
|
|
{
|
|
List<int> pageRange = new List<int>();
|
|
List<int> pageRange = new List<int>();
|
|
switch (index)
|
|
switch (index)
|
|
@@ -2111,24 +2096,24 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case 5://自定义
|
|
case 5://自定义
|
|
-
|
|
|
|
- //await Task.Delay(20);
|
|
|
|
- //TbPageRange = "1,3";
|
|
|
|
|
|
+ TxtPageInputVisibility = Visibility.Visible;
|
|
|
|
+ await Task.Delay(30);
|
|
|
|
+ TbPageRange = "";
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
if (pageRange.Count > 0)
|
|
if (pageRange.Count > 0)
|
|
{
|
|
{
|
|
|
|
+ //避免在下面的过程中频繁触发SelectionChanged事件
|
|
|
|
+ IsSelectFormSelf = true;
|
|
NotifyUIToRefresh(pageRange);
|
|
NotifyUIToRefresh(pageRange);
|
|
|
|
+ IsSelectFormSelf = false;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- if (index != 5)
|
|
|
|
- {
|
|
|
|
- //没有符合条件时 清空选中项
|
|
|
|
- ListSelectedIndex = -1;
|
|
|
|
- }
|
|
|
|
|
|
+ //没有符合条件时 清空选中项
|
|
|
|
+ ListSelectedIndex = -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2338,7 +2323,7 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//通知UI选中Items
|
|
//通知UI选中Items
|
|
- //NotifyUIToRefresh(selectedPages);
|
|
|
|
|
|
+ NotifyUIToRefresh(selectedPages);
|
|
//刷新页码和图片
|
|
//刷新页码和图片
|
|
ReloadAfterOption(true, true, new Tuple<int, int>(0, PDFViewer.Document.PageCount));
|
|
ReloadAfterOption(true, true, new Tuple<int, int>(0, PDFViewer.Document.PageCount));
|
|
|
|
|
|
@@ -2374,6 +2359,11 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
var source = PageEditItems[sourceindex];
|
|
var source = PageEditItems[sourceindex];
|
|
PageEditItems.RemoveAt(sourceindex);
|
|
PageEditItems.RemoveAt(sourceindex);
|
|
PageEditItems.Insert(targetindex, source);
|
|
PageEditItems.Insert(targetindex, source);
|
|
|
|
+
|
|
|
|
+ if(PDFViewer.CurrentIndex==sourceindex)
|
|
|
|
+ {
|
|
|
|
+ PDFViewer.GoToPage(targetindex);
|
|
|
|
+ }
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|