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_Office.Helper;
using PDFSettings.Settings;
namespace PDF_Office.Views.HomePanel.RecentFiles
{
///
/// DocItemListViewControl.xaml 的交互逻辑
///
public partial class DocItemListViewControl : UserControl
{
public event EventHandler DeleteItemHandler;
public event EventHandler OpenFileItemHandler;
public DocItemListViewControl()
{
InitializeComponent();
SetLangText();
}
private void SetLangText()
{
}
#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);
}
}
}