1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using System;
- using System.Collections.ObjectModel;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Controls.Primitives;
- using System.Windows.Data;
- using Aitex.Common.Util;
- using Aitex.Core.UI.MVVM;
- using MECF.Framework.Common.IOCore;
- using VirgoSimulator.Instances;
- namespace VirgoSimulator.Views
- {
- /// <summary>
- /// IoView.xaml 的交互逻辑
- /// </summary>
- public partial class SimulatorIo1View : UserControl
- {
- public SimulatorIo1View()
- {
- InitializeComponent();
- var ioFileName = "_ioDefineVirgo.xml";
- if (AppSettingHelper.IsVirgoR()) ioFileName = "_ioDefineVirgo_R.xml";
- DataContext = new IoViewModel(6731, "PMA.PLC", PathManager.GetCfgDir() + ioFileName, "PMA");
- this.IsVisibleChanged += IOView_IsVisibleChanged;
- }
- private void IOView_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
- {
- if (this.DataContext == null)
- {
- }
- (DataContext as TimerViewModelBase).EnableTimer(IsVisible);
- }
- }
-
- 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;
- }
- }
- }
|