|
@@ -3,6 +3,7 @@ using Microsoft.Win32;
|
|
using PDF_Office.CustomControl;
|
|
using PDF_Office.CustomControl;
|
|
using PDF_Office.Helper;
|
|
using PDF_Office.Helper;
|
|
using PDF_Office.Properties;
|
|
using PDF_Office.Properties;
|
|
|
|
+using PDF_Office.ViewModels.HomePanel.RecentFiles;
|
|
using PDFSettings.Settings;
|
|
using PDFSettings.Settings;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
@@ -19,20 +20,16 @@ using winform = System.Windows.Forms;
|
|
|
|
|
|
namespace PDF_Office.Views.HomePanel.RecentFiles
|
|
namespace PDF_Office.Views.HomePanel.RecentFiles
|
|
{
|
|
{
|
|
- public partial class RecentFilesView : UserControl
|
|
|
|
|
|
+ public partial class RecentFilesContent : UserControl
|
|
{
|
|
{
|
|
-
|
|
|
|
- private ObservableCollection<OpenFileInfo> RecentFilesGroup = new ObservableCollection<OpenFileInfo>();
|
|
|
|
- public RecentFilesView()
|
|
|
|
|
|
+ private RecentFilesContentViewModel ViewModel => DataContext as RecentFilesContentViewModel;
|
|
|
|
+ public RecentFilesContent()
|
|
{
|
|
{
|
|
InitializeComponent();
|
|
InitializeComponent();
|
|
}
|
|
}
|
|
|
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
{
|
|
- RecentFilesGroup = new ObservableCollection<OpenFileInfo>(Settings.Default.RecentOpenFiles);
|
|
|
|
- RecentFilesList.ItemsSource = RecentFilesGroup;
|
|
|
|
- GridRecentFilesList.ItemsSource = RecentFilesGroup;
|
|
|
|
RecentFilesList.SelectedItem = null;
|
|
RecentFilesList.SelectedItem = null;
|
|
ShowListViewContentUI();
|
|
ShowListViewContentUI();
|
|
}
|
|
}
|
|
@@ -135,37 +132,6 @@ namespace PDF_Office.Views.HomePanel.RecentFiles
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
- private void btnDelete_Click(object sender, RoutedEventArgs e)
|
|
|
|
- {
|
|
|
|
- string msg = "";
|
|
|
|
- int SelectedItemsType = 0;
|
|
|
|
- if (RecentFilesList.SelectedItems.Count == RecentFilesList.Items.Count || RecentFilesList.SelectedItems.Count == 0)
|
|
|
|
- {
|
|
|
|
- if (RecentFilesList.SelectedItems.Count == 1 && RecentFilesList.Items.Count == 1)
|
|
|
|
- msg = "ClearFile";
|
|
|
|
- else
|
|
|
|
- msg = "AllClearFiles";
|
|
|
|
-
|
|
|
|
- SelectedItemsType = 0;
|
|
|
|
- }
|
|
|
|
- else if (RecentFilesList.SelectedItems.Count == 1)
|
|
|
|
- {
|
|
|
|
- msg = "ClearFile";
|
|
|
|
- SelectedItemsType = 1;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- msg = "ClearSelectedFiles";
|
|
|
|
- SelectedItemsType = 2;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- winform.DialogResult result = MessageBoxEx.Show(msg, "", winform.MessageBoxButtons.OKCancel, winform.MessageBoxIcon.Question);
|
|
|
|
- if (result == winform.DialogResult.OK)
|
|
|
|
- {
|
|
|
|
- RemoveRecentFilesFrom(SelectedItemsType);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private void RecentFilesList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
private void RecentFilesList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
{
|
|
|
|
|
|
@@ -202,47 +168,23 @@ namespace PDF_Office.Views.HomePanel.RecentFiles
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
#region Events
|
|
#region Events
|
|
- /// <summary>
|
|
|
|
- /// 删除最近文件的操作
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="selectedItemsType">0:全部文件;1:一个文件;2:多个文件</param>
|
|
|
|
- private void RemoveRecentFilesFrom(int selectedItemsType)
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void DeleteMenuItem_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
{
|
|
- if (selectedItemsType == 0)
|
|
|
|
- {
|
|
|
|
- SettingHelper.RemoveAllRecentOpenFiles();
|
|
|
|
- RecentFilesGroup.Clear();
|
|
|
|
- }
|
|
|
|
- else if (selectedItemsType == 1)
|
|
|
|
|
|
+ if (RecentFilesList.SelectedItems == null || RecentFilesList.SelectedItems.Count == 0)
|
|
{
|
|
{
|
|
- var file = RecentFilesList.SelectedItems[0] as OpenFileInfo;
|
|
|
|
- SettingHelper.RemoveRecentOpenFile(file.FilePath);
|
|
|
|
- RecentFilesGroup.Remove(file);
|
|
|
|
|
|
+ var item = (sender as MenuItem).DataContext as OpenFileInfo;
|
|
|
|
+ if (item != null)
|
|
|
|
+ {
|
|
|
|
+ ViewModel?.RemoveFileItemCommand.Execute(item);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- List<OpenFileInfo> OpenFileInfos = new List<OpenFileInfo>();
|
|
|
|
- foreach (var item in RecentFilesList.SelectedItems)
|
|
|
|
- {
|
|
|
|
- var openFileInfo = item as OpenFileInfo;
|
|
|
|
- OpenFileInfos.Add(openFileInfo);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- foreach (var item in OpenFileInfos)
|
|
|
|
- {
|
|
|
|
- SettingHelper.RemoveRecentOpenFile(item.FilePath);
|
|
|
|
- RecentFilesGroup.Remove(item);
|
|
|
|
- }
|
|
|
|
- OpenFileInfos.Clear();
|
|
|
|
|
|
+ ViewModel?.RemoveFilesFromContainerCommand.Execute(RecentFilesList.SelectedItems);
|
|
}
|
|
}
|
|
|
|
|
|
- ShowListViewContentUI();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void DeleteMenuItem_Click(object sender, RoutedEventArgs e)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- DeleteFileItem(sender);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private void DeleteItemHandler_Click(object sender, RoutedEventArgs e)
|
|
private void DeleteItemHandler_Click(object sender, RoutedEventArgs e)
|
|
@@ -273,10 +215,10 @@ namespace PDF_Office.Views.HomePanel.RecentFiles
|
|
else
|
|
else
|
|
msg = "RecentFiles_SelectedClearMsg";
|
|
msg = "RecentFiles_SelectedClearMsg";
|
|
|
|
|
|
- if (MessageBoxEx.Show(msg, "", winform.MessageBoxButtons.OKCancel, winform.MessageBoxIcon.Question) == winform.DialogResult.OK)
|
|
|
|
- RemoveRecentFilesFrom(2);
|
|
|
|
- else
|
|
|
|
- return;
|
|
|
|
|
|
+ //if (MessageBoxEx.Show(msg, "", winform.MessageBoxButtons.OKCancel, winform.MessageBoxIcon.Question) == winform.DialogResult.OK)
|
|
|
|
+ // RemoveRecentFilesFrom(2);
|
|
|
|
+ //else
|
|
|
|
+ // return;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -291,7 +233,7 @@ namespace PDF_Office.Views.HomePanel.RecentFiles
|
|
if (file != null)
|
|
if (file != null)
|
|
{
|
|
{
|
|
SettingHelper.RemoveRecentOpenFile(file.FilePath);
|
|
SettingHelper.RemoveRecentOpenFile(file.FilePath);
|
|
- RecentFilesGroup.Remove(file);
|
|
|
|
|
|
+ // RecentFilesGroup.Remove(file);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if ((sender as Button) != null)
|
|
else if ((sender as Button) != null)
|
|
@@ -301,7 +243,7 @@ namespace PDF_Office.Views.HomePanel.RecentFiles
|
|
if (file != null)
|
|
if (file != null)
|
|
{
|
|
{
|
|
SettingHelper.RemoveRecentOpenFile(file.FilePath);
|
|
SettingHelper.RemoveRecentOpenFile(file.FilePath);
|
|
- RecentFilesGroup.Remove(file);
|
|
|
|
|
|
+ // RecentFilesGroup.Remove(file);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -314,20 +256,24 @@ namespace PDF_Office.Views.HomePanel.RecentFiles
|
|
var item = sender as ListViewItem;
|
|
var item = sender as ListViewItem;
|
|
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)
|
|
|
|
+ {
|
|
|
|
+ ViewModel?.OpenFilesCommand.Execute(fileInfo);
|
|
|
|
+ }
|
|
if (File.Exists(fileInfo.FilePath))
|
|
if (File.Exists(fileInfo.FilePath))
|
|
{
|
|
{
|
|
- MainWindow parentWindow = Window.GetWindow(this) as MainWindow;
|
|
|
|
|
|
+ //MainWindow parentWindow = Window.GetWindow(this) as MainWindow;
|
|
|
|
|
|
- string[] filePath = new string[1];
|
|
|
|
- filePath[0] = fileInfo.FilePath;
|
|
|
|
- parentWindow.LoadPdfViewer(filePath);
|
|
|
|
|
|
+ //string[] filePath = new string[1];
|
|
|
|
+ //filePath[0] = fileInfo.FilePath;
|
|
|
|
+ //parentWindow.LoadPdfViewer(filePath);
|
|
|
|
+ // ViewModel?.OpenFilesCommand.Execute(fileInfo);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- //MessageBoxEx.Show(App.MainPageLoader.GetString("Main_TheFileNotExistWarning"));
|
|
|
|
- SettingHelper.RemoveRecentOpenFile(fileInfo.FilePath);
|
|
|
|
- RecentFilesGroup.Remove(fileInfo);
|
|
|
|
|
|
+ // ViewModel?.RemoveFilesCommand.Execute(fileInfo);
|
|
ShowListViewContentUI();
|
|
ShowListViewContentUI();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -351,27 +297,7 @@ namespace PDF_Office.Views.HomePanel.RecentFiles
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
- private void PrintFile(CPDFViewer pdfViewer)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- private void PrintMenuItem_Click(object sender, RoutedEventArgs e)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void FileInfoMenuItem_Click(object sender, RoutedEventArgs e)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void ShareMenuItem_Click(object sender, RoutedEventArgs e)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+
|
|
private void FilePathMenuItem_Click(object sender, RoutedEventArgs e)
|
|
private void FilePathMenuItem_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
{
|
|
|
|
|