WatermarkTemplateListTextContent.xaml.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using ComPDFKitViewer;
  2. using PDF_Master.ViewModels.EditTools.Watermark;
  3. using PDFSettings;
  4. using System.Diagnostics;
  5. using System;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Media.Imaging;
  9. using System.IO;
  10. namespace PDF_Master.Views.EditTools.Watermark
  11. {
  12. /// <summary>
  13. /// Interaction logic for WatermarkTemplateListTextContent
  14. /// </summary>
  15. public partial class WatermarkTemplateListTextContent : UserControl
  16. {
  17. private WatermarkTemplateListTextContentViewModel viewModel;
  18. public WatermarkTemplateListTextContent()
  19. {
  20. InitializeComponent();
  21. viewModel = this.DataContext as WatermarkTemplateListTextContentViewModel;
  22. }
  23. private void DeleteTemplateBtn_Click(object sender, System.Windows.RoutedEventArgs e)
  24. {
  25. viewModel.DeleteTemplateItemCommand?.Execute(sender);
  26. }
  27. private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  28. {
  29. viewModel.SelectTemplateItemCommand?.Execute(sender);
  30. //TextWatermarkListbox.SelectedIndex = -1;
  31. }
  32. private void MenuEdit_Click(object sender, RoutedEventArgs e)
  33. {
  34. viewModel.EditTemplateItemCommand?.Execute(sender);
  35. }
  36. private void MenuDeleteCurrent_Click(object sender, RoutedEventArgs e)
  37. {
  38. viewModel.DeleteTemplateItemCommand?.Execute(sender);
  39. }
  40. private void MenuDeleteAll_Click(object sender, RoutedEventArgs e)
  41. {
  42. viewModel.DeleteAllTemplateItemCommand?.Execute();
  43. }
  44. private void EditTemplateBtn_Click(object sender, RoutedEventArgs e)
  45. {
  46. viewModel.EditTemplateItemCommand?.Execute(sender);
  47. }
  48. private void itemPanel_Loaded(object sender, RoutedEventArgs e)
  49. {
  50. try
  51. {
  52. StackPanel panel = sender as StackPanel;
  53. var data = panel.DataContext as WatermarkItem;
  54. var img = panel.FindName("WatermarkPreview") as Image;
  55. Trace.WriteLine(data.previewImagePath);
  56. if (!string.IsNullOrEmpty(data.previewImagePath) && File.Exists(data.previewImagePath))
  57. {
  58. BitmapSource bmp = new BitmapImage(new Uri(data.previewImagePath));
  59. img.Source = bmp;
  60. }
  61. }
  62. catch { }
  63. }
  64. }
  65. }