|
@@ -15,6 +15,7 @@ using System.Globalization;
|
|
using System.Windows.Ink;
|
|
using System.Windows.Ink;
|
|
using Compdfkit_Tools.Common;
|
|
using Compdfkit_Tools.Common;
|
|
using ComPDFKitViewer.Helper;
|
|
using ComPDFKitViewer.Helper;
|
|
|
|
+using ComPDFKit.PDFDocument;
|
|
|
|
|
|
namespace Compdfkit_Tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI
|
|
namespace Compdfkit_Tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI
|
|
{
|
|
{
|
|
@@ -28,6 +29,9 @@ namespace Compdfkit_Tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI
|
|
private double StrokeWidth = 3;
|
|
private double StrokeWidth = 3;
|
|
private double StrokeHigh = 3;
|
|
private double StrokeHigh = 3;
|
|
private bool IsPageLoaded = false;
|
|
private bool IsPageLoaded = false;
|
|
|
|
+
|
|
|
|
+ private string postScriptName;
|
|
|
|
+
|
|
public CPDFCreateSignatureDialog()
|
|
public CPDFCreateSignatureDialog()
|
|
{
|
|
{
|
|
InitializeComponent();
|
|
InitializeComponent();
|
|
@@ -44,6 +48,9 @@ namespace Compdfkit_Tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI
|
|
|
|
|
|
DrawinkCanvas.DefaultDrawingAttributes.Color = solidColorBrush.Color;
|
|
DrawinkCanvas.DefaultDrawingAttributes.Color = solidColorBrush.Color;
|
|
InPutTextBox.Foreground = solidColorBrush;
|
|
InPutTextBox.Foreground = solidColorBrush;
|
|
|
|
+
|
|
|
|
+ FontNameCmb.Items.Clear();
|
|
|
|
+ FontNameCmb.ItemsSource = CPDFFont.GetFontNameDictionary().Keys;
|
|
}
|
|
}
|
|
|
|
|
|
private void Cancel_Click(object sender, RoutedEventArgs e)
|
|
private void Cancel_Click(object sender, RoutedEventArgs e)
|
|
@@ -84,7 +91,7 @@ namespace Compdfkit_Tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI
|
|
DrawinkCanvas.DefaultDrawingAttributes.Color = solidColorBrush.Color;
|
|
DrawinkCanvas.DefaultDrawingAttributes.Color = solidColorBrush.Color;
|
|
InPutTextBox.Foreground = solidColorBrush;
|
|
InPutTextBox.Foreground = solidColorBrush;
|
|
|
|
|
|
- if (CreateSignatureControl.SelectedIndex==1)
|
|
|
|
|
|
+ if (CreateSignatureControl.SelectedIndex == 1)
|
|
{
|
|
{
|
|
InPutTextBox.Focus();
|
|
InPutTextBox.Focus();
|
|
}
|
|
}
|
|
@@ -174,6 +181,7 @@ namespace Compdfkit_Tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
private void SaveTextSignature()
|
|
private void SaveTextSignature()
|
|
{
|
|
{
|
|
if (string.IsNullOrEmpty(InPutTextBox.Text))
|
|
if (string.IsNullOrEmpty(InPutTextBox.Text))
|
|
@@ -182,7 +190,7 @@ namespace Compdfkit_Tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI
|
|
}
|
|
}
|
|
System.Windows.Media.Brush fontcolor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#252629"));
|
|
System.Windows.Media.Brush fontcolor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#252629"));
|
|
fontcolor = TextColorPickerControl.Brush;
|
|
fontcolor = TextColorPickerControl.Brush;
|
|
- Bitmap bmp = TextToBitmap(InPutTextBox.Text, TextName.SelectionBoxItem.ToString(), 50, System.Drawing.Rectangle.Empty, fontcolor, System.Drawing.Color.Transparent);
|
|
|
|
|
|
+ Bitmap bmp = TextToBitmap(InPutTextBox.Text, postScriptName, 50, System.Drawing.Rectangle.Empty, fontcolor, System.Drawing.Color.Transparent);
|
|
string guid = Guid.NewGuid().ToString();
|
|
string guid = Guid.NewGuid().ToString();
|
|
string path = System.IO.Path.Combine(SignaturePath, guid);
|
|
string path = System.IO.Path.Combine(SignaturePath, guid);
|
|
bmp.Save(path, ImageFormat.Png);
|
|
bmp.Save(path, ImageFormat.Png);
|
|
@@ -230,7 +238,7 @@ namespace Compdfkit_Tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI
|
|
double inkThickness;
|
|
double inkThickness;
|
|
inkThickness = StrokeWidth;
|
|
inkThickness = StrokeWidth;
|
|
WriteableBitmap writeStamp = RawPointListToBitmap(RawPointList, inkThickness, DrawinkCanvas.DefaultDrawingAttributes.Color);
|
|
WriteableBitmap writeStamp = RawPointListToBitmap(RawPointList, inkThickness, DrawinkCanvas.DefaultDrawingAttributes.Color);
|
|
- if (writeStamp==null)
|
|
|
|
|
|
+ if (writeStamp == null)
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -343,6 +351,7 @@ namespace Compdfkit_Tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
+
|
|
private Bitmap TextToBitmap(string text, string FontFamily, double size, System.Drawing.Rectangle rect, System.Windows.Media.Brush fontcolor, System.Drawing.Color backColor)
|
|
private Bitmap TextToBitmap(string text, string FontFamily, double size, System.Drawing.Rectangle rect, System.Windows.Media.Brush fontcolor, System.Drawing.Color backColor)
|
|
{
|
|
{
|
|
FormattedText formatText = new FormattedText(
|
|
FormattedText formatText = new FormattedText(
|
|
@@ -377,13 +386,6 @@ namespace Compdfkit_Tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI
|
|
return bitmap;
|
|
return bitmap;
|
|
}
|
|
}
|
|
|
|
|
|
- private void TextName_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
- {
|
|
|
|
- if (TextName.SelectedIndex != -1 && IsPageLoaded)
|
|
|
|
- {
|
|
|
|
- InPutTextBox.FontFamily = new System.Windows.Media.FontFamily((TextName.SelectedItem as ComboBoxItem)?.Content.ToString());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
private void Grid_Drop(object sender, DragEventArgs e)
|
|
private void Grid_Drop(object sender, DragEventArgs e)
|
|
{
|
|
{
|
|
@@ -543,9 +545,21 @@ namespace Compdfkit_Tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void TextName_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
|
+ private void FontNameCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ StyleNameCmb.ItemsSource = CPDFFont.GetFontNameDictionary()[FontNameCmb.SelectedValue.ToString()];
|
|
|
|
+ StyleNameCmb.SelectedIndex = 0;
|
|
|
|
+ CPDFFont.GetPostScriptName(FontNameCmb.SelectedValue.ToString(), StyleNameCmb.SelectedValue.ToString(),ref postScriptName);
|
|
|
|
+ InPutTextBox.FontFamily = new System.Windows.Media.FontFamily(postScriptName);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void StyleNameCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
{
|
|
- InPutTextBox.FontFamily = new System.Windows.Media.FontFamily((TextName.SelectedItem as ComboBoxItem)?.Content.ToString());
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty(StyleNameCmb.SelectedValue?.ToString()))
|
|
|
|
+ {
|
|
|
|
+ CPDFFont.GetPostScriptName(FontNameCmb.SelectedValue.ToString(), StyleNameCmb.SelectedValue.ToString(), ref postScriptName);
|
|
|
|
+ InPutTextBox.FontFamily = new System.Windows.Media.FontFamily(postScriptName);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|