CPDFBookmarkAddUI.xaml.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace compdfkit_tools.PDFControlUI
  17. {
  18. public partial class CPDFBookmarkAddUI : UserControl
  19. {
  20. /// <summary>
  21. /// 书签添加按钮点击通知
  22. /// </summary>
  23. public event EventHandler<string> BookmarkAddEvent;
  24. private bool toggleState;
  25. public CPDFBookmarkAddUI()
  26. {
  27. InitializeComponent();
  28. }
  29. /// <summary>
  30. /// 书签添加界面切换显示添加输入界面
  31. /// </summary>
  32. private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  33. {
  34. toggleState = !toggleState;
  35. BookmarkInputPanel.Visibility=toggleState?Visibility.Visible:Visibility.Collapsed;
  36. }
  37. /// <summary>
  38. /// 取消添加 隐藏 添加界面
  39. /// </summary>
  40. private void ButtonCancel_Click(object sender, RoutedEventArgs e)
  41. {
  42. toggleState = false;
  43. BookmarkInputPanel.Visibility = Visibility.Collapsed;
  44. }
  45. /// <summary>
  46. /// 书签添加按钮点击 触发添加通知
  47. /// </summary>
  48. private void ButtonAdd_Click(object sender, RoutedEventArgs e)
  49. {
  50. if(!string.IsNullOrEmpty(BookmarkText.Text))
  51. {
  52. BookmarkAddEvent?.Invoke(this, BookmarkText.Text);
  53. BookmarkText.Text = string.Empty;
  54. }
  55. }
  56. }
  57. internal class BoolEnableConvert : IValueConverter
  58. {
  59. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  60. {
  61. if (value == null)
  62. {
  63. return false;
  64. }
  65. else
  66. {
  67. try
  68. {
  69. if (value is string)
  70. {
  71. string checkValue=value as string;
  72. if(checkValue.Length>0)
  73. {
  74. return true;
  75. }
  76. }
  77. }
  78. catch(Exception ex)
  79. {
  80. }
  81. return false;
  82. }
  83. }
  84. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  85. {
  86. throw new NotImplementedException();
  87. }
  88. }
  89. }