MainWindow.xaml.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using NumMachine;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. using WpfApp1.Entry;
  17. namespace WpfApp1
  18. {
  19. /// <summary>
  20. /// MainWindow.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class MainWindow : Window
  23. {
  24. public MainWindow()
  25. {
  26. InitializeComponent();
  27. IntPtr flpHandle = flowLayoutPanel1.Handle;
  28. SystemInitializer.Init(flpHandle);
  29. }
  30. private void win_Closed(object sender, EventArgs e)
  31. {
  32. SystemInitializer.Stop();
  33. Close();
  34. System.Environment.Exit(0);
  35. }
  36. private void GetNum_Click(object sender, RoutedEventArgs e)
  37. {
  38. if (SystemInitializer.numMachineLinker != null)
  39. {
  40. try
  41. {
  42. int id = Int32.Parse(NumMachineId.Text);
  43. string lic="";
  44. Task.Factory.StartNew(()=> {
  45. lic = SystemInitializer.numMachineLinker.GetLicensePlate(id);
  46. License.Dispatcher.BeginInvoke(new Action(() => { License.Text = lic; }));
  47. Console.WriteLine("号牌" + lic);
  48. });
  49. }
  50. catch { }
  51. }
  52. }
  53. }
  54. }