public LibraryStateDetailsViewModel(SKDLibraryDevice skdLibraryDevice)
			: base()
		{
			Title = "Добавить состояние";

			var skdLibraryStates = new List<SKDLibraryState>();
			foreach (XStateClass stateClass in Enum.GetValues(typeof(XStateClass)))
			{
				if ((!skdLibraryDevice.States.Any(x => x.StateClass == stateClass && x.Code == null)) && (skdLibraryDevice.Driver.AvailableStateClasses.Exists(x => x == stateClass)))
				{
					var skdLibraryState = new SKDLibraryState()
					{
						StateClass = stateClass
					};
					skdLibraryStates.Add(skdLibraryState);
				}
			}

			States = new List<StateViewModel>();
			foreach (var libraryState in skdLibraryStates)
			{
				var stateViewModel = new StateViewModel(libraryState, skdLibraryDevice.Driver);
				States.Add(stateViewModel);
			}
			SelectedState = States.FirstOrDefault();
		}
Пример #2
0
		public SKDLibraryDevice()
		{
			UID = Guid.NewGuid();
			IsAlternative = false;
			States = new List<SKDLibraryState>();
			var libraryXState = new SKDLibraryState()
			{
				StateClass = XStateClass.No,
			};
			States.Add(libraryXState);
		}
Пример #3
0
		public StateViewModel(SKDLibraryState skdLibraryState, SKDDriver driver)
		{
			AddFrameCommand = new RelayCommand(OnAddFrame);
			RemoveFrameCommand = new RelayCommand(OnRemoveFrame, CanRemoveFrame);

			State = skdLibraryState;
			Driver = driver;

			Frames = new ObservableCollection<FrameViewModel>(
				State.Frames.Select(frame => new FrameViewModel(frame))
			);
			SelectedFrame = Frames.FirstOrDefault();
		}
Пример #4
0
		public SKDStateViewModel(SKDLibraryState state, ICollection<Canvas> stateCanvases)
		{
			_canvases = new List<Canvas>();
			_frames = state.Frames;
			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;
		}