|
@@ -23,12 +23,14 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
|
|
public partial class RecentFilesContent : UserControl
|
|
public partial class RecentFilesContent : UserControl
|
|
{
|
|
{
|
|
private RecentFilesContentViewModel ViewModel => DataContext as RecentFilesContentViewModel;
|
|
private RecentFilesContentViewModel ViewModel => DataContext as RecentFilesContentViewModel;
|
|
|
|
+
|
|
public RecentFilesContent()
|
|
public RecentFilesContent()
|
|
{
|
|
{
|
|
InitializeComponent();
|
|
InitializeComponent();
|
|
}
|
|
}
|
|
|
|
|
|
#region 初始化
|
|
#region 初始化
|
|
|
|
+
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
{
|
|
InitVariables();
|
|
InitVariables();
|
|
@@ -43,14 +45,17 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
|
|
if (GridRecentFilesList.SelectedItems != null)
|
|
if (GridRecentFilesList.SelectedItems != null)
|
|
GridRecentFilesList.SelectedItems.Clear();
|
|
GridRecentFilesList.SelectedItems.Clear();
|
|
}
|
|
}
|
|
|
|
+
|
|
private void InitEvents()
|
|
private void InitEvents()
|
|
{
|
|
{
|
|
ViewModel.RecentFilesSelectionHandler -= ViewModel_RecentFilesSelection;
|
|
ViewModel.RecentFilesSelectionHandler -= ViewModel_RecentFilesSelection;
|
|
ViewModel.RecentFilesSelectionHandler += ViewModel_RecentFilesSelection;
|
|
ViewModel.RecentFilesSelectionHandler += ViewModel_RecentFilesSelection;
|
|
}
|
|
}
|
|
- #endregion
|
|
|
|
|
|
+
|
|
|
|
+ #endregion 初始化
|
|
|
|
|
|
#region UI操作
|
|
#region UI操作
|
|
|
|
+
|
|
private void ViewModel_RecentFilesSelection(object sender, bool e)
|
|
private void ViewModel_RecentFilesSelection(object sender, bool e)
|
|
{
|
|
{
|
|
//if (e)
|
|
//if (e)
|
|
@@ -111,7 +116,7 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
|
|
if (menuitem.Name == "FilePathMenuItem")
|
|
if (menuitem.Name == "FilePathMenuItem")
|
|
menuitem.Visibility = Visibility.Collapsed;
|
|
menuitem.Visibility = Visibility.Collapsed;
|
|
|
|
|
|
- if(menuitem.Name == "MenuOpenFile")
|
|
|
|
|
|
+ if (menuitem.Name == "MenuOpenFile")
|
|
{
|
|
{
|
|
menuitem.Visibility = Visibility.Visible;
|
|
menuitem.Visibility = Visibility.Visible;
|
|
}
|
|
}
|
|
@@ -128,8 +133,6 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
catch { }
|
|
catch { }
|
|
}
|
|
}
|
|
@@ -143,12 +146,10 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
|
|
e.Handled = true;
|
|
e.Handled = true;
|
|
}
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
|
-
|
|
|
|
|
|
+ #endregion UI操作
|
|
|
|
|
|
#region Events
|
|
#region Events
|
|
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 右键菜单:删除文件记录
|
|
/// 右键菜单:删除文件记录
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -160,7 +161,6 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
|
|
else
|
|
else
|
|
listView = GridRecentFilesList;
|
|
listView = GridRecentFilesList;
|
|
|
|
|
|
-
|
|
|
|
if (listView.SelectedItems == null || listView.SelectedItems.Count == 0)
|
|
if (listView.SelectedItems == null || listView.SelectedItems.Count == 0)
|
|
{
|
|
{
|
|
var item = (sender as MenuItem).DataContext as OpenFileInfo;
|
|
var item = (sender as MenuItem).DataContext as OpenFileInfo;
|
|
@@ -173,7 +173,6 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
|
|
{
|
|
{
|
|
ViewModel?.RemoveFilesFromContainerCommand.Execute(listView.SelectedItems);
|
|
ViewModel?.RemoveFilesFromContainerCommand.Execute(listView.SelectedItems);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -200,12 +199,11 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
|
|
if (item != null && (item.DataContext as OpenFileInfo) != null)
|
|
if (item != null && (item.DataContext as OpenFileInfo) != null)
|
|
{
|
|
{
|
|
var fileInfo = item.DataContext as OpenFileInfo;
|
|
var fileInfo = item.DataContext as OpenFileInfo;
|
|
- if(fileInfo != null)
|
|
|
|
|
|
+ if (fileInfo != null)
|
|
{
|
|
{
|
|
ViewModel?.OpenRecentFilesCommand.Execute(fileInfo);
|
|
ViewModel?.OpenRecentFilesCommand.Execute(fileInfo);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -232,23 +230,23 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
|
|
|
+ #endregion Events
|
|
|
|
|
|
private void UserControl_KeyDown(object sender, KeyEventArgs e)
|
|
private void UserControl_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
{
|
|
- if (e.Key == Key.Escape)
|
|
|
|
- {
|
|
|
|
- //Windows:最近文件列表补充点击空白处取消选中;移除Esc取消选中逻辑
|
|
|
|
- //点击ESC取消选中
|
|
|
|
- //if (GridRecentFilesList.Visibility == Visibility.Visible)
|
|
|
|
- //{
|
|
|
|
- // GridRecentFilesList.SelectedIndex = -1;
|
|
|
|
- //}
|
|
|
|
- //else
|
|
|
|
- //{
|
|
|
|
- // RecentFilesList.SelectedIndex = -1;
|
|
|
|
- //}
|
|
|
|
- }
|
|
|
|
|
|
+ //Windows:最近文件列表补充点击空白处取消选中;移除Esc取消选中逻辑
|
|
|
|
+ //if (e.Key == Key.Escape)
|
|
|
|
+ //{
|
|
|
|
+ //点击ESC取消选中
|
|
|
|
+ //if (GridRecentFilesList.Visibility == Visibility.Visible)
|
|
|
|
+ //{
|
|
|
|
+ // GridRecentFilesList.SelectedIndex = -1;
|
|
|
|
+ //}
|
|
|
|
+ //else
|
|
|
|
+ //{
|
|
|
|
+ // RecentFilesList.SelectedIndex = -1;
|
|
|
|
+ //}
|
|
|
|
+ //}
|
|
}
|
|
}
|
|
|
|
|
|
private void MenuOpenFile_Click(object sender, RoutedEventArgs e)
|
|
private void MenuOpenFile_Click(object sender, RoutedEventArgs e)
|
|
@@ -259,7 +257,7 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
|
|
else
|
|
else
|
|
listView = GridRecentFilesList;
|
|
listView = GridRecentFilesList;
|
|
|
|
|
|
- if (listView.SelectedItems.Count >=2)
|
|
|
|
|
|
+ if (listView.SelectedItems.Count >= 2)
|
|
{
|
|
{
|
|
List<string> files = new List<string>();
|
|
List<string> files = new List<string>();
|
|
foreach (OpenFileInfo item in listView.SelectedItems)
|
|
foreach (OpenFileInfo item in listView.SelectedItems)
|
|
@@ -281,10 +279,10 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
|
|
private void UserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
|
private void UserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
{
|
|
//已经加载后,切换页签时,确认是否要刷新数据源
|
|
//已经加载后,切换页签时,确认是否要刷新数据源
|
|
- if(IsLoaded&&(bool)e.NewValue)
|
|
|
|
|
|
+ if (IsLoaded && (bool)e.NewValue)
|
|
{
|
|
{
|
|
ViewModel.UpdateItemSoucre();
|
|
ViewModel.UpdateItemSoucre();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|