void InitializeZones(ZoneType zoneType) { foreach (var zone in FiresecManager.Zones) { if (zone.ZoneType != zoneType) continue; var zoneViewModel = new ZoneViewModel(zone); if (InstructionZonesList.IsNotNullOrEmpty()) { var instructionZone = InstructionZonesList.FirstOrDefault(x => x == zoneViewModel.Zone.UID); if (instructionZone != Guid.Empty) InstructionZones.Add(zoneViewModel); else AvailableZones.Add(zoneViewModel); } else { AvailableZones.Add(zoneViewModel); } } if (InstructionZones.IsNotNullOrEmpty()) SelectedInstructionZone = InstructionZones[0]; if (AvailableZones.IsNotNullOrEmpty()) SelectedAvailableZone = AvailableZones[0]; }
public ZoneSelectationViewModel(Device device) { Title = "Выбор зоны устройства " + device.PresentationAddressAndName; CreateCommand = new RelayCommand(OnCreate); EditCommand = new RelayCommand(OnEdit, CanEdit); Device = device; IsGuardDevice = (device.Driver.DeviceType == DeviceType.Sequrity); Zones = new BindingList<ZoneViewModel>(); foreach (var zone in from zone in FiresecManager.Zones orderby zone.No select zone) { var isGuardZone = (zone.ZoneType == ZoneType.Guard); if (isGuardZone ^ IsGuardDevice) continue; if (device.Driver.DriverType == DriverType.StopButton || device.Driver.DriverType == DriverType.StartButton || device.Driver.DriverType == DriverType.AutomaticButton) { if (!zone.DevicesInZone.Any(x => x.Driver.DriverType == DriverType.MPT)) continue; } var zoneViewModel = new ZoneViewModel(zone); Zones.Add(zoneViewModel); } if (Device.Zone != null) SelectedZone = Zones.FirstOrDefault(x => x.Zone == Device.Zone); }
public IndicatorZoneSelectionViewModel(List<int> zones, Device device) { Title = "Свойства индикатора"; AddOneCommand = new RelayCommand(OnAddOne, CanAdd); RemoveOneCommand = new RelayCommand(OnRemoveOne, CanRemove); AddAllCommand = new RelayCommand(OnAddAll, CanAdd); RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemove); Zones = zones; TargetZones = new ObservableCollection<ZoneViewModel>(); SourceZones = new ObservableCollection<ZoneViewModel>(); foreach (var zone in FiresecManager.FiresecConfiguration.GetChannelZones(device)) { var zoneViewModel = new ZoneViewModel(zone); if (Zones.Contains(zone.No)) TargetZones.Add(zoneViewModel); else SourceZones.Add(zoneViewModel); } SelectedTargetZone = TargetZones.FirstOrDefault(); SelectedSourceZone = SourceZones.FirstOrDefault(); }
public ZonesSelectionViewModel(Device device, List<Guid> zones, ZoneLogicState zoneLogicState) { Title = "Выбор зон устройства " + device.PresentationAddressAndName; AddCommand = new RelayCommand<object>(OnAdd, CanAdd); RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove); AddAllCommand = new RelayCommand(OnAddAll, CanAddAll); RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll); Zones = zones; TargetZones = new ObservableCollection<ZoneViewModel>(); SourceZones = new ObservableCollection<ZoneViewModel>(); var zoneTypeFilter = ZoneType.Fire; switch (zoneLogicState) { case ZoneLogicState.Alarm: case ZoneLogicState.GuardSet: case ZoneLogicState.GuardUnSet: case ZoneLogicState.PCN: case ZoneLogicState.Lamp: zoneTypeFilter = ZoneType.Guard; break; } List<Zone> availableZones = FiresecManager.FiresecConfiguration.GetChannelZones(device); if (device.Driver.DriverType == DriverType.Exit) { availableZones = FiresecManager.FiresecConfiguration.GetPanelZones(device); } foreach (var zone in availableZones) { var zoneViewModel = new ZoneViewModel(zone); if (zone.ZoneType != zoneTypeFilter) { continue; } if ((zoneLogicState == ZoneLogicState.MPTAutomaticOn) || (zoneLogicState == ZoneLogicState.MPTOn) || (zoneLogicState == ZoneLogicState.Firefighting)) { if (!zone.DevicesInZone.Any(x => x.Driver.DriverType == DriverType.MPT)) continue; //if (device.ParentPanel.Children.Any(x => x.Driver.DriverType == DriverType.MPT && x.ZoneUID == zone.UID) == false) //{ // continue; //} } if (Zones.Contains(zone.UID)) TargetZones.Add(zoneViewModel); else SourceZones.Add(zoneViewModel); } SelectedTargetZone = TargetZones.FirstOrDefault(); SelectedSourceZone = SourceZones.FirstOrDefault(); }
private void OnCreate() { var createZoneEventArg = new CreateZoneEventArg(); createZoneEventArg.Zone = new Zone(); if (IsGuardDevice) createZoneEventArg.Zone.ZoneType = ZoneType.Guard; else createZoneEventArg.Zone.ZoneType = ZoneType.Fire; ServiceFactory.Events.GetEvent<CreateZoneEvent>().Publish(createZoneEventArg); if (!createZoneEventArg.Cancel) { var zoneViewModel = new ZoneViewModel(createZoneEventArg.Zone); Zones.Add(zoneViewModel); SelectedZone = zoneViewModel; } }
public ZonePropertiesViewModel(IElementZone iElementZone, ZonesViewModel zonesViewModel) { _zonesViewModel = zonesViewModel; IElementZone = iElementZone; CreateCommand = new RelayCommand(OnCreate); EditCommand = new RelayCommand(OnEdit, CanEdit); Title = "Свойства фигуры: Зона"; var zones = (from zone in FiresecManager.Zones orderby zone.No select zone); Zones = new ObservableCollection<ZoneViewModel>(); foreach (var zone in zones) { var zoneViewModel = new ZoneViewModel(zone); Zones.Add(zoneViewModel); } if (iElementZone.ZoneUID != Guid.Empty) SelectedZone = Zones.FirstOrDefault(x => x.Zone.UID == iElementZone.ZoneUID); IsHiddenZone = iElementZone.IsHiddenZone; }
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(); }
private void InitializeZones() { foreach (var zone in FiresecManager.Zones) { var zoneViewModel = new ZoneViewModel(zone); if (ChosenZonesList.IsNotNullOrEmpty()) { var chosenZone = ChosenZonesList.FirstOrDefault(x => x == zoneViewModel.Zone.UID); if (chosenZone != Guid.Empty) ChosenZones.Add(zoneViewModel); else AvailableZones.Add(zoneViewModel); } else { AvailableZones.Add(zoneViewModel); } } if (ChosenZones.IsNotNullOrEmpty()) SelectedChosenZone = ChosenZones[0]; if (AvailableZones.IsNotNullOrEmpty()) SelectedAvailableZone = AvailableZones[0]; }
public ZonesSelectionViewModel(Device device, List<Guid> zones) { Title = "Выбор зон индикатора"; AddCommand = new RelayCommand<object>(OnAdd, CanAdd); RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove); AddAllCommand = new RelayCommand(OnAddAll, CanAdd); RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemove); Zones = zones; TargetZones = new ObservableCollection<ZoneViewModel>(); SourceZones = new ObservableCollection<ZoneViewModel>(); foreach (var zone in FiresecManager.FiresecConfiguration.GetChannelZones(device)) { var zoneViewModel = new ZoneViewModel(zone); if (Zones.Contains(zone.UID)) TargetZones.Add(zoneViewModel); else SourceZones.Add(zoneViewModel); } SelectedTargetZone = TargetZones.FirstOrDefault(); SelectedSourceZone = SourceZones.FirstOrDefault(); }
void OnRemoveOne() { AvailableZones.Add(SelectedInstructionZone); InstructionZones.Remove(SelectedInstructionZone); if (AvailableZones.IsNotNullOrEmpty()) SelectedAvailableZone = AvailableZones[0]; if (InstructionZones.IsNotNullOrEmpty()) SelectedInstructionZone = InstructionZones[0]; }
void OnRemoveAll() { foreach (var instructionZone in InstructionZones) { AvailableZones.Add(instructionZone); } InstructionZones.Clear(); SelectedInstructionZone = null; if (AvailableZones.IsNotNullOrEmpty()) SelectedAvailableZone = AvailableZones[0]; }
void OnAddAll() { foreach (var availableZone in AvailableZones) { InstructionZones.Add(availableZone); } AvailableZones.Clear(); SelectedAvailableZone = null; if (InstructionZones.IsNotNullOrEmpty()) SelectedInstructionZone = InstructionZones[0]; }