StampAnnotProperty.xaml.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using PDF_Master.CustomControl;
  2. using PDF_Master.Helper;
  3. using PDF_Master.Model.AnnotPanel;
  4. using PDF_Master.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_Master.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. //KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
  30. //KeyEventsHelper.KeyDown += ShortCut_KeyDown;
  31. }
  32. private void ShortCut_KeyDown(object sender, KeyEventArgs e)
  33. {
  34. if (e.Key == Key.Escape)
  35. {
  36. (DataContext as StampAnnotPropertyViewModel).Close();
  37. e.Handled = true;
  38. }
  39. }
  40. private void ListBoxItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  41. {
  42. ListBox listBox = CommonHelper.FindVisualParent<ListBox>(sender as ListBoxItem);
  43. if (listBox != null)
  44. {
  45. if (listBox.Tag != null && listBox.Tag.ToString() == "Dynamic")
  46. {
  47. (DataContext as StampAnnotPropertyViewModel).SetDynamicStamp((sender as ListBoxItem).DataContext as Stamp);
  48. return;
  49. }
  50. }
  51. (DataContext as StampAnnotPropertyViewModel).SetStamp((sender as ListBoxItem).DataContext as Stamp);
  52. }
  53. private void DydamicListBox_Loaded(object sender, RoutedEventArgs e)
  54. {
  55. (DataContext as StampAnnotPropertyViewModel).UpDataDynamicStampList();
  56. }
  57. private void Save_Click(object sender, RoutedEventArgs e)
  58. {
  59. MenuItem item = sender as MenuItem;
  60. (DataContext as StampAnnotPropertyViewModel).SaveToPath(item.Tag.ToString(), item.DataContext as Stamp);
  61. }
  62. private void Delete_Click(object sender, RoutedEventArgs e)
  63. {
  64. if (sender is MenuItem)
  65. {
  66. MenuItem item = sender as MenuItem;
  67. (DataContext as StampAnnotPropertyViewModel).DeleteStamp(item.DataContext as Stamp);
  68. }
  69. else if (sender is Button)
  70. {
  71. Button item = sender as Button;
  72. (DataContext as StampAnnotPropertyViewModel).DeleteStamp(item.DataContext as Stamp);
  73. }
  74. }
  75. private void DeleteAll_Click(object sender, RoutedEventArgs e)
  76. {
  77. AlertsMessage alertsMessage = new AlertsMessage();
  78. alertsMessage.ShowDialog("提示", "确定要全部删除吗?", "Cancel", "OK");
  79. if (alertsMessage.result == ContentResult.Ok)
  80. {
  81. (DataContext as StampAnnotPropertyViewModel).DeleteAll();
  82. }
  83. }
  84. private void Editor_Click(object sender, RoutedEventArgs e)
  85. {
  86. MenuItem item = sender as MenuItem;
  87. (DataContext as StampAnnotPropertyViewModel).EditorCustomStamp(item.DataContext as Stamp);
  88. }
  89. private void UserControl_KeyDown(object sender, KeyEventArgs e)
  90. {
  91. if (e.Key == Key.Escape)
  92. {
  93. (DataContext as StampAnnotPropertyViewModel).Close();
  94. e.Handled = true;
  95. }
  96. }
  97. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  98. {
  99. AnnoteTypeTitle.Text = App.MainPageLoader.GetString("Stamp_Title");
  100. }
  101. }
  102. }