本文整理汇总了C#中System.Collections.ObservableCollection.FirstOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.FirstOrDefault方法的具体用法?C# ObservableCollection.FirstOrDefault怎么用?C# ObservableCollection.FirstOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.FirstOrDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ZonesSelectationViewModel
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: InitializeAvailableDevice
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();
}
示例3: InitializeAvailableDevices
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();
}
示例4: CodesSelectationViewModel
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: Initialize
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();
}
示例6: ZonesSelectionViewModel
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();
}
示例7: SqlTemplateOptionViewModel
/// <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();
}
示例8: GuardZonesWithFuncSelectationViewModel
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: LineViewModel
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();
}
示例10: Initialize
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();
}
示例11: DirectionsSelectationViewModel
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();
}
示例12: CamerasSelectionViewModel
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();
}
示例13: OrganisationsSelectionViewModel
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();
}
示例14: UpdateDevices
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");
}
示例15: UpdateAppointmentPeople
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);
}