using System.Collections.ObjectModel; using Aitex.Core.UI.MVVM; using FurnaceSimulator.Instances; using MECF.Framework.Common.IOCore; using System.Windows.Controls.Primitives; using System.Windows; using System.Windows.Data; using System; namespace FurnaceSimulator.Views { public class IoButton : ToggleButton { public static readonly DependencyProperty ONProperty; static IoButton() { ONProperty = DependencyProperty.Register("ON", typeof(bool), typeof(IoButton)); } public bool ON { get { return (bool)GetValue(ONProperty); } set { SetValue(ONProperty, value); } } } public class BoolBackgroundConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { bool? ret = (bool?)value; return ret.HasValue && ret.Value ? "LightBlue" : "Transparent"; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return null; } } public class IoViewModel : TimerViewModelBase { public SimulatorPlc Plc { get; set; } public ObservableCollection DIs { get; set; } public ObservableCollection DOs { get; set; } public ObservableCollection AIs { get; set; } public ObservableCollection AOs { get; set; } public IoViewModel(int port, string source, string ioMapPathFile, string module) : base(nameof(IoViewModel)) { Plc = new SimulatorPlc(port, source, ioMapPathFile, module); DIs = Plc.DiItemList; DOs = Plc.DoItemList; AIs = Plc.AiItemList; AOs = Plc.AoItemList; } protected override void Poll() { } } }