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();
		}
Esempio n. 2
0
        public LibraryXDevice()
        {
			UID = Guid.NewGuid();
			IsAlternative = false;
            XStates = new List<LibraryXState>();
            var libraryXState = new LibraryXState()
            {
                XStateClass = XStateClass.No,
            };
            XStates.Add(libraryXState);
        }
Esempio n. 3
0
		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();
		}
Esempio n. 4
0
		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;
		}