public StateDetailsViewModel(LibraryXDevice libraryDevice) : base() { Title = "Добавить состояние"; var libraryStates = new List<LibraryXState>(); foreach (XStateClass xstateClass in Enum.GetValues(typeof(XStateClass))) { if ((!libraryDevice.XStates.Any(x => x.XStateClass == xstateClass && x.Code == null)) && (libraryDevice.Driver.AvailableStateClasses.Exists(x => x == xstateClass))) { var libraryState = new LibraryXState() { XStateClass = xstateClass }; libraryStates.Add(libraryState); } } States = new List<StateViewModel>(); foreach (var libraryState in libraryStates) { var stateViewModel = new StateViewModel(libraryState, libraryDevice.Driver); States.Add(stateViewModel); } SelectedState = States.FirstOrDefault(); }
public LibraryXDevice() { UID = Guid.NewGuid(); IsAlternative = false; XStates = new List<LibraryXState>(); var libraryXState = new LibraryXState() { XStateClass = XStateClass.No, }; XStates.Add(libraryXState); }
public StateViewModel(LibraryXState libraryState, XDriver driver) { AddFrameCommand = new RelayCommand(OnAddFrame); RemoveFrameCommand = new RelayCommand(OnRemoveFrame, CanRemoveFrame); State = libraryState; Driver = driver; Frames = new ObservableCollection<FrameViewModel>( State.XFrames.Select(frame => new FrameViewModel(frame)) ); SelectedFrame = Frames.FirstOrDefault(); }
public XStateViewModel(LibraryXState state, ICollection<Canvas> stateCanvases) { _canvases = new List<Canvas>(); _frames = state.XFrames; foreach (var xframe in _frames) { var canvas = Helper.Xml2Canvas(xframe.Image); if (canvas.Children.Count == 0) { canvas.Background = Brushes.White; canvas.Opacity = 0.01; } canvas.Visibility = Visibility.Collapsed; _canvases.Add(canvas); stateCanvases.Add(canvas); } if (_canvases.Count > 0) _canvases[0].Visibility = Visibility.Visible; if (_frames.Count <= 1) return; Timer.Tick += OnTick; }