Browse Source

视图-优化显示模式

OYXH\oyxh 2 years ago
parent
commit
4691cab290

+ 30 - 5
PDF Office/ViewModels/BottomToolContentViewModel.cs

@@ -53,6 +53,21 @@ namespace PDF_Office.ViewModels
         public DelegateCommand<object> SelectionChangedCommand { get; set; }
 
         public DelegateCommand<object> ShowViewModularCommand { get; set; }
+
+        private bool isShowViewModular = false;
+
+        /// <summary>
+        /// 属性栏是否展开
+        /// </summary>
+        public bool IsShowViewModular
+        {
+            get { return isShowViewModular; }
+            set
+            {
+                SetProperty(ref isShowViewModular, value);
+            }
+        }
+
         private bool isSingleView;
 
         public bool IsSingleView
@@ -180,11 +195,20 @@ namespace PDF_Office.ViewModels
 
         private void ShowViewModularEvent(object obj)
         {
-            NavigationParameters param = new NavigationParameters();
-            param.Add(ParameterNames.PDFViewer, PDFViewer);
-            param.Add("BottomToolContentViewModel", this);
-            region.RequestNavigate(RegionNames.PropertyRegionName, "ViewModularContent", param);
-            viewContentViewModel.IsPropertyOpen = true;
+            if (viewContentViewModel.IsPropertyOpen == false)
+            {
+                viewContentViewModel.IsPropertyOpen = true;
+
+                NavigationParameters param = new NavigationParameters();
+                param.Add(ParameterNames.PDFViewer, PDFViewer);
+                param.Add("BottomToolContentViewModel", this);
+                region.RequestNavigate(RegionNames.PropertyRegionName, "ViewModularContent", param);
+            }
+            else
+            {
+                viewContentViewModel.IsPropertyOpen = false;
+            }
+            IsShowViewModular = viewContentViewModel.IsPropertyOpen;
         }
 
         /// <summary>
@@ -513,6 +537,7 @@ namespace PDF_Office.ViewModels
             if (viewContentViewModel != null)
             {
                 this.viewContentViewModel = viewContentViewModel;
+                IsShowViewModular = viewContentViewModel.IsPropertyOpen;
             }
 
             var pdfview = navigationContext.Parameters[ParameterNames.PDFViewer] as CPDFViewer;

+ 4 - 28
PDF Office/ViewModels/PropertyPanel/ViewModularContentViewModel.cs

@@ -117,9 +117,7 @@ namespace PDF_Office.ViewModels.PropertyPanel
         public DelegateCommand<object> VerticalSplitScreenCommand { get; set; }
         public DelegateCommand<object> DisableCommand { get; set; }
 
-        public DelegateCommand<object> SinglePageCommand { get; set; }
-        public DelegateCommand<object> TwoPageCommand { get; set; }
-        public DelegateCommand<object> BookModeCommand { get; set; }
+        public DelegateCommand SetViewModeCommand { get; set; }
         public DelegateCommand<object> chkContinueCommand { get; set; }
         public DelegateCommand<object> chkPagesBreakCommand { get; set; }
 
@@ -127,7 +125,7 @@ namespace PDF_Office.ViewModels.PropertyPanel
         {
             region = regionManager;
             dialogs = dialogService;
-            //未显示时无法注册上Region名称
+            //未显示时无法注册上Region名称,所以需要短暂显示
             SplitScreenViewVisible = Visibility.Visible;
             SplitScreenViewRegionName = RegionNames.SplitScreenViewRegionName;
 
@@ -135,9 +133,7 @@ namespace PDF_Office.ViewModels.PropertyPanel
 
             VerticalSplitScreenCommand = new DelegateCommand<object>(VerticalSplitScreenEvent);
             DisableCommand = new DelegateCommand<object>(DisableEvent);
-            SinglePageCommand = new DelegateCommand<object>(SinglePageEvent);
-            TwoPageCommand = new DelegateCommand<object>(TwoPageEvent);
-            BookModeCommand = new DelegateCommand<object>(BookModeEvent);
+            SetViewModeCommand = new DelegateCommand(SetModeView);
             chkContinueCommand = new DelegateCommand<object>(chkContinueEvent);
             chkPagesBreakCommand = new DelegateCommand<object>(chkPagesBreakEvent);
         }
@@ -157,7 +153,7 @@ namespace PDF_Office.ViewModels.PropertyPanel
             SaveMode(IsPagesBreak);
         }
 
-        public void SetModeView()
+        private void SetModeView()
         {
             if (PDFViewer != null)
             {
@@ -200,26 +196,6 @@ namespace PDF_Office.ViewModels.PropertyPanel
         /// </summary>
         /// <param name="obj"></param>
         private void chkContinueEvent(object obj)
-        {
-            SetModeView();
-            //SaveMode(PDFViewer.ModeView);
-        }
-
-        private void BookModeEvent(object obj)
-        {
-            SetModeView();
-        }
-
-        private void TwoPageEvent(object obj)
-        {
-            SetModeView();
-        }
-
-        /// <summary>
-        /// 显示模式-单页
-        /// </summary>
-        /// <param name="obj"></param>
-        private void SinglePageEvent(object obj)
         {
             SetModeView();
         }

+ 1 - 0
PDF Office/Views/BottomToolContent.xaml

@@ -208,6 +208,7 @@
                 Width="24"
                 Height="24"
                 Margin="4"
+                 IsChecked="{Binding IsShowViewModular}"
                 Command="{Binding ShowViewModularCommand}" />
             <StackPanel
                 Height="16"

+ 3 - 3
PDF Office/Views/PropertyPanel/ViewModularContent.xaml

@@ -55,7 +55,7 @@
         <StackPanel Orientation="Horizontal">
             <RadioButton
                 Name="RBtnSinglePage"
-                Command="{Binding SinglePageCommand}"
+                Command="{Binding SetViewModeCommand}"
                 GroupName="DisplayMode"
                 IsChecked="{Binding IsSingleView}"
                 Style="{StaticResource PageViewRadioBtn}">
@@ -74,7 +74,7 @@
             <RadioButton
                 Name="RBtnTwoPage"
                 Margin="2,0,2,0"
-                Command="{Binding TwoPageCommand}"
+                Command="{Binding SetViewModeCommand}"
                 GroupName="DisplayMode"
                 IsChecked="{Binding IsTwoPageView}"
                 Style="{StaticResource PageViewRadioBtn}">
@@ -93,7 +93,7 @@
             <RadioButton
                 Name="RBtnBookMode"
                 Margin="0,0,2,0"
-                Command="{Binding BookModeCommand}"
+                Command="{Binding SetViewModeCommand}"
                 GroupName="DisplayMode"
                 IsChecked="{Binding IsBookModeView}"
                 Style="{StaticResource PageViewRadioBtn}">