本文整理汇总了C#中ObservableCollection.Any方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.Any方法的具体用法?C# ObservableCollection.Any怎么用?C# ObservableCollection.Any使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.Any方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildSearchFilters
void BuildSearchFilters()
{
Extensions = new ObservableCollection<NodeItem>()
{
new NodeItem() {Title = Any,IsSelected = true},
new NodeItem() {Title = "itrace"},
new NodeItem() {Title = "wmv"},
new NodeItem() {Title = "xesc"},
new NodeItem() {Title = "coverage"},
new NodeItem() {Title = "trmx"},
new NodeItem() {Title = "trx"},
new NodeItem() {Title = "cov"},
new NodeItem() {Title = "docx"},
new NodeItem() {Title = "doc"},
new NodeItem() {Title = "xls"},
new NodeItem() {Title = "xlsx"},
new NodeItem() {Title = "png"},
new NodeItem() {Title = "jpg"},
new NodeItem() {Title = "gif"},
};
States = new ObservableCollection<NodeItem>() { new NodeItem() { Title = Any, IsSelected = true } };
foreach (var t in TfsShared.Instance.Transitions)
{
if (!States.Any(s => s.Title.Equals(t.From)) && !string.IsNullOrEmpty(t.From)) States.Add(new NodeItem() { Title = t.From });
if (!States.Any(s => s.Title.Equals(t.To)) && !string.IsNullOrEmpty(t.To)) States.Add(new NodeItem() { Title = t.To });
}
}
示例2: SelectInvoicesVm
public SelectInvoicesVm(SelectInvoices selectInvoicesWindow, IPaymentService service)
: base(service)
{
SelectInvoicesWindow = selectInvoicesWindow;
CommitCommand = new DelegateCommand<object>(OnCommitExecute, CanCommitExecute);
CancelCommand = new DelegateCommand<object>(OnCancelExecute, CanCancelExecute);
Suppliers = new QueryableDataServiceCollectionView<SupplierDTO>(service.Context, service.Context.Suppliers);
Currencies = new QueryableDataServiceCollectionView<CurrencyDTO>(service.Context, service.Context.Currencies);
_supplierFilter = new FilterDescriptor("SupplierId", FilterOperator.IsEqualTo, 0);
#region 发票
Invoices = new QueryableDataServiceCollectionView<BaseInvoiceDTO>(service.Context, service.Context.Invoices);
Invoices.FilterDescriptors.Add(_supplierFilter);
Invoices.LoadedData += (e, o) =>
{
InvoiceList = new ObservableCollection<BaseInvoiceDTO>();
Invoices.ToList().ForEach(InvoiceList.Add);
SelectInvoices = new ObservableCollection<BaseInvoiceDTO>();
if (!InvoiceList.Any()) return;
_paymentNotice.PaymentNoticeLines.ToList().ForEach(p =>
{
if (InvoiceList.Any(t => t.InvoiceId == p.InvoiceId))
SelectInvoices.Add(InvoiceList.FirstOrDefault(t => t.InvoiceId == p.InvoiceId));
});
};
#endregion
}
示例3: ValidateAvailabilityOfSpecialItems
public void ValidateAvailabilityOfSpecialItems (ObservableCollection<Video> collectionToCheck)
{
if(this.modifyUrlButton != null && this.startDownloadingButton != null && this.moveQueuedItemDown != null && this.moveQueuedItemUp != null)
{
this.modifyUrlButton.IsEnabled = collectionToCheck.Any();
this.startDownloadingButton.IsEnabled = collectionToCheck.Any();
var countCheck = collectionToCheck.Count > 1;
this.moveQueuedItemDown.IsEnabled = countCheck;
this.moveQueuedItemUp.IsEnabled = countCheck;
}
}
示例4: ValidateAvailabilityOfSpecialItems
public void ValidateAvailabilityOfSpecialItems (ObservableCollection<Video> collectionToCheck)
{
if(this.IsInitialized)
{
this.modifyUrlButton.IsEnabled = collectionToCheck.Any();
this.startDownloadingButton.IsEnabled = collectionToCheck.Any();
var countCheck = collectionToCheck.Count > 1;
this.moveQueuedItemDown.IsEnabled = countCheck;
this.downArrowImage.Opacity = countCheck ? 1.0 : .15;
this.moveQueuedItemUp.IsEnabled = countCheck;
this.upArrowImage.Opacity = countCheck ? 1.0 : .15;
}
}
示例5: ChooseTaxonsViewModel
public ChooseTaxonsViewModel(ITaxonService taxonService)
{
TaxonFilter = "";
Title = "Välj arter";
Device.BeginInvokeOnMainThread(async () =>
{
var taxons = await taxonService.GetSpecies();
Taxons = new ObservableCollection<TaxonItemModel>(taxons.Select(x => new TaxonItemModel { Name = x.Name, Prefix = x.Prefix }).ToList());
if (Taxons != null)
{
foreach (var taxon in Taxons)
{
taxon.Selected = selectedTaxons.Any(t => t == taxon.Name);
}
foreach (var taxon in selectedTaxons)
{
if (!Taxons.Any(t => t.Name == taxon))
{
Taxons.Add(new TaxonItemModel { Name = taxon, Selected = true });
}
}
RaisePropertyChanged<ChooseTaxonsViewModel, ObservableCollection<TaxonItemModel>>(x => x.Taxons);
}
});
}
示例6: TreeOrganizedByDeviceTypeViewModel
public TreeOrganizedByDeviceTypeViewModel(IList<Machine> machines)
{
_treeData = new ObservableCollection<DeviceTypeNode>();
foreach (Machine machine in machines)
{
if (machine.Devices != null)
foreach (Device device in machine.Devices)
{
if (_treeData.Any(t => t.DeviceType == device.DeviceType))
{
var deviceTypeNode = _treeData.First(t => t.DeviceType == device.DeviceType);
deviceTypeNode.Devices.Add(string.Format("{0} - {1}", machine.MachineName, device.DeviceName), device); //NOTE: In real application, this is actually just LocationId, need to look up meaningful location name
}
else
{
_treeData.Add(new DeviceTypeNode
{
DeviceType = device.DeviceType,
Devices = new Dictionary<string, Device>()
{
{ string.Format("{0} - {1}",machine.MachineName, device.DeviceName), device }
}
});
}
}
}
}
示例7: PortalGroupViewModel
public PortalGroupViewModel()
{
Messenger.Default.Register<ChangeGroupSelectedMessage>(this,
msg => { PortalGroup = msg.Group; });
// initialize ListGroupContent RelayCommand
ListGroupContentCommand = new RelayCommand<ArcGISPortalGroup>(async pg =>
{
if (pg == null)
return;
var gsItems = await pg.GetItemsAsync();
if (gsItems == null || !gsItems.Any())
return;
// filter out any ArcGISPortalItem that is not a WebMap
var webMapItems = gsItems.Where(item => item.Type == ItemType.WebMap);
// create an observable collection of the WebMap items
var groupSharedItems = new ObservableCollection<ArcGISPortalItem>(webMapItems);
if (!groupSharedItems.Any())
return;
// send ChangePortalItemsCollectionMessage message to other ViewModels who are registered with it.
Messenger.Default.Send<ChangePortalItemsCollectionMessage>(new ChangePortalItemsCollectionMessage()
{
ItemCollection = groupSharedItems,
Title = string.Format("Content of Group: {0}", pg.Title)
});
// use the navigation service to navigate to the page showing the specific collection of portal items
(new NavigationService()).Navigate(App.CollectionPageName);
});
}
示例8: ActionsViewModel
public ActionsViewModel(IPackageManager packageManager, List<PackageAction> actions)
{
DisplayName = "";
List = new ObservableCollection<PackageAction>(actions);
List.CollectionChanged += (sender, args) => RaisePropertyChanged(() => OrderedList);
var eventHandler = new PropertyChangedEventHandler((sender, args) =>
{
if (List.Any(n => n.Progress != 100))
return;
CanClose = true;
RaisePropertyChanged(() => CanClose);
// TODO: if autoclose in options: TryClose(true)
});
actions.ForEach(n => n.SubscribeToPropertyChanged(eventHandler));
foreach (var action in actions)
{
action.ActionAdded += a => DispatcherHelper.CheckBeginInvokeOnUI(() => List.Add(a));
}
CloseCommand = new RelayCommand(() => TryClose(true));
packageManager.Execute(actions.ToArray());
}
示例9: OperatorActivitiesVM
public OperatorActivitiesVM(OperatorVM opr, AccessType access) : base(access)
{
UnitOfWork = new SoheilEdmContext();
CurrentOperator = opr;
OperatorDataService = new OperatorDataService(UnitOfWork);
OperatorDataService.ActivityAdded += OnActivityAdded;
OperatorDataService.ActivityRemoved += OnActivityRemoved;
ActivityDataService = new ActivityDataService(UnitOfWork);
ActivityOperatorDataService = new ActivitySkillDataService(UnitOfWork);
ActivityGroupDataService = new ActivityGroupDataService(UnitOfWork);
var selectedVms = new ObservableCollection<ActivityOperatorVM>();
foreach (var generalActivitySkill in OperatorDataService.GetActivities(opr.Id))
{
selectedVms.Add(new ActivityOperatorVM(generalActivitySkill, Access, ActivityOperatorDataService, RelationDirection.Reverse));
}
SelectedItems = new ListCollectionView(selectedVms);
var allVms = new ObservableCollection<ActivityVM>();
foreach (var activity in ActivityDataService.GetActives()
.Where(activity => !selectedVms.Any(activityOperator => activityOperator.ActivityId == activity.Id)))
{
allVms.Add(new ActivityVM(activity, Access, ActivityDataService, ActivityGroupDataService));
}
AllItems = new ListCollectionView(allVms);
IncludeCommand = new Command(Include, CanInclude);
ExcludeCommand = new Command(Exclude, CanExclude);
}
示例10: TopicsModel
public TopicsModel()
: base("TrendingTopics")
{
this.PropertyChanged += (sender, e) =>
{
if (e.PropertyName == "ListSelection")
OnSelectionChanged();
if (e.PropertyName == "SelectedLocation")
UserChoseLocation();
};
geoWatcher = new GeoCoordinateWatcher();
if (Config.EnabledGeolocation == true)
geoWatcher.Start();
Locations = new ObservableCollection<string>();
LocationMap = new Dictionary<string, long>();
refresh = new DelegateCommand((obj) => GetTopics());
showGlobal = new DelegateCommand((obj) => { currentLocation = 1; PlaceName = Localization.Resources.Global; GetTopics(); });
showLocations = new DelegateCommand((obj) => RaiseShowLocations(), (obj) => Locations.Any());
ServiceDispatcher.GetCurrentService().ListAvailableTrendsLocations(ReceiveLocations);
IsLoading = true;
if (Config.EnabledGeolocation == true && (Config.TopicPlaceId == -1 || Config.TopicPlaceId == null))
ServiceDispatcher.GetCurrentService().ListClosestTrendsLocations(new ListClosestTrendsLocationsOptions{ Lat = geoWatcher.Position.Location.Latitude, Long = geoWatcher.Position.Location.Longitude }, ReceiveMyLocation);
else
{
currentLocation = Config.TopicPlaceId.HasValue ? (long)Config.TopicPlaceId : 1;
PlaceName = Config.TopicPlace;
GetTopics();
}
}
示例11: TaskListViewModel
public TaskListViewModel()
{
Tasks = new ObservableCollection<PandocTask>(TaskRepository.ToList());
SelectedTask = Tasks.Any() ? Tasks.First() : null;
Add = new RelayCommand(() =>
{
var task = new PandocTask();
Tasks.Add(task);
});
Save = new RelayCommand(() =>
{
var trans = TaskRepository.BeginBatch();
foreach (var task in Tasks)
{
if (TaskRepository.Exists(task.Key))
trans.Update(task);
else trans.Add(task);
}
trans.Commit();
});
Load = new RelayCommand(() =>
{
Tasks.Clear();
foreach (var task in TaskRepository.GetAll())
{
Tasks.Add(task);
}
});
}
示例12: Initialize
public void Initialize()
{
IsNowPlaying = false;
Sounds = new ObservableCollection<SoundViewModel>();
var stateClasses = new List<XStateClass>();
stateClasses.Add(XStateClass.Attention);
stateClasses.Add(XStateClass.Fire1);
stateClasses.Add(XStateClass.Fire2);
stateClasses.Add(XStateClass.AutoOff);
stateClasses.Add(XStateClass.ConnectionLost);
stateClasses.Add(XStateClass.Failure);
stateClasses.Add(XStateClass.Ignore);
stateClasses.Add(XStateClass.Off);
stateClasses.Add(XStateClass.On);
stateClasses.Add(XStateClass.TurningOff);
stateClasses.Add(XStateClass.TurningOn);
foreach (var stateClass in stateClasses)
{
var newSound = new Sound() { StateClass = stateClass };
var sound = FiresecClient.FiresecManager.SystemConfiguration.Sounds.FirstOrDefault(x => x.StateClass == stateClass);
if (sound == null)
FiresecClient.FiresecManager.SystemConfiguration.Sounds.Add(newSound);
else
newSound = sound;
Sounds.Add(new SoundViewModel(newSound));
}
SelectedSound = Sounds.FirstOrDefault();
if (FiresecClient.FiresecManager.SystemConfiguration.Sounds.RemoveAll(x => !Sounds.Any(y => y.StateClass == x.StateClass)) > 0)
ServiceFactory.SaveService.SoundsChanged = true;
}
示例13: GetLeftFromChildren
private double GetLeftFromChildren(ObservableCollection<ICanvasItem> children)
{
if (!children.Any())
{
return double.NaN;
}
var min = children.Min(item => item.Left);
return min;
}
示例14: Initialize
public async Task<bool> Initialize()
{
AccountUsers = new ObservableCollection<AccountUser>();
var users = await AccountDatabase.GetUserAccounts();
foreach (var user in users)
{
AccountUsers.Add(user);
}
return AccountUsers.Any();
}
示例15: IssueOptions
public IssueOptions()
{
InitializeComponent();
viewModels = new ObservableCollection<IssueOptionsViewModel>(
from p in IssueManager.IssueProviders
where p.Attribute != null
select new IssueOptionsViewModel(p)
);
ICollectionView view = CollectionViewSource.GetDefaultView(viewModels);
if (viewModels.Any(p => !string.IsNullOrEmpty(p.Category)))
view.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
listBox.ItemsSource = view;
}