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.Settings;
using PDF_Office.Helper;
using ComPDFKit.PDFDocument;

namespace PDF_Office.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 (!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");
                }
                  
            }
        }

    }
}
