public DirectionDeviceSelectorViewModel(Direction direction, DriverType driverType)
        {
            Title = "Выбор устройства";

            var devices = new HashSet<Device>();

            foreach (var device in FiresecManager.Devices)
            {
                if (device.Driver.DriverType == driverType)
                {
                    if (device.Parent.Children.Any(x => x.Driver.IsZoneDevice && x.ZoneUID != Guid.Empty && direction.ZoneUIDs.Contains(x.ZoneUID)))
                    {
                        device.AllParents.ForEach(x => { devices.Add(x); });
                        devices.Add(device);
                    }
                }
            }

            Devices = new ObservableCollection<DeviceViewModel>();
            foreach (var device in devices)
            {
                var deviceViewModel = new DeviceViewModel(device);
                deviceViewModel.IsExpanded = true;
                Devices.Add(deviceViewModel);
            }

            foreach (var device in Devices.Where(x => x.Device.Parent != null))
            {
                var parent = Devices.FirstOrDefault(x => x.Device.UID == device.Device.Parent.UID);
                parent.AddChild(device);
            }

            SelectedDevice = Devices.FirstOrDefault(x => x.HasChildren == false);
        }
 bool ValidateDirectionZonesContent(Direction direction)
 {
     if (direction.ZoneUIDs.IsNotNullOrEmpty() == false)
     {
         Errors.Add(new DirectionValidationError(direction, "В направлении тушения нет ни одной зоны", ValidationErrorLevel.CannotWrite));
         return false;
     }
     return true;
 }
        public DirectionDetailsViewModel(Direction direction = null)
        {
            ResetRmCommand = new RelayCommand(OnResetRm);
            ResetButtonCommand = new RelayCommand(OnResetButton);
            ChooseRmCommand = new RelayCommand(OnChooseRm);
            ChooseButtonCommand = new RelayCommand(OnChooseButton);

            _isNew = direction == null;
            Title = _isNew ? "Создать направление" : "Редактировать направление";
            if (direction == null)
                CreateNew();
            else
                Direction = direction;

            CopyProperties();
        }
        void ConvertDirections(DeviceConfiguration deviceConfiguration, Firesec.Models.CoreConfiguration.config coreConfig)
		{
			deviceConfiguration.Directions = new List<Direction>();

			if (coreConfig.part != null)
			{
				foreach (var innerDirection in coreConfig.part)
				{
					if (innerDirection.type == "direction")
					{
						var direction = new Direction()
						{
							Id = int.Parse(innerDirection.id),
							Name = innerDirection.name,
							Description = innerDirection.desc
						};

						if (innerDirection.PinZ != null)
						{
							foreach (var item in innerDirection.PinZ)
							{
                                if (string.IsNullOrWhiteSpace(item.pidz) == false)
                                {
                                    var zoneNo = int.Parse(item.pidz);
                                    var zone = deviceConfiguration.Zones.FirstOrDefault(x=>x.No == zoneNo);
                                    direction.ZoneUIDs.Add(zone.UID);
                                }
							}
						}

						if (innerDirection.param != null)
						{
							var rmParameter = innerDirection.param.FirstOrDefault(x => x.name == "Device_RM");
							direction.DeviceRm = GuidHelper.ToGuid(rmParameter.value);
							var buttonParameter = innerDirection.param.FirstOrDefault(x => x.name == "Device_AM");
							direction.DeviceButton = GuidHelper.ToGuid(buttonParameter.value);
						}

						deviceConfiguration.Directions.Add(direction);
					}
				}
			}
		}
        void ConvertDirections()
        {
            DeviceConfiguration.Directions = new List<Direction>();

            if (FiresecConfiguration.part != null)
            {
                foreach (var innerDirection in FiresecConfiguration.part)
                {
                    if (innerDirection.type == "direction")
                    {
                        var direction = new Direction()
                        {
                            Id = int.Parse(innerDirection.id),
                            Name = innerDirection.name,
                            Description = innerDirection.desc
                        };

                        if (innerDirection.PinZ != null)
                        {
                            foreach (var item in innerDirection.PinZ)
                            {
                                if (string.IsNullOrWhiteSpace(item.pidz) == false)
                                    direction.Zones.Add(int.Parse(item.pidz));
                            }
                        }

                        if (innerDirection.param != null)
                        {
                            var rmParameter = innerDirection.param.FirstOrDefault(x => x.name == "Device_RM");
                            direction.DeviceRm = GuidHelper.ToGuid(rmParameter.value);
                            var buttonParameter = innerDirection.param.FirstOrDefault(x => x.name == "Device_AM");
                            direction.DeviceButton = GuidHelper.ToGuid(buttonParameter.value);
                        }

                        DeviceConfiguration.Directions.Add(direction);
                    }
                }
            }
        }
Beispiel #6
0
        public DirectionViewModel(Direction direction)
        {
            AddZoneCommand = new RelayCommand(OnAddZone, CanAdd);
            RemoveZoneCommand = new RelayCommand(OnRemoveZone, CanRemove);

            Direction = direction;

            Zones = new ObservableCollection<ZoneViewModel>();
            SourceZones = new ObservableCollection<ZoneViewModel>();

            foreach (var zone in FiresecManager.Zones)
            {
                var zoneViewModel = new ZoneViewModel(zone);
                if (Direction.Zones.Contains(zone.No))
                    Zones.Add(zoneViewModel);
                else
                    SourceZones.Add(zoneViewModel);
            }

            SelectedZone = Zones.FirstOrDefault();
            SelectedSourceZone = SourceZones.FirstOrDefault();
        }
Beispiel #7
0
		public DirectionTable(FlashDatabase flashDatabase, Direction direction)
			: base(flashDatabase, direction.Name)
		{
			Direction = direction;
		}
        void CreateNew()
        {
            Direction = new Direction();
            if (FiresecManager.Directions.Count > 0)
                Direction.Id = FiresecManager.Directions.Max(x => x.Id) + 1;
            else
                Direction.Id = 1;

            Direction.Name = "Новое направление " + Direction.Id.ToString();
        }