DeviceSerialControl.xaml.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Management;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Media.Imaging;
  6. using System.Windows.Threading;
  7. using ComPDFKit.NativeMethod;
  8. namespace ComPDFKit.Controls.PDFControl
  9. {
  10. public partial class DeviceSerialControl : Window
  11. {
  12. public DeviceSerialControl()
  13. {
  14. InitializeComponent();
  15. Loaded += MainWindow_Loaded;
  16. Icon = new BitmapImage(new Uri("pack://application:,,,/ComPDFKit.Controls;component/ComPDFKit_Logo.ico"));
  17. }
  18. private void MainWindow_Loaded(object sender, RoutedEventArgs e)
  19. {
  20. try
  21. {
  22. BoardText.Text = CPDFSDKVerifier.GetDeviceId();
  23. }
  24. catch (Exception)
  25. {
  26. }
  27. }
  28. private void CopyBtn_Click(object sender, RoutedEventArgs e)
  29. {
  30. try
  31. {
  32. if (BoardText != null && BoardText.Text != string.Empty)
  33. {
  34. Clipboard.SetText(BoardText.Text);
  35. CopyTips.Visibility = Visibility.Visible;
  36. DispatcherTimer dispatcherTimer = new DispatcherTimer();
  37. dispatcherTimer.Tick -= this.StartTimer_Tick;
  38. dispatcherTimer.Tick += this.StartTimer_Tick;
  39. dispatcherTimer.IsEnabled = false;
  40. dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1);
  41. dispatcherTimer.Start();
  42. }
  43. }
  44. catch (Exception)
  45. {
  46. }
  47. }
  48. private void StartTimer_Tick(object sender, EventArgs e)
  49. {
  50. try
  51. {
  52. CopyTips.Visibility = Visibility.Collapsed;
  53. DispatcherTimer dispatcherTimer = sender as DispatcherTimer;
  54. if (dispatcherTimer != null)
  55. {
  56. dispatcherTimer.Stop();
  57. }
  58. }
  59. catch (Exception)
  60. {
  61. }
  62. }
  63. }
  64. }