StampAnnotProperty.xaml.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using PDF_Office.CustomControl;
  2. using PDF_Office.Helper;
  3. using PDF_Office.Model.AnnotPanel;
  4. using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Navigation;
  18. using System.Windows.Shapes;
  19. namespace PDF_Office.Views.PropertyPanel.AnnotPanel
  20. {
  21. /// <summary>
  22. /// StampAnnotProperty.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class StampAnnotProperty : UserControl
  25. {
  26. public StampAnnotProperty()
  27. {
  28. InitializeComponent();
  29. }
  30. private void ListBoxItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  31. {
  32. ListBox listBox = CommonHelper.FindVisualParent<ListBox>(sender as ListBoxItem);
  33. if (listBox != null)
  34. {
  35. if (listBox.Tag!=null&&listBox.Tag.ToString() == "Dynamic")
  36. {
  37. (DataContext as StampAnnotPropertyViewModel).SetDynamicStamp((sender as ListBoxItem).DataContext as Stamp);
  38. return;
  39. }
  40. }
  41. (DataContext as StampAnnotPropertyViewModel).SetStamp((sender as ListBoxItem).DataContext as Stamp);
  42. }
  43. private void DydamicListBox_Loaded(object sender, RoutedEventArgs e)
  44. {
  45. (DataContext as StampAnnotPropertyViewModel).UpDataDynamicStampList();
  46. }
  47. private void Save_Click(object sender, RoutedEventArgs e)
  48. {
  49. MenuItem item = sender as MenuItem;
  50. (DataContext as StampAnnotPropertyViewModel).SaveToPath(item.Tag.ToString(), item.DataContext as Stamp);
  51. }
  52. private void Delete_Click(object sender, RoutedEventArgs e)
  53. {
  54. if (sender is MenuItem)
  55. {
  56. MenuItem item = sender as MenuItem;
  57. (DataContext as StampAnnotPropertyViewModel).DeleteStamp(item.DataContext as Stamp);
  58. }
  59. else if (sender is Button)
  60. {
  61. Button item = sender as Button;
  62. (DataContext as StampAnnotPropertyViewModel).DeleteStamp(item.DataContext as Stamp);
  63. }
  64. }
  65. private void DeleteAll_Click(object sender, RoutedEventArgs e)
  66. {
  67. AlertsMessage alertsMessage = new AlertsMessage();
  68. alertsMessage.ShowDialog("提示", "确定要全部删除吗?", "Cancel", "OK");
  69. if (alertsMessage.result == ContentResult.Ok)
  70. {
  71. (DataContext as StampAnnotPropertyViewModel).DeleteAll();
  72. }
  73. }
  74. private void Editor_Click(object sender, RoutedEventArgs e)
  75. {
  76. MenuItem item = sender as MenuItem;
  77. (DataContext as StampAnnotPropertyViewModel).EditorCustomStamp(item.DataContext as Stamp);
  78. }
  79. private void UserControl_KeyDown(object sender, KeyEventArgs e)
  80. {
  81. if (e.Key == Key.Escape)
  82. {
  83. (DataContext as StampAnnotPropertyViewModel).Close();
  84. e.Handled = true;
  85. }
  86. }
  87. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  88. {
  89. AnnoteTypeTitle.Text= App.MainPageLoader.GetString("Stamp_Title");
  90. }
  91. }
  92. }