123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- using System;
- using System.Collections.Generic;
- 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 System.IO;
- using PDFSettings;
- using PDF_Master.Helper;
- using ComPDFKit.PDFDocument;
- namespace PDF_Master.Views.HomePanel.RecentFiles
- {
- /// <summary>
- /// DocItemControl.xaml 的交互逻辑
- /// </summary>
- public partial class DocItemControl : UserControl
- {
- public DocItemControl()
- {
- InitializeComponent();
- }
- 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 (!string.IsNullOrEmpty(data.ThumbImgPath))
- CoverImage.Source = ToolMethod.GetFileThumbImg(data.ThumbImgPath);
- else
- {
- CPDFDocument tempdoc = CPDFDocument.InitWithFilePath(data.FilePath);
- if (tempdoc != null && (bool)(tempdoc.IsLocked))
- {
- 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");
- tempdoc?.Release();
- }
- }
- }
- private void Grid_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
- {
- var grid = sender as Grid;
- if (grid != null&&CoverImage.Source==null)
- {
- var data = grid.DataContext as OpenFileInfo;
- if (data == null) return;
- if (data.IsGuidPDF && App.IsGuidPDFUpdated)
- {
- RecNewMark.Visibility = Visibility.Visible;
- }
- if (!string.IsNullOrEmpty(data.ThumbImgPath))
- CoverImage.Source = ToolMethod.GetFileThumbImg(data.ThumbImgPath);
- else
- {
- CPDFDocument tempdoc = CPDFDocument.InitWithFilePath(data.FilePath);
- if (tempdoc != null && (bool)(tempdoc.IsLocked))
- {
- 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");
- tempdoc?.Release();
- }
- }
- }
- }
- }
|