123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using ComPDFKit.PDFDocument;
- using ComPDFKitViewer.PdfViewer;
- using PDF_Master.Helper;
- using PDFSettings;
- namespace PDF_Master.Views.HomePanel.RecentFiles
- {
- /// <summary>
- /// DocItemListViewControl.xaml 的交互逻辑
- /// </summary>
- public partial class DocItemListViewControl : UserControl
- {
- public event EventHandler<RoutedEventArgs> DeleteItemHandler;
- public event EventHandler<RoutedEventArgs> OpenFileItemHandler;
- public DocItemListViewControl()
- {
- InitializeComponent();
- SetLangText();
- }
- private void SetLangText()
- {
- MenuOpenFile.Header = App.HomePageLoader.GetString("Home_OpenFiles");
- MenuDelete.Header = App.HomePageLoader.GetString("HomeList_MenuRemove");
- }
- #region UI
- public bool IsHoverState
- {
- get { return (bool)GetValue(IsHoverStateProperty); }
- set { SetValue(IsHoverStateProperty, value); }
- }
- public static readonly DependencyProperty IsHoverStateProperty =
- DependencyProperty.Register("IsHoverState", typeof(bool), typeof(DocItemListViewControl), new PropertyMetadata(false));
- private void UserControl_MouseEnter(object sender, MouseEventArgs e)
- {
- // IsHoverState = true;
- }
- private void UserControl_MouseLeave(object sender, MouseEventArgs e)
- {
- // IsHoverState = false;
- }
- private void UserControl_MouseMove(object sender, MouseEventArgs e)
- {
- // IsHoverState = true;
- }
- private void MoreButton_Initialized(object sender, EventArgs e)
- {
- MoreButton.ContextMenu = null;
- }
- private void MoreButton_Click(object sender, RoutedEventArgs e)
- {
- MenuMore.PlacementTarget = MoreButton;
- MenuMore.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
- MenuMore.IsOpen = true;
- }
- #endregion
- #region 事件
- #endregion
- private void DeleteButton_Click(object sender, RoutedEventArgs e)
- {
- DeleteItemHandler.Invoke(sender, e);
- }
- private void MenuMore_Loaded(object sender, RoutedEventArgs e)
- {
- }
- private void Grid_Loaded(object sender, RoutedEventArgs e)
- {
- var grid = sender as Grid;
- if (grid != null)
- {
- var data = grid.DataContext as OpenFileInfo;
- if (data == null) return;
- //显示新文档符号
- if (data.IsGuidPDF&& App.IsGuidPDFUpdated)
- {
- RecNewMark.Visibility = Visibility.Visible;
- }
- if (File.Exists(data.ThumbImgPath))
- {
- CoverImage.Source = ToolMethod.GetFileThumbImg(data.ThumbImgPath);
- }
- else if (data.ThumbImgPath.Equals("pack://application:,,,/Resources/FilesType/ic_propertybar_file_pdf_lock.png"))
- CoverImage.Source = ToolMethod.GetFileThumbImg("pack://application:,,,/Resources/FilesType/ic_propertybar_file_pdf_lock.png");
- else//最近文档 但是删除了缩略图的情况
- CoverImage.Source = ToolMethod.GetFileThumbImg("pack://application:,,,/Resources/FilesType/ic_propertybar_file_png_Large.png");
- }
- }
- private void MenuOpenFile_Click(object sender, RoutedEventArgs e)
- {
- OpenFileItemHandler?.Invoke(sender, e);
- }
- private void MenuDelete_Click(object sender, RoutedEventArgs e)
- {
- DeleteItemHandler?.Invoke(sender, e);
- }
- }
- }
|