Quellcode durchsuchen

图章-图章UI,数据结构以及添加方法

zhuyi vor 2 Jahren
Ursprung
Commit
97c8457ad3
29 geänderte Dateien mit 302 neuen und 8 gelöschten Zeilen
  1. 91 0
      PDF Office/Model/AnnotPanel/Stamp.cs
  2. 23 0
      PDF Office/PDF Office.csproj
  3. BIN
      PDF Office/Resources/StampIcons/Accepted.png
  4. BIN
      PDF Office/Resources/StampIcons/Approved.png
  5. BIN
      PDF Office/Resources/StampIcons/Completed.png
  6. BIN
      PDF Office/Resources/StampIcons/Confidential.png
  7. BIN
      PDF Office/Resources/StampIcons/Draft.png
  8. BIN
      PDF Office/Resources/StampIcons/Empty_stamp.png
  9. BIN
      PDF Office/Resources/StampIcons/Final.png
  10. BIN
      PDF Office/Resources/StampIcons/ForComment.png
  11. BIN
      PDF Office/Resources/StampIcons/ForPublicRelease.png
  12. BIN
      PDF Office/Resources/StampIcons/InformationOnly.png
  13. BIN
      PDF Office/Resources/StampIcons/InitialHere.png
  14. BIN
      PDF Office/Resources/StampIcons/NotApproved.png
  15. BIN
      PDF Office/Resources/StampIcons/NotForPublicRelease.png
  16. BIN
      PDF Office/Resources/StampIcons/PreliminaryResults.png
  17. BIN
      PDF Office/Resources/StampIcons/PrivateMark1.png
  18. BIN
      PDF Office/Resources/StampIcons/PrivateMark2.png
  19. BIN
      PDF Office/Resources/StampIcons/PrivateMark3.png
  20. BIN
      PDF Office/Resources/StampIcons/Rejected.png
  21. BIN
      PDF Office/Resources/StampIcons/SignHere.png
  22. BIN
      PDF Office/Resources/StampIcons/Void.png
  23. BIN
      PDF Office/Resources/StampIcons/Witness.png
  24. BIN
      PDF Office/Resources/StampIcons/revised.png
  25. 120 2
      PDF Office/ViewModels/PropertyPanel/AnnotPanel/StampAnnotPropertyViewModel.cs
  26. 1 1
      PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs
  27. 6 1
      PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs
  28. 53 3
      PDF Office/Views/PropertyPanel/AnnotPanel/StampAnnotProperty.xaml
  29. 8 1
      PDF Office/Views/PropertyPanel/AnnotPanel/StampAnnotProperty.xaml.cs

+ 91 - 0
PDF Office/Model/AnnotPanel/Stamp.cs

@@ -0,0 +1,91 @@
+using ComPDFKitViewer.AnnotEvent;
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model.AnnotPanel
+{
+    public class Stamp : BindableBase
+    {
+        private string stampText;
+
+        public string StampText
+        {
+            get { return stampText; }
+            set
+            {
+                SetProperty(ref stampText, value);
+            }
+        }
+
+        private string sourcePath;
+
+        public string SourcePath
+        {
+            get { return sourcePath; }
+            set
+            {
+                SetProperty(ref sourcePath, value);
+            }
+        }
+
+        private int maxWidth;
+
+        public int MaxWidth
+        {
+            get { return maxWidth; }
+            set
+            {
+                SetProperty(ref maxWidth, value);
+            }
+        }
+
+        private int maxHeight;
+
+        public int MaxHeight
+        {
+            get { return maxHeight; }
+            set
+            {
+                SetProperty(ref maxHeight, value);
+            }
+        }
+
+        private StampType type;
+
+        public StampType Type
+        {
+            get { return type; }
+            set
+            {
+                SetProperty(ref type, value);
+            }
+        }
+
+        private string author;
+
+        public string Author
+        {
+            get { return author; }
+            set
+            {
+                SetProperty(ref author, value);
+            }
+        }
+        private double opacity;
+
+        public double Opacity
+        {
+            get { return opacity; }
+            set
+            {
+                SetProperty(ref opacity, value);
+            }
+        }
+
+
+    }
+}

+ 23 - 0
PDF Office/PDF Office.csproj

@@ -239,6 +239,7 @@
     <Compile Include="Helper\SetterAction.cs" />
     <Compile Include="Helper\SettingHelper.cs" />
     <Compile Include="Helper\ToolMethod.cs" />
+    <Compile Include="Model\AnnotPanel\Stamp.cs" />
     <Compile Include="Model\BOTA\OutlineNode.cs" />
     <Compile Include="Model\CloudDrive\CloudDriveItem.cs" />
     <Compile Include="Model\CloudDrive\CloudFiles.cs" />
@@ -1244,6 +1245,28 @@
     <Resource Include="Resources\PageEdit\Staff.png">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Resource>
+    <Resource Include="Resources\StampIcons\Accepted.png" />
+    <Resource Include="Resources\StampIcons\Approved.png" />
+    <Resource Include="Resources\StampIcons\Completed.png" />
+    <Resource Include="Resources\StampIcons\Confidential.png" />
+    <Resource Include="Resources\StampIcons\Draft.png" />
+    <Resource Include="Resources\StampIcons\Empty_stamp.png" />
+    <Resource Include="Resources\StampIcons\Final.png" />
+    <Resource Include="Resources\StampIcons\ForComment.png" />
+    <Resource Include="Resources\StampIcons\ForPublicRelease.png" />
+    <Resource Include="Resources\StampIcons\InformationOnly.png" />
+    <Resource Include="Resources\StampIcons\InitialHere.png" />
+    <Resource Include="Resources\StampIcons\NotApproved.png" />
+    <Resource Include="Resources\StampIcons\NotForPublicRelease.png" />
+    <Resource Include="Resources\StampIcons\PreliminaryResults.png" />
+    <Resource Include="Resources\StampIcons\PrivateMark1.png" />
+    <Resource Include="Resources\StampIcons\PrivateMark2.png" />
+    <Resource Include="Resources\StampIcons\PrivateMark3.png" />
+    <Resource Include="Resources\StampIcons\Rejected.png" />
+    <Resource Include="Resources\StampIcons\revised.png" />
+    <Resource Include="Resources\StampIcons\SignHere.png" />
+    <Resource Include="Resources\StampIcons\Void.png" />
+    <Resource Include="Resources\StampIcons\Witness.png" />
     <Content Include="source\AnalysisWord\Res\_rels\.rels">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>

BIN
PDF Office/Resources/StampIcons/Accepted.png


BIN
PDF Office/Resources/StampIcons/Approved.png


BIN
PDF Office/Resources/StampIcons/Completed.png


BIN
PDF Office/Resources/StampIcons/Confidential.png


BIN
PDF Office/Resources/StampIcons/Draft.png


BIN
PDF Office/Resources/StampIcons/Empty_stamp.png


BIN
PDF Office/Resources/StampIcons/Final.png


BIN
PDF Office/Resources/StampIcons/ForComment.png


BIN
PDF Office/Resources/StampIcons/ForPublicRelease.png


BIN
PDF Office/Resources/StampIcons/InformationOnly.png


BIN
PDF Office/Resources/StampIcons/InitialHere.png


BIN
PDF Office/Resources/StampIcons/NotApproved.png


BIN
PDF Office/Resources/StampIcons/NotForPublicRelease.png


BIN
PDF Office/Resources/StampIcons/PreliminaryResults.png


BIN
PDF Office/Resources/StampIcons/PrivateMark1.png


BIN
PDF Office/Resources/StampIcons/PrivateMark2.png


BIN
PDF Office/Resources/StampIcons/PrivateMark3.png


BIN
PDF Office/Resources/StampIcons/Rejected.png


BIN
PDF Office/Resources/StampIcons/SignHere.png


BIN
PDF Office/Resources/StampIcons/Void.png


BIN
PDF Office/Resources/StampIcons/Witness.png


BIN
PDF Office/Resources/StampIcons/revised.png


+ 120 - 2
PDF Office/ViewModels/PropertyPanel/AnnotPanel/StampAnnotPropertyViewModel.cs

@@ -1,12 +1,130 @@
-using System;
+using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model;
+using PDF_Office.Model.AnnotPanel;
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Media.Imaging;
 
 namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 {
-    internal class StampAnnotPropertyViewModel
+    internal class StampAnnotPropertyViewModel : BindableBase, INavigationAware
     {
+        #region 标准图章相关默认配置(如果需要修改,要留意按顺序一一对应的)
+
+        List<string> Path = new List<string>
+        {
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/Approved.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/NotApproved.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/Completed.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/Final.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/Draft.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/Confidential.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/ForPublicRelease.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/NotForPublicRelease.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/ForComment.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/Void.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/PreliminaryResults.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/InformationOnly.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/Accepted.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/Rejected.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/Witness.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/InitialHere.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/SignHere.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/revised.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/PrivateMark1.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/PrivateMark2.png",
+            "pack://application:,,,/PDF Office;component/Resources/StampIcons/PrivateMark3.png",
+        };
+        List<string> StampText = new List<string>
+        {
+            "Approved","NotApproved","Completed","Final","Draft","Confidential","ForPublicRelease","NotForPublicRelease",
+            "ForComment","Void","PreliminaryResults","InformationOnly","Accepted","Rejected","Witness","InitialHere","SignHere",
+            "revised","PrivateMark#1","PrivateMark#2","PrivateMark#3"
+        };
+        List<int> MaxWidth = new List<int>
+        {
+            218,292,234,130,150,280,386,461,282,121,405,366,30,30,133,133,133,173,30,30,30
+        };
+        List<int> MaxHeight = new List<int>
+        {
+           66,66,66,66,66,66,66,66,66,66,66,66,30,30,39,39,39,66,30,30,30
+        };
+
+        #endregion
+
+        private CPDFViewer PDFViewer;
+        public ObservableCollection<Stamp> StandardStampList { get; set; }
+        public ObservableCollection<Stamp> DynamicStampList { get; set; }
+        public ObservableCollection<Stamp> CustomStampList { get; set; }
+
+        public StampAnnotPropertyViewModel()
+        {
+            StandardStampList = new ObservableCollection<Stamp>();
+            DynamicStampList = new ObservableCollection<Stamp>();
+            CustomStampList = new ObservableCollection<Stamp>();
+            InitStandardStamp();
+        }
+
+        /// <summary>
+        /// 初始化标准图章相关内容
+        /// </summary>
+        private void InitStandardStamp()
+        {
+            for (int i = 0; i < Path.Count; i++)
+            {
+                Stamp standardStamp = new Stamp();
+                standardStamp.Author = "";
+                standardStamp.Opacity = 1;
+                standardStamp.SourcePath = Path[i];
+                standardStamp.StampText = StampText[i];
+                standardStamp.MaxWidth = MaxWidth[i];
+                standardStamp.MaxHeight = MaxHeight[i];
+                standardStamp.Type = StampType.STANDARD_STAMP;
+                StandardStampList.Add(standardStamp);
+            }
+        }
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+            return;
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            if (PDFViewer == null)
+            {
+                return;
+            }
+        }
+        public void SetStandardStamp(Stamp stamp)
+        {
+            StampAnnotArgs Args = new StampAnnotArgs();
+            Args.StampText = stamp.StampText;
+            Args.Author = stamp.Author;
+            Args.Opacity = stamp.Opacity;
+            Args.MaxWidth = stamp.MaxWidth;
+            Args.MaxHeight = stamp.MaxHeight;
+            BitmapImage image = new BitmapImage(new Uri(stamp.SourcePath));
+            Args.ImageArray = new byte[image.PixelWidth * image.PixelHeight * 4];
+            image.CopyPixels(Args.ImageArray, image.PixelWidth * 4, 0);
+            Args.ImageHeight = image.PixelHeight;
+            Args.ImageWidth = image.PixelWidth;
+            Args.Type = stamp.Type;
+            PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
+            PDFViewer.SetToolParam(Args);
+        }
     }
 }

+ 1 - 1
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -561,7 +561,7 @@ namespace PDF_Office.ViewModels.Tools
             stampAnnotArgs.Type = StampType.STANDARD_STAMP;
 
             annotAttribsList[AnnotAttrib.Transparency] = stampAnnotArgs.Opacity;
-
+             
             AddToPropertyPanel(stampAnnotArgs, null, "StampAnnotProperty", annotAttribsList);
             return stampAnnotArgs;
         }

+ 6 - 1
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -115,7 +115,12 @@ namespace PDF_Office.ViewModels.Tools
                     annotArgs.Author = Settings.Default.AppProperties.Description.Author;
                     PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
                     PDFViewer.SetToolParam(annotArgs);
-                   
+                }
+                else
+                {
+                    PDFViewer.SetMouseMode(MouseModes.PanTool);
+                    viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
+                    ShowPropertyPanel(false);
                 }
                 ShowPropertyPanel();
 

+ 53 - 3
PDF Office/Views/PropertyPanel/AnnotPanel/StampAnnotProperty.xaml

@@ -3,10 +3,60 @@
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-             xmlns:local="clr-namespace:PDF_Office.Views.PropertyPanel.AnnotPanel"
+             xmlns:local="clr-namespace:PDF_Office.Views.PropertyPanel.AnnotPanel" 
+             xmlns:annotpanel="clr-namespace:PDF_Office.ViewModels.PropertyPanel.AnnotPanel"
+             xmlns:dd="clr-namespace:PDFSettings;assembly=PDFSettings"
+             d:DataContext="{d:DesignInstance Type=annotpanel:StampAnnotPropertyViewModel}"
              mc:Ignorable="d" 
-             d:DesignHeight="450" d:DesignWidth="800">
+             >
     <Grid>
-            
+        <Grid.RowDefinitions>
+            <RowDefinition Height="40"/>
+            <RowDefinition Height="*"/>
+        </Grid.RowDefinitions>
+        <TextBlock x:Name="AnnoteTypeTitle" Text="Stamp" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0 8 0 0" FontFamily="Segoe UI Semibold" FontWeight="SemiBold" FontSize="18"/>
+        <TabControl Grid.Row="1" Name="StampTabControl"  HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" Style="{StaticResource TabControlWithUnderLineStyle}">
+            <TabItem x:Name="TabStandard"
+                        Header="Standard"
+                        FontFamily="Segoe UI" Foreground="#FF666666"
+                        HorizontalContentAlignment="Center"
+                        FontSize="16"
+                        Height="40"
+                        Width="88"
+                        IsSelected="True">
+                <ListBox ItemsSource="{Binding StandardStampList}" SelectionMode="Single" Width="256" Height="auto" VerticalAlignment="Top"  BorderThickness="0" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
+                    <ListBox.ItemTemplate>
+                        <DataTemplate >
+                            <ListBoxItem>
+                            <Image Source="{Binding SourcePath}" Stretch="Uniform" Height="48"/>
+                            </ListBoxItem>
+                        </DataTemplate>
+                    </ListBox.ItemTemplate>
+                    <ListBox.ItemContainerStyle>
+                        <Style TargetType="ListBoxItem">
+                            <Setter Property="Height" Value="64"/>
+                            <Setter Property="Padding" Value="12 8 12 8"/>
+                            <Setter Property="HorizontalContentAlignment" Value="Center"/>
+                            <EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListBoxItem_PreviewMouseLeftButtonDown"/>
+                        </Style>
+                    </ListBox.ItemContainerStyle>
+                </ListBox>
+                
+            </TabItem>
+            <TabItem  x:Name="TabDydamic"
+                        Header="Dynamic"
+                        FontFamily="Segoe UI" Foreground="#FF666666"
+                        HorizontalContentAlignment="Center"
+                        FontSize="16"
+                        Width="86">
+            </TabItem>
+            <TabItem  x:Name="TabCustom"
+                        Header="Custom"
+                        FontFamily="Segoe UI" Foreground="#FF666666"
+                        FontSize="16" 
+                        HorizontalContentAlignment="Center"
+                        Width="76">
+            </TabItem>
+        </TabControl>
     </Grid>
 </UserControl>

+ 8 - 1
PDF Office/Views/PropertyPanel/AnnotPanel/StampAnnotProperty.xaml.cs

@@ -1,4 +1,6 @@
-using System;
+using PDF_Office.Model.AnnotPanel;
+using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -24,5 +26,10 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
         {
             InitializeComponent();
         }
+
+        private void ListBoxItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        {
+            (DataContext as StampAnnotPropertyViewModel).SetStandardStamp((sender as ListBoxItem).DataContext as Stamp);
+        }
     }
 }