using PDF_Master.Helper; using PDF_Master.ViewModels.BOTA; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace PDF_Master.Views.BOTA { /// /// BOTAContent.xaml 的交互逻辑 /// public partial class BOTAContent : UserControl { public BOTAContent() { InitializeComponent(); } private void IconAndTextTabItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var item = sender as TabItem; if (item != null) { ///重复点击选中项时,收起侧边栏 if (item.IsSelected) { (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = false; item.IsSelected = false; } else { (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = true; item.IsSelected = true; } e.Handled = true; } } private void MenuThumbnail_Unchecked(object sender, RoutedEventArgs e) { //取消勾选后,如果是将选中的tabitem隐藏了,需要收起侧边栏 var menuitem = sender as MenuItem; switch (menuitem.Name) { case "MenuThumbnail": if(TabItemThumbnail.IsSelected) { (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = false; } break; case "MenuOutLine": if (TabItemOutLine.IsSelected) { (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = false; } break; case "MenuBookMark": if (TabItemBookMark.IsSelected) { (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = false; } break; case "MenuAnnotation": if (TabItemAnnotation.IsSelected) { (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = false; } break; case "MenuSearch": if (TabItemSearch.IsSelected) { (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = false; } break; case "MenuFrom": if (TabItemForm.IsSelected) { (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = false; } break; case "MenuSign": if (TabItemSign.IsSelected) { (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = false; } break; default: break; } } private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e) { if(e.NewSize.Width<=48&&TabBOTA.SelectedItem!=null&&(TabBOTA.SelectedItem as TabItem)!=null) { (TabBOTA.SelectedItem as TabItem).IsSelected = false; } } } }