BOTAContent.xaml.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using PDF_Master.Helper;
  2. using PDF_Master.ViewModels.BOTA;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. namespace PDF_Master.Views.BOTA
  18. {
  19. /// <summary>
  20. /// BOTAContent.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class BOTAContent : UserControl
  23. {
  24. public BOTAContent()
  25. {
  26. InitializeComponent();
  27. }
  28. private void IconAndTextTabItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  29. {
  30. var item = sender as TabItem;
  31. if (item != null)
  32. {
  33. ///重复点击选中项时,收起侧边栏
  34. if (item.IsSelected)
  35. {
  36. (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = false;
  37. item.IsSelected = false;
  38. }
  39. else
  40. {
  41. (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = true;
  42. item.IsSelected = true;
  43. }
  44. e.Handled = true;
  45. }
  46. }
  47. private void MenuThumbnail_Unchecked(object sender, RoutedEventArgs e)
  48. {
  49. //取消勾选后,如果是将选中的tabitem隐藏了,需要收起侧边栏
  50. var menuitem = sender as MenuItem;
  51. switch (menuitem.Name)
  52. {
  53. case "MenuThumbnail":
  54. if(TabItemThumbnail.IsSelected)
  55. {
  56. (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = false;
  57. }
  58. break;
  59. case "MenuOutLine":
  60. if (TabItemOutLine.IsSelected)
  61. {
  62. (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = false;
  63. }
  64. break;
  65. case "MenuBookMark":
  66. if (TabItemBookMark.IsSelected)
  67. {
  68. (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = false;
  69. }
  70. break;
  71. case "MenuAnnotation":
  72. if (TabItemAnnotation.IsSelected)
  73. {
  74. (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = false;
  75. }
  76. break;
  77. case "MenuSearch":
  78. if (TabItemSearch.IsSelected)
  79. {
  80. (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = false;
  81. }
  82. break;
  83. case "MenuFrom":
  84. if (TabItemForm.IsSelected)
  85. {
  86. (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = false;
  87. }
  88. break;
  89. case "MenuSign":
  90. if (TabItemSign.IsSelected)
  91. {
  92. (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = false;
  93. }
  94. break;
  95. default:
  96. break;
  97. }
  98. }
  99. private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
  100. {
  101. if(e.NewSize.Width<=48&&TabBOTA.SelectedItem!=null&&(TabBOTA.SelectedItem as TabItem)!=null)
  102. {
  103. (TabBOTA.SelectedItem as TabItem).IsSelected = false;
  104. }
  105. }
  106. }
  107. }