AnnotToolContent.xaml.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using ComPDFKitViewer.PdfViewer;
  2. using PDF_Master.CustomControl;
  3. using PDF_Master.ViewModels.Tools;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Globalization;
  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.Tools
  20. {
  21. public class AnnotToolIsCheckedConvert : IValueConverter
  22. {
  23. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  24. {
  25. if(value != null && parameter != null && value is string && parameter is string)
  26. {
  27. if((string)value == (string)parameter)
  28. return true;
  29. }
  30. return false;
  31. }
  32. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  33. {
  34. if(value != null && value is bool)
  35. {
  36. if((bool)value)
  37. {
  38. return parameter;
  39. }
  40. }
  41. return "";
  42. }
  43. }
  44. /// <summary>
  45. /// AnnotToolContent.xaml 的交互逻辑
  46. /// </summary>
  47. public partial class AnnotToolContent : UserControl
  48. {
  49. AnnotToolContentViewModel ViewModel => DataContext as AnnotToolContentViewModel;
  50. public AnnotToolContent()
  51. {
  52. InitializeComponent();
  53. }
  54. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  55. {
  56. if(ViewModel != null)
  57. {
  58. foreach(var item in ToolPanel.Children)
  59. {
  60. if(item is CustomIconToggleBtn)
  61. {
  62. CustomIconToggleBtn btn = (CustomIconToggleBtn)item;
  63. if(btn.Tag != null)
  64. {
  65. var itemDict = ViewModel.GetToolTipDict.FirstOrDefault(temp => temp.Key == btn.Tag.ToString());
  66. ToolTipService.SetToolTip(btn, itemDict.Value);
  67. }
  68. }
  69. }
  70. }
  71. }
  72. private void BtnHand_Click(object sender, RoutedEventArgs e)
  73. {
  74. }
  75. private void BtnTool_Click(object sender, RoutedEventArgs e)
  76. {
  77. CustomIconToggleBtn keepBtn = sender as CustomIconToggleBtn;
  78. if (keepBtn != null)
  79. {
  80. // ClearSelectedToolPanel(keepBtn);
  81. }
  82. }
  83. private void ClearSelectedToolPanel(CustomIconToggleBtn keepBtn = null)
  84. {
  85. foreach (var item in ToolPanel.Children)
  86. {
  87. CustomIconToggleBtn checkBtn = item as CustomIconToggleBtn;
  88. //排除显示注释类型按钮
  89. if (checkBtn != null && checkBtn != keepBtn&&checkBtn.Name!= "BtnShowAnnot")
  90. {
  91. checkBtn.IsChecked = false;
  92. }
  93. }
  94. }
  95. private void BtnBookMark_Click(object sender, RoutedEventArgs e)
  96. {
  97. }
  98. }
  99. }