WatermarkTemplateListFileContent.xaml.cs 2.8 KB

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