WagoView.xaml.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using Aitex.Core.UI.MVVM;
  2. using CyberX8_Simulator.Devices;
  3. using MECF.Framework.Simulator.Core.Commons;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. namespace CyberX8_Simulator.Views
  19. {
  20. /// <summary>
  21. /// WagoView.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class WagoView : UserControl
  24. {
  25. public WagoView()
  26. {
  27. InitializeComponent();
  28. this.Loaded += OnViewLoaded;
  29. }
  30. private void OnViewLoaded(object sender, RoutedEventArgs e)
  31. {
  32. (DataContext as TimerViewModelBase)?.Start();
  33. }
  34. }
  35. class WagoViewModel : SocketDeviceViewModel
  36. {
  37. public string Title
  38. {
  39. get { return "Wago Simulator"; }
  40. }
  41. private WagoSocketSimulator _sim;
  42. public WagoViewModel(string str) : base("WagoViewModel")
  43. {
  44. int.TryParse(str, out int port);
  45. _sim = new WagoSocketSimulator(port);
  46. Init(_sim);
  47. }
  48. }
  49. }