Просмотр исходного кода

综合-修复页面编辑、缩略图bug

ZhouJieSheng 2 лет назад
Родитель
Сommit
bbe317540d

+ 3 - 0
PDF Office/EventAggregators/CleanSelectAllEvent.cs

@@ -7,6 +7,9 @@ using System.Threading.Tasks;
 
 namespace PDF_Master.EventAggregators
 {
+    /// <summary>
+    /// 双击阅读页清空多选的事件
+    /// </summary>
     public class CleanSelectAllArgs
     {
         public string Unicode { get; set; }

+ 12 - 3
PDF Office/ViewModels/BottomToolContentViewModel.cs

@@ -412,17 +412,26 @@ namespace PDF_Master.ViewModels
                     {
                         case 0:
                             PDFViewer?.ChangeFitMode(FitMode.FitSize);
-                            OpenFileInfo.LastFitMode = FitMode.FitSize;
+                            if (OpenFileInfo != null)
+                            {
+                                OpenFileInfo.LastFitMode = FitMode.FitSize;
+                            }
                             break;
 
                         case 1:
                             PDFViewer?.ChangeFitMode(FitMode.FitWidth);
-                            OpenFileInfo.LastFitMode = FitMode.FitWidth;
+                            if (OpenFileInfo != null)
+                            {
+                                OpenFileInfo.LastFitMode = FitMode.FitWidth;
+                            }
                             break;
 
                         case 2:
                             PDFViewer?.ChangeFitMode(FitMode.FitHeight);
-                            OpenFileInfo.LastFitMode = FitMode.FitHeight;
+                            if (OpenFileInfo != null)
+                            {
+                                OpenFileInfo.LastFitMode = FitMode.FitHeight;
+                            }
                             break;
 
                         default:

+ 51 - 15
PDF Office/ViewModels/PageEdit/PageEditContentViewModel.cs

@@ -146,10 +146,6 @@ namespace PDF_Master.ViewModels.PageEdit
                     TxtPageInputVisibility = Visibility.Visible;
                     TbPageRange = (ListSelectedIndex + 1).ToString();
                 }
-                //if (IsBOTAThumb == Visibility.Visible && PDFViewer != null)
-                //{
-                //    PDFViewer.GoToPage(listSelecedIndex);
-                //}
             }
         }
 
@@ -272,19 +268,47 @@ namespace PDF_Master.ViewModels.PageEdit
             }
         }
 
-        private Visibility hasShowPageSize = Visibility.Collapsed;
+        private Visibility showedPageSize = Visibility.Collapsed;
         /// <summary>
-        /// 是否显示页面尺寸
+        /// 显示页面尺寸
         /// </summary>
-        public Visibility HasShowPageSize
+        public Visibility ShowedPageSize
         {
-            get { return hasShowPageSize; }
+            get { return showedPageSize; }
             set
             {
-                SetProperty(ref hasShowPageSize, value);
+                SetProperty(ref showedPageSize, value);
+                if(IsBOTAThumb!=Visibility.Visible)
+                {
+                    if(value == Visibility.Visible)
+                    {
+                        HidePageSize = Visibility.Collapsed;
+                    }
+                   else
+                    {
+                        HidePageSize = Visibility.Visible;
+                    }
+                }
             }
         }
 
+        private Visibility hidePageSize;
+
+        /// <summary>
+        /// 隐藏页面尺寸
+        /// </summary>
+        public Visibility HidePageSize
+        {
+            get { return hidePageSize; }
+            set
+            {
+                SetProperty(ref hidePageSize, value);
+            }
+        }
+
+
+
+
         private bool canUndo;
 
         /// <summary>
@@ -440,6 +464,10 @@ namespace PDF_Master.ViewModels.PageEdit
 
         public DelegateCommand ClearSelectedCommand { get; set; }
 
+        /// <summary>
+        /// 进入页面编辑
+        /// </summary>
+        public DelegateCommand EnterPageEditCommand { get; set; }
 
         #endregion
 
@@ -472,6 +500,7 @@ namespace PDF_Master.ViewModels.PageEdit
             CutCommand = new DelegateCommand(cut);
             PrintCommand = new DelegateCommand(print);
             ClearSelectedCommand = new DelegateCommand(clearSelected);
+            EnterPageEditCommand = new DelegateCommand(enterpageeditr);
 
             //订阅页面刷新事件
             eventAggregator.GetEvent<PageEditRefreshEvent>().Subscribe(OnPageEditRefreshEvent, e => e.Unicode == unicode);
@@ -485,8 +514,13 @@ namespace PDF_Master.ViewModels.PageEdit
 
 
         #region 事件
-
-
+        /// <summary>
+        /// 进入页面编辑
+        /// </summary>
+        private void enterpageeditr()
+        {
+            viewContentViewModel.EnterPageEdit();
+        }
 
         private void Instance_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
         {
@@ -2020,7 +2054,7 @@ namespace PDF_Master.ViewModels.PageEdit
             for (int i = 0; i < PageEditItems.Count; i++)
             {
                 PageEditItems[i].PageNumber = i + 1;
-                PageEditItems[i].ShowPageSize = HasShowPageSize == Visibility.Visible ? true : false;
+                PageEditItems[i].ShowPageSize = ShowedPageSize == Visibility.Visible ? true : false;
             }
 
         }
@@ -2125,15 +2159,15 @@ namespace PDF_Master.ViewModels.PageEdit
         private void ShowPageSize()
         {
             bool show = true;
-            if (HasShowPageSize == Visibility.Visible)
+            if (ShowedPageSize == Visibility.Visible)
             {
                 show = false;
-                HasShowPageSize = Visibility.Collapsed;
+                ShowedPageSize = Visibility.Collapsed;
             }
             else
             {
                 show = true;
-                HasShowPageSize = Visibility.Visible;
+                ShowedPageSize = Visibility.Visible;
             }
             for (int i = 0; i < PageEditItems.Count; i++)
             {
@@ -2438,6 +2472,8 @@ namespace PDF_Master.ViewModels.PageEdit
                 if (isBOTA)
                 {
                     IsBOTAThumb = Visibility.Visible;
+                    ShowedPageSize = Visibility.Collapsed;
+                    HidePageSize = Visibility.Collapsed;
                 }
                 else
                 {

+ 2 - 1
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -117,7 +117,8 @@ namespace PDF_Master.ViewModels.Tools
                 //}
                 bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemBookMark");
 
-                if (viewContentViewModel.OpenBOTA == true && isTabItemAnnotation == true && bOTAContent.TabItemBookMark.IsSelected == true)
+                //BOTA所有列表都需要响应 单击阅读页取消多选
+                if (viewContentViewModel.OpenBOTA == true/* && isTabItemAnnotation == true && bOTAContent.TabItemBookMark.IsSelected == true*/)
                 {
                     this.events.GetEvent<CleanSelectAllEvent>().Publish(new CleanSelectAllArgs() { Unicode = App.mainWindowViewModel.SelectedItem.Unicode, IsCleanSelectAll = true });
                 }

+ 13 - 11
PDF Office/Views/BOTA/BOTAContent.xaml

@@ -24,7 +24,7 @@
 
 
 
-        <Grid Background="{StaticResource color.sys.layout.mg}">
+    <Grid Background="{StaticResource color.sys.layout.mg}">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="48" />
             <ColumnDefinition />
@@ -75,22 +75,24 @@
             Name="TabBOTA"
             Grid.ColumnSpan="2"
             Background="Transparent"
-            PreviewMouseLeftButtonDown="TabControl_PreviewMouseLeftButtonDown"
             SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}"
             Style="{StaticResource TabControlWithUnderLineStyle}"
             TabStripPlacement="Left">
+            <TabControl.ItemContainerStyle>
+                <Style BasedOn="{StaticResource BOTATab}" TargetType="{x:Type customcontrol:IconAndTextTabItem}">
+                    <EventSetter Event="PreviewMouseLeftButtonDown" Handler="IconAndTextTabItem_PreviewMouseLeftButtonDown" />
+                </Style>
+            </TabControl.ItemContainerStyle>
             <!--  建立一个空的标头占位  -->
             <customcontrol:IconAndTextTabItem
                 Height="0"
                 Margin="0"
                 BorderThickness="0"
-                IsSelected="True"
-                Style="{StaticResource BOTATab}" />
+                IsSelected="True" />
             <customcontrol:IconAndTextTabItem
                 x:Name="TabItemThumbnail"
                 Width="48"
                 Height="48"
-                Style="{StaticResource BOTATab}"
                 IsVisibleChanged="TabItemThumbnail_IsVisibleChanged"
                 Visibility="{Binding ElementName=MenuThumbnail, Path=IsChecked, Converter={StaticResource BoolToVisibleConvert}, Mode=TwoWay}">
                 <customcontrol:IconAndTextTabItem.NormalPathIcon>
@@ -105,7 +107,7 @@
                 Width="48"
                 Height="48"
                 Header="大纲"
-                Style="{StaticResource BOTATab}"
+                IsVisibleChanged="TabItemThumbnail_IsVisibleChanged"
                 Visibility="{Binding ElementName=MenuOutLine, Path=IsChecked, Converter={StaticResource BoolToVisibleConvert}, Mode=TwoWay}">
                 <customcontrol:IconAndTextTabItem.NormalPathIcon>
                     <PathGeometry Figures="M3 6H6V5C6 4.44772 6.44772 4 7 4H18C18.5523 4 19 4.44772 19 5V9C19 9.55228 18.5523 10 18 10H7C6.44772 10 6 9.55228 6 9V8H3V14L6 14V13C6 12.4477 6.44772 12 7 12H18C18.5523 12 19 12.4477 19 13V17C19 17.5523 18.5523 18 18 18H7C6.44772 18 6 17.5523 6 17V16H3C1.89543 16 1 15.1046 1 14V6V2H3V6ZM8 6V8H17V6H8ZM8 16V14H17V16H8Z" />
@@ -119,7 +121,7 @@
                 Width="48"
                 Height="48"
                 Header="书签"
-                Style="{StaticResource BOTATab}"
+                IsVisibleChanged="TabItemThumbnail_IsVisibleChanged"
                 Visibility="{Binding ElementName=MenuBookMark, Path=IsChecked, Converter={StaticResource BoolToVisibleConvert}, Mode=TwoWay}">
                 <customcontrol:IconAndTextTabItem.NormalPathIcon>
                     <PathGeometry Figures="M11.3793 12.8851C10.6069 12.1494 9.3931 12.1494 8.62069 12.8851L5 16.3333V3H15V16.3333L11.3793 12.8851ZM15.3103 19.3908L10 14.3333L4.68966 19.3908C4.053 19.9971 3 19.5459 3 18.6667V3C3 1.89543 3.89543 1 5 1H15C16.1046 1 17 1.89543 17 3V18.6667C17 19.5459 15.947 19.9971 15.3103 19.3908ZM7 5H8H12H13V6V7H12H8H7V6V5Z" />
@@ -133,7 +135,7 @@
                 Width="48"
                 Height="48"
                 Header="注释"
-                Style="{StaticResource BOTATab}"
+                IsVisibleChanged="TabItemThumbnail_IsVisibleChanged"
                 Visibility="{Binding ElementName=MenuAnnotation, Path=IsChecked, Converter={StaticResource BoolToVisibleConvert}, Mode=TwoWay}">
                 <customcontrol:IconAndTextTabItem.NormalPathIcon>
                     <PathGeometry Figures="M3.5 1.5C2.39543 1.5 1.5 2.39543 1.5 3.5V16.5C1.5 17.6046 2.39543 18.5 3.5 18.5H16.5C17.6046 18.5 18.5 17.6046 18.5 16.5V3.5C18.5 2.39543 17.6046 1.5 16.5 1.5H3.5ZM8.06104 14H6.3584L9.04932 6.24951H10.9561L13.6523 14H11.9443L11.3696 12.1201H8.63574L8.06104 14ZM10.0537 7.79639H9.95703L9.00635 10.9062H10.999L10.0537 7.79639Z" />
@@ -147,7 +149,7 @@
                 Width="48"
                 Height="48"
                 Header="搜索"
-                Style="{StaticResource BOTATab}"
+                IsVisibleChanged="TabItemThumbnail_IsVisibleChanged"
                 Visibility="{Binding ElementName=MenuSearch, Path=IsChecked, Converter={StaticResource BoolToVisibleConvert}, Mode=TwoWay}">
                 <customcontrol:IconAndTextTabItem.NormalPathIcon>
                     <PathGeometry Figures="M14 8.5C14 11.5376 11.5376 14 8.5 14C5.46243 14 3 11.5376 3 8.5C3 5.46243 5.46243 3 8.5 3C11.5376 3 14 5.46243 14 8.5ZM13.0492 14.4633C11.7874 15.4274 10.2106 16 8.5 16C4.35786 16 1 12.6421 1 8.5C1 4.35786 4.35786 1 8.5 1C12.6421 1 16 4.35786 16 8.5C16 10.2105 15.4274 11.7873 14.4634 13.0491L18.4572 17.0429L17.043 18.4571L13.0492 14.4633Z" />
@@ -161,14 +163,14 @@
                 Width="48"
                 Height="48"
                 Header="域"
-                Style="{StaticResource BOTATab}"
+                IsVisibleChanged="TabItemThumbnail_IsVisibleChanged"
                 Visibility="{Binding ElementName=MenuFrom, Path=IsChecked, Converter={StaticResource BoolToVisibleConvert}, Mode=TwoWay}" />
             <customcontrol:IconAndTextTabItem
                 x:Name="TabItemSign"
                 Width="48"
                 Height="48"
                 Header="签名"
-                Style="{StaticResource BOTATab}"
+                IsVisibleChanged="TabItemThumbnail_IsVisibleChanged"
                 Visibility="{Binding ElementName=MenuSign, Path=IsChecked, Converter={StaticResource BoolToVisibleConvert}, Mode=TwoWay}" />
             <i:Interaction.Triggers>
                 <i:EventTrigger EventName="SelectionChanged">

+ 12 - 22
PDF Office/Views/BOTA/BOTAContent.xaml.cs

@@ -32,28 +32,6 @@ namespace PDF_Master.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;
-            }
-        }
-
         private void TabItemThumbnail_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
         {
             var item = sender as TabItem;
@@ -65,5 +43,17 @@ namespace PDF_Master.Views.BOTA
                 }
             }
         }
+
+        private void IconAndTextTabItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        {
+            var item = sender as TabItem;
+            if (item != null)
+            {
+                ///重复点击选中项时,收起侧边栏
+                (this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA = !(this.DataContext as BOTAContentViewModel).viewContentViewModel.OpenBOTA;
+                item.IsSelected = !item.IsSelected;
+                e.Handled = true;
+            }
+        }
     }
 }

+ 0 - 1
PDF Office/Views/HomePanel/RecentFiles/RecentFilesContent.xaml

@@ -50,7 +50,6 @@
 
             <ContextMenu
                 x:Key="FlyoutMenu"
-                DataContext="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=DataContext}"
                 FontSize="14"
                 Opened="ContextMenu_Opened">
                 <MenuItem

+ 4 - 0
PDF Office/Views/HomePanel/RecentFiles/RecentFilesContent.xaml.cs

@@ -107,6 +107,10 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
                             menuitem.Visibility = Visibility.Collapsed;
                     }
                 }
+
+                //临时绑定文案
+                (contexMenu.Items[0] as MenuItem).Header = ViewModel.T_MenuShow;
+                (contexMenu.Items[1] as MenuItem).Header = ViewModel.T_MenuRemove;
             }
             catch { }
         }

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

@@ -15,6 +15,7 @@
     Height="800"
     MinWidth="540"
     MinHeight="460"
+    PreviewMouseLeftButtonDown="Window_PreviewMouseLeftButtonDown"
     d:DataContext="{d:DesignInstance Type=viewmodels:MainWindowViewModel}"
     prism:ViewModelLocator.AutoWireViewModel="True"
     Activated="Window_Activated"

+ 15 - 0
PDF Office/Views/MainWindow.xaml.cs

@@ -240,5 +240,20 @@ namespace PDF_Master.Views
                 e.Cancel = true;
             }
         }
+
+        private void Window_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        {
+            //通过转移焦点来触发文本框失去焦点事件
+            var uiElement = FocusManager.GetFocusedElement(this);
+            if (uiElement != null)
+            {
+                var textBox = uiElement as TextBox;
+                if (textBox != null)
+                {
+                    GridRoot.Focusable = true;
+                    GridRoot.Focus();
+                }
+            }
+        }
     }
 }

+ 9 - 4
PDF Office/Views/PageEdit/PageEditContent.xaml

@@ -114,6 +114,11 @@
                     Header="替换页面"
                     Visibility="Collapsed" />
                 <MenuItem Command="{Binding DeleteCommand}" Header="{x:Static mainpage:MainPage.PageEdit_MenuDelete}" />
+                <MenuItem
+                    Command="{Binding EnterPageEditCommand}"
+                    Header="Enter PageEdit"
+                    Visibility="{Binding IsBOTAThumb}" />
+                <Separator Style="{StaticResource HorizontalSeparatorStyle}" />
                 <MenuItem Command="{Binding RightRotateCommand}" Header="{x:Static mainpage:MainPage.PageEdit_MenuRotateClockwise}" />
                 <MenuItem Command="{Binding LeftRotateCommand}" Header="{x:Static mainpage:MainPage.PageEdit_MenuRotateCounterclockwise}" />
                 <Separator Style="{StaticResource HorizontalSeparatorStyle}" />
@@ -124,13 +129,13 @@
                 <MenuItem
                     Command="{Binding ShowPageSizeCommand}"
                     Header="{x:Static mainpage:MainPage.PageEdit_MenuShowPageSize}"
-                    Visibility="{Binding Source={x:Reference Name=MenuHidePageSize}, Path=Visibility, Converter={StaticResource UnVisibleConvert}}" />
+                    Visibility="{Binding HidePageSize}" />
                 <MenuItem
                     Name="MenuHidePageSize"
                     Command="{Binding ShowPageSizeCommand}"
-                    Header="隐藏页面大小"
-                    Visibility="{Binding HasShowPageSize}" />
-                <Separator Style="{StaticResource HorizontalSeparatorStyle}" />
+                    Header="Hide PageSize"
+                    Visibility="{Binding ShowedPageSize}" />
+                <Separator Style="{StaticResource HorizontalSeparatorStyle}" Visibility="{Binding IsBOTAThumb, Converter={StaticResource UnVisibleConvert}}" />
                 <MenuItem Command="{Binding PrintCommand}" Header="{x:Static mainpage:MainPage.PageEdit_MenuPrint}" />
             </ContextMenu>
 

+ 8 - 2
PDF Office/Views/PageEdit/PageEditContent.xaml.cs

@@ -98,7 +98,6 @@ namespace PDF_Master.Views.PageEdit
         {
             InitializeComponent();
 
-         
         }
 
         private void PageEditItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
@@ -124,6 +123,13 @@ namespace PDF_Master.Views.PageEdit
 
             //订阅页面刷新事件
             eventor.GetEvent<PageEditNotifyEvent>().Subscribe(OneNotifyEvent, e => e.Unicode == unicode);
+            eventAggregator.GetEvent<CleanSelectAllEvent>().Subscribe(CleanSelectAll, e => e.Unicode == unicode);
+        }
+
+        private void CleanSelectAll(CleanSelectAllArgs obj)
+        {
+            ListPageEdit.SelectedItems.Clear();
+            ListPageEdit.SelectedIndex = viewModel.PDFViewer.CurrentIndex;
         }
 
         private void Timer_Tick(object sender, EventArgs e)
@@ -989,7 +995,7 @@ namespace PDF_Master.Views.PageEdit
         private void Grid_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
         {
             var visual = VisualTreeHelper.HitTest(this, Mouse.GetPosition(this));
-            if ((visual.VisualHit as Grid)!=null)
+            if (visual!=null&&(visual.VisualHit as Grid)!=null)
             {
                 //点击工具栏空白处时 失去焦点
                 ListPageEdit.Focus();