Browse Source

Merge branch 'dev' of http://git.kdan.cc:8865/Windows/PDFOffice_Windows_exe into dev

ZhouJieSheng 2 years ago
parent
commit
9ab7f50a6d

+ 65 - 0
PDF Office/DataConvert/StringToVisibleConvert.cs

@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Data;
+
+namespace PDF_Office.DataConvert
+{
+    public class StringToVisibleConvert : IValueConverter
+    {
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            if (value == null || string.IsNullOrEmpty((string)value))
+            {
+                return Visibility.Collapsed;
+            }
+            else
+            {
+                if (value is string && (value as string).Length > 0)
+                {
+                    return Visibility.Visible;
+                }
+                else
+                {
+                    return Visibility.Collapsed;
+                }
+            }
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            return null;
+        }
+    }
+
+    public class StringToUnVisibleConvert : IValueConverter
+    {
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            if (value == null)
+            {
+                return Visibility.Visible;
+            }
+            else
+            {
+                if (value is string && (value as string).Length > 0)
+                {
+                    return Visibility.Collapsed;
+                }
+                else
+                {
+                    return Visibility.Visible;
+                }
+            }
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            return null;
+        }
+    }
+}

+ 1 - 0
PDF Office/PDF Office.csproj

@@ -214,6 +214,7 @@
     </Compile>
     <Compile Include="DataConvert\FileFormatToIconConvert.cs" />
     <Compile Include="DataConvert\PropertyPanelVisible.cs" />
+    <Compile Include="DataConvert\StringToVisibleConvert.cs" />
     <Compile Include="DataConvert\UnVisivleConvert.cs" />
     <Compile Include="EventAggregators\PageEditNotifyEvent.cs" />
     <Compile Include="EventAggregators\PageEditRefreshEvent.cs" />

+ 408 - 73
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -1,6 +1,8 @@
-using ComPDFKitViewer;
+using ComPDFKit.PDFAnnotation;
+using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
+using Microsoft.Win32;
 using PDF_Office.CustomControl;
 using PDF_Office.Helper;
 using PDF_Office.Model;
@@ -38,103 +40,436 @@ namespace PDF_Office.ViewModels.Tools
         private Dictionary<string, bool> ToolExpandDict = new Dictionary<string, bool>();
         public void BtnMyTools_Click(CustomIconToggleBtn annotBtn)
         {
-            Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
-            UserControl propertyPanel = null;
-            AnnotHandlerEventArgs annotArgs = null;
-            switch (annotBtn.Tag.ToString())
+         
+
+            if(annotBtn.IsChecked == true)
             {
-                case "SnapshotEdit":
-                    break;
+                Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
+                
+                AnnotHandlerEventArgs annotArgs = null;
 
-                case "HighLight":
-                    TextHighlightAnnotArgs highlightArgs = new TextHighlightAnnotArgs(); 
-                    highlightArgs.Color = Color.FromRgb(0xFF, 0xBB, 0x00);
-                    highlightArgs.Transparency = 0.5;
-                    DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotHighlight);
-                    if (annotProperty != null)
-                    {
-                        highlightArgs.Color = annotProperty.ForgoundColor;
-                        highlightArgs.Transparency = annotProperty.Opacity;
-                        highlightArgs.Content = annotProperty.NoteText;
-                    }
-                    annotAttribsList[AnnotAttrib.Color] = highlightArgs.Color;
-                    annotAttribsList[AnnotAttrib.Transparency] = highlightArgs.Transparency;
-                    annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
+                switch (annotBtn.Tag.ToString())
+                {
+                    case "SnapshotEdit":
+                        break;
 
-                    TextAnnotProperty textAnnotProperty = new TextAnnotProperty();
-                    //textAnnotProperty.DataChanged += AnnotPropertyPanel_DataChanged;
-                    //textAnnotProperty.DefaultStored += AnnotProperty_DefaultStored;
-                    //textAnnotProperty.SetAnnotType(highlightArgs.EventType);
-                    //textAnnotProperty.SetSelectedColor(highlightArgs.Color);
-                    //textAnnotProperty.SetSelectOpacity(highlightArgs.Transparency);
-                    //textAnnotProperty.SetNoteContent(highlightArgs.Content);
-                    //textAnnotProperty.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(highlightArgs, annotAttribsList);
-                    propertyPanel = textAnnotProperty;
-                    annotArgs = highlightArgs;
+                    case "HighLight":
+                        {
+                            TextHighlightAnnotArgs highlightArgs = new TextHighlightAnnotArgs();
+                            highlightArgs.Color = Color.FromRgb(0xFF, 0xBB, 0x00);
+                            highlightArgs.Transparency = 0.5;
+                            DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotHighlight);
+                            if (annotProperty != null)
+                            {
+                                highlightArgs.Color = annotProperty.ForgoundColor;
+                                highlightArgs.Transparency = annotProperty.Opacity;
+                                highlightArgs.Content = annotProperty.NoteText;
+                            }
+                            annotAttribsList[AnnotAttrib.Color] = highlightArgs.Color;
+                            annotAttribsList[AnnotAttrib.Transparency] = highlightArgs.Transparency;
+                            annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
 
-                    if (!ToolExpandDict.ContainsKey("HighLight"))
-                    {
-                        ToolExpandDict["HighLight"] = true;
-                      //  viewCtrl.PropRow.Width = new GridLength(256 + (int)SystemParameters.ScrollWidth);
-                    }
+                            TextAnnotProperty textAnnotProperty = new TextAnnotProperty();
+                            annotArgs = highlightArgs;
 
-                    break;
+                            if (!ToolExpandDict.ContainsKey("HighLight"))
+                            {
+                                ToolExpandDict["HighLight"] = true;
+                            }
+                        }
 
-                case "UnderLine":
-                    break;
+                        break;
 
-                case "Squiggly":
-                    break;
+                    case "UnderLine":
+                        {
+                            TextUnderlineAnnotArgs underlineArgs = new TextUnderlineAnnotArgs();
+                            underlineArgs.Color = Color.FromRgb(0x12, 0xFD, 0xFF);
+                            underlineArgs.Transparency = 1;
+                            DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotUnderline);
+                            if (annotProperty != null)
+                            {
+                                underlineArgs.Color = annotProperty.ForgoundColor;
+                                underlineArgs.Transparency = annotProperty.Opacity;
+                                underlineArgs.Content = annotProperty.NoteText;
+                            }
+                            annotAttribsList[AnnotAttrib.Color] = underlineArgs.Color;
+                            annotAttribsList[AnnotAttrib.Transparency] = underlineArgs.Transparency;
+                            annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
+                            annotArgs = underlineArgs;
+                            if (!ToolExpandDict.ContainsKey("UnderLine"))
+                            {
+                                ToolExpandDict["UnderLine"] = true;
+                            }
+                        }
+                       
+                        break;
 
-                case "Strikeout":
-                    break;
+                    case "Squiggly":
+                        {
+                            TextSquigglyAnnotArgs squigglyArgs = new TextSquigglyAnnotArgs();
+                            squigglyArgs.Color = Color.FromRgb(0xFF, 0x87, 0x16);
+                            squigglyArgs.Transparency = 1;
+                            DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotSquiggly);
+                            if (annotProperty != null)
+                            {
+                                squigglyArgs.Color = annotProperty.ForgoundColor;
+                                squigglyArgs.Transparency = annotProperty.Opacity;
+                                squigglyArgs.Content = annotProperty.NoteText;
+                            }
+                            annotAttribsList[AnnotAttrib.Color] = squigglyArgs.Color;
+                            annotAttribsList[AnnotAttrib.Transparency] = squigglyArgs.Transparency;
+                            annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
+                           
+                            annotArgs = squigglyArgs;
+                            if (!ToolExpandDict.ContainsKey("Squiggly"))
+                            {
+                                ToolExpandDict["Squiggly"] = true;
+                            }
+                        }
+                        break;
 
-                case "Freehand":
-                    break;
+                    case "Strikeout":
+                        {
+                            TextStrikeoutAnnotArgs strikeoutArgs = new TextStrikeoutAnnotArgs();
+                            strikeoutArgs.Color = Color.FromRgb(0xFF, 0x3B, 0x30);
+                            strikeoutArgs.Transparency = 1;
+                            DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotStrikeout);
+                            if (annotProperty != null)
+                            {
+                                strikeoutArgs.Color = annotProperty.ForgoundColor;
+                                strikeoutArgs.Transparency = annotProperty.Opacity;
+                                strikeoutArgs.Content = annotProperty.NoteText;
+                            }
+                            annotAttribsList[AnnotAttrib.Color] = strikeoutArgs.Color;
+                            annotAttribsList[AnnotAttrib.Transparency] = strikeoutArgs.Transparency;
+                            annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
+                            annotArgs = strikeoutArgs;
+                            if (!ToolExpandDict.ContainsKey("Strikeout"))
+                            {
+                                ToolExpandDict["Strikeout"] = true;
+                            }
+                        }
+                        break;
 
-                case "Freetext":
-                    break;
+                    case "Freehand":
+                        {
+                            FreehandAnnotArgs freehandArgs = new FreehandAnnotArgs();
+                            freehandArgs.InkColor = Color.FromRgb(0x38, 0xE0, 0x2E);
+                            freehandArgs.Transparency = 1;
+                            freehandArgs.LineWidth = 1;
+                            DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotFreehand);
+                            if (annotProperty != null)
+                            {
+                                freehandArgs.InkColor = annotProperty.ForgoundColor;
+                                freehandArgs.Transparency = annotProperty.Opacity;
+                                freehandArgs.LineWidth = annotProperty.Thickness;
+                                freehandArgs.Content = annotProperty.NoteText;
+                            }
+                            annotAttribsList[AnnotAttrib.Color] = freehandArgs.InkColor;
+                            annotAttribsList[AnnotAttrib.Transparency] = freehandArgs.Transparency;
+                            annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
+                            annotAttribsList[AnnotAttrib.NoteText] = freehandArgs.Content;
+                            annotArgs = freehandArgs;
+                            if (!ToolExpandDict.ContainsKey("Freehand"))
+                            {
+                                ToolExpandDict["Freehand"] = true;
+                            }
+                        }
+                        break;
 
-                case "StickyNote":
-                    break;
+                    case "Freetext":
+                        {
+                            FreeTextAnnotArgs freetextArgs = new FreeTextAnnotArgs();
+                            freetextArgs.Align = TextAlignment.Left;
+                            freetextArgs.BgColor = Colors.Transparent;
+                            freetextArgs.FontFamily = new FontFamily(Settings.Default.AppProperties.Annotate.TextFontFamaily);
+                            freetextArgs.FontColor = Colors.Black;
+                            freetextArgs.FontSize = 14;
+                            freetextArgs.Transparency = 1;
+                            freetextArgs.LineColor = Colors.Black;
+                            freetextArgs.LineWidth = 0;
+                            freetextArgs.TextContent = string.Empty;
 
-                case "Rect":
-                    break;
+                            DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotFreeText);
+                            if (annotProperty != null)
+                            {
+                                freetextArgs.Align = annotProperty.TextAlign;
+                                freetextArgs.BgColor = annotProperty.BackgroundColor;
+                                freetextArgs.FontFamily = new FontFamily(annotProperty.FontFamily);
+                                freetextArgs.FontColor = annotProperty.ForgoundColor;
+                                freetextArgs.FontSize = annotProperty.FontSize;
+                                freetextArgs.Transparency = annotProperty.Opacity;
+                                freetextArgs.LineColor = annotProperty.BorderColor;
+                                freetextArgs.LineWidth = annotProperty.Thickness;
+                                freetextArgs.TextContent = annotProperty.NoteText;
+                                freetextArgs.FontWeight = annotProperty.FontWeight;
+                                freetextArgs.FontStyle = annotProperty.FontStyle;
+                            }
+                            int align = Settings.Default.AppProperties.Annotate.TextAlign;
+                            TextAlignment textAlignment;
+                            if (align == 0)
+                                textAlignment = TextAlignment.Left;
+                            else if (align == 1)
+                                textAlignment = TextAlignment.Center;
+                            else
+                                textAlignment = TextAlignment.Right;
+                            annotAttribsList[AnnotAttrib.Color] = freetextArgs.LineColor;
+                            annotAttribsList[AnnotAttrib.FillColor] = freetextArgs.BgColor;
+                            annotAttribsList[AnnotAttrib.Thickness] = freetextArgs.LineWidth;
+                            annotAttribsList[AnnotAttrib.Transparency] = freetextArgs.Transparency;
+                            annotAttribsList[AnnotAttrib.FontColor] = freetextArgs.FontColor;
+                            annotAttribsList[AnnotAttrib.FontSize] = freetextArgs.FontSize;
+                            annotAttribsList[AnnotAttrib.FontFamily] = freetextArgs.FontFamily;
+                            annotAttribsList[AnnotAttrib.FontStyle] = freetextArgs.FontStyle;
+                            annotAttribsList[AnnotAttrib.FontWeight] = freetextArgs.FontWeight;
+                            annotAttribsList[AnnotAttrib.TextAlign] = textAlignment;
+                            annotAttribsList[AnnotAttrib.NoteText] = freetextArgs.TextContent;
+                          
+                            annotArgs = freetextArgs;
+                            if (!ToolExpandDict.ContainsKey("Freetext"))
+                            {
+                                ToolExpandDict["Freetext"] = true;
+                            }
+                        }
+                        break;
 
-                case "Circle":
-                    break;
+                    case "StickyNote":
+                        {
+                            StickyAnnotArgs stickyAnnotArgs = new StickyAnnotArgs();
+                            stickyAnnotArgs.Color = Color.FromRgb(0xFF, 0x81, 0x33);
+                            stickyAnnotArgs.StickyNote = string.Empty;
+                            stickyAnnotArgs.Transparency = 1;
 
-                case "Arrow":
-                    break;
+                            DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotSticky);
+                            if (annotProperty != null)
+                            {
+                                stickyAnnotArgs.Color = annotProperty.ForgoundColor;
+                                stickyAnnotArgs.StickyNote = annotProperty.NoteText;
+                                stickyAnnotArgs.Transparency = annotProperty.Opacity;
+                            }
 
-                case "Line":
-                    break;
+                            annotAttribsList[AnnotAttrib.Color] = stickyAnnotArgs.Color;
+                            annotAttribsList[AnnotAttrib.Transparency] = stickyAnnotArgs.Transparency;
+                            annotAttribsList[AnnotAttrib.NoteText] = stickyAnnotArgs.StickyNote;
+                           
+                            annotArgs = stickyAnnotArgs;
+                            if (!ToolExpandDict.ContainsKey("StickyNote"))
+                            {
+                                ToolExpandDict["StickyNote"] = true;
+                            }
+                        }
+                        break;
 
-                case "Stamp":
-                    break;
+                    case "Rect":
+                        {
+                            SquareAnnotArgs squareArgs = new SquareAnnotArgs();
+                            squareArgs.LineColor = Colors.Red;
+                            squareArgs.BgColor = Colors.Transparent;
+                            squareArgs.LineWidth = 1;
+                            squareArgs.Transparency = 1;
+                            squareArgs.LineDash = DashStyles.Solid;
+                            squareArgs.Content = string.Empty;
+                            DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotSquare);
+                            if (annotProperty != null)
+                            {
+                                squareArgs.LineColor = annotProperty.BorderColor;
+                                squareArgs.BgColor = annotProperty.BackgroundColor;
+                                if (annotProperty.DashArray == null || annotProperty.DashArray.Count == 0)
+                                {
+                                    squareArgs.LineDash = DashStyles.Solid;
+                                }
+                                else
+                                {
+                                    DashStyle dash = new DashStyle();
+                                    foreach (var offset in annotProperty.DashArray)
+                                    {
+                                        dash.Dashes.Add(offset);
+                                    }
+                                    squareArgs.LineDash = dash;
+                                }
+                                squareArgs.LineWidth = annotProperty.Thickness;
+                                squareArgs.Transparency = annotProperty.Opacity;
+                                squareArgs.Content = annotProperty.NoteText;
+                            }
+                            annotAttribsList[AnnotAttrib.Color] = squareArgs.LineColor;
+                            annotAttribsList[AnnotAttrib.FillColor] = squareArgs.BgColor;
+                            annotAttribsList[AnnotAttrib.LineStyle] = squareArgs.LineDash;
+                            annotAttribsList[AnnotAttrib.Thickness] = squareArgs.LineWidth;
+                            annotAttribsList[AnnotAttrib.Transparency] = squareArgs.Transparency;
+                            annotAttribsList[AnnotAttrib.NoteText] = squareArgs.Content;
+                            annotArgs = squareArgs;
+                            if (!ToolExpandDict.ContainsKey("Rect"))
+                            {
+                                ToolExpandDict["Rect"] = true;
+                            }
+                        }
+                        break;
 
-                case "Image":
-                    break;
+                    case "Circle":
+                        {
+                            CircleAnnotArgs circleAnnotArgs = new CircleAnnotArgs();
+                            circleAnnotArgs.LineColor = Colors.Red;
+                            circleAnnotArgs.BgColor = Colors.Transparent;
+                            circleAnnotArgs.LineWidth = 1;
+                            circleAnnotArgs.Transparency = 1;
+                            circleAnnotArgs.LineDash = DashStyles.Solid;
+                            circleAnnotArgs.Content = string.Empty;
+                            DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotCircle);
+                            if (annotProperty != null)
+                            {
+                                circleAnnotArgs.LineColor = annotProperty.BorderColor;
+                                circleAnnotArgs.BgColor = annotProperty.BackgroundColor;
+                                if (annotProperty.DashArray == null || annotProperty.DashArray.Count == 0)
+                                {
+                                    circleAnnotArgs.LineDash = DashStyles.Solid;
+                                }
+                                else
+                                {
+                                    DashStyle dash = new DashStyle();
+                                    foreach (var offset in annotProperty.DashArray)
+                                    {
+                                        dash.Dashes.Add(offset);
+                                    }
+                                    circleAnnotArgs.LineDash = dash;
+                                }
+                                circleAnnotArgs.LineWidth = annotProperty.Thickness;
+                                circleAnnotArgs.Transparency = annotProperty.Opacity;
+                                circleAnnotArgs.Content = annotProperty.NoteText;
+                            }
+                            annotAttribsList[AnnotAttrib.Color] = circleAnnotArgs.LineColor;
+                            annotAttribsList[AnnotAttrib.FillColor] = circleAnnotArgs.BgColor;
+                            annotAttribsList[AnnotAttrib.LineStyle] = circleAnnotArgs.LineDash;
+                            annotAttribsList[AnnotAttrib.Thickness] = circleAnnotArgs.LineWidth;
+                            annotAttribsList[AnnotAttrib.Transparency] = circleAnnotArgs.Transparency;
+                            annotAttribsList[AnnotAttrib.NoteText] = circleAnnotArgs.Content;
+                           
+                            annotArgs = circleAnnotArgs;
+                            if (!ToolExpandDict.ContainsKey("Circle"))
+                            {
+                                ToolExpandDict["Circle"] = true;
+                            }
+                        }
+                        break;
 
-                case "Signature":
-                    break;
+                    case "Arrow":
+                    case "Line":
+                        {
+                            LineAnnotArgs lineArgs = new LineAnnotArgs();
+                            lineArgs.LineColor = Colors.Red;
+                            lineArgs.HeadLineType = C_LINE_TYPE.LINETYPE_NONE;
+                            if (annotBtn.Tag.ToString() == "Line")
+                            {
+                                lineArgs.TailLineType = C_LINE_TYPE.LINETYPE_NONE;
+                            }
+                            else
+                            {
+                                lineArgs.TailLineType = C_LINE_TYPE.LINETYPE_ARROW;
+                            }
+                            lineArgs.LineDash = DashStyles.Solid;
+                            lineArgs.LineWidth = 1;
+                            lineArgs.Transparency = 1;
+                            lineArgs.Content = string.Empty;
 
-                case "Link":
-                    break;
+                            DefaultAnnotProperty annotProperty = null;
+                            if (annotBtn.Tag.ToString() == "Line")
+                            {
+                                annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotLine, "Line");
+                                if (annotProperty != null)
+                                {
+                                    annotProperty.HeadLineType = C_LINE_TYPE.LINETYPE_NONE;
+                                    annotProperty.TailLineType = C_LINE_TYPE.LINETYPE_NONE;
+                                }
+                            }
+                            else
+                            {
+                                annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotLine, "Arrow");
+                            }
 
-            }
+                            if (annotProperty != null)
+                            {
+                                lineArgs.LineColor = annotProperty.BorderColor;
+                                lineArgs.HeadLineType = annotProperty.HeadLineType;
+                                lineArgs.TailLineType = annotProperty.TailLineType;
 
+                                DashStyle dash = new DashStyle();
+                                foreach (var offset in annotProperty.DashArray)
+                                {
+                                    dash.Dashes.Add(offset);
+                                }
+                                lineArgs.LineDash = dash;
+                                lineArgs.LineWidth = annotProperty.Thickness;
+                                lineArgs.Transparency = annotProperty.Opacity;
+                                lineArgs.Content = annotProperty.NoteText;
+                            }
+                            annotAttribsList[AnnotAttrib.Color] = lineArgs.LineColor;
+                            annotAttribsList[AnnotAttrib.LineStart] = lineArgs.HeadLineType;
+                            annotAttribsList[AnnotAttrib.LineEnd] = lineArgs.TailLineType;
+                            annotAttribsList[AnnotAttrib.LineStyle] = lineArgs.LineDash;
+                            annotAttribsList[AnnotAttrib.Thickness] = lineArgs.LineWidth;
+                            annotAttribsList[AnnotAttrib.Transparency] = lineArgs.Transparency;
+                            annotAttribsList[AnnotAttrib.NoteText] = lineArgs.Content;
 
-            if (annotArgs != null)
-            {
-                annotArgs.Author = Settings.Default.AppProperties.Description.Author;
-                PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
-                PDFViewer.SetToolParam(annotArgs);
-                if (propertyPanel != null)
+                            annotArgs = lineArgs;
+                            if (!ToolExpandDict.ContainsKey(annotBtn.Tag.ToString()))
+                            {
+                                ToolExpandDict[annotBtn.Tag.ToString()] = true; 
+                            }
+                        }
+                        break;
+
+                    case "Stamp":
+                        {
+                            StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
+                            stampAnnotArgs.Opacity = 1;
+                            stampAnnotArgs.StampText = "APPROVED";
+                            stampAnnotArgs.Type = StampType.STANDARD_STAMP;
+
+                            annotAttribsList[AnnotAttrib.Transparency] = stampAnnotArgs.Opacity;
+                           
+                        }
+                        break;
+
+                    case "Image":
+                        {
+                            annotBtn.IsChecked = false;
+                            StampAnnotArgs stampArgs = new StampAnnotArgs();
+                            stampArgs.Opacity = 1;
+                            stampArgs.Type = StampType.IMAGE_STAMP;
+                            OpenFileDialog openFileDialog = new OpenFileDialog();
+                            openFileDialog.Filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png;*.bmp;";
+                            if (openFileDialog.ShowDialog() == true)
+                            {
+                                stampArgs.ImagePath = openFileDialog.FileName;
+                 
+                                annotArgs = stampArgs;
+                            }
+                        }
+                        break;
+
+                    case "Signature":
+                        break;
+
+                    case "Link":
+                        break;
+
+                }
+
+
+                if (annotArgs != null)
                 {
-                 //   viewCtrl.AddAnnotPropertyPanel(propertyPanel);
+                    annotArgs.Author = Settings.Default.AppProperties.Description.Author;
+                    PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
+                    PDFViewer.SetToolParam(annotArgs);
+                   
                 }
             }
+
+            else
+            {
+                PDFViewer.SetMouseMode(MouseModes.PanTool);
+            }
+
+          
         }
 
         public bool IsNavigationTarget(NavigationContext navigationContext)

+ 161 - 1
PDF Office/Views/PropertyPanel/AnnotPanel/LinkAnnotProperty.xaml

@@ -4,9 +4,169 @@
              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:Convert="clr-namespace:PDF_Office.DataConvert"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <!--<ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../Resources/Style/ToggleButtonStyle.xaml"/>
+            </ResourceDictionary.MergedDictionaries>-->
+            <Convert:StringToVisibleConvert x:Key="StringToVisibleConvert"/>
+            <Convert:StringToUnVisibleConvert x:Key="StringToUnVisibleConvert"></Convert:StringToUnVisibleConvert>
+        </ResourceDictionary>
+    </UserControl.Resources>
     <Grid>
-            
+        <StackPanel>
+            <TextBlock Name="AnnotTypeTitle" FontFamily="Segoe UI" FontWeight="Bold" FontSize="18" LineHeight="24" HorizontalAlignment="Center" Margin="0,12,0,12">Hyperlink</TextBlock>
+            <StackPanel Orientation="Horizontal" Margin="12,0,0,0">
+                <ToggleButton Name="LinkPageBtn" Width="72" Height="80"  VerticalContentAlignment="Center" Tag="Page" Background="Transparent" BorderThickness="0" IsChecked="True">
+                    <StackPanel  VerticalAlignment="Center">
+                        <Path Margin="8 8 8 8" Fill="#000000" HorizontalAlignment="Center">
+                            <Path.Data>
+                                M10.7071068,0 L15,4.29289322 L15,16 L1,16 L1,0 L10.7071068,0 Z M10.293,1 L2,1 L2,15 L14,15 L14,4.707 L10.293,1 Z M12,11 L12,12 L4,
+                        12 L4,11 L12,11 Z M12,9 L12,10 L4,10 L4,9 L12,9 Z M12,7 L12,8 L4,8 L4,7 L12,7 Z M8,5 L8,6 L4,6 L4,5 L8,5 Z
+                            </Path.Data>
+                        </Path>
+                        <TextBlock x:Name="LinkPageText" Width="36" TextWrapping="Wrap" FontSize="12" FontFamily="Segoe UI" LineHeight="16" TextAlignment="Center"/>
+                    </StackPanel>
+                </ToggleButton>
+
+                <ToggleButton Name="LinkWebBtn" Width="72" Height="80" VerticalContentAlignment="Center"  Tag="Web" Background="Transparent" BorderThickness="0">
+                    <StackPanel  Grid.Column="1" >
+                        <Path Margin="8 8 8 8" Fill="#000000" HorizontalAlignment="Center">
+                            <Path.Data>
+                                M8,0 C12.418278,0 16,3.581722 16,8 C16,12.418278 12.418278,16 8,16 C3.581722,16 0,12.418278 0,8 C0,
+                        3.581722 3.581722,0 8,0 Z M10.015957,11.4996518 L5.98404305,11.4996518 C6.28228653,12.6171156 6.71860376,
+                        13.7718221 7.29369179,14.9638748 C7.52703012,14.9881352 7.76212948,15 8,15 C8.23787052,15 8.47296988,14.9881352 8.70473856,14.9649652 L8.5527864,
+                        15.2763932 C9.20429615,13.9733737 9.69172111,12.7145042 10.015957,11.4996518 Z M4.95140445,11.5005273 L1.93671038,11.5004062 C2.83671487,
+                        13.0560047 4.31818608,14.2331131 6.08391456,14.7345218 C5.59233631,13.6294852 5.2144726,12.5517364 4.95140445,11.5005273 Z M14.0632896,
+                        11.5004062 L11.0485955,11.5005273 C10.7855274,12.5517364 10.4076637,13.6294852 9.91549498,14.733701 C11.6818139,14.2331131 13.1632851,
+                        13.0560047 14.0632896,11.5004062 Z M4.73409625,5.50071837 L1.45951741,5.5002913 C1.16263785,6.27661068 1,7.11931229 1,
+                        8 C1,8.88106408 1.16277689,9.72410957 1.4598981,10.5007039 L4.73428007,10.5002845 C4.5781846,9.64883923 4.5,8.81539751 4.5,8 C4.5,
+                        7.18492263 4.57812322,6.35181522 4.73409625,5.50071837 Z M10.2481144,5.50109727 L5.7518856,5.50109727 C5.583851,
+                        6.3567708 5.5,7.18972192 5.5,8 C5.5,8.81059324 5.58391624,9.64387716 5.75208172,10.4999012 L10.2479183,10.4999012 C10.4160838,9.64387716 10.5,
+                        8.81059324 10.5,8 C10.5,7.18972192 10.416149,6.3567708 10.2481144,5.50109727 Z M14.5404826,5.5002913 L11.2659038,5.50071837 C11.4218768,6.35181522 11.5,
+                        7.18492263 11.5,8 C11.5,8.81539751 11.4218154,9.64883923 11.2657199,10.5002845 L14.5401019,10.5007039 C14.8372231,9.72410957 15,8.88106408 15,8 C15,
+                        7.11931229 14.8373622,6.27661068 14.5404826,5.5002913 Z M6.08450502,1.26629895 L5.91841413,1.31470614 C4.22534161,1.84130637 2.80783045,2.99335133 1.93613744,
+                        4.50058424 L4.95115335,4.5004762 C5.21423213,3.44894951 5.5921797,2.37086613 6.08450502,1.26629895 Z M8,1 C7.76212948,1 7.52703012,1.01186476 7.29526144,
+                        1.03503476 L7.4472136,0.723606798 C6.79552511,2.02698377 6.30801146,3.28618649 5.98377622,4.50134805 L10.0162238,4.50134805 C9.73005017,3.42883299 9.31668229,
+                        2.32200977 8.77550381,1.18078687 L8.70473856,1.03503476 C8.47296988,1.01186476 8.23787052,1 8,1 Z M9.91608544,1.26547815 L10.1069462,1.70819247 C10.50689,
+                        2.65884847 10.8209632,3.58962551 11.0488466,4.5004762 L14.0638626,4.50058424 C13.1639139,2.94449491 11.6821887,1.76699331 9.91608544,1.26547815 Z
+                            </Path.Data>
+                        </Path>
+                        <TextBlock x:Name="URLText" Width="52" TextWrapping="Wrap" FontSize="12" FontFamily="Segoe UI" LineHeight="16" TextAlignment="Center">Open web Page</TextBlock>
+                    </StackPanel>
+                </ToggleButton>
+
+                <ToggleButton Name="LinkMailBtn" Width="72" Height="80" VerticalContentAlignment="Center" Tag="Mail" Background="Transparent" BorderThickness="0">
+                    <StackPanel  Grid.Column="2">
+                        <Path Margin="8 8 8 8"  Fill="#000000" HorizontalAlignment="Center">
+                            <Path.Data>
+                                M16,2 L16,14 L0,14 L0,2 L16,2 Z M5.792,7.628 L1.533,13 L14.465,13 L10.203,7.631 L8,9.100925 L5.792,7.628 Z M15,4.434 L11.038,
+                        7.075 L15,12.067 L15,4.434 Z M1,4.435 L1,12.064 L4.957,7.072 L1,4.435 Z M15,3 L1,3 L1,3.232 L8,7.898 L15,3.231 L15,3 Z
+                            </Path.Data>
+                        </Path>
+                        <TextBlock x:Name="EmailText"  TextWrapping="Wrap" FontSize="12" FontFamily="Segoe UI" LineHeight="16" TextAlignment="Center">Email</TextBlock>
+                    </StackPanel>
+                </ToggleButton>
+
+            </StackPanel>
+            <Line Margin="0,4,0,0" Stroke="#1A000000" StrokeThickness="1" Width="232" HorizontalAlignment="Center" X1="0" X2="232" Y1="0" Y2="0"></Line>
+            <Grid Height="100">
+                <StackPanel Name="LinkPagePanel">
+                    <TextBlock x:Name="PageNumberText" Margin="12,12,0,4" FontSize="14" FontFamily="Segoe UI" LineHeight="20" Height="20">Control header</TextBlock>
+                    <StackPanel Orientation="Horizontal">
+                        <Grid>
+                            <TextBox Name="PageNumText" Margin="12,0,0,0" Width="199" Height="32" BorderBrush="#FFE2E3E6" Padding="12,0,0,0" Background="Gray" MaxLength="7"
+                         VerticalContentAlignment="Center"  IsEnabled="False"></TextBox>
+                            <Button Tag="PageNumText" HorizontalAlignment="Right" Margin="0,8,8,8" VerticalAlignment="Center" Width="16" Height="16" Background="Transparent"
+                            >
+                                <Button.Content>
+                                    <Path Fill="#333333">
+                                        <Path.Data>
+                                            M9.48528137,2.98528137 L9.48428137,8.48428137 L14.9852814,8.48528137 L14.9852814,9.48528137 L9.48428137,9.48428137 L9.48528137,14.9852814 L8.48528137,
+                                14.9852814 L8.48428137,9.48428137 L2.98528137,9.48528137 L2.98528137,8.48528137 L8.48428137,8.48428137 L8.48528137,2.98528137 L9.48528137,2.98528137 Z
+                                        </Path.Data>
+                                        <Path.RenderTransform>
+                                            <TransformGroup>
+                                                <TranslateTransform X="-8"/>
+                                                <RotateTransform Angle="45"/>
+                                                <TranslateTransform X="13"/>
+                                            </TransformGroup>
+                                        </Path.RenderTransform>
+                                    </Path>
+                                </Button.Content>
+                            </Button>
+                        </Grid>
+
+                        <TextBlock Name="PageNumBlock" Margin="8,0,0,0" Height="20" FontSize="14" FontFamily="Segoe UI" LineHeight="20" TextAlignment="Center" VerticalAlignment="Center"></TextBlock>
+                    </StackPanel>
+                    <TextBlock Name="ErrorNumTips" Foreground="Red" Margin="12,0,0,0" Visibility="Collapsed">Page number error.</TextBlock>
+                    <TextBlock Name="ErrorRangeTips" Foreground="Red" Margin="12,0,0,0" Visibility="Collapsed">Page number out of range.</TextBlock>
+                </StackPanel>
+                <StackPanel Name="LinkWebPanel" Visibility="Collapsed">
+                    <TextBlock Margin="12,12,0,4" FontSize="14" FontFamily="Segoe UI" LineHeight="20" Height="20">URL</TextBlock>
+                    <Grid>
+                        <TextBox Name="PageWebText" Margin="12,0,12,0" Width="232" Height="32" BorderBrush="#FFE2E3E6" HorizontalAlignment="Left" Padding="12,0,25,0" VerticalContentAlignment="Center"
+                      IsEnabled="False" Background="Gray"></TextBox>
+                        <TextBlock x:Name="defaultPageWebText" IsHitTestVisible="False" Margin="25,0,0,0" VerticalAlignment="Center" Foreground="Gray" FontSize="14"
+                          
+                                   >https://www.pdfreaderpro.com</TextBlock>
+                        <Button Tag="PageWebText" HorizontalAlignment="Right" Margin="0,8,18,8" VerticalAlignment="Center" Width="16" Height="16" Background="Transparent"
+                    >
+                            <Button.Content>
+                                <Path Fill="#333333">
+                                    <Path.Data>
+                                        M9.48528137,2.98528137 L9.48428137,8.48428137 L14.9852814,8.48528137 L14.9852814,9.48528137 L9.48428137,9.48428137 L9.48528137,14.9852814 L8.48528137,
+                                14.9852814 L8.48428137,9.48428137 L2.98528137,9.48528137 L2.98528137,8.48528137 L8.48428137,8.48428137 L8.48528137,2.98528137 L9.48528137,2.98528137 Z
+                                    </Path.Data>
+                                    <Path.RenderTransform>
+                                        <TransformGroup>
+                                            <TranslateTransform X="-8"/>
+                                            <RotateTransform Angle="45"/>
+                                            <TranslateTransform X="13"/>
+                                        </TransformGroup>
+                                    </Path.RenderTransform>
+                                </Path>
+                            </Button.Content>
+                        </Button>
+                    </Grid>
+                    <TextBlock Name="ErrorUrlTips" Foreground="Red" Margin="12,0,0,0" Visibility="Collapsed">Invalid link.</TextBlock>
+                </StackPanel>
+                <StackPanel Name="LinkMailPanel" Visibility="Collapsed">
+                    <TextBlock Margin="12,12,0,4" FontSize="14" FontFamily="Segoe UI" LineHeight="20" Height="20">Email</TextBlock>
+                    <Grid>
+                        <TextBox Name="PageMailText" Margin="12,0,12,0" Width="232" Height="32" BorderBrush="#FFE2E3E6" HorizontalAlignment="Left" Background="Gray"
+                     Padding="12,0,0,0" VerticalContentAlignment="Center"  IsEnabled="False"></TextBox>
+                        <TextBlock x:Name="defaultPageMailText" IsHitTestVisible="False" Margin="25,0,0,0" VerticalAlignment="Center" Foreground="Gray" FontSize="14"
+                           
+                                   >support@pdfreaderpro.com</TextBlock>
+                        <Button Tag="PageMailText" HorizontalAlignment="Right" Margin="0,8,18,8" VerticalAlignment="Center" Width="16" Height="16" Background="Transparent"
+                   >
+                            <Button.Content>
+                                <Path Fill="#333333">
+                                    <Path.Data>
+                                        M9.48528137,2.98528137 L9.48428137,8.48428137 L14.9852814,8.48528137 L14.9852814,9.48528137 L9.48428137,9.48428137 L9.48528137,14.9852814 L8.48528137,
+                                14.9852814 L8.48428137,9.48428137 L2.98528137,9.48528137 L2.98528137,8.48528137 L8.48428137,8.48428137 L8.48528137,2.98528137 L9.48528137,2.98528137 Z
+                                    </Path.Data>
+                                    <Path.RenderTransform>
+                                        <TransformGroup>
+                                            <TranslateTransform X="-8"/>
+                                            <RotateTransform Angle="45"/>
+                                            <TranslateTransform X="13"/>
+                                        </TransformGroup>
+                                    </Path.RenderTransform>
+                                </Path>
+                            </Button.Content>
+                        </Button>
+                    </Grid>
+                    <TextBlock Name="ErrorMailTips" Foreground="Red" Margin="12,0,0,0" TextWrapping="Wrap" Visibility="Collapsed">The email is invalid.Please enter a valid email address.</TextBlock>
+                </StackPanel>
+            </Grid>
+            <Button Name="SaveBtn" Width="120" Height="32" Tag="go" FontSize="16" Foreground="White" BorderThickness="0"  Background="#273C62" IsEnabled="False">
+                <!--<TextBlock x:Name="GoText" Foreground="White">Go</TextBlock>-->
+            </Button>
+        </StackPanel>
     </Grid>
 </UserControl>