FillDigitalSignatureControl.xaml.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. using ComPDFKit.DigitalSign;
  2. using ComPDFKit.Import;
  3. using ComPDFKit.PDFAnnotation;
  4. using ComPDFKit.PDFAnnotation.Form;
  5. using ComPDFKit.PDFDocument;
  6. using ComPDFKit.PDFPage;
  7. using Compdfkit_Tools.Helper;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Drawing;
  11. using System.Drawing.Imaging;
  12. using System.IO;
  13. using System.Reflection;
  14. using System.Runtime.Remoting.Messaging;
  15. using System.Text;
  16. using System.Windows;
  17. using System.Windows.Controls;
  18. using System.Windows.Controls.Primitives;
  19. using System.Windows.Ink;
  20. using System.Windows.Input;
  21. using System.Windows.Media;
  22. using System.Windows.Media.Imaging;
  23. using static System.Windows.Forms.VisualStyles.VisualStyleElement;
  24. using Color = System.Drawing.Color;
  25. using Pen = System.Windows.Media.Pen;
  26. using PixelFormat = System.Windows.Media.PixelFormat;
  27. using Point = System.Windows.Point;
  28. using Window = System.Windows.Window;
  29. namespace Compdfkit_Tools.PDFControl
  30. {
  31. /// <summary>
  32. /// Interaction logic for CPDFSignControl.xaml
  33. /// </summary>
  34. public partial class FillDigitalSignatureControl : UserControl
  35. {
  36. private readonly string logoPath = "Logo_opa40.png";
  37. private string imagePath = string.Empty;
  38. private string Text = string.Empty;
  39. private Dictionary<string, Border> TabDict { get; set; }
  40. private CPDFSignatureConfig tempSignatureConfig = new CPDFSignatureConfig();
  41. private CPDFSignatureCertificate signatureCertificate;
  42. public CPDFDocument Document;
  43. private string signatureName = string.Empty;
  44. private string location = string.Empty;
  45. private string reason = string.Empty;
  46. private float[] textColor = new float[] { 0, 0, 0 };
  47. private string _signaturePath = string.Empty;
  48. public string SignaturePath
  49. {
  50. get => _signaturePath;
  51. set
  52. {
  53. _signaturePath = value;
  54. }
  55. }
  56. private string _password = string.Empty;
  57. public string Password
  58. {
  59. get => _password;
  60. set
  61. {
  62. _password = value;
  63. signatureCertificate = CPDFPKCS12CertHelper.GetCertificateWithPKCS12Path(SignaturePath, Password);
  64. signatureName = DictionaryValueConverter.GetGrantorFromDictionary(signatureCertificate.SubjectDict);
  65. tempSignatureConfig.Text = signatureName;
  66. InitTempSignature();
  67. }
  68. }
  69. private void InitTempSignature()
  70. {
  71. NameChk.IsChecked = true;
  72. DateChk.IsChecked = true;
  73. LogoChk.IsChecked = true;
  74. TabChk.IsChecked = true;
  75. SetProperty();
  76. CreateTempSignature();
  77. KeyboardInPutTextBox.Text = signatureName;
  78. }
  79. public CPDFSignatureWidget signatureWidget { get; set; }
  80. public event EventHandler<string> AfterFillSignature;
  81. public FillDigitalSignatureControl()
  82. {
  83. InitializeComponent();
  84. TabDict = new Dictionary<string, Border>
  85. {
  86. ["Keyboard"] = KeyboardBorder,
  87. ["Trackpad"] = TrackpadBorder,
  88. ["Image"] = ImageBorder,
  89. ["None"] = NoneBorder
  90. };
  91. SetCheckedTab("Keyboard");
  92. ReasonCmb.SelectedIndex = 0;
  93. }
  94. private void CreateTempSignature()
  95. {
  96. CPDFDocument tempDocument = CPDFDocument.CreateDocument();
  97. tempDocument.InsertPage(0, 200, 200, string.Empty);
  98. CPDFPage page = tempDocument.PageAtIndex(0);
  99. CPDFSignatureWidget signatureWidget = page.CreateWidget(C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS) as CPDFSignatureWidget;
  100. signatureWidget.SetRect(new CRect(0, 100, 300, 0));
  101. tempSignatureConfig.IsDrawLogo = (bool)LogoChk.IsChecked;
  102. if (tempSignatureConfig.IsDrawLogo)
  103. {
  104. using (FileStream fileData = File.OpenRead(logoPath))
  105. {
  106. BitmapFrame frame = null;
  107. BitmapDecoder decoder = BitmapDecoder.Create(fileData, BitmapCreateOptions.None, BitmapCacheOption.Default);
  108. if (decoder != null && decoder.Frames.Count > 0)
  109. {
  110. frame = decoder.Frames[0];
  111. }
  112. if (frame != null)
  113. {
  114. byte[] imageArray = new byte[frame.PixelWidth * frame.PixelHeight * 4];
  115. //int ImageWidth = frame.PixelWidth;
  116. //int ImageHeight = frame.PixelHeight;
  117. frame.CopyPixels(imageArray, frame.PixelWidth * 4, 0);
  118. if(signatureWidget.IsValid())
  119. {
  120. tempSignatureConfig.LogoData = imageArray;
  121. //signatureWidget.UpdateApWithImage(ImageArray, ImageWidth, ImageHeight, C_Scale_Type.fitCenter, 0);
  122. }
  123. }
  124. }
  125. //tempSignatureConfig.LogoData = CommonHelper.ConvertBitmapToByteArray(new Bitmap(logoPath));
  126. }
  127. tempSignatureConfig.Content = Text;
  128. tempSignatureConfig.TextColor = textColor;
  129. tempSignatureConfig.ContentColor = new float[] { 0, 0, 0 };
  130. signatureWidget.UpdataApWithSignature(tempSignatureConfig);
  131. byte[] signatureBitmapBytes = GetTempSignatureImage(signatureWidget, out int width, out int height);
  132. signatureWidget.ReleaseAnnot();
  133. if (signatureBitmapBytes.Length > 0)
  134. {
  135. PixelFormat fmt = PixelFormats.Bgra32;
  136. BitmapSource bps = BitmapSource.Create(width, height, 96, 96, fmt, null, signatureBitmapBytes, (width * fmt.BitsPerPixel + 7) / 8);
  137. imageControl.Source = bps;
  138. }
  139. else
  140. {
  141. imageControl.Source = null;
  142. }
  143. }
  144. public static byte[] GetTempSignatureImage(CPDFSignatureWidget signatureWidget, out int width, out int height)
  145. {
  146. CRect rect = signatureWidget.GetRect();
  147. var flags = BindingFlags.NonPublic | BindingFlags.Static;
  148. var dpiProperty = typeof(SystemParameters).GetProperty("Dpi", flags);
  149. int dpi = (int)dpiProperty.GetValue(null, null);
  150. width = (int)(rect.width() * dpi / 72D * 2);
  151. height = (int)(rect.height() * dpi / 72D * 2);
  152. byte[] imageData = new byte[width * height * 4];
  153. signatureWidget.RenderAnnot(width, height, imageData, CPDFAppearanceType.Normal);
  154. return imageData;
  155. }
  156. private void TextAlignBtn_Click(object sender, RoutedEventArgs e)
  157. {
  158. ToggleButton checkBtn = sender as ToggleButton;
  159. if (checkBtn == null)
  160. {
  161. return;
  162. }
  163. checkBtn.IsChecked = true;
  164. if (checkBtn != TextAlignLeftBtn)
  165. {
  166. tempSignatureConfig.IsContentAlignLeft = true;
  167. TextAlignLeftBtn.IsChecked = false;
  168. }
  169. if (checkBtn != TextAlignRightBtn)
  170. {
  171. tempSignatureConfig.IsContentAlignLeft = false;
  172. TextAlignRightBtn.IsChecked = false;
  173. }
  174. CreateTempSignature();
  175. }
  176. private void Border_MouseDown(object sender, MouseButtonEventArgs e)
  177. {
  178. Border clickBorder = sender as Border;
  179. if (clickBorder == null || clickBorder.Tag == null)
  180. {
  181. return;
  182. }
  183. SetCheckedTab(clickBorder.Tag.ToString());
  184. ImagePickPanel.Visibility = Visibility.Hidden;
  185. if (clickBorder == NoneBorder)
  186. {
  187. tempSignatureConfig.IsDrawOnlyContent = true;
  188. }
  189. else
  190. {
  191. tempSignatureConfig.IsDrawOnlyContent = false;
  192. if (clickBorder == KeyboardBorder)
  193. {
  194. tempSignatureConfig.Text = signatureName;
  195. //tempSignatureConfig.ImageBitmap = null;
  196. KeyboardPopup.Visibility = Visibility.Visible;
  197. }
  198. else
  199. {
  200. tempSignatureConfig.Text = string.Empty;
  201. if (clickBorder == TrackpadBorder)
  202. {
  203. CanvaDrawPopup.Visibility = Visibility.Visible;
  204. }
  205. else if (clickBorder == ImageBorder)
  206. {
  207. ImagePickPanel.Visibility = Visibility.Visible;
  208. if (!string.IsNullOrEmpty(imagePath))
  209. {
  210. //tempSignatureConfig.ImageBitmap = new Bitmap(imagePath);
  211. }
  212. }
  213. }
  214. }
  215. SetProperty();
  216. CreateTempSignature();
  217. }
  218. private void SetCheckedTab(string tab)
  219. {
  220. if (TabDict != null && TabDict.ContainsKey(tab))
  221. {
  222. foreach (string key in TabDict.Keys)
  223. {
  224. Border checkBorder = TabDict[key];
  225. if (checkBorder == null)
  226. {
  227. continue;
  228. }
  229. checkBorder.BorderThickness = new Thickness(0);
  230. if (key == tab)
  231. {
  232. checkBorder.BorderThickness = new Thickness(0, 0, 0, 2);
  233. }
  234. }
  235. }
  236. }
  237. private void CanvasPopupClose_Click(object sender, RoutedEventArgs e)
  238. {
  239. CanvaDrawPopup.Visibility = Visibility.Collapsed;
  240. }
  241. private void CanvasClearBtn_Click(object sender, RoutedEventArgs e)
  242. {
  243. DrawInkCanvas.Strokes.Clear();
  244. }
  245. private void CanvasPopupConfirm_Click(object sender, RoutedEventArgs e)
  246. {
  247. //tempSignatureConfig.ImageBitmap = GetDrawInk();
  248. CanvaDrawPopup.Visibility = Visibility.Collapsed;
  249. SetProperty();
  250. CreateTempSignature();
  251. }
  252. public Bitmap GetDrawInk()
  253. {
  254. if (DrawInkCanvas != null && DrawInkCanvas.Strokes != null && DrawInkCanvas.Strokes.Count > 0)
  255. {
  256. Rect bound = DrawInkCanvas.Strokes.GetBounds();
  257. DrawingVisual drawVisual = new DrawingVisual();
  258. DrawingContext drawContext = drawVisual.RenderOpen();
  259. foreach (Stroke drawStroke in DrawInkCanvas.Strokes)
  260. {
  261. Pen drawPen = new Pen(new SolidColorBrush(drawStroke.DrawingAttributes.Color), drawStroke.DrawingAttributes.Width);
  262. PathGeometry drawPath = new PathGeometry();
  263. PathFigureCollection Figures = new PathFigureCollection();
  264. PathFigure AddFigure = new PathFigure();
  265. Figures.Add(AddFigure);
  266. drawPath.Figures = Figures;
  267. if (drawStroke.StylusPoints.Count > 1)
  268. {
  269. StylusPoint startPoint = drawStroke.StylusPoints[0];
  270. AddFigure.StartPoint = new Point(startPoint.X - bound.X, startPoint.Y - bound.Y);
  271. for (int i = 1; i < drawStroke.StylusPoints.Count; i++)
  272. {
  273. StylusPoint drawPoint = drawStroke.StylusPoints[i];
  274. Point offsetPoint = new Point(drawPoint.X - bound.X, drawPoint.Y - bound.Y);
  275. LineSegment drawSegment = new LineSegment();
  276. drawSegment.Point = offsetPoint;
  277. AddFigure.Segments.Add(drawSegment);
  278. }
  279. }
  280. if (AddFigure.Segments.Count > 0)
  281. {
  282. drawContext.DrawGeometry(null, drawPen, drawPath);
  283. }
  284. }
  285. drawContext.Close();
  286. RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)bound.Width, (int)bound.Height, 96, 96, PixelFormats.Pbgra32);
  287. renderBitmap.Render(drawVisual);
  288. BitmapFrame newFrame = BitmapFrame.Create(renderBitmap);
  289. PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
  290. pngEncoder.Frames.Add(newFrame);
  291. using (MemoryStream newStream = new MemoryStream())
  292. {
  293. pngEncoder.Save(newStream);
  294. return new Bitmap(newStream);
  295. }
  296. }
  297. else
  298. {
  299. return null;
  300. }
  301. }
  302. private void SetProperty()
  303. {
  304. Text = string.Empty;
  305. if ((bool)NameChk.IsChecked)
  306. {
  307. if ((bool)TabChk.IsChecked)
  308. {
  309. Text += "Name: ";
  310. }
  311. Text += DictionaryValueConverter.GetGrantorFromDictionary(signatureCertificate.SubjectDict) + "\n";
  312. }
  313. if ((bool)DateChk.IsChecked)
  314. {
  315. if ((bool)TabChk.IsChecked)
  316. {
  317. Text += "Date: ";
  318. }
  319. DateTime currentDateTime = DateTime.Now;
  320. string customFormat = "yyyy.MM.dd HH:mm:ss";
  321. string formattedDateTime = currentDateTime.ToString(customFormat);
  322. Text += formattedDateTime + "\n";
  323. }
  324. if ((bool)LogoChk.IsChecked)
  325. {
  326. tempSignatureConfig.IsDrawLogo = true;
  327. }
  328. else
  329. {
  330. tempSignatureConfig.IsDrawLogo = false;
  331. }
  332. if ((bool)ReasonChk.IsChecked)
  333. {
  334. if ((bool)TabChk.IsChecked)
  335. {
  336. Text += "Reason: ";
  337. }
  338. Text += (ReasonCmb.SelectedItem as ComboBoxItem).Content.ToString() + "\n";
  339. }
  340. if ((bool)DistinguishableNameChk.IsChecked)
  341. {
  342. if ((bool)TabChk.IsChecked)
  343. {
  344. Text += "DN: ";
  345. }
  346. var keyOrder = new List<string> { "CN", "O", "OU", "emailAddress", "L", "ST", "C" };
  347. var keyMapping = new Dictionary<string, string>
  348. {
  349. { "CN", "cn" },
  350. { "OU", "ou" },
  351. { "O", "o" },
  352. { "L", "l" },
  353. { "ST", "st" },
  354. { "C", "c" },
  355. { "emailAddress", "email" }
  356. };
  357. var stringBuilder = new StringBuilder();
  358. foreach (var originalKey in keyOrder)
  359. {
  360. if (keyMapping.TryGetValue(originalKey, out string newKey) &&
  361. signatureCertificate.SubjectDict.TryGetValue(originalKey, out string value) && !string.IsNullOrEmpty(value))
  362. {
  363. if (stringBuilder.Length > 0)
  364. {
  365. stringBuilder.Append(",");
  366. }
  367. stringBuilder.Append(newKey + "=" + value);
  368. }
  369. }
  370. Text += stringBuilder.ToString()+"\n";
  371. }
  372. if ((bool)ComPDFKitVersionChk.IsChecked)
  373. {
  374. Assembly assembly = Assembly.GetExecutingAssembly();
  375. Version version = assembly.GetName().Version;
  376. if ((bool)TabChk.IsChecked)
  377. {
  378. Text += "ComPDFKit Version: ";
  379. }
  380. Text += version.Major.ToString() + "." + version.Minor.ToString() + "." + version.Build.ToString() + "." + version.Revision.ToString() + "\n";
  381. }
  382. if ((bool)PositionChk.IsChecked)
  383. {
  384. if ((bool)TabChk.IsChecked)
  385. {
  386. Text += "Position: ";
  387. }
  388. Text += PositionTbx.Text + "\n";
  389. }
  390. }
  391. private void ReasonCheckBox_Click(object sender, RoutedEventArgs e)
  392. {
  393. CheckBox checkItem = sender as CheckBox;
  394. if (checkItem == null)
  395. {
  396. return;
  397. }
  398. ReasonPanel.Visibility = checkItem.IsChecked == true ? Visibility.Visible : Visibility.Collapsed;
  399. }
  400. private void BrowseTxt_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  401. {
  402. string filter = "Image files (*.jpg, *.jpeg, *.png, *.bmp)|*.jpg;*.jpeg;*.png;*.bmp";
  403. string pngPath = CommonHelper.GetExistedPathOrEmpty(filter);
  404. if (!string.IsNullOrEmpty(pngPath))
  405. {
  406. imagePath = pngPath;
  407. try
  408. {
  409. //tempSignatureConfig.ImageBitmap = new Bitmap(imagePath);
  410. }
  411. catch (Exception exception)
  412. {
  413. MessageBox.Show("The image is invalid.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
  414. return;
  415. }
  416. SetProperty();
  417. CreateTempSignature();
  418. }
  419. }
  420. private void ClearTxt_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  421. {
  422. imagePath = string.Empty;
  423. //tempSignatureConfig.ImageBitmap = null;
  424. SetProperty();
  425. CreateTempSignature();
  426. }
  427. private void NameChk_Click(object sender, RoutedEventArgs e)
  428. {
  429. SetProperty();
  430. CreateTempSignature();
  431. }
  432. private void DateChk_Click(object sender, RoutedEventArgs e)
  433. {
  434. SetProperty();
  435. CreateTempSignature();
  436. }
  437. private void LogoChk_Click(object sender, RoutedEventArgs e)
  438. {
  439. SetProperty();
  440. CreateTempSignature();
  441. }
  442. private void ReasonChk_Click(object sender, RoutedEventArgs e)
  443. {
  444. if (!(bool)ReasonChk.IsChecked)
  445. {
  446. Reasonstp.Visibility = Visibility.Collapsed;
  447. }
  448. else
  449. {
  450. Reasonstp.Visibility = Visibility.Visible;
  451. }
  452. SetProperty();
  453. CreateTempSignature();
  454. }
  455. private void DistinguishableNameChk_Click(object sender, RoutedEventArgs e)
  456. {
  457. SetProperty();
  458. CreateTempSignature();
  459. }
  460. private void PositionChk_Click(object sender, RoutedEventArgs e)
  461. {
  462. if (!(bool)PositionChk.IsChecked)
  463. {
  464. PositionStp.Visibility = Visibility.Collapsed;
  465. }
  466. else
  467. {
  468. PositionStp.Visibility = Visibility.Visible;
  469. }
  470. SetProperty();
  471. CreateTempSignature();
  472. }
  473. private void TabChk_Click(object sender, RoutedEventArgs e)
  474. {
  475. SetProperty();
  476. CreateTempSignature();
  477. }
  478. private void ReasonCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
  479. {
  480. SetProperty();
  481. CreateTempSignature();
  482. }
  483. private void ComPDFKitVersionChk_Click(object sender, RoutedEventArgs e)
  484. {
  485. SetProperty();
  486. CreateTempSignature();
  487. }
  488. private void PositionTbx_TextChanged(object sender, TextChangedEventArgs e)
  489. {
  490. if (!(bool)PositionChk.IsChecked)
  491. {
  492. PositionStp.Visibility = Visibility.Collapsed;
  493. }
  494. else
  495. {
  496. PositionStp.Visibility = Visibility.Visible;
  497. }
  498. SetProperty();
  499. CreateTempSignature();
  500. }
  501. private void ContinueBtn_Click(object sender, RoutedEventArgs e)
  502. {
  503. string filePath = CommonHelper.GetGeneratePathOrEmpty("PDF files (*.pdf)|*.pdf", Document.FileName + "_Signed.pdf");
  504. if (string.IsNullOrEmpty(filePath))
  505. {
  506. return;
  507. }
  508. if (filePath.ToLower() == Document.FilePath.ToLower())
  509. {
  510. MessageBox.Show("Do not use the new file name that is the same as the current file name.");
  511. return;
  512. }
  513. if ((bool)ReasonChk.IsChecked)
  514. {
  515. reason = (ReasonCmb?.SelectedItem as ComboBoxItem)?.Content?.ToString();
  516. }
  517. else
  518. {
  519. reason = string.Empty;
  520. }
  521. if ((bool)PositionChk.IsChecked)
  522. {
  523. location = PositionTbx.Text;
  524. }
  525. else
  526. {
  527. location = string.Empty;
  528. }
  529. signatureWidget.UpdataApWithSignature(tempSignatureConfig);
  530. if (Document.WriteSignatureToFilePath(signatureWidget, filePath, SignaturePath, Password, location, reason, CPDFSignaturePermissions.CPDFSignaturePermissionsNone))
  531. {
  532. signatureCertificate.AddToTrustedCertificates();
  533. AfterFillSignature?.Invoke(sender, filePath);
  534. }
  535. CloseWindow(sender);
  536. }
  537. private void CancelBtn_Click(object sender, RoutedEventArgs e)
  538. {
  539. CloseWindow(sender);
  540. }
  541. private void CloseWindow(object sender)
  542. {
  543. Window parentWindow = Window.GetWindow(sender as DependencyObject);
  544. parentWindow?.Close();
  545. }
  546. private void TextColorPickerControl_Loaded(object sender, RoutedEventArgs e)
  547. {
  548. TextColorPickerControl.SetIsChecked(0);
  549. TextColorPickerControl.Brush = new SolidColorBrush(Colors.Black);
  550. }
  551. private void TextColorPickerControl_ColorChanged(object sender, EventArgs e)
  552. {
  553. KeyboardInPutTextBox.Foreground = TextColorPickerControl.Brush;
  554. }
  555. private void KeyboardCancel_Click(object sender, RoutedEventArgs e)
  556. {
  557. KeyboardPopup.Visibility = Visibility.Collapsed;
  558. }
  559. private void KeyboardClear_Click(object sender, RoutedEventArgs e)
  560. {
  561. KeyboardInPutTextBox.Text = string.Empty;
  562. }
  563. private void KeyboardSave_Click(object sender, RoutedEventArgs e)
  564. {
  565. signatureName = KeyboardInPutTextBox.Text;
  566. tempSignatureConfig.Text = signatureName;
  567. SolidColorBrush solidColorBrush = TextColorPickerControl.Brush as SolidColorBrush;
  568. float red = solidColorBrush.Color.R;
  569. float green = solidColorBrush.Color.G;
  570. float blue = solidColorBrush.Color.B;
  571. textColor = new[] { red / 255, green / 255, blue / 255 };
  572. KeyboardPopup.Visibility = Visibility.Collapsed;
  573. SetProperty();
  574. CreateTempSignature();
  575. }
  576. private void KeyboardPopupClose_Click(object sender, RoutedEventArgs e)
  577. {
  578. KeyboardPopup.Visibility = Visibility.Collapsed;
  579. }
  580. }
  581. }