using PLCSharp.Core.Common; using Prism.Commands; using Prism.Mvvm; using System.Windows.Media; namespace PLCSharp.Core.UserControls { /// /// SimpleCell视图模型 /// public class SimpleCellViewModel : BindableBase { private DelegateCommand _MenuItemCommand; /// /// 菜单项Command /// public DelegateCommand MenuItemCommand => _MenuItemCommand ??= new DelegateCommand(ExecuteMenuItemCommand); private void ExecuteMenuItemCommand(object state) { CellInfo.State = (CellState)state; } /// /// CellChanged /// /// sender /// e internal void CellChanged(object sender, CellState e) { Background = CellInfo.State switch { CellState.无料 => Brushes.Gray, CellState.有料 => Brushes.CornflowerBlue, CellState.请求 => Brushes.LightYellow, CellState.完成 => Brushes.SpringGreen, CellState.允许 => Brushes.White, CellState.确认 => Brushes.Gold, CellState.OK => Brushes.Lime, CellState.NG => Brushes.Red, _ => Brushes.White, }; } private Brush _Background; /// /// 背景画刷 /// public Brush Background { get { return _Background; } set { SetProperty(ref _Background, value); } } private CellInfo _CellInfo; /// /// 单元格信息 /// public CellInfo CellInfo { get { return _CellInfo; } set { SetProperty(ref _CellInfo, value); } } } }