FfuView.xaml.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Aitex.Core.UI.MVVM;
  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. namespace MECF.Framework.Simulator.Core.FFUs
  17. {
  18. /// <summary>
  19. /// FfuView.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class FfuView : UserControl
  22. {
  23. public static int CurrentTick = 0;
  24. public FfuView()
  25. {
  26. InitializeComponent();
  27. DataContext = new FfuViewModel((CurrentTick++==0) ? "COM34":"COM36");
  28. (DataContext as TimerViewModelBase).Start();
  29. this.Loaded += OnViewLoaded;
  30. }
  31. private void OnViewLoaded(object sender, RoutedEventArgs e)
  32. {
  33. if (DataContext == null)
  34. {
  35. }
  36. }
  37. private void UserControl_Initialized(object sender, EventArgs e)
  38. {
  39. InitSerialPort();
  40. }
  41. //GetPortNames()方法:获取当前计算机的串行端口名的数组
  42. private void InitSerialPort()
  43. {
  44. PortName.Items.Clear();
  45. foreach (string com in System.IO.Ports.SerialPort.GetPortNames())
  46. {
  47. PortName.Items.Add(com);
  48. }
  49. PortName.SelectedIndex = 0;
  50. }
  51. }
  52. }