本文整理汇总了C#中BindableCollection.FirstOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# BindableCollection.FirstOrDefault方法的具体用法?C# BindableCollection.FirstOrDefault怎么用?C# BindableCollection.FirstOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BindableCollection
的用法示例。
在下文中一共展示了BindableCollection.FirstOrDefault方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChooseServerDialogViewModel
public ChooseServerDialogViewModel(BindableCollection<ServerItemModel> servers)
{
this.servers = servers;
this.DisplayName = "Choose default server:";
this.SelectedServer = servers.FirstOrDefault(x => x.IsChecked);
if (this.SelectedServer == null)
{
this.SelectedServer = servers.FirstOrDefault();
}
}
示例2: DatabaseModel
public DatabaseModel(string name, DocumentStore documentStore)
{
this.name = name;
this.documentStore = documentStore;
Tasks = new BindableCollection<TaskModel>(x => x.Name)
{
new ImportTask(),
new ExportTask(),
new StartBackupTask(),
new IndexingTask(),
new SampleDataTask()
};
SelectedTask = new Observable<TaskModel> { Value = Tasks.FirstOrDefault() };
Statistics = new Observable<DatabaseStatistics>();
Status = new Observable<string>
{
Value = "Offline"
};
asyncDatabaseCommands = name.Equals(Constants.SystemDatabase, StringComparison.OrdinalIgnoreCase)
? documentStore.AsyncDatabaseCommands.ForDefaultDatabase()
: documentStore.AsyncDatabaseCommands.ForDatabase(name);
DocumentChanges.Select(c => Unit.Default).Merge(IndexChanges.Select(c => Unit.Default))
.SampleResponsive(TimeSpan.FromSeconds(2))
.Subscribe(_ => RefreshStatistics(), exception => ApplicationModel.Current.Server.Value.IsConnected.Value = false);
RefreshStatistics();
}
示例3: EndoscopyViewModel
public EndoscopyViewModel(IEventAggregator events, int sessionId)
{
DisplayName = "Nội soi";
if (App.Current != null)
{
_esClinicContext = App.Current.EsClinicContext;
}
_events = events;
_sessionId = sessionId;
Photos = new BindableCollection<TmpPhoto>();
IsEnabledScopy = true;
NotifyOfPropertyChange(() => IsEnabledScopy);
EsTypes = new BindableCollection<EndoscopyType>();
var esTypes = _esClinicContext.EndoscopyTypes.ToList();
foreach (var esType in esTypes)
{
EsTypes.Add(esType);
}
Cameras = new BindableCollection<Camera>();
foreach (var camera in CameraService.AvailableCameras)
{
Cameras.Add(camera);
}
_selectedCamera = Cameras.FirstOrDefault();
}
示例4: GenericPropertiesViewModel
public GenericPropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
{
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.LayerAnimations);
OpacityProperties = new LayerDynamicPropertiesViewModel("Opacity", editorVm);
SelectedLayerAnimation =
LayerAnimations.FirstOrDefault(l => l.Name == editorVm.ProposedLayer.LayerAnimation?.Name) ??
LayerAnimations.First(l => l.Name == "None");
}
示例5: DatabaseModel
public DatabaseModel(string name, IAsyncDatabaseCommands asyncDatabaseCommands)
{
Name = name;
this.asyncDatabaseCommands = asyncDatabaseCommands;
Tasks = new BindableCollection<TaskModel>(x => x.Name)
{
new ImportTask(asyncDatabaseCommands),
new ExportTask(asyncDatabaseCommands)
};
SelectedTask = new Observable<TaskModel> {Value = Tasks.FirstOrDefault()};
Statistics = new Observable<DatabaseStatistics>();
}
示例6: DatabaseModel
public DatabaseModel(string name, DocumentStore documentStore)
{
this.name = name;
Tasks = new BindableCollection<TaskModel>(x => x.Name)
{
new ImportTask(),
new ExportTask(),
new StartBackupTask(),
};
SelectedTask = new Observable<TaskModel> {Value = Tasks.FirstOrDefault()};
Statistics = new Observable<DatabaseStatistics>();
asyncDatabaseCommands = name.Equals(DefaultDatabaseName, StringComparison.OrdinalIgnoreCase)
? documentStore.AsyncDatabaseCommands.ForDefaultDatabase()
: documentStore.AsyncDatabaseCommands.ForDatabase(name);
}
示例7: DatabaseModel
public DatabaseModel(string name, DocumentStore documentStore)
{
this.name = name;
this.documentStore = documentStore;
Tasks = new BindableCollection<TaskModel>(x => x.Name)
{
new ImportTask(),
new ExportTask(),
new StartBackupTask(),
new IndexingTask(),
new SampleDataTask(),
new CsvImportTask()
};
if (name == null || name == Constants.SystemDatabase)
Tasks.Insert(3, new StartRestoreTask());
SelectedTask = new Observable<TaskModel> { Value = Tasks.FirstOrDefault() };
Statistics = new Observable<DatabaseStatistics>();
Status = new Observable<string>
{
Value = "Offline"
};
OnPropertyChanged(() => StatusImage);
asyncDatabaseCommands = name.Equals(Constants.SystemDatabase, StringComparison.OrdinalIgnoreCase)
? documentStore.AsyncDatabaseCommands.ForDefaultDatabase()
: documentStore.AsyncDatabaseCommands.ForDatabase(name);
DocumentChanges.Select(c => Unit.Default).Merge(IndexChanges.Select(c => Unit.Default))
.SampleResponsive(TimeSpan.FromSeconds(2))
.Subscribe(_ => RefreshStatistics());
databaseChanges.ConnectionStatusChanged += (sender, args) =>
{
ApplicationModel.Current.Server.Value.SetConnected(((IDatabaseChanges)sender).Connected);
UpdateStatus();
};
RefreshStatistics();
}
示例8: AfterUpdate
private void AfterUpdate(NameAndCount[] collectionDocumentsCount)
{
// update documents count
var nameToCount = collectionDocumentsCount.OrderByDescending(count => count.Count).ToDictionary(i => i.Name, i => i.Count);
var collections = Collections.OrderByDescending(model => model.Count).ToList();
Collections = new BindableCollection<CollectionModel>(model => model.Name);
foreach (var collectionModel in collections)
{
Collections.Add(collectionModel);
}
foreach (var collectionModel in Collections)
{
collectionModel.Count = nameToCount[collectionModel.Name];
}
if (initialSelectedDatabaseName != null &&
(SelectedCollection.Value == null || SelectedCollection.Value.Name != initialSelectedDatabaseName || Collections.Contains(SelectedCollection.Value) == false))
{
SelectedCollection.Value = Collections.FirstOrDefault(x => x.Name == initialSelectedDatabaseName);
}
if (SelectedCollection.Value == null)
SelectedCollection.Value = Collections.FirstOrDefault();
OnPropertyChanged(() => Collections);
}
示例9: SetupControls
private void SetupControls()
{
var dataModelProps = _layerEditorViewModel.DataModelProps;
Name = _property + ":";
// Populate target combobox
Targets = new BindableCollection<GeneralHelpers.PropertyCollection>
{
new GeneralHelpers.PropertyCollection {Display = "None"}
};
Targets.AddRange(dataModelProps.Where(p => (p.Type == "Int32") || (p.Type == "Single")));
// Populate sources combobox
Sources = new BindableCollection<GeneralHelpers.PropertyCollection>();
Sources.AddRange(dataModelProps.Where(p => (p.Type == "Int32") || (p.Type == "Single")));
// Preselect according to the model
SelectedTarget = dataModelProps.FirstOrDefault(p => p.Path == Proposed.GameProperty);
SelectedSource = dataModelProps.FirstOrDefault(p => p.Path == Proposed.PercentageProperty);
LayerPropertyType = Proposed.LayerPropertyType;
// Populate the extra options combobox
switch (_property)
{
case "Width":
LayerPropertyOptions = new BindableCollection<LayerPropertyOptions>
{
Artemis.Profiles.Layers.Models.LayerPropertyOptions.LeftToRight,
Artemis.Profiles.Layers.Models.LayerPropertyOptions.RightToLeft
};
break;
case "Height":
LayerPropertyOptions = new BindableCollection<LayerPropertyOptions>
{
Artemis.Profiles.Layers.Models.LayerPropertyOptions.Downwards,
Artemis.Profiles.Layers.Models.LayerPropertyOptions.Upwards
};
break;
case "Opacity":
LayerPropertyOptions = new BindableCollection<LayerPropertyOptions>
{
Artemis.Profiles.Layers.Models.LayerPropertyOptions.Increase,
Artemis.Profiles.Layers.Models.LayerPropertyOptions.Decrease
};
break;
}
UserSourceIsVisible = LayerPropertyType == LayerPropertyType.PercentageOf;
SourcesIsVisible = LayerPropertyType == LayerPropertyType.PercentageOfProperty;
// Set up a default for SelectedTarget if it was null
if (SelectedTarget.Display == null)
SelectedTarget = Targets.FirstOrDefault();
// Set up a default for the extra option if it fell outside the range
if (!LayerPropertyOptions.Contains(Proposed.LayerPropertyOptions))
Proposed.LayerPropertyOptions = LayerPropertyOptions.FirstOrDefault();
}
示例10: RefreshDevices
public void RefreshDevices()
{
VideoDevices = new BindableCollection<string>(DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice).Select((device) => device.Name));
InputName = VideoDevices.FirstOrDefault();
}