DeviceSerialControl.xaml.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_Tools.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_Tools;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.IsEnabled = false;
  39. dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1);
  40. dispatcherTimer.Start();
  41. }
  42. }
  43. catch (Exception)
  44. {
  45. }
  46. }
  47. private void StartTimer_Tick(object sender, EventArgs e)
  48. {
  49. try
  50. {
  51. CopyTips.Visibility = Visibility.Collapsed;
  52. DispatcherTimer dispatcherTimer = sender as DispatcherTimer;
  53. if (dispatcherTimer != null)
  54. {
  55. dispatcherTimer.Stop();
  56. }
  57. }
  58. catch (Exception)
  59. {
  60. }
  61. }
  62. }
  63. }