TitleBarControl.xaml.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using compdfkit_tools.Helper;
  2. using ComPDFKitViewer.PdfViewer;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. namespace compdfkit_tools.PDFControl
  18. {
  19. /// <summary>
  20. /// TitleBarControl.xaml 的交互逻辑
  21. /// </summary>
  22. ///
  23. public partial class TitleBarControl : UserControl
  24. {
  25. public CPDFViewer pdfViewer;
  26. public event EventHandler<CPDFViewer> OpenFileEvent;
  27. public TitleBarControl()
  28. {
  29. InitializeComponent();
  30. }
  31. private void OpenFileItem_Click(object sender, RoutedEventArgs e)
  32. {
  33. var fileItem = sender as MenuItem;
  34. if (fileItem != null)
  35. {
  36. string filePath = CommonHelper.GetFilePathOrEmpty();
  37. if (!string.IsNullOrEmpty(filePath))
  38. {
  39. pdfViewer?.CloseDocument();
  40. pdfViewer = new CPDFViewer();
  41. pdfViewer.InitDocument(filePath);
  42. OpenFileEvent?.Invoke(sender, pdfViewer);
  43. SolidColorBrush solidColorBrush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 255));
  44. byte[] by = { 1, 0, 0 };
  45. pdfViewer.Document.GetBackground().SetColor(by);
  46. }
  47. }
  48. }
  49. }
  50. }