public ZonesSelectationViewModel(List<XZone> zones, bool canCreateNew = false)
		{
			Title = "Выбор зон";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			Zones = zones;
			CanCreateNew = canCreateNew;
			TargetZones = new ObservableCollection<XZone>();
			SourceZones = new ObservableCollection<XZone>();

			foreach (var zone in XManager.DeviceConfiguration.SortedZones)
			{
				if (Zones.Contains(zone))
					TargetZones.Add(zone);
				else
					SourceZones.Add(zone);
			}

			SelectedTargetZone = TargetZones.FirstOrDefault();
			SelectedSourceZone = SourceZones.FirstOrDefault();
		}
示例#2
0
		public void InitializeAvailableDevice()
		{
			var availableDevices = new HashSet<GKDevice>();
			foreach (var device in GKManager.Devices)
			{
				if (device.Driver.HasZone && device.ZoneUIDs.Count == 0)
				{
					if ((device.IsInMPT && !GlobalSettingsHelper.GlobalSettings.ShowMPTsDevicesForZone) ||
						(device.GuardZones.Count > 0 && !GlobalSettingsHelper.GlobalSettings.ShowGuardZonesDevices) ||
						(device.Door != null && !GlobalSettingsHelper.GlobalSettings.ShowDoorsDevicesForZone))
						continue;

					availableDevices.Add(device);
				}
			}

			AvailableDevices = new ObservableCollection<ZoneDeviceViewModel>();
			foreach (var device in availableDevices)
			{
				var deviceViewModel = new ZoneDeviceViewModel(device)
				{
					IsBold = device.Driver.HasZone
				};

				AvailableDevices.Add(deviceViewModel);
			}

			OnPropertyChanged(() => AvailableDevices);
			SelectedAvailableDevice = AvailableDevices.FirstOrDefault();
		}
		public void InitializeAvailableDevices(GKGuardZone zone)
		{
			AvailableDevices = new ObservableCollection<GuardZoneDeviceViewModel>();
			foreach (var device in GKManager.Devices)
			{
				if (device.Driver.HasGuardZone && !zone.GuardZoneDevices.Any(x => x.DeviceUID == device.UID))
				{
					if (device.GuardZones.Count > 0 || (device.IsInMPT && !GlobalSettingsHelper.GlobalSettings.ShowMPTsDevices)
							|| (device.ZoneUIDs.Count > 0 && !GlobalSettingsHelper.GlobalSettings.ShowZonesDevices)
							|| (device.Door != null && !GlobalSettingsHelper.GlobalSettings.ShowDoorsDevices))
						continue;

					var guardZoneDevice = new GKGuardZoneDevice
					{
						DeviceUID = device.UID,
						Device = device
					};
					var deviceViewModel = new GuardZoneDeviceViewModel(guardZoneDevice);
					AvailableDevices.Add(deviceViewModel);
				}
			}

			OnPropertyChanged(() => AvailableDevices);
			SelectedAvailableDevice = AvailableDevices.FirstOrDefault();
		}
		public CodesSelectationViewModel(List<GKCode> codes, bool canCreateNew = true)
		{
			Title = "Выбор кодов";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			Codes = codes;
			CanCreateNew = canCreateNew;
			TargetCodes = new ObservableCollection<GKCode>();
			SourceCodes = new ObservableCollection<GKCode>();

			foreach (var code in GKManager.DeviceConfiguration.Codes)
			{
				if (Codes.Contains(code))
					TargetCodes.Add(code);
				else
					SourceCodes.Add(code);
			}

			SelectedTargetCode = TargetCodes.FirstOrDefault();
			SelectedSourceCode = SourceCodes.FirstOrDefault();
		}
示例#5
0
		public void Initialize(GKZone zone)
		{
			Zone = zone;
			var devices = new HashSet<GKDevice>();

			foreach (var device in GKManager.Devices)
			{
				if (device.Driver.HasZone)
				{
					if (device.ZoneUIDs.Contains(Zone.UID) && device.ZoneUIDs.Count != 0)
					{
						devices.Add(device);
					}
				}
			}

			Devices = new ObservableCollection<ZoneDeviceViewModel>();
			foreach (var device in devices)
			{
				var deviceViewModel = new ZoneDeviceViewModel(device)
				{
					IsBold = device.ZoneUIDs.Contains(Zone.UID)
				};
				Devices.Add(deviceViewModel);
			}

			OnPropertyChanged(() => Devices);
			SelectedDevice = Devices.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();
		}
        /// <summary>
        /// Initializes a new instance of the SqlTemplateOptionViewModel class.
        /// </summary>
        /// <param name="templates"></param>
        public SqlTemplateOptionViewModel(List<Template> templates)
        {
            _filterText = String.Empty;
            _originalTemplates = templates;

            Templates = new ObservableCollection<Template>(_originalTemplates);

            Save = new DelegateCommand(ExecuteSave, IsDirty);
            Cancel = new DelegateCommand(ExecuteCancel);
            Add = new DelegateCommand(ExecuteAdd);
            Remove = new DelegateCommand(ExecuteRemove, () => SelectedTemplate != null);

            Templates.CollectionChanged += CollectionChanged;
            AssignPropertyChangedHandler(Templates);
            SelectedTemplate = Templates.FirstOrDefault();
        }
		public GuardZonesWithFuncSelectationViewModel(GKDevice device, bool canCreateNew = false)
		{
			Title = "Выбор охранных зон";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			Device = device;
			DeviceGuardZones = new ObservableCollection<DeviceGuardZoneViewModel>();
			foreach (var zone in device.GuardZones)
			{
				var guardZoneDevice = zone.GuardZoneDevices.FirstOrDefault(x => x.Device == device);
				if (guardZoneDevice != null)
				{
					var deviceGuardZone = new GKDeviceGuardZone();
					deviceGuardZone.GuardZone = zone;
					deviceGuardZone.GuardZoneUID = zone.UID;
					deviceGuardZone.ActionType = guardZoneDevice.ActionType;
					deviceGuardZone.CodeReaderSettings = guardZoneDevice.CodeReaderSettings;
					DeviceGuardZones.Add(new DeviceGuardZoneViewModel(deviceGuardZone, device));
				}
			}

			CanCreateNew = canCreateNew;
			TargetZones = new SortableObservableCollection<DeviceGuardZoneViewModel>();
			SourceZones = new SortableObservableCollection<DeviceGuardZoneViewModel>();

			foreach (var guardZone in GKManager.GuardZones)
			{
				var deviceGuardZone = DeviceGuardZones.FirstOrDefault(x => x.DeviceGuardZone.GuardZone == guardZone);
				if (deviceGuardZone != null)
					TargetZones.Add(deviceGuardZone);
				else
				{
					var gkDeviceGuardZone = new GKDeviceGuardZone();
					gkDeviceGuardZone.GuardZone = guardZone;
					gkDeviceGuardZone.GuardZoneUID = guardZone.UID;
					SourceZones.Add(new DeviceGuardZoneViewModel(gkDeviceGuardZone, device));
				}
			}

			SelectedTargetZone = TargetZones.FirstOrDefault();
			SelectedSourceZone = SourceZones.FirstOrDefault();
		}
示例#9
0
        public LineViewModel(Line line)
		{
			Line = line;
			AddCommand = new RelayCommand(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			CopyCommand = new RelayCommand<object>(OnCopy, CanCutCopy);
			CutCommand = new RelayCommand<object>(OnCut, CanCutCopy);
			PasteCommand = new RelayCommand(OnPaste, CanPaste);

			Devices = new ObservableCollection<DeviceViewModel>();
			foreach (var device in line.Devices)
			{
				var deviceViewModel = new DeviceViewModel(device, this);
				Devices.Add(deviceViewModel);
			}
			SelectedDevice = Devices.FirstOrDefault();
			UpdateAddresses();
            Calculate();
		}
		public void Initialize(GKGuardZone zone)
		{
			Zone = zone;

			Devices = new ObservableCollection<GuardZoneDeviceViewModel>();
			foreach (var device in GKManager.Devices)
			{
				if (device.DriverType == GKDriverType.RSR2_GuardDetector || device.DriverType == GKDriverType.RSR2_GuardDetectorSound || device.DriverType == GKDriverType.RSR2_HandGuardDetector
					|| device.DriverType == GKDriverType.RSR2_AM_1 || device.DriverType == GKDriverType.RSR2_MAP4 || device.Driver.IsCardReaderOrCodeReader)
				{
					var guardZoneDevice = Zone.GuardZoneDevices.FirstOrDefault(x => x.DeviceUID == device.UID);
					if (guardZoneDevice != null)
					{
						var deviceViewModel = new GuardZoneDeviceViewModel(guardZoneDevice);
						Devices.Add(deviceViewModel);
					}
				}
			}
			OnPropertyChanged(() => Devices);
			SelectedDevice = Devices.FirstOrDefault();
		}
		public DirectionsSelectationViewModel(List<XDirection> directions)
        {
            Title = "Выбор зон";
            AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
            RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
            AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
            RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);

			Directions = directions;
			TargetDirections = new ObservableCollection<XDirection>();
			SourceDirections = new ObservableCollection<XDirection>();

            foreach (var direction in XManager.Directions)
            {
				if (Directions.Contains(direction))
                    TargetDirections.Add(direction);
                else
                    SourceDirections.Add(direction);
            }

			SelectedTargetDirection = TargetDirections.FirstOrDefault();
			SelectedSourceDirection = SourceDirections.FirstOrDefault();
        }
		public CamerasSelectionViewModel(List<Camera> cameras)
		{
			Title = "Выбор камер";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);

			Cameras = cameras;
			TargetCameras = new ObservableCollection<Camera>();
			SourceCameras = new ObservableCollection<Camera>();

			foreach (var camera in ClientManager.SystemConfiguration.Cameras)
			{
				if (Cameras.Contains(camera))
					TargetCameras.Add(camera);
				else
					SourceCameras.Add(camera);
			}

			SelectedTargetCamera = TargetCameras.FirstOrDefault();
			SelectedSourceCamera = SourceCameras.FirstOrDefault();
		}
		public OrganisationsSelectionViewModel(List<Organisation> organisations)
		{
			Title = "Выбор организаций";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);

			Organisations = organisations;
			TargetOrganisations = new ObservableCollection<Organisation>();
			SourceOrganisations = new ObservableCollection<Organisation>();

			foreach (var organisation in OrganisationHelper.GetByCurrentUser())
			{
				if (Organisations.Any(x => x.UID == organisation.UID))
					TargetOrganisations.Add(organisation);
				else
					SourceOrganisations.Add(organisation);
			}

			SelectedTargetOrganisation = TargetOrganisations.FirstOrDefault();
			SelectedSourceOrganisation = SourceOrganisations.FirstOrDefault();
		}
		void UpdateDevices()
		{
			AvailableDevices = new ObservableCollection<XDevice>();
			Devices = new ObservableCollection<XDevice>();
			SelectedAvailableDevice = null;
			SelectedDevice = null;

			foreach (var device in SourceDevices)
			{
				if (!device.Driver.IsGroupDevice)
				{
					if (DevicesList.Contains(device))
						Devices.Add(device);
					else
						AvailableDevices.Add(device);
				}
			}

			SelectedDevice = Devices.FirstOrDefault();
			SelectedAvailableDevice = AvailableDevices.FirstOrDefault();

			OnPropertyChanged("Devices");
			OnPropertyChanged("AvailableDevices");
		}
        private async void UpdateAppointmentPeople()
        {
            AppointmentPeople = new ObservableCollection<Person>();

            var temp = await PersonRepository.GetPeople();
            IEnumerable<Person> items = new ObservableCollection<Person>(temp)
                .Where(p => p.ID == _selectedAppointment.SeniorID);

            Person senior = items.FirstOrDefault();
            AppointmentPeople.Add(senior);

            items = new ObservableCollection<Person>(temp)
                .Where(p => p.ID == _selectedAppointment.VolunteerID);

            Person volunteer = items.FirstOrDefault();
            AppointmentPeople.Add(volunteer);

        }
		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();
		}
示例#17
0
        private void LoadTransactionUsersCollection()
        {
            var transactionUsers = transaction.TransactionUsers;
            TransactionUsersCollection = new ObservableCollection<TransactionUser>(transactionUsers);

            var otherUsers = allUsers.Except(transactionUsers.Select(tu => tu.User));
            OtherUsers = new ObservableCollection<User>(otherUsers);
            SelectedUser = OtherUsers.FirstOrDefault();
        }
示例#18
0
        /// <summary>
        /// Attempts to look through the view and locate the specific exact 
        /// text match.
        /// </summary>
        /// <param name="searchText">The search text.</param>
        /// <param name="view">The view reference.</param>
        /// <param name="predicate">The predicate to use for the partial or 
        /// exact match.</param>
        /// <returns>Returns the object or null.</returns>
        private object TryGetMatch(string searchText, ObservableCollection<object> view, AutoCompleteFilterPredicate<string> predicate)
        {
            if(view != null && view.Count > 0)
            {
                return view.FirstOrDefault(o => predicate(searchText, FormatValue(o)));
            }

            return null;
        }
示例#19
0
        private async Task LoadArtists(CancellationToken token)
        {
            try
            {
                var audio = await DataService.GetUserTracks();

                if (audio.Items == null || token.IsCancellationRequested)
                {
                    return;
                }

                var tracks = audio.Items;

                var artists = await DataService.GetArtistsFromTracks(tracks, token);
                if (artists != null)
                {
                    Artists = new ObservableCollection<AudioArtist>(artists);

                    SelectedArtist = Artists.FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                LoggingService.Log(ex);
            }
        }
示例#20
0
 /// <summary>
 /// 
 /// </summary>
 public void LoadSubSidiary()
 {
     if (KmtConstants.IsOemCorp || KmtConstants.IsTpiCorp)
     {
         Subsidiarys = new ObservableCollection<Subsidiary>(ssProxy.GetSubsidiaries());
         Subsidiarys.Insert(0, new Subsidiary() { SsId = 0, DisplayName = MergedResources.Common_All });
         //Select 'Show All' on First Load
         SelectedSubSidiary = Subsidiarys.FirstOrDefault();
     }
     else// Factory Floor
         Subsidiarys = new ObservableCollection<Subsidiary>();
 }