コード例 #1
0
		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();
		}
コード例 #2
0
		public DeviceDetailsViewModel()
		{
			Title = "Добавить устройство";

			Devices = new ObservableCollection<XDeviceViewModel>();
			var drivers = (from XDriver driver in XManager.Drivers select driver).ToList();
			foreach (var driver in drivers)
			{
				if (!XManager.DeviceLibraryConfiguration.XDevices.Any(x => x.XDriverId == driver.UID) && (driver.IsPlaceable))
				{
					var libraryXDevice = new LibraryXDevice()
					{
						Driver = driver,
						XDriverId = driver.UID
					};
					var xdeviceViewModel = new XDeviceViewModel(libraryXDevice);
					Devices.Add(xdeviceViewModel);
				}
			}
			SelectedDevice = Devices.FirstOrDefault();
		}
コード例 #3
0
		private static FrameworkElement GetDefaultXPicture(LibraryXDevice device)
		{
			var state = device.XStates.FirstOrDefault(x => x.Code == null && x.XStateClass == XStateClass.No);
			return state.XFrames.Count > 0 ? Helper.GetVisual(state.XFrames[0].Image) : EmptyPicture;
		}
コード例 #4
0
		private static void RegisterXBrush(LibraryXDevice libraryXDevice)
		{
			var frameworkElement = libraryXDevice == null ? EmptyPicture : GetDefaultXPicture(libraryXDevice);
			var brush = new VisualBrush(frameworkElement);
			if (_xbrushes.ContainsKey(libraryXDevice == null ? Guid.Empty : libraryXDevice.XDriverId))
				_xbrushes[libraryXDevice == null ? Guid.Empty : libraryXDevice.XDriverId] = brush;
			else
				_xbrushes.Add(libraryXDevice == null ? Guid.Empty : libraryXDevice.XDriverId, brush);
		}