OmronBarcodeReaderView.xaml.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  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 Aitex.Core.UI.MVVM;
  17. using Aitex.Core.Utilities;
  18. using MECF.Framework.Simulator.Core.Aligners;
  19. using MECF.Framework.Simulator.Core.Commons;
  20. using MECF.Framework.Simulator.Core.Driver;
  21. namespace MECF.Framework.Simulator.Core.LoadPorts
  22. {
  23. /// <summary>
  24. /// OmronCIDRWView.xaml 的交互逻辑
  25. /// </summary>
  26. public partial class OmronBarcodeReaderView : UserControl
  27. {
  28. public static readonly DependencyProperty PortProperty = DependencyProperty.Register(
  29. "Port", typeof(string), typeof(OmronBarcodeReaderView),
  30. new FrameworkPropertyMetadata("COM1", FrameworkPropertyMetadataOptions.AffectsRender));
  31. public string Port
  32. {
  33. get
  34. {
  35. return (string)this.GetValue(PortProperty);
  36. }
  37. set
  38. {
  39. this.SetValue(PortProperty, value);
  40. }
  41. }
  42. public OmronBarcodeReaderView()
  43. {
  44. InitializeComponent();
  45. this.Loaded += OnViewLoaded;
  46. }
  47. private void OnViewLoaded(object sender, RoutedEventArgs e)
  48. {
  49. if (DataContext == null)
  50. {
  51. DataContext = new OmronBarcodeReaderViewModel( Port );
  52. (DataContext as TimerViewModelBase).Start();
  53. }
  54. }
  55. }
  56. class OmronBarcodeReaderViewModel : SerialPortDeviceViewModel
  57. {
  58. public string Title
  59. {
  60. get { return "Omron barcode reader Simulator"; }
  61. }
  62. private OmronBarcodeReaderSimulator _reader;
  63. public bool IsFailed
  64. {
  65. get
  66. {
  67. return _reader.Failed;
  68. }
  69. set
  70. {
  71. _reader.Failed = value;
  72. }
  73. }
  74. //private string _value;
  75. [IgnorePropertyChange]
  76. public string ResultValue
  77. {
  78. get
  79. {
  80. return _reader.ResultValue;
  81. }
  82. set
  83. {
  84. _reader.ResultValue = value;
  85. }
  86. }
  87. public OmronBarcodeReaderViewModel(string port) : base("OmronBarcodeReaderViewModel")
  88. {
  89. _reader = new OmronBarcodeReaderSimulator(port);
  90. Init(_reader);
  91. }
  92. }
  93. }