Browse Source

BOTA-补充BOTA交互

ZhouJieSheng 2 years ago
parent
commit
1d77d1a1da

+ 2 - 1
PDF Office/Styles/ToggleButton.xaml

@@ -4,7 +4,7 @@
         <Setter Property="FocusVisualStyle" Value="{x:Null}" />
         <Setter Property="Background" Value="Transparent" />
         <Setter Property="BorderThickness" Value="0" />
-        <Setter Property="Foreground" Value="{StaticResource color.sys.text.neutral.lv1}" />
+        <Setter Property="Foreground" Value="{StaticResource color.icon.base.neutral.norm.lv1}" />
         <Setter Property="Template">
             <Setter.Value>
                 <ControlTemplate TargetType="{x:Type ToggleButton}">
@@ -36,6 +36,7 @@
                         </Trigger>
                         <Trigger Property="IsChecked" Value="True">
                             <Setter TargetName="border" Property="Panel.Background" Value="{StaticResource color.item-state.sel.bg.lv2}" />
+                            <Setter Property="Foreground" Value="{StaticResource color.icon.base.neutral.norm.lv1}" />
                         </Trigger>
                         <Trigger Property="IsEnabled" Value="False">
                             <Setter TargetName="border" Property="Panel.Background" Value="Transparent" />

+ 6 - 3
PDF Office/ViewModels/BOTA/BOTAContentViewModel.cs

@@ -22,7 +22,7 @@ namespace PDF_Office.ViewModels.BOTA
         private IRegionManager regions { get; set; }
         private IDialogService dialogs { get; set; }
 
-        private ViewContentViewModel viewContentViewModel { get; set; }
+        public ViewContentViewModel viewContentViewModel { get; set; }
 
         private Dictionary<string, string> viewNameByTabItem;
 
@@ -56,8 +56,11 @@ namespace PDF_Office.ViewModels.BOTA
             var args = e as SelectionChangedEventArgs;
             if (args != null)
             {
-                EnterSelectedBar((args.AddedItems[0] as TabItem).Name);
-                viewContentViewModel.OpenBOTA = true;
+                if (!string.IsNullOrEmpty((args.AddedItems[0] as TabItem).Name))
+                {
+                    EnterSelectedBar((args.AddedItems[0] as TabItem).Name);
+                    viewContentViewModel.OpenBOTA = true;
+                }
             }
         }
 

+ 4 - 2
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -398,6 +398,7 @@ namespace PDF_Office.ViewModels
             }
         }
 
+
         private int selectedIndex;
 
         /// <summary>
@@ -422,11 +423,12 @@ namespace PDF_Office.ViewModels
             get { return openBOTA; }
             set
             {
-                openBOTA = value;
+                SetProperty(ref openBOTA, value);
                 if (openBOTA && BOTAWidth.Value <= 48)
                 {
-                    BOTAWidth = new GridLength(256);
+                    BOTAWidth = new GridLength(260);
                 }
+                //关闭BOTA的逻辑在xaml.cs代码里控制,无法绑定后台
             }
         }
 

+ 3 - 0
PDF Office/Views/BOTA/BOTAContent.xaml

@@ -66,13 +66,16 @@
             </Border.ContextMenu>
         </Border>
         <TabControl
+            Name="TabBOTA"
             Grid.ColumnSpan="2"
             Background="Transparent"
+            PreviewMouseLeftButtonDown="TabControl_PreviewMouseLeftButtonDown"
             Style="{StaticResource TabControlWithUnderLineStyle}"
             TabStripPlacement="Left">
             <!--  建立一个空的标头占位  -->
             <TabItem
                 Height="0"
+                IsSelected="True"
                 Margin="0"
                 BorderThickness="0" />
             <TabItem

+ 25 - 1
PDF Office/Views/BOTA/BOTAContent.xaml.cs

@@ -1,4 +1,6 @@
-using System;
+using PDF_Office.Helper;
+using PDF_Office.ViewModels.BOTA;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -29,5 +31,27 @@ namespace PDF_Office.Views.BOTA
         {
 
         }
+
+        private void TabControl_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        {
+            var visual = VisualTreeHelper.HitTest(TabBOTA, e.GetPosition(TabBOTA));
+            if (visual == null)
+            {
+                return;
+            }
+            var item = CommonHelper.FindVisualParent<TabItem>(visual.VisualHit);
+            if (item == null)
+            {
+                return;
+            }
+
+          
+
+            ///重复点击选中项时,收起侧边栏
+            if (item.IsSelected == true)
+            {
+                (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = !(this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA;
+            }
+        }
     }
 }

+ 6 - 0
PDF Office/Views/PageEdit/PageEditContent.xaml.cs

@@ -227,6 +227,11 @@ namespace PDF_Office.Views.PageEdit
         {
             var itemSize = (ListPageEdit.Items[0] as PageEditItem).ItemSize;
             var range = GetRoughFromView(ListPageEdit, itemSize, new Thickness(5, 10, 5, 10));
+            if((bool)TbnTwoLine.IsChecked)
+            {
+                ///双列模式下要计算两列item
+                range = new Tuple<int, int, int>(range.Item1,range.Item2*2,range.Item3);
+            }
             eventor.GetEvent<PageEditRefreshEvent>().Publish(new PageEditRefreshEventArgs() { Unicode = unicode, PageRange = range });
         }
 
@@ -844,6 +849,7 @@ namespace PDF_Office.Views.PageEdit
         private void TbnTwoLine_Click(object sender, RoutedEventArgs e)
         {
             ItemSuitAcutalWidth(this.ActualWidth);
+            PulishEvent();
         }
 
         /// <summary>

+ 7 - 5
PDF Office/Views/ViewContent.xaml

@@ -279,7 +279,7 @@
                     x:Name="BOTACloumn"
                     Width="{Binding BOTAWidth, Mode=TwoWay}"
                     MinWidth="48"
-                    MaxWidth="400" />
+                    MaxWidth="472" />
                 <ColumnDefinition Width="auto" />
                 <ColumnDefinition
                     Name="ViewerColumn"
@@ -301,8 +301,9 @@
                 </ColumnDefinition>
             </Grid.ColumnDefinitions>
 
-            <ContentControl prism:RegionManager.RegionName="{Binding BOTARegionName}" />
+            <ContentControl prism:RegionManager.RegionName="{Binding BOTARegionName}" SizeChanged="ContentControl_SizeChanged"/>
             <GridSplitter
+                Name="BOTASplitter"
                 Grid.Column="1"
                 Width="3"
                 Background="Transparent"
@@ -372,13 +373,14 @@
                 VerticalAlignment="Top"
                 prism:RegionManager.RegionName="{Binding TipContentRegionName}"
                 Visibility="{Binding TipVisible}" />
-            <!-- 阅读页顶部侧面提示区域 -->
+            <!--  阅读页顶部侧面提示区域  -->
             <ContentControl
                 Grid.Column="2"
-                VerticalAlignment="Top"
+                Margin="16,8"
                 HorizontalAlignment="Right"
+                VerticalAlignment="Top"
                 prism:RegionManager.RegionName="{Binding LeftTipContentRegionName}"
-                Visibility="{Binding LeftTipVisible}"  Margin="16,8"/>
+                Visibility="{Binding LeftTipVisible}" />
             <Border
                 Grid.Column="2"
                 Width="145"

+ 26 - 0
PDF Office/Views/ViewContent.xaml.cs

@@ -34,6 +34,27 @@ namespace PDF_Office.Views
             InitializeComponent();
             unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             viewModel = (ViewContentViewModel)this.DataContext;
+
+            viewModel.PropertyChanged += ViewModel_PropertyChanged;
+        }
+
+        private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+        {
+            if(e.PropertyName == "OpenBOTA")
+            {
+                if(!viewModel.OpenBOTA)
+                {
+                    //动态改变BOTA的最小宽度只能在这里设置,VM里绑定会有异常
+                    BOTACloumn.MinWidth = 48;
+                    viewModel.BOTAWidth = new GridLength(48);
+                    BOTASplitter.Visibility = Visibility.Collapsed;
+                }
+                else
+                {
+                    BOTACloumn.MinWidth = 260;
+                    BOTASplitter.Visibility = Visibility.Visible;
+                }
+            }
         }
 
         public ViewContent(IEventAggregator eventAggregator) : this()
@@ -134,5 +155,10 @@ namespace PDF_Office.Views
             FileMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
             FileMenu.IsOpen = true;
         }
+
+        private void ContentControl_SizeChanged(object sender, SizeChangedEventArgs e)
+        {
+
+        }
     }
 }