CPDFCreateSignatureDialog.xaml.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. using ComPDFKit.Controls.Data;
  2. using Microsoft.Win32;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Drawing.Imaging;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Globalization;
  15. using System.Windows.Ink;
  16. using ComPDFKit.Controls.Common;
  17. using ComPDFKitViewer.Helper;
  18. using ComPDFKit.PDFDocument;
  19. namespace ComPDFKit.Controls.Annotation.PDFAnnotationPanel.PDFAnnotationUI
  20. {
  21. public partial class CPDFCreateSignatureDialog : Window
  22. {
  23. SolidColorBrush solidColorBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
  24. public CPDFSignatureData cPDFSignatureData;
  25. private string SaveToPath;
  26. private string SignaturePath;
  27. private string DrawingSaveToPath;
  28. private double StrokeWidth = 3;
  29. private double StrokeHigh = 3;
  30. private bool IsPageLoaded = false;
  31. private string postScriptName;
  32. public CPDFCreateSignatureDialog()
  33. {
  34. InitializeComponent();
  35. }
  36. private void Window_Loaded(object sender, RoutedEventArgs e)
  37. {
  38. SignaturePath = System.IO.Path.Combine(Environment.CurrentDirectory, "ComPDFKit");
  39. SignaturePath = System.IO.Path.Combine(SignaturePath, "Signature");
  40. System.IO.DirectoryInfo directoryInfo = System.IO.Directory.CreateDirectory(SignaturePath);
  41. IsPageLoaded = true;
  42. DrawinkCanvas.DefaultDrawingAttributes.Width = StrokeWidth;
  43. DrawinkCanvas.DefaultDrawingAttributes.Height = StrokeHigh;
  44. DrawinkCanvas.DefaultDrawingAttributes.Color = solidColorBrush.Color;
  45. InPutTextBox.Foreground = solidColorBrush;
  46. FontNameCmb.Items.Clear();
  47. FontNameCmb.ItemsSource = CPDFFont.GetFontNameDictionary().Keys;
  48. }
  49. private void Cancel_Click(object sender, RoutedEventArgs e)
  50. {
  51. this.Close();
  52. }
  53. private void Save_Click(object sender, RoutedEventArgs e)
  54. {
  55. switch (CreateSignatureControl.SelectedIndex)
  56. {
  57. case 0:
  58. SaveDrawSignature();
  59. break;
  60. case 1:
  61. SaveTextSignature();
  62. break;
  63. case 2:
  64. SaveImageSignature();
  65. break;
  66. default:
  67. break;
  68. }
  69. this.Close();
  70. }
  71. private void Clear_Click(object sender, RoutedEventArgs e)
  72. {
  73. ColorPickerControl.SetIsChecked(1);
  74. TextColorPickerControl.SetIsChecked(1);
  75. DrawinkCanvas.Strokes.Clear();
  76. InPutTextBox.Text = "";
  77. ImageImage.Source = null;
  78. AddImageBackground.Visibility = Visibility.Visible;
  79. SaveBtn.IsEnabled = false;
  80. DrawinkCanvas.DefaultDrawingAttributes.Color = solidColorBrush.Color;
  81. InPutTextBox.Foreground = solidColorBrush;
  82. if (CreateSignatureControl.SelectedIndex == 1)
  83. {
  84. InPutTextBox.Focus();
  85. }
  86. }
  87. private void UpDateToStrokesObject()
  88. {
  89. foreach (var item in DrawinkCanvas.Strokes)
  90. {
  91. item.DrawingAttributes = DrawinkCanvas.DefaultDrawingAttributes.Clone();
  92. }
  93. }
  94. private void SaveToImage(string FilePath)
  95. {
  96. string path = SignaturePath;
  97. string name = Guid.NewGuid().ToString();
  98. if (!string.IsNullOrEmpty(path))
  99. {
  100. try
  101. {
  102. BitmapImage image = new BitmapImage(new Uri(FilePath));
  103. double scale = Math.Min((double)600 / image.PixelWidth, (double)600 / image.PixelHeight);
  104. scale = Math.Min(scale, 1);
  105. BitmapEncoder encoder = new PngBitmapEncoder();
  106. var targetBitmap = new TransformedBitmap(image, new ScaleTransform(scale, scale));
  107. encoder.Frames.Add(BitmapFrame.Create(targetBitmap));
  108. path = System.IO.Path.Combine(path, name);
  109. using (FileStream stream = new FileStream(path, FileMode.Create))
  110. {
  111. encoder.Save(stream);
  112. }
  113. if (!string.IsNullOrEmpty(SaveToPath))
  114. {
  115. DirectoryInfo CreatedFilePathFolder = new DirectoryInfo(SaveToPath);
  116. if (CreatedFilePathFolder.Exists)
  117. {
  118. Directory.Delete(SaveToPath, true);
  119. }
  120. }
  121. SaveToPath = path;
  122. AddImageBackground.Visibility = Visibility.Collapsed;
  123. ImageImage.Source = targetBitmap;
  124. SaveBtn.IsEnabled = true;
  125. }
  126. catch
  127. {
  128. }
  129. }
  130. else
  131. {
  132. SaveToPath = "";
  133. }
  134. }
  135. private void OpenImage_Click(object sender, RoutedEventArgs e)
  136. {
  137. OpenFileDialog openFile = new OpenFileDialog();
  138. openFile.Filter = "All Image Files(*.bmp;*.gif;*.jpeg;*.jpg;*.png;*.tiff)|*.bmp;*.gif;*.jpeg;*.jpg;*.png;*.tiff|(*.bmp)|*.bmp|" +
  139. "(*.gif)|*.gif|" +
  140. "(*.jpeg)|*.jpeg|" +
  141. "(*.jpg)|*.jpg|" +
  142. "(*.png)|*.png|" +
  143. "(*.tiff)|*.tiff";
  144. if (openFile.ShowDialog() == false)
  145. {
  146. return;
  147. }
  148. SaveToImage(openFile.FileName);
  149. }
  150. private void ColorPickerControl_ColorChanged(object sender, EventArgs e)
  151. {
  152. if (IsPageLoaded)
  153. {
  154. DrawinkCanvas.DefaultDrawingAttributes.Color = ((SolidColorBrush)ColorPickerControl.Brush).Color;
  155. UpDateToStrokesObject();
  156. }
  157. }
  158. private void TextColorPickerControl_ColorChanged(object sender, EventArgs e)
  159. {
  160. if (IsPageLoaded)
  161. {
  162. InPutTextBox.Foreground = TextColorPickerControl.Brush;
  163. }
  164. }
  165. private void SaveTextSignature()
  166. {
  167. if (string.IsNullOrEmpty(InPutTextBox.Text))
  168. {
  169. return;
  170. }
  171. System.Windows.Media.Brush fontcolor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#252629"));
  172. fontcolor = TextColorPickerControl.Brush;
  173. Bitmap bmp = TextToBitmap(InPutTextBox.Text, postScriptName, 50, System.Drawing.Rectangle.Empty, fontcolor, System.Drawing.Color.Transparent);
  174. string guid = Guid.NewGuid().ToString();
  175. string path = System.IO.Path.Combine(SignaturePath, guid);
  176. bmp.Save(path, ImageFormat.Png);
  177. SaveToPath = path;
  178. cPDFSignatureData = new CPDFSignatureData();
  179. cPDFSignatureData.SourcePath = SaveToPath;
  180. cPDFSignatureData.AnnotationType = CPDFAnnotationType.Signature;
  181. cPDFSignatureData.Type = SignatureType.TextType;
  182. }
  183. private void SaveImageSignature()
  184. {
  185. cPDFSignatureData = new CPDFSignatureData();
  186. cPDFSignatureData.SourcePath = SaveToPath;
  187. cPDFSignatureData.AnnotationType = CPDFAnnotationType.Signature;
  188. cPDFSignatureData.Type = SignatureType.ImageType;
  189. }
  190. private void SaveDrawSignature()
  191. {
  192. var FreeHandpath = SignaturePath;
  193. string name = Guid.NewGuid().ToString();
  194. FreeHandpath = System.IO.Path.Combine(FreeHandpath, name);
  195. using (System.IO.FileStream stream = new System.IO.FileStream(FreeHandpath, System.IO.FileMode.Create))
  196. {
  197. DrawinkCanvas.Strokes.Save(stream);
  198. }
  199. List<List<System.Windows.Point>> RawPointList = new List<List<System.Windows.Point>>();
  200. for (int kk = 0; kk < DrawinkCanvas.Strokes.Count; kk++)
  201. {
  202. List<System.Windows.Point> p = new List<System.Windows.Point>();
  203. RawPointList.Add(p);
  204. for (int gg = 0; gg < DrawinkCanvas.Strokes[kk].StylusPoints.Count; gg++)
  205. {
  206. var point = DrawinkCanvas.Strokes[kk].StylusPoints[gg].ToPoint();
  207. if (point.X >= 0 && point.Y >= 0)
  208. RawPointList[kk].Add(point);
  209. }
  210. }
  211. DrawingSaveToPath = FreeHandpath;
  212. double inkThickness;
  213. inkThickness = StrokeWidth;
  214. WriteableBitmap writeStamp = RawPointListToBitmap(RawPointList, inkThickness, DrawinkCanvas.DefaultDrawingAttributes.Color);
  215. if (writeStamp == null)
  216. {
  217. return;
  218. }
  219. FreeHandpath = SignaturePath;
  220. string thumbnailName = Guid.NewGuid().ToString();
  221. FreeHandpath = System.IO.Path.Combine(FreeHandpath, thumbnailName);
  222. using (FileStream stream5 = new FileStream(FreeHandpath, FileMode.Create))
  223. {
  224. PngBitmapEncoder encoder5 = new PngBitmapEncoder();
  225. encoder5.Frames.Add(BitmapFrame.Create(writeStamp));
  226. encoder5.Save(stream5);
  227. }
  228. SaveToPath = FreeHandpath;
  229. cPDFSignatureData = new CPDFSignatureData();
  230. cPDFSignatureData.AnnotationType = CPDFAnnotationType.Signature;
  231. cPDFSignatureData.SourcePath = SaveToPath;
  232. cPDFSignatureData.DrawingPath = DrawingSaveToPath;
  233. cPDFSignatureData.Type = SignatureType.Drawing;
  234. cPDFSignatureData.inkThickness = inkThickness;
  235. cPDFSignatureData.inkColor = DrawinkCanvas.DefaultDrawingAttributes.Color;
  236. }
  237. private WriteableBitmap RawPointListToBitmap(List<List<System.Windows.Point>> RawPointList, double InkThickness, System.Windows.Media.Color InkColor)
  238. {
  239. if (RawPointList != null && RawPointList.Count > 0)
  240. {
  241. GeometryGroup PaintGeomtry = new GeometryGroup();
  242. int minLeft = -1;
  243. int minTop = -1;
  244. int maxLeft = -1;
  245. int maxTop = -1;
  246. foreach (List<System.Windows.Point> Item in RawPointList)
  247. {
  248. for (int i = 0; i < Item.Count; i++)
  249. {
  250. System.Windows.Point paintPoint = Item[i];
  251. if (minLeft == -1)
  252. {
  253. minLeft = (int)paintPoint.X;
  254. maxLeft = (int)paintPoint.X;
  255. minTop = (int)paintPoint.Y;
  256. maxTop = (int)paintPoint.Y;
  257. }
  258. else
  259. {
  260. minLeft = (int)Math.Min(minLeft, paintPoint.X);
  261. maxLeft = (int)Math.Max(maxLeft, paintPoint.X);
  262. minTop = (int)Math.Min(minTop, paintPoint.Y);
  263. maxTop = (int)Math.Max(maxTop, paintPoint.Y);
  264. }
  265. }
  266. }
  267. if (minLeft >= 0 && maxLeft > minLeft && minTop >= 0 && maxTop > minTop)
  268. {
  269. List<List<System.Windows.Point>> points = new List<List<System.Windows.Point>>();
  270. foreach (List<System.Windows.Point> Item in RawPointList)
  271. {
  272. PathGeometry PaintPath = new PathGeometry();
  273. PathFigureCollection Figures = new PathFigureCollection();
  274. PathFigure AddFigure = new PathFigure();
  275. Figures.Add(AddFigure);
  276. PaintPath.Figures = Figures;
  277. PaintGeomtry.Children.Add(PaintPath);
  278. List<System.Windows.Point> changeList = new List<System.Windows.Point>();
  279. for (int i = 0; i < Item.Count; i++)
  280. {
  281. System.Windows.Point paintPoint = DpiHelper.CurrentPointToStandardPoint(new System.Windows.Point(Item[i].X - minLeft, Item[i].Y - minTop));
  282. changeList.Add(paintPoint);
  283. if (i == 0)
  284. {
  285. AddFigure.StartPoint = paintPoint;
  286. }
  287. else
  288. {
  289. LineSegment AddSegment = new LineSegment();
  290. AddSegment.Point = paintPoint;
  291. AddFigure.Segments.Add(AddSegment);
  292. }
  293. }
  294. if (changeList.Count > 0)
  295. {
  296. points.Add(changeList);
  297. }
  298. }
  299. int drawWidth = (int)DpiHelper.CurrentNumToStandardNum(maxLeft - minLeft);
  300. int drawHeight = (int)DpiHelper.CurrentNumToStandardNum(maxTop - minTop);
  301. RawPointList = points;
  302. DrawingVisual copyVisual = new DrawingVisual();
  303. DrawingContext copyContext = copyVisual.RenderOpen();
  304. System.Windows.Media.Pen drawPen = new System.Windows.Media.Pen(new SolidColorBrush(InkColor), InkThickness);
  305. copyContext?.DrawGeometry(null, drawPen, PaintGeomtry);
  306. copyContext.Close();
  307. RenderTargetBitmap targetBitmap = new RenderTargetBitmap(drawWidth, drawHeight, 96, 96, PixelFormats.Pbgra32);
  308. targetBitmap.Render(copyVisual);
  309. byte[] ImageArray = new byte[targetBitmap.PixelWidth * targetBitmap.PixelHeight * 4];
  310. targetBitmap.CopyPixels(new Int32Rect(0, 0, (int)targetBitmap.PixelWidth, (int)targetBitmap.PixelHeight), ImageArray, targetBitmap.PixelWidth * 4, 0);
  311. WriteableBitmap writeBitmap = new WriteableBitmap(targetBitmap.PixelWidth, targetBitmap.PixelHeight, 96, 96, PixelFormats.Bgra32, null);
  312. writeBitmap.WritePixels(new Int32Rect(0, 0, targetBitmap.PixelWidth, targetBitmap.PixelHeight), ImageArray, targetBitmap.PixelWidth * 4, 0);
  313. return writeBitmap;
  314. }
  315. }
  316. return null;
  317. }
  318. private Bitmap TextToBitmap(string text, string FontFamily, double size, System.Drawing.Rectangle rect, System.Windows.Media.Brush fontcolor, System.Drawing.Color backColor)
  319. {
  320. FormattedText formatText = new FormattedText(
  321. text,
  322. CultureInfo.CurrentCulture,
  323. FlowDirection.LeftToRight,
  324. new Typeface(new System.Windows.Media.FontFamily(FontFamily), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal),
  325. size,
  326. fontcolor
  327. );
  328. DrawingVisual drawingVisual = new DrawingVisual();
  329. DrawingContext dc = drawingVisual.RenderOpen();
  330. dc.DrawText(formatText, new System.Windows.Point(2, 10));
  331. dc.Close();
  332. Rect x = drawingVisual.ContentBounds;
  333. Rect DrawRect = new Rect(0, 0, x.Width + (x.X / 2), x.Height + x.Y);
  334. RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap((int)((int)DrawRect.Width + (x.X / 2)), (int)((int)DrawRect.Height + x.Y), 96F, 96F, PixelFormats.Pbgra32);
  335. renderTargetBitmap.Render(drawingVisual);
  336. MemoryStream stream = new MemoryStream();
  337. BitmapEncoder encoder = new PngBitmapEncoder();
  338. encoder.Frames.Add(BitmapFrame.Create(renderTargetBitmap));
  339. encoder.Save(stream);
  340. Bitmap bitmap = new Bitmap(stream);
  341. return bitmap;
  342. }
  343. private void Grid_Drop(object sender, DragEventArgs e)
  344. {
  345. string[] file = (string[])e.Data.GetData(DataFormats.FileDrop);
  346. foreach (string f in file)
  347. {
  348. string FileType = System.IO.Path.GetExtension(f).Trim().ToLower();
  349. string type = "*.bmp;*.gif;*.jpeg;*.jpg;*.png;*.tiff)|*.bmp;*.gif;*.jpeg;*.jpg;*.png;*.tiff";
  350. if (!string.IsNullOrEmpty(FileType))
  351. {
  352. string imagetype = "*" + FileType;
  353. string[] x = type.ToLower().Split(';');
  354. List<string> list = x.ToList();
  355. int imageindex = list.IndexOf(imagetype);
  356. if (imageindex > 0)
  357. {
  358. SaveToImage(f);
  359. }
  360. }
  361. }
  362. }
  363. private void CreateSignatureControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
  364. {
  365. TabControl tabControl = sender as TabControl;
  366. if (IsPageLoaded && tabControl != null)
  367. {
  368. switch (tabControl.SelectedIndex)
  369. {
  370. case 0:
  371. if (DrawinkCanvas.Strokes.Count <= 0)
  372. {
  373. SaveBtn.IsEnabled = false;
  374. }
  375. else
  376. {
  377. SaveBtn.IsEnabled = true;
  378. }
  379. break;
  380. case 1:
  381. if (string.IsNullOrEmpty(InPutTextBox.Text))
  382. {
  383. SaveBtn.IsEnabled = false;
  384. }
  385. else
  386. {
  387. SaveBtn.IsEnabled = true;
  388. }
  389. break;
  390. case 2:
  391. if (ImageImage.Source == null)
  392. {
  393. SaveBtn.IsEnabled = false;
  394. }
  395. else
  396. {
  397. SaveBtn.IsEnabled = true;
  398. }
  399. break;
  400. default:
  401. break;
  402. }
  403. }
  404. }
  405. private void InPutTextBox_TextChanged(object sender, TextChangedEventArgs e)
  406. {
  407. if (IsPageLoaded)
  408. {
  409. if (string.IsNullOrEmpty((sender as TextBox).Text))
  410. {
  411. SaveBtn.IsEnabled = false;
  412. }
  413. else
  414. {
  415. SaveBtn.IsEnabled = true;
  416. }
  417. }
  418. }
  419. private void ImageImage_SourceUpdated(object sender, DataTransferEventArgs e)
  420. {
  421. if (IsPageLoaded)
  422. {
  423. if (ImageImage.Source == null)
  424. {
  425. SaveBtn.IsEnabled = false;
  426. }
  427. else
  428. {
  429. SaveBtn.IsEnabled = true;
  430. }
  431. }
  432. }
  433. private void DrawinkCanvas_Unloaded(object sender, RoutedEventArgs e)
  434. {
  435. DrawinkCanvas.Strokes.StrokesChanged -= Strokes_StrokesChanged;
  436. }
  437. private void DrawinkCanvas_Loaded(object sender, RoutedEventArgs e)
  438. {
  439. DrawinkCanvas.Strokes.StrokesChanged -= Strokes_StrokesChanged;
  440. DrawinkCanvas.Strokes.StrokesChanged += Strokes_StrokesChanged;
  441. }
  442. private void Strokes_StrokesChanged(object sender, StrokeCollectionChangedEventArgs e)
  443. {
  444. if (IsPageLoaded)
  445. {
  446. if (DrawinkCanvas.Strokes.Count <= 0)
  447. {
  448. SaveBtn.IsEnabled = false;
  449. }
  450. else
  451. {
  452. SaveBtn.IsEnabled = true;
  453. }
  454. }
  455. }
  456. private void StrokeWidth_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
  457. {
  458. if (IsPageLoaded)
  459. {
  460. DrawinkCanvas.DefaultDrawingAttributes.Height = DrawinkCanvas.DefaultDrawingAttributes.Width = StrokeHigh = StrokeWidth = e.NewValue;
  461. UpDateToStrokesObject();
  462. }
  463. }
  464. private void ColorPickerControl_Loaded(object sender, RoutedEventArgs e)
  465. {
  466. ColorPickerControl.SetIsChecked(1);
  467. }
  468. private void TextColorPickerControl_Loaded(object sender, RoutedEventArgs e)
  469. {
  470. TextColorPickerControl.SetIsChecked(1);
  471. }
  472. private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
  473. {
  474. if (!string.IsNullOrEmpty((sender as TextBox).Text))
  475. {
  476. int num;
  477. int.TryParse((sender as TextBox).Text, out num);
  478. if (num > StrokeWidthSlider.Maximum)
  479. {
  480. (sender as TextBox).Text = StrokeWidthSlider.Maximum.ToString();
  481. }
  482. if (num < StrokeWidthSlider.Minimum)
  483. {
  484. (sender as TextBox).Text = StrokeWidthSlider.Minimum.ToString();
  485. }
  486. }
  487. }
  488. private void FontNameCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
  489. {
  490. //StyleNameCmb.ItemsSource = CPDFFont.GetFontNameDictionary()[FontNameCmb.SelectedValue.ToString()];
  491. StyleNameCmb.SelectedIndex = 0;
  492. CPDFFont.GetPostScriptName(FontNameCmb.SelectedValue.ToString(), StyleNameCmb.SelectedValue.ToString(),ref postScriptName);
  493. InPutTextBox.FontFamily = new System.Windows.Media.FontFamily(postScriptName);
  494. }
  495. private void StyleNameCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
  496. {
  497. if (!string.IsNullOrEmpty(StyleNameCmb.SelectedValue?.ToString()))
  498. {
  499. InPutTextBox.FontStyle = GetFontStyle(StyleNameCmb.SelectedValue.ToString());
  500. InPutTextBox.FontWeight = GetFontWeight(StyleNameCmb.SelectedValue.ToString());
  501. }
  502. }
  503. private FontWeight GetFontWeight(string toString)
  504. {
  505. switch (toString)
  506. {
  507. case "Regular":
  508. return FontWeights.Normal;
  509. case "Oblique":
  510. return FontWeights.Normal;
  511. case "Bold":
  512. return FontWeights.Bold;
  513. case "BoldOblique":
  514. return FontWeights.Bold;
  515. default:
  516. return FontWeights.Normal;
  517. }
  518. }
  519. private System.Windows.FontStyle GetFontStyle(string style)
  520. {
  521. switch (style)
  522. {
  523. case "Regular":
  524. return FontStyles.Normal;
  525. case "Oblique":
  526. return FontStyles.Italic;
  527. case "Bold":
  528. return FontStyles.Normal;
  529. case "BoldOblique":
  530. return FontStyles.Oblique;
  531. default:
  532. return FontStyles.Normal;
  533. }
  534. }
  535. }
  536. }