Quellcode durchsuchen

综合-注释链接-UI、添加书签错误

OYXH\oyxh vor 2 Jahren
Ursprung
Commit
38ce350775

+ 41 - 23
PDF Office/ViewModels/BOTA/BookmarkContentViewModel.cs

@@ -209,6 +209,7 @@ namespace PDF_Office.ViewModels.BOTA
                 {
                     Bookmarklist.Remove(bookmark);
                     isAddBookMark = true;
+                    PDFViewer.UndoManager.CanSave = true;
                 }
             }
         }
@@ -311,7 +312,7 @@ namespace PDF_Office.ViewModels.BOTA
                 DialogParameters value = new DialogParameters();
                 value.Add(ParameterNames.Bookmark, mark);
                 value.Add(ParameterNames.Title, "创建一个新的书签");
-                dialogs.ShowDialog(DialogNames.AddBookmarkDialog, value, async e =>
+                dialogs.ShowDialog(DialogNames.AddBookmarkDialog, value, e =>
                 {
                     if (e.Result == ButtonResult.OK && e.Parameters != null)
                     {
@@ -347,30 +348,44 @@ namespace PDF_Office.ViewModels.BOTA
         {
             if (listView.SelectedItem != bookmark)
             {
-                listView.SelectedItem = bookmark;
-                listView.ScrollIntoView(bookmark);
-                ListViewItem myListBoxItem = (ListViewItem)(listView.ItemContainerGenerator.ContainerFromItem(bookmark));
-                TextBox textBox = CommonHelper.FindVisualChild<TextBox>(myListBoxItem);
-                TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(myListBoxItem);
-                textBlock.Visibility = Visibility.Collapsed;
-
-                textBox.Focus();
-                textBox.SelectAll();
+                //listView.SelectedItem = bookmark;
+                //listView.ScrollIntoView(bookmark);
+
+                //ListViewItem myListBoxItem = (ListViewItem)(listView.ItemContainerGenerator.ContainerFromItem(bookmark));
                 //if (myListBoxItem == null)
                 //{
-                //    await Task.Delay(3);
-                //    while (listView.RenderSize.Width <= 0 && listView.RenderSize.Height <= 0)
-                //    {
-                //        await Task.Delay(3);
-                //    }
+                //    listView.UpdateLayout();
+                //    listView.ScrollIntoView(bookmark);
                 //    myListBoxItem = (ListViewItem)(listView.ItemContainerGenerator.ContainerFromItem(bookmark));
-                //    TextBox textBox = CommonHelper.FindVisualChild<TextBox>(myListBoxItem);
-                //    TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(myListBoxItem);
-                //    textBlock.Visibility = Visibility.Collapsed;
-
-                //    textBox.Focus();
-                //    textBox.SelectAll();
                 //}
+
+                listView.ItemContainerGenerator.StatusChanged += (sender, e) =>
+                {
+                    listView.Dispatcher.Invoke(() =>
+                    {
+                        if (listView.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
+                        {
+                            ListViewItem myListBoxItem = (ListViewItem)(listView.ItemContainerGenerator.ContainerFromItem(bookmark));
+                            if (myListBoxItem != null)
+                            {
+                                myListBoxItem.IsSelected = true;
+
+                                if (myListBoxItem.RenderSize.Width < 0 && myListBoxItem.RenderSize.Height < 0)
+                                {
+                                    listView.UpdateLayout();
+                                    myListBoxItem.UpdateLayout();
+                                    listView.ScrollIntoView(bookmark);
+                                }
+                                TextBox textBox = CommonHelper.FindVisualChild<TextBox>(myListBoxItem);
+                                TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(myListBoxItem);
+                                textBlock.Visibility = Visibility.Collapsed;
+
+                                textBox.Focus();
+                                textBox.SelectAll();
+                            }
+                        }
+                    });
+                };
             }
         }
 
@@ -378,6 +393,11 @@ namespace PDF_Office.ViewModels.BOTA
         {
             bool isExistBookmark = false;
             int index = PDFViewer.CurrentIndex;
+            if (PDFViewer.Document == null)
+            {
+                isExistBookmark = true;
+                return isExistBookmark;
+            }
             //检测是否已存在相同数据
             var list = PDFViewer.Document.GetBookmarkList().FindAll(q => q.PageIndex == index);
 
@@ -420,8 +440,6 @@ namespace PDF_Office.ViewModels.BOTA
 
         private ListViewItem selectListViewItem = null;
 
-
-
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);

+ 5 - 7
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Layout.cs

@@ -30,7 +30,6 @@ namespace PDF_Office.ViewModels.Tools
         /// <param name="annotAttribsList">更改注释属性的键值对,更改值后会自动记录undoRedo容器里</param>
         private void AddToPropertyPanel(string viewContent, string toolTag = null, List<AnnotHandlerEventArgs> annots = null, Dictionary<AnnotAttrib, object> annotAttribsList = null, AnnotAttribEvent annotAttribEvent = null)
         {
-
             if (annots != null)
             {
                 propertyPanel.annotlists = annots;
@@ -82,6 +81,7 @@ namespace PDF_Office.ViewModels.Tools
         #endregion 属性面板
 
         #region 阅读页 - 右键菜单
+
         private ContextMenu ViewerContextMenu()
         {
             ContextMenu contextMenu = App.Current.FindResource("ViewerContextMenu") as ContextMenu;
@@ -90,7 +90,6 @@ namespace PDF_Office.ViewModels.Tools
             return contextMenu;
         }
 
-
         private void ViewerContextMenu_Loaded(object sender, RoutedEventArgs e)
         {
             ContextMenu contextMenu = sender as ContextMenu;
@@ -158,8 +157,9 @@ namespace PDF_Office.ViewModels.Tools
                                 break;
 
                             case "AddBookMark":
-                                menuItem1.Click -= AddBookMark_Click;
-                                menuItem1.Click += AddBookMark_Click;
+                                //menuItem1.Click -= AddBookMark_Click;
+                                //menuItem1.Click += AddBookMark_Click;
+                                menuItem1.Command = AddBookMarkCommand;
                                 SetMenuItemVisibility(menuItem1, "DelBookMark", "AddBookMark", isAddBookMark);
                                 break;
 
@@ -516,8 +516,6 @@ namespace PDF_Office.ViewModels.Tools
             return popMenu;
         }
 
-
         #endregion 注释-右键菜单
-
     }
-}
+}

+ 4 - 6
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Properties.cs

@@ -48,19 +48,16 @@ namespace PDF_Office.ViewModels.Tools
             {
                 if (item > 0)
                 {
-
                     isSolid = false;
                     break;
                 }
             }
             return isSolid;
-
         }
 
         //单个属性更改
         public void UpdateAnnotAAttrib(AnnotAttrib annotAttrib, object obj)
         {
-
             if (annotlists != null && annotlists.Count > 1)
             {
                 foreach (var itemevent in AnnotEvents)
@@ -74,7 +71,6 @@ namespace PDF_Office.ViewModels.Tools
                 AnnotEvent?.UpdateAttrib(annotAttrib, obj);
                 AnnotEvent?.UpdateAnnot();
             }
-
         }
 
         //多个属性更改
@@ -101,11 +97,12 @@ namespace PDF_Office.ViewModels.Tools
 
                 AnnotEvent?.UpdateAnnot();
             }
-
         }
 
         //是否为多选
-        public bool IsMultiSelected { get { return (annotlists != null && annotlists.Count > 1); } }
+        public bool IsMultiSelected
+        { get { return (annotlists != null && annotlists.Count > 1); } }
+
         /// <summary>
         /// 更新多个属性,触发到工具栏注释工具,改变工具图标下的颜色值
         /// </summary>
@@ -242,6 +239,7 @@ namespace PDF_Office.ViewModels.Tools
         private SnapshotEditMenuViewModel snapshotEditMenuViewModel = new SnapshotEditMenuViewModel();
         public SnapshotEditMenuViewModel SnapshotEditMenuViewModel { get => snapshotEditMenuViewModel; set => snapshotEditMenuViewModel = value; }
         public DelegateCommand<object> SetAddAnnotationCommand { get; set; }
+        public DelegateCommand AddBookMarkCommand { get; set; }
 
         #endregion 事件
     }

+ 2 - 30
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -58,6 +58,7 @@ namespace PDF_Office.ViewModels.Tools
         {
             MyToolsCommand = new DelegateCommand<CustomIconToggleBtn>(BtnMyTools_Click);
             SetAddAnnotationCommand = new DelegateCommand<object>(AddAnnotation_Click);
+            AddBookMarkCommand = new DelegateCommand(AddBookMark_Click);
             PropertyRegionName = Guid.NewGuid().ToString();
         }
 
@@ -408,34 +409,6 @@ namespace PDF_Office.ViewModels.Tools
             }
         }
 
-        private void BookMark(MenuItem addBookMark, MenuItem delBookMark)
-        {
-            int index = PDFViewer.CurrentIndex;
-            //检测是否已存在相同数据
-            CPDFBookmark list = PDFViewer.Document.GetBookmarkList().FirstOrDefault(q => q.PageIndex == index);
-            if (list != null)
-            {
-                isAddBookMark = false;
-            }
-            else
-            {
-                isAddBookMark = true;
-            }
-
-            if (isAddBookMark)
-            {
-                addBookMark.Visibility = Visibility.Visible;
-                delBookMark.Visibility = Visibility.Collapsed;
-                addBookMark.Click += AddBookMark_Click;
-            }
-            else
-            {
-                delBookMark.Visibility = Visibility.Visible;
-                addBookMark.Visibility = Visibility.Collapsed;
-                delBookMark.Click += DelBookMark_Click;
-            }
-        }
-
         private void DelBookMark_Click(object sender, RoutedEventArgs e)
         {
             if (viewContentViewModel.OpenBOTA == false)
@@ -452,7 +425,6 @@ namespace PDF_Office.ViewModels.Tools
             int index = PDFViewer.CurrentIndex;
             //检测是否已存在相同数据
             CPDFBookmark list = PDFViewer.Document.GetBookmarkList().FirstOrDefault(q => q.PageIndex == index);
-
             if (bookmarkContentViewModel != null && bookmark != null && bOTAContent != null && list != null)
             {
                 bookmarkContentViewModel.DeleteCommand.Execute(list);
@@ -468,7 +440,7 @@ namespace PDF_Office.ViewModels.Tools
             //}
         }
 
-        private async void AddBookMark_Click(object sender, RoutedEventArgs e)
+        private void AddBookMark_Click()
         {
             if (viewContentViewModel.OpenBOTA == false)
             {

+ 2 - 3
PDF Office/Views/Dialog/SettingsDialog.xaml

@@ -311,12 +311,12 @@
                                         Height="30"
                                         ItemsSource="{Binding PageViewList}"
                                         SelectedIndex="{Binding PageViewSelctedIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
-                                        <ComboBoxItem Content="单页" Foreground="{StaticResource color.field.text.act}" />
+                                        <!--<ComboBoxItem Content="单页" Foreground="{StaticResource color.field.text.act}" />
                                         <ComboBoxItem Content="单页连续" Foreground="{StaticResource color.field.text.act}" />
                                         <ComboBoxItem Content="双页" Foreground="{StaticResource color.field.text.act}" />
                                         <ComboBoxItem Content="双页连续" Foreground="{StaticResource color.field.text.act}" />
                                         <ComboBoxItem Content="书本" Foreground="{StaticResource color.field.text.act}" />
-                                        <ComboBoxItem Content="书本连续" Foreground="{StaticResource color.field.text.act}" />
+                                        <ComboBoxItem Content="书本连续" Foreground="{StaticResource color.field.text.act}" />-->
                                     </ComboBox>
                                 </WrapPanel>
                                 <WrapPanel Grid.Row="1" Margin="0,12">
@@ -329,7 +329,6 @@
                                         Height="30"
                                         ItemsSource="{Binding ZoomModeList}"
                                         SelectedIndex="{Binding ZoomModeSelectedIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
-  
                                     </ComboBox>
                                 </WrapPanel>
                             </Grid>

+ 35 - 28
PDF Office/Views/PropertyPanel/AnnotPanel/LinkAnnotProperty.xaml

@@ -35,10 +35,10 @@
         <StackPanel Background="White" Orientation="Vertical">
             <TextBlock
                 Name="AnnotTypeTitle"
-                Margin="0,12,0,12"
+                Margin="16,14,0,16"
                 HorizontalAlignment="Left"
                 FontFamily="Segoe UI"
-                FontSize="18"
+                FontSize="14"
                 FontWeight="Bold"
                 LineHeight="24">
                 Link
@@ -57,7 +57,8 @@
                     GroupName="LinkTab"
                     IsChecked="{Binding BtnLinkPageIsChecked}"
                     Style="{StaticResource PageViewRadioBtn}"
-                    Tag="Page">
+                    Tag="Page"
+                    Visibility="Collapsed">
                     <StackPanel>
                         <Path
                             Margin="8,8,8,8"
@@ -94,7 +95,8 @@
                     GroupName="LinkTab"
                     IsChecked="{Binding BtnLinkWebIsChecked}"
                     Style="{StaticResource PageViewRadioBtn}"
-                    Tag="Web">
+                    Tag="Web"
+                    Visibility="Collapsed">
                     <StackPanel>
                         <Path
                             Margin="8,8,8,8"
@@ -136,7 +138,8 @@
                     GroupName="LinkTab"
                     IsChecked="{Binding BtnLinkMailIsChecked}"
                     Style="{StaticResource PageViewRadioBtn}"
-                    Tag="Mail">
+                    Tag="Mail"
+                    Visibility="Collapsed">
                     <StackPanel>
                         <Path
                             Margin="8,8,8,8"
@@ -163,14 +166,16 @@
             Y1="0"
             Y2="0" />-->
             <Grid MinWidth="260">
-                <StackPanel Name="LinkPagePanel" Visibility="{Binding ElementName=BtnLinkPage, Path=IsChecked, Converter={StaticResource BoolToVisible}, Mode=OneWay}">
+                <!--<StackPanel Name="LinkPagePanel" Visibility="{Binding ElementName=BtnLinkPage, Path=IsChecked, Converter={StaticResource BoolToVisible}, Mode=OneWay}">-->
+                <StackPanel Name="LinkPagePanel">
                     <TextBlock
                         x:Name="TxtPage"
                         Height="20"
-                        Margin="16,12,0,4"
+                        Margin="16,0,0,4"
                         FontFamily="Segoe UI"
                         FontSize="12"
-                        Foreground="#616469"
+                        FontWeight="Bold"
+                        Foreground="{StaticResource color.sys.text.neutral.lv2}"
                         LineHeight="20"
                         Text="Page" />
                     <StackPanel Orientation="Horizontal">
@@ -195,26 +200,28 @@
                             </i:Interaction.Triggers>
                         </CustomControl:TextBoxWithTip>
                     </StackPanel>
-                    <Button
-                        Name="BtnLocation"
-                        Width="228"
-                        Height="32"
-                        Margin="16,30,16,0"
-                        Command="{Binding LocationCommand}"
-                        IsEnabled="{Binding BtnLocationIsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
-                        Style="{StaticResource btn.sec-icon}">
-                        <Button.Content>
-                            <StackPanel Orientation="Horizontal">
-                                <Path
-                                    Name="PathLocation"
-                                    HorizontalAlignment="Left"
-                                    VerticalAlignment="Center"
-                                    Data="M15.064 6.88052L13.5661 6.49468L9.57748 11.6857L10.2156 13.8898C10.3593 14.3863 9.74722 14.7479 9.38174 14.3824L6.59721 11.5979L0.0145727 15.9711L4.38786 9.38851L1.60356 6.60421C1.23807 6.23873 1.59967 5.62665 2.09615 5.77038L4.30107 6.40871L9.49166 2.42039L9.10576 0.92227C8.97879 0.42937 9.58359 0.0840825 9.9435 0.443993L15.5423 6.04277C15.9022 6.40268 15.5569 7.00748 15.064 6.88052Z"
-                                    Fill=" #616469" />
-                                <TextBlock Margin="10,0" Text="定位目标区域" />
-                            </StackPanel>
-                        </Button.Content>
-                    </Button>
+                    <Border CornerRadius="4" Width="228"
+                            Height="32"
+                            Margin="16,30,16,0" BorderBrush="{StaticResource color.field.border.norm}" BorderThickness="1">
+                        <ToggleButton
+                            Name="BtnLocation"
+                            BorderThickness="0" BorderBrush="Transparent"
+                            Command="{Binding LocationCommand}"
+                            IsEnabled="{Binding BtnLocationIsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                            Background="Transparent">
+                            <ToggleButton.Content>
+                                <StackPanel Orientation="Horizontal">
+                                    <Path
+                                        Name="PathLocation"
+                                        HorizontalAlignment="Left"
+                                        VerticalAlignment="Center"
+                                        Data="M15.064 6.88052L13.5661 6.49468L9.57748 11.6857L10.2156 13.8898C10.3593 14.3863 9.74722 14.7479 9.38174 14.3824L6.59721 11.5979L0.0145727 15.9711L4.38786 9.38851L1.60356 6.60421C1.23807 6.23873 1.59967 5.62665 2.09615 5.77038L4.30107 6.40871L9.49166 2.42039L9.10576 0.92227C8.97879 0.42937 9.58359 0.0840825 9.9435 0.443993L15.5423 6.04277C15.9022 6.40268 15.5569 7.00748 15.064 6.88052Z"
+                                        Fill=" #616469" />
+                                    <TextBlock Margin="10,0" Text="定位目标区域" />
+                                </StackPanel>
+                            </ToggleButton.Content>
+                        </ToggleButton>
+                    </Border>
                     <Image
                         Name="ImagePreview"
                         Width="{Binding ImagePreviewWidth}"

+ 15 - 15
PDF Office/Views/TipContent/LinkAnnotTip.xaml

@@ -2,26 +2,24 @@
     x:Class="PDF_Office.Views.TipContent.LinkAnnotTip"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:TipContent="clr-namespace:PDF_Office.ViewModels.TipContent"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:local="clr-namespace:PDF_Office.Views.TipContent"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     xmlns:prism="http://prismlibrary.com/"
-    prism:ViewModelLocator.AutoWireViewModel="True"
-    xmlns:TipContent="clr-namespace:PDF_Office.ViewModels.TipContent"
     d:DataContext="{d:DesignInstance Type=TipContent:LinkAnnotTipViewModel}"
-    d:DesignHeight="450"
-    d:DesignWidth="800"
+    d:DesignHeight="50"
+    d:DesignWidth="760"
+    prism:ViewModelLocator.AutoWireViewModel="True"
     mc:Ignorable="d">
-    <Border
-        Name="LinkAnnotTip1"
-        Width="{Binding ElementName=PDFViewerContent, Path=Width}"
-        Margin="0,0,17,0"
-        HorizontalAlignment="Stretch"
-        VerticalAlignment="Top"
-        Background=" #BDDFFD"
-        Visibility="{Binding LinkAnnotTipVisibility}">
-        <WrapPanel Orientation="Horizontal">
+    <Border Margin="0,0,17,0" Background=" #BDDFFD">
+        <Grid>
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="35" />
+                <ColumnDefinition Width="*" />
+            </Grid.ColumnDefinitions>
             <Grid
+                Grid.Column="0"
                 Width="16"
                 Height="16"
                 Margin="9,4">
@@ -34,11 +32,13 @@
 
             <TextBlock
                 x:Name="DrawTipsText"
+                Grid.Column="1"
                 Margin="0,4,12,4"
                 Padding="4,2,4,2"
                 FontSize="14"
                 Foreground="#252629"
-                Text="Please use the scroll bar, thumbnail tool to locate the target page, click or box the area to select the target range" />
-        </WrapPanel>
+                Text="Please use the scroll bar, thumbnail tool to locate the target page, click or box the area to select the target range"
+                TextWrapping="Wrap" />
+        </Grid>
     </Border>
 </UserControl>

+ 2 - 1
PDF Office/Views/ViewContent.xaml

@@ -301,7 +301,7 @@
                 </ColumnDefinition>
             </Grid.ColumnDefinitions>
 
-            <ContentControl prism:RegionManager.RegionName="{Binding BOTARegionName}" SizeChanged="ContentControl_SizeChanged"/>
+            <ContentControl prism:RegionManager.RegionName="{Binding BOTARegionName}" SizeChanged="ContentControl_SizeChanged" />
             <GridSplitter
                 Name="BOTASplitter"
                 Grid.Column="1"
@@ -371,6 +371,7 @@
             <ContentControl
                 Grid.Column="2"
                 VerticalAlignment="Top"
+                Width="{Binding ElementName=PDFViewerContent, Path=Width}"
                 prism:RegionManager.RegionName="{Binding TipContentRegionName}"
                 Visibility="{Binding TipVisible}" />
             <!--  阅读页顶部侧面提示区域  -->