Prechádzať zdrojové kódy

标记密文-补充标记密文基础逻辑

ZhouJieSheng 2 rokov pred
rodič
commit
d8b1417f12

+ 1 - 0
PDF Office/Styles/TabControlStyle.xaml

@@ -226,6 +226,7 @@
         </Setter>
     </Style>
 
+    <!--  Design Token TabItem ControlTemplate  for Forms Property Title  -->
     <ControlTemplate x:Key="Segmented" TargetType="{x:Type TabItem}">
         <Grid x:Name="templateRoot" SnapsToDevicePixels="True">
             <Border

+ 33 - 4
PDF Office/ViewModels/EditTools/Redaction/RedactionContentViewModel.cs

@@ -1,4 +1,5 @@
-using ComPDFKitViewer.PdfViewer;
+using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer.PdfViewer;
 using PDF_Office.EventAggregators;
 using PDF_Office.Model;
 using Prism.Commands;
@@ -9,6 +10,7 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Windows;
+using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.EditTools.Redaction
 {
@@ -41,6 +43,9 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
 
         public void CloseEditTool()
         {
+            PDFViewer.SetMouseMode(MouseModes.Default);
+            redactionRegion.Regions[RegionNames.ViwerRegionName].Remove(PDFViewer);
+            redactionRegion.Regions[RedactionDocumentRegionName].Remove(PDFViewer);
             this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = this.Unicode, Status = EnumCloseMode.StatusCancel });
         }
 
@@ -56,9 +61,33 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
-            NavigationParameters param = new NavigationParameters();
-            param.Add(ParameterNames.PDFViewer, PDFViewer);
-            redactionRegion.RequestNavigate(RedactionDocumentRegionName, RedactionDocumentName, param);
+            if(!redactionRegion.Regions[RedactionDocumentRegionName].Views.Contains(PDFViewer))
+            {
+                RedactionAnnotArgs redactionArgs = new RedactionAnnotArgs();
+                AnnotHandlerEventArgs annotArgs = null;
+                redactionArgs.LineColor = ((SolidColorBrush)Brushes.Black).Color;
+                redactionArgs.BgColor = ((SolidColorBrush)Brushes.Black).Color;
+                redactionArgs.FontColor = ((SolidColorBrush)Brushes.Red).Color;
+                //redactionArgs.LineColor = Settings.Default.RedactionsSettings.LineColor;
+                //redactionArgs.BgColor = Settings.Default.RedactionsSettings.BgColor;
+                //redactionArgs.FontColor = Settings.Default.RedactionsSettings.FontColor;
+                //redactionArgs.Align = Settings.Default.RedactionsSettings.Align;
+                //redactionArgs.FontSize = Settings.Default.RedactionsSettings.FontSize;
+                //redactionArgs.Content = Settings.Default.RedactionsSettings.Content;
+                //if (!Settings.Default.RedactionsSettings.isUseText)
+                //{
+                //    redactionArgs.Content = "";
+                //}
+                annotArgs = redactionArgs;
+                if (annotArgs != null)
+                {
+                    //annotArgs.Author = Settings.Default.AppProperties.Description.Author;
+                    PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
+                    PDFViewer.SetToolParam(annotArgs);
+                }
+                redactionRegion.AddToRegion(RedactionDocumentRegionName, PDFViewer);
+            }
+  
         }
     }
 }

+ 6 - 0
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -1039,6 +1039,12 @@ namespace PDF_Office.ViewModels
                 PDFViewer.ReloadDocument();
             }
 
+            //如果是其他工具共用一个PDFview,退出工具模式后,需要重新添加到Region,否则不会显示
+            if (!region.Regions[ViwerRegionName].Views.Contains(PDFViewer))
+            {
+                region.AddToRegion(ViwerRegionName, PDFViewer);
+            }
+
             CurrentBar = "TabItemTool";
             EnterSelectedBar(CurrentBar);
         }

+ 53 - 27
PDF Office/Views/EditTools/Redaction/RedactionContent.xaml

@@ -1,46 +1,72 @@
-<UserControl x:Class="PDF_Office.Views.EditTools.Redaction.RedactionContent"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:prism="http://prismlibrary.com/"             
-             prism:ViewModelLocator.AutoWireViewModel="True"
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:redaction="clr-namespace:PDF_Office.ViewModels.EditTools.Redaction" d:DataContext="{d:DesignInstance Type=redaction:RedactionContentViewModel}"
-             mc:Ignorable =" d"
-             d:DesignHeight="760"
-             d:DesignWidth="1280">
+<UserControl
+    x:Class="PDF_Office.Views.EditTools.Redaction.RedactionContent"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:prism="http://prismlibrary.com/"
+    xmlns:redaction="clr-namespace:PDF_Office.ViewModels.EditTools.Redaction"
+    d:DataContext="{d:DesignInstance Type=redaction:RedactionContentViewModel}"
+    d:DesignHeight="760"        
+    d:DesignWidth="1280"
+    prism:ViewModelLocator.AutoWireViewModel="True"
+    mc:Ignorable=" d">
     <Grid Background="#FFFFFF">
         <Grid.RowDefinitions>
-            <RowDefinition Height="40"></RowDefinition>
-            <RowDefinition></RowDefinition>
+            <RowDefinition Height="40" />
+            <RowDefinition />
         </Grid.RowDefinitions>
         <Grid>
             <WrapPanel HorizontalAlignment="Center">
-                <Button Style="{StaticResource InsideBarBtnStyle }">
-                    <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
+                <Button Style="{StaticResource InsideBarBtnStyle}">
+                    <StackPanel Margin="12,0,12,0" Orientation="Horizontal">
                         <StackPanel Margin="0,0,8,0">
-                            <Border Height="30" Width="30" Background="LightSeaGreen" ></Border>
-                        </StackPanel >
-                        <TextBlock Text="文本和图像标记密文" VerticalAlignment="Center"></TextBlock>
+                            <Border
+                                Width="30"
+                                Height="30"
+                                Background="LightSeaGreen" />
+                        </StackPanel>
+                        <TextBlock VerticalAlignment="Center" Text="文本和图像标记密文" />
                     </StackPanel>
                 </Button>
-                <Button Style="{StaticResource InsideBarBtnStyle }">
-                    <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
+                <Button Style="{StaticResource InsideBarBtnStyle}">
+                    <StackPanel Margin="12,0,12,0" Orientation="Horizontal">
                         <StackPanel Margin="0,0,8,0">
-                            <Border Height="30" Width="30" Background="LightSeaGreen" ></Border>
-                        </StackPanel >
-                        <TextBlock Text="页面标记密文" VerticalAlignment="Center"></TextBlock>
+                            <Border
+                                Width="30"
+                                Height="30"
+                                Background="LightSeaGreen" />
+                        </StackPanel>
+                        <TextBlock VerticalAlignment="Center" Text="页面标记密文" />
                     </StackPanel>
                 </Button>
             </WrapPanel>
             <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
-                <Button Content="应用密文" Height="24" Padding="10,2,10,2"></Button>
-                <Button Content="擦除密文" Height="24"  Margin="8,0,8,0" Padding="10,2,10,2"></Button>
-                <Button Content="关闭" Height="24" Padding="10,2,10,2"  Margin="0,0,16,0"  Command="{Binding CloseEditToolCommand}"></Button>
+                <Button
+                    Height="24"
+                    Margin="8,0"
+                    Padding="8,0"
+                    Content="应用密文"
+                    Style="{StaticResource Btn.cta}" />
+                <Button
+                    Height="24"
+                    Margin="8,0"
+                    Padding="8,0"
+                    Content="擦除密文"
+                    Style="{StaticResource Btn.cta}" />
+                <Button
+                    Width="auto"
+                    Height="24"
+                    Margin="8,0,16,0"
+                    Padding="8,0"
+                    Command="{Binding CloseEditToolCommand}"
+                    Content="关闭"
+                    Style="{StaticResource btn.sec}" />
             </StackPanel>
         </Grid>
         <Grid Grid.Row="1" Background="#E7E9EC">
-            <Grid Margin="60,12,0,0">
-                <ContentControl prism:RegionManager.RegionName="{Binding RedactionDocumentRegionName}" Visibility ="Visible"></ContentControl>
+            <Grid>
+                <ContentControl prism:RegionManager.RegionName="{Binding RedactionDocumentRegionName}" Visibility="Visible" />
             </Grid>
         </Grid>
     </Grid>