Pārlūkot izejas kodu

图章-自定义图章的添加与缓存

zhuyi 2 gadi atpakaļ
vecāks
revīzija
90c7ff8e4b

+ 2 - 2
PDF Office/PDF Office.csproj

@@ -45,11 +45,11 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>.\ComOCRKit.Desk.dll</HintPath>
     </Reference>
-    <Reference Include="ComPDFKit.Desk, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
+    <Reference Include="ComPDFKit.Desk, Version=1.7.0.0, Culture=neutral, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>.\ComPDFKit.Desk.dll</HintPath>
     </Reference>
-    <Reference Include="ComPDFKit.Viewer, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
+    <Reference Include="ComPDFKit.Viewer, Version=1.7.0.0, Culture=neutral, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>.\ComPDFKit.Viewer.dll</HintPath>
     </Reference>

+ 1 - 1
PDF Office/ViewModels/BOTA/OutLineControlViewModel.cs

@@ -89,7 +89,7 @@ namespace PDF_Office.ViewModels.BOTA
                     Outlinelist.Add(dto);
                 }
             }
-            PDFViewer.GetSelectedTextDict();
+            PDFViewer.GetCreateOutLineInfo();
         }
 
         public void Updata(bool IsMoveData)

+ 107 - 8
PDF Office/ViewModels/PropertyPanel/AnnotPanel/CustomCreateDialogViewModel.cs

@@ -1,16 +1,19 @@
 using ComPDFKit.PDFAnnotation;
 using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
+using Microsoft.Win32;
 using PDF_Office.Model;
 using Prism.Commands;
 using Prism.Mvvm;
 using Prism.Services.Dialogs;
 using System;
 using System.Collections.Generic;
+using System.Drawing;
 using System.IO;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
 using System.Windows.Media;
@@ -28,16 +31,26 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         public DelegateCommand CreateCommnad { get; set; }
 
         public DelegateCommand UpDataDynamicCommnad { get; set; }
+        public DelegateCommand OpenImageCommnad { get; set; }
 
         public DelegateCommand<object> KeyDown { get; set; }
 
-        private BitmapSource imageSource;
-        public BitmapSource ImageSource
+        private BitmapSource textImageSource;
+        public BitmapSource TextImageSource
         {
-            get { return imageSource; }
+            get { return textImageSource; }
             set
             {
-                SetProperty(ref imageSource, value);
+                SetProperty(ref textImageSource, value);
+            }
+        }
+        private BitmapSource imagePreviewSource;
+        public BitmapSource ImagePreviewSource
+        {
+            get { return imagePreviewSource; }
+            set
+            {
+                SetProperty(ref imagePreviewSource, value);
             }
         }
         private string stampText = "Stamp Text";
@@ -73,6 +86,18 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
+        private Visibility showImageButton = Visibility.Visible;
+
+        public Visibility ShowImageButton
+        {
+            get { return showImageButton; }
+            set
+            {
+                SetProperty(ref showImageButton, value);
+            }
+        }
+
+
         private C_TEXTSTAMP_SHAPE shape = C_TEXTSTAMP_SHAPE.TEXTSTAMP_RECT;
 
         public C_TEXTSTAMP_SHAPE Shape
@@ -155,6 +180,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             CreateCommnad = new DelegateCommand(Create);
             UpDataDynamicCommnad = new DelegateCommand(UpDataStamp);
             KeyDown = new DelegateCommand<object>(PreviewKeyDown);
+            OpenImageCommnad = new DelegateCommand(OpenImage);
         }
         private void Cancel()
         {
@@ -163,7 +189,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
         private void Create()
         {
-            SaveImageToPath();
+            if (Type == StampType.TEXT_STAMP)
+            {
+                SaveImageToPath();
+            }
             DialogParameters valuePairs = new DialogParameters();
             valuePairs.Add(ParameterNames.DataModel, this);
             RequestClose.Invoke(new DialogResult(ButtonResult.OK, valuePairs));
@@ -176,7 +205,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             if (!string.IsNullOrEmpty(path))
             {
                 BitmapEncoder encoder = new PngBitmapEncoder();
-                encoder.Frames.Add(BitmapFrame.Create(ImageSource));
+                encoder.Frames.Add(BitmapFrame.Create(TextImageSource));
                 path = System.IO.Path.Combine(path, name);
                 using (FileStream stream = new FileStream(path, FileMode.Create))
                 {
@@ -235,7 +264,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 PixelFormat fmt = PixelFormats.Bgra32;
                 BitmapSource bps = BitmapSource.Create(width, height, 96, 96, fmt, null, bytes, (width * fmt.BitsPerPixel + 7) / 8);
-                ImageSource = bps;
+                TextImageSource = bps;
                 StampTextDate = date;
                 StampWidth = stampWidth;
                 StampHeight = stampHeight;
@@ -243,7 +272,77 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
             else
             {
-                ImageSource = null;
+                TextImageSource = null;
+            }
+        }
+
+        public void OpenImage()
+        {
+            OpenFileDialog openFile = new OpenFileDialog();
+            openFile.Filter = "All Image Files(*.bmp;*.gif;*.jpeg;*.jpg;*.png;*.tiff)|*.bmp;*.gif;*.jpeg;*.jpg;*.png;*.tiff|(*.bmp)|*.bmp|" +
+                "(*.gif)|*.gif|" +
+                "(*.jpeg)|*.jpeg|" +
+                "(*.jpg)|*.jpg|" +
+                "(*.png)|*.png|" +
+                "(*.tiff)|*.tiff";
+            if (openFile.ShowDialog() == false)
+            {
+                return;
+            }
+            string path = App.CachePath.CustomStampPath;
+            string name = Guid.NewGuid().ToString();
+            if (!string.IsNullOrEmpty(path))
+            {
+                BitmapImage image = new BitmapImage(new Uri(openFile.FileName));
+                double scale = Math.Min((double)600 / image.PixelWidth, (double)600 / image.PixelHeight);
+                scale = Math.Min(scale, 1);
+                string ext = Path.GetExtension(openFile.FileName);
+                if (ext.ToUpper() == ".PNG")
+                {
+                    BitmapEncoder encoder = new PngBitmapEncoder();
+                    var targetBitmap = new TransformedBitmap(image, new ScaleTransform(scale, scale));
+                    encoder.Frames.Add(BitmapFrame.Create(targetBitmap));
+                    path = System.IO.Path.Combine(path, name);
+                    using (FileStream stream = new FileStream(path, FileMode.Create))
+                    {
+                        encoder.Save(stream);
+                    }
+                    if (!string.IsNullOrEmpty(SaveToPath))
+                    {
+                        App.CachePath.AddToDeleteFiles(SaveToPath);
+                    }
+                    SaveToPath = path;
+                    ImagePreviewSource = targetBitmap;
+                    StampWidth = targetBitmap.PixelWidth;
+                    StampHeight = targetBitmap.PixelHeight;
+                    Type = StampType.IMAGE_STAMP;
+                    ShowImageButton = Visibility.Collapsed;
+                }
+                else
+                {
+                    BitmapEncoder encoder = new JpegBitmapEncoder();
+                    TransformedBitmap targetBitmap = new TransformedBitmap(image, new ScaleTransform(scale, scale));
+                    encoder.Frames.Add(BitmapFrame.Create(targetBitmap));
+                    path = System.IO.Path.Combine(path, name);
+                    using (FileStream stream = new FileStream(path, FileMode.Create))
+                    {
+                        encoder.Save(stream);
+                    }
+                    if (!string.IsNullOrEmpty(SaveToPath))
+                    {
+                        App.CachePath.AddToDeleteFiles(SaveToPath);
+                    }
+                    SaveToPath = path;
+                    ImagePreviewSource = targetBitmap;
+                    StampWidth = targetBitmap.PixelWidth;
+                    StampHeight = targetBitmap.PixelHeight;
+                    Type = StampType.IMAGE_STAMP;
+                    ShowImageButton = Visibility.Collapsed;
+                }
+            }
+            else
+            {
+                SaveToPath = "";
             }
         }
         public void OnDialogOpened(IDialogParameters parameters)

+ 96 - 30
PDF Office/ViewModels/PropertyPanel/AnnotPanel/StampAnnotPropertyViewModel.cs

@@ -163,24 +163,32 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             ShowDialogCommand = new DelegateCommand(ShowDialog);
             InitStandardStamp();
             UpDataDynamicStampList();
+            LoadSettings();
         }
 
+        /// <summary>
+        /// 加载缓存的自定义图章
+        /// </summary>
         private void LoadSettings()
         {
             PDFSettings.CustomStampList stamps = Settings.Default.CustomStampList;
-            for (int i = 0; i < stamps.Count; i++)
+            if (stamps != null)
             {
-                Stamp customStamp = new Stamp();
-                customStamp.Opacity = 1;
-                customStamp.Author = stamps[i].Author;
-                customStamp.StampText = stamps[i].StampText;
-                customStamp.StampTextDate = stamps[i].StampTextDate;
-                customStamp.MaxWidth = stamps[i].ImageWidth;
-                customStamp.MaxHeight = stamps[i].ImageHeight;
-                customStamp.SourcePath = stamps[i].SourcePath;
-                customStamp.Type = stamps[i].Type;
-                customStamp.TextColor = stamps[i].TextColor;
-                CustomStampList.Add(customStamp);
+                for (int i = 0; i < stamps.Count; i++)
+                {
+                    Stamp customStamp = new Stamp();
+                    customStamp.Opacity = 1;
+                    customStamp.Author = stamps[i].Author;
+                    customStamp.StampText = stamps[i].StampText;
+                    customStamp.StampTextDate = stamps[i].StampTextDate;
+                    customStamp.MaxWidth = stamps[i].ImageWidth;
+                    customStamp.MaxHeight = stamps[i].ImageHeight;
+                    customStamp.SourcePath = stamps[i].SourcePath;
+                    customStamp.Type = stamps[i].Type;
+                    customStamp.TextSharp = stamps[i].TextSharp;
+                    customStamp.TextColor = stamps[i].TextColor;
+                    CustomStampList.Add(customStamp);
+                }
             }
         }
 
@@ -231,8 +239,17 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             Args.StampText = stamp.StampText;
             Args.Author = stamp.Author;
             Args.Opacity = stamp.Opacity;
-            Args.MaxWidth = stamp.MaxWidth;
-            Args.MaxHeight = stamp.MaxHeight;
+            if (stamp.Type == StampType.IMAGE_STAMP)
+            {
+
+                Args.ImageWidth = stamp.MaxWidth;
+                Args.ImageHeight = stamp.MaxHeight;
+            }
+            else
+            {
+                Args.MaxWidth = stamp.MaxWidth;
+                Args.MaxHeight = stamp.MaxHeight;
+            }
             Args.StampTextDate = stamp.StampTextDate;
             Args.TextColor = stamp.TextColor;
             Args.TextSharp = stamp.TextSharp;
@@ -331,6 +348,9 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
+        /// <summary>
+        /// 导出图章
+        /// </summary>
         public void SaveToPath(string FileType, Stamp Item)
         {
             SaveFileDialog saveFileDialog = new SaveFileDialog();
@@ -351,25 +371,49 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 encoder = new PngBitmapEncoder();
             }
             encoder.Frames.Add(BitmapFrame.Create(new Uri(Item.SourcePath)));
-
-            if (FileType.ToUpper() != "PDF")
+            string path = saveFileDialog.FileName;
+            switch (FileType.ToUpper())
             {
-                string path = saveFileDialog.FileName;
-                using (FileStream stream = new FileStream(path, FileMode.Create))
-                {
-                    encoder.Save(stream);
-                }
-
-                CPDFDocument doc = CPDFDocument.CreateDocument();
-                bool tt = doc.InsertPage(0, 300, 500, path);
-                doc.WriteToFilePath("C:\\Users\\93131\\Desktop\\test\\cache\\fafdas.pdf");
-                doc.Release();
-                System.Diagnostics.Process.Start("explorer", "/select,\"" + path + "\"");
+                case "PDF":
+                    CPDFDocument newDoc = CPDFDocument.CreateDocument();
+                    BitmapFrame frame = BitmapFrame.Create(new Uri(Item.SourcePath));
+                    byte[] imageData = new byte[frame.PixelWidth * frame.PixelHeight * 4];
+                    frame.CopyPixels(imageData, frame.PixelWidth * 4, 0);
+                    newDoc.InsertPage(0, frame.PixelWidth, frame.PixelHeight, imageData, CPDFDocumentImageMode.CPDFDocumentImageModeScaleToFill);
+                    newDoc.WriteToFilePath(path);
+                    break;
+                case "PNG":
+                    using (FileStream stream = new FileStream(path, FileMode.Create))
+                    {
+                        encoder.Save(stream);
+                    }
+                    break;
+                default:
+                    break;
             }
-            else
-            {
+            System.Diagnostics.Process.Start("explorer", "/select,\"" + path + "\"");
+        }
+
+        public void DeleteStamp(Stamp stamp)
+        {
+            int index = CustomStampList.IndexOf(stamp);
+            App.CachePath.AddToDeleteFiles(stamp.SourcePath);
+            CustomStampList.RemoveAt(index);
+            PDFSettings.CustomStampList stamps = Settings.Default.CustomStampList;
+            stamps.RemoveAt(index);
+            Settings.Default.Save();
+        }
 
+        public void DeleteAll()
+        {
+            foreach (Stamp item in CustomStampList)
+            {
+                App.CachePath.AddToDeleteFiles(item.SourcePath);
             }
+            CustomStampList.Clear();
+            PDFSettings.CustomStampList stamps = Settings.Default.CustomStampList;
+            stamps.Clear();
+            Settings.Default.Save();
         }
         private void ShowDialog()
         {
@@ -434,6 +478,9 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
+        /// <summary>
+        /// 创建自定义图章,并且保存到APP缓存
+        /// </summary>
         private void CreateCustomStamp(CustomCreateDialogViewModel viewModel)
         {
             Stamp stamp = new Stamp();
@@ -441,13 +488,32 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             stamp.Opacity = 1;
             stamp.SourcePath = viewModel.SaveToPath;
             stamp.StampText = viewModel.StampText;
-            stamp.MaxWidth = (int)DpiHelpers.GetDpiUnrelatedNum(viewModel.StampWidth/ 72D * DpiHelpers.Dpi);
+            stamp.MaxWidth = (int)DpiHelpers.GetDpiUnrelatedNum(viewModel.StampWidth / 72D * DpiHelpers.Dpi);
             stamp.MaxHeight = (int)DpiHelpers.GetDpiUnrelatedNum(viewModel.StampHeight / 72D * DpiHelpers.Dpi);
             stamp.StampTextDate = viewModel.StampTextDate;
             stamp.Type = viewModel.Type;
             stamp.TextColor = (TextStampColor)(int)viewModel.Color;
             stamp.TextSharp = (TextStampSharp)(int)viewModel.Shape;
             CustomStampList.Add(stamp);
+
+            PDFSettings.CustomStampList stamps = Settings.Default.CustomStampList;
+            if (stamps == null)
+            {
+                stamps = Settings.Default.CustomStampList = new PDFSettings.CustomStampList();
+            }
+            PDFSettings.StampAnnote annote = new PDFSettings.StampAnnote();
+            Stamp customStamp = new Stamp();
+            annote.Author = stamp.Author;
+            annote.StampText = stamp.StampText;
+            annote.StampTextDate = stamp.StampTextDate;
+            annote.ImageWidth = stamp.MaxWidth;
+            annote.ImageHeight = stamp.MaxHeight;
+            annote.SourcePath = stamp.SourcePath;
+            annote.Type = stamp.Type;
+            annote.TextSharp = stamp.TextSharp;
+            annote.TextColor = stamp.TextColor;
+            stamps.Add(annote);
+            Settings.Default.Save();
         }
     }
 }

+ 33 - 6
PDF Office/Views/PropertyPanel/AnnotPanel/CustomCreateDialog.xaml

@@ -1,16 +1,21 @@
 <UserControl x:Class="PDF_Office.Views.PropertyPanel.AnnotPanel.CustomCreateDialog"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:customcontrol="clr-namespace:PDF_Office.CustomControl"
              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:cus="clr-namespace:PDF_Office.CustomControl" xmlns:annotpanel="clr-namespace:PDF_Office.ViewModels.PropertyPanel.AnnotPanel" xmlns:i="http://schemas.microsoft.com/xaml/behaviors" d:DataContext="{d:DesignInstance Type=annotpanel:CustomCreateDialogViewModel}"
+             xmlns:local="clr-namespace:PDF_Office.Views.PropertyPanel.AnnotPanel" xmlns:cus="clr-namespace:PDF_Office.CustomControl" xmlns:annotpanel="clr-namespace:PDF_Office.ViewModels.PropertyPanel.AnnotPanel" xmlns:i="http://schemas.microsoft.com/xaml/behaviors" xmlns:dataconvert="clr-namespace:PDF_Office.DataConvert" d:DataContext="{d:DesignInstance Type=annotpanel:CustomCreateDialogViewModel}"
              mc:Ignorable="d" >
 
+    <UserControl.Resources>
+        <PathGeometry x:Key="Ic_AddButtonPath" Figures="M8.5,2.5 L8.5,7.5 L13.5,7.5 L13.5,8.5 L8.5,8.5 L8.5,13.5 L7.5,13.5 L7.5,8.5 L2.5,8.5 L2.5,7.5 L7.5,7.5 L7.5,2.5 L8.5,2.5 Z"/>
+        <dataconvert:UnVisivleConvert x:Key="UnVisivleConvert"/>
+    </UserControl.Resources>
     <cus:DialogContent Header="新建图章">
         <cus:DialogContent.Content>
-            <TabControl Grid.Row="1" Name="StampTabControl"  HorizontalAlignment="Center" HorizontalContentAlignment="Center" Style="{StaticResource TabControlWithUnderLineStyle}">
+            <TabControl Grid.Row="1" Name="StampTabControl" SelectedIndex="2"  HorizontalAlignment="Center" HorizontalContentAlignment="Center" Style="{StaticResource TabControlWithUnderLineStyle}">
                 <TabItem x:Name="文字图章"
-                        Header="Standard"
+                        Header="文字图章"
                         FontFamily="Segoe UI" Foreground="#FF666666"
                         HorizontalContentAlignment="Center"
                         FontSize="16"
@@ -24,7 +29,7 @@
                             <RowDefinition Height="*"/>
                             <RowDefinition Height="*"/>
                         </Grid.RowDefinitions>
-                        <Image Height="50" Source="{Binding ImageSource}"/>
+                        <Image Height="50" Source="{Binding TextImageSource}"/>
                         <TextBox Grid.Row="1" Text="{Binding StampText,Mode=TwoWay}" TextChanged="TextBox_TextChanged">
                             <i:Interaction.Triggers>
                                 <i:EventTrigger EventName="LostFocus">
@@ -57,12 +62,34 @@
                     </Grid>
                 </TabItem>
                 <TabItem  x:Name="图片图章"
-                        Header="Dynamic"
+                        Header="图片图章"
                         FontFamily="Segoe UI" Foreground="#FF666666"
                         HorizontalContentAlignment="Center"
                         FontSize="16"
                         Width="86">
-                    <Image/>
+                    <Grid>
+                        <customcontrol:PathButton
+                        x:Name="BtnAdd"
+                        Height="24" Width="24"  IconHeight="20"  IconWidth="20" 
+                        Icon="{StaticResource Ic_AddButtonPath}"  IconFill="Red"
+                        IconPress="{StaticResource Ic_AddButtonPath}" IconPressFill="#C04CF8"
+                        IconMouseOver="{StaticResource Ic_AddButtonPath}" IconMouseOverFill="#C04CF8" Visibility="{Binding ShowImageButton}"  Command="{Binding OpenImageCommnad}"/>
+                        <Grid Visibility="{Binding ElementName=BtnAdd,Path=Visibility,Converter={StaticResource UnVisivleConvert}}">
+                            <Grid.RowDefinitions>
+                                <RowDefinition Height="24"/>
+                                <RowDefinition Height="*"/>
+                            </Grid.RowDefinitions>
+                            <Image Grid.RowSpan="2" Width="200" Height="200" Source="{Binding ImagePreviewSource}" />
+
+                            <customcontrol:PathButton
+                            x:Name="BtnReAdd"
+                            HorizontalAlignment="Right" VerticalAlignment="Top"
+                            Height="24" Width="24"  IconHeight="20"  IconWidth="20" 
+                            Icon="{StaticResource Ic_AddButtonPath}"  IconFill="Red"
+                            IconPress="{StaticResource Ic_AddButtonPath}" IconPressFill="#C04CF8"
+                            IconMouseOver="{StaticResource Ic_AddButtonPath}" IconMouseOverFill="#C04CF8" Command="{Binding OpenImageCommnad}"/>
+                        </Grid>
+                    </Grid>
                 </TabItem>
             </TabControl>
         </cus:DialogContent.Content>

+ 2 - 1
PDF Office/Views/PropertyPanel/AnnotPanel/CustomCreateDialog.xaml.cs

@@ -1,4 +1,5 @@
-using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
+using PDF_Office.Helper;
+using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
 using System;
 using System.Collections.Generic;
 using System.Linq;

+ 13 - 2
PDF Office/Views/PropertyPanel/AnnotPanel/StampAnnotProperty.xaml

@@ -53,7 +53,6 @@
                                     <ContextMenu>
                                         <MenuItem Header="导出图章">
                                             <MenuItem x:Name="SavePNG" Header="PNG" Tag="PNG" Click="Save_Click"/>
-                                            <MenuItem x:Name="SaveJPG" Header="JPG" Tag="JPG" Click="Save_Click"/>
                                             <MenuItem x:Name="SavePDF" Header="PDF" Tag="PDF" Click="Save_Click"/>
                                         </MenuItem>
                                     </ContextMenu>
@@ -113,7 +112,19 @@
                              >
                     <ListBox.ItemTemplate>
                         <HierarchicalDataTemplate  DataType="{x:Type model:Stamp}" >
-                            <Image Source="{Binding SourcePath}"/>
+                            <Grid>
+                                <Grid.ContextMenu>
+                                    <ContextMenu>
+                                        <MenuItem x:Name="Delete" Header="删除图章" Click="Delete_Click"/>
+                                        <MenuItem x:Name="DeleteAll" Header="删除全部图章" Click="DeleteAll_Click"/>
+                                        <MenuItem Header="导出图章">
+                                            <MenuItem x:Name="SavePNG" Header="PNG" Tag="PNG" Click="Save_Click"/>
+                                            <MenuItem x:Name="SavePDF" Header="PDF" Tag="PDF" Click="Save_Click"/>
+                                        </MenuItem>
+                                    </ContextMenu>
+                                </Grid.ContextMenu>
+                                <Image Source="{Binding SourcePath}"/>
+                            </Grid>
                         </HierarchicalDataTemplate>
                     </ListBox.ItemTemplate>
 

+ 11 - 0
PDF Office/Views/PropertyPanel/AnnotPanel/StampAnnotProperty.xaml.cs

@@ -42,5 +42,16 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
             MenuItem item = sender as MenuItem;
             (DataContext as StampAnnotPropertyViewModel).SaveToPath(item.Tag.ToString(), item.DataContext as Stamp);
         }
+
+        private void Delete_Click(object sender, RoutedEventArgs e)
+        {
+            MenuItem item = sender as MenuItem;
+            (DataContext as StampAnnotPropertyViewModel).DeleteStamp(item.DataContext as Stamp);
+        }
+
+        private void DeleteAll_Click(object sender, RoutedEventArgs e)
+        {
+            (DataContext as StampAnnotPropertyViewModel).DeleteAll();
+        }
     }
 }