public LibraryDevice() { UID = Guid.NewGuid(); IsAlternative = false; States = new List<LibraryState>(); var libraryState = new LibraryState() { StateType = StateType.No, }; States.Add(libraryState); Presenters = new List<LibraryDevicePresenter>(); }
public StateViewModel(LibraryState libraryState, Driver driver) { AddFrameCommand = new RelayCommand(OnAddFrame); RemoveFrameCommand = new RelayCommand(OnRemoveFrame, CanRemoveFrame); State = libraryState; Driver = driver; Frames = new ObservableCollection<FrameViewModel>( State.Frames.Select(frame => new FrameViewModel(frame)) ); SelectedFrame = Frames.FirstOrDefault(); }
public StateViewModel(LibraryState state, Driver parentDriver) { State = state; if (state.Frames == null) SetDefaultFrameTo(State); ParentDriver = parentDriver; FrameViewModels = new ObservableCollection<FrameViewModel>( State.Frames.Select(frame => new FrameViewModel(frame)) ); SelectedFrameViewModel = FrameViewModels[0]; AddFrameCommand = new RelayCommand(OnAddFrame); RemoveFrameCommand = new RelayCommand(OnRemoveFrame, CanRemoveFrame); }
public StateViewModel(LibraryState state, ICollection<Canvas> stateCanvases) { _canvases = new List<Canvas>(); _frames = state.Frames; foreach (var frame in _frames) { var canvas = Helper.Xml2Canvas(frame.Image); if (canvas.Children.Count == 0) { canvas.Background = Brushes.White; canvas.Opacity = 0.01; } canvas.Visibility = Visibility.Collapsed; _canvases.Add(canvas); stateCanvases.Add(canvas); } _canvases[0].Visibility = Visibility.Visible; if (_frames.Count <= 1) return; Timer.Tick += OnTick; }
public StateDetailsViewModel(DeviceViewModel deviceViewModel) : base() { Title = "Добавить состояние"; var libraryStates = new List<LibraryState>(); foreach (StateType stateType in Enum.GetValues(typeof(StateType))) { if (!deviceViewModel.States.Any(x => x.StateType == stateType && x.Code == null)) { var libraryState = new LibraryState() { StateType = stateType }; libraryStates.Add(libraryState); } } var driverStates = from DriverState driverState in deviceViewModel.Driver.States orderby driverState.StateType select driverState; foreach (var driverState in driverStates) { if (driverState.Name != null && !deviceViewModel.States.Any(x => x.Code == driverState.Code)) { var libraryState = new LibraryState() { StateType = driverState.StateType, Code = driverState.Code }; libraryStates.Add(libraryState); } } States = new List<StateViewModel>(); foreach (var libraryState in libraryStates) { var stateViewModel = new StateViewModel(libraryState, deviceViewModel.Driver); States.Add(stateViewModel); } SelectedState = States.FirstOrDefault(); }
public static void SetDefaultFrameTo(LibraryState state) { state.Frames = new List<LibraryFrame>(); state.Frames.Add(FrameViewModel.GetDefaultFrameWith(state.Frames.Count)); }
public static LibraryState GetDefaultStateWith(StateType stateType = DefaultStateType, string code = null) { var state = new LibraryState(); state.StateType = stateType; state.Code = code; SetDefaultFrameTo(state); return state; }