本文整理汇总了C#中ICollectionView.Cast方法的典型用法代码示例。如果您正苦于以下问题:C# ICollectionView.Cast方法的具体用法?C# ICollectionView.Cast怎么用?C# ICollectionView.Cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICollectionView
的用法示例。
在下文中一共展示了ICollectionView.Cast方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectAllItems
public void SelectAllItems(ICollectionView availableItemsCollectionView)
{
if (availableItemsCollectionView.SourceCollection is ICollection<Store>)
{
availableItemsCollectionView.Cast<Store>().ToList().ForEach(x => SelectItem(x));
}
}
示例2: LoadedHandler
private void LoadedHandler(object sender, RoutedEventArgs e)
{
// The following code doesn't work in the WPF Designer environment (Cider or Blend).
if (!WafConfiguration.IsInDesignMode)
{
contactCollectionView = CollectionViewSource.GetDefaultView(ViewModel.Contacts);
contactCollectionView.Filter = Filter;
ViewModel.ContactCollectionView = contactCollectionView.Cast<Contact>();
ViewModel.SelectedContact = ViewModel.ContactCollectionView.FirstOrDefault();
}
ViewModel.PropertyChanged += ViewModelPropertyChanged;
contactsBox.Focus();
if (ViewModel.SelectedContact != null) { FocusItem(); }
}
示例3: FirstTimeLoadedHandler
private void FirstTimeLoadedHandler(object sender, RoutedEventArgs e)
{
// Ensure that this handler is called only once.
Loaded -= FirstTimeLoadedHandler;
// The following code doesn't work in the WPF Designer environment (Cider or Blend).
if (!WafConfiguration.IsInDesignMode)
{
bookCollectionView = CollectionViewSource.GetDefaultView(ViewModel.Books);
bookCollectionView.Filter = Filter;
ViewModel.BookCollectionView = bookCollectionView.Cast<BookDataModel>();
bookTable.Focus();
bookTable.CurrentCell = new DataGridCellInfo(ViewModel.Books.FirstOrDefault(), bookTable.Columns[0]);
}
}
示例4: LoadedHandler
private void LoadedHandler(object sender, RoutedEventArgs e)
{
// The following code doesn't work in the WPF Designer environment (Cider or Blend).
if (!WafConfiguration.IsInDesignMode)
{
emailCollectionView = CollectionViewSource.GetDefaultView(ViewModel.Emails);
emailCollectionView.Filter = Filter;
emailCollectionView.SortDescriptions.Add(new SortDescription(nameof(Email.Sent), ListSortDirection.Descending));
ViewModel.EmailCollectionView = emailCollectionView.Cast<Email>();
ViewModel.SelectedEmail = ViewModel.EmailCollectionView.FirstOrDefault();
}
ViewModel.PropertyChanged += ViewModelPropertyChanged;
emailsBox.Focus();
if (ViewModel.SelectedEmail != null)
{
FocusItem();
}
}
示例5: SelectAllItems
public void SelectAllItems(ICollectionView availableItemsCollectionView)
{
if (availableItemsCollectionView.SourceCollection is ICollection<StoreLanguageDisplay>)
{
var itemsList = availableItemsCollectionView.Cast<StoreLanguageDisplay>().ToList();
itemsList.ForEach(x => SelectItem(x));
}
else if (availableItemsCollectionView.SourceCollection is ICollection<StoreCurrency>)
{
var itemsList = availableItemsCollectionView.Cast<StoreCurrency>();
InnerItem.Currencies.Add(itemsList);
}
else if (availableItemsCollectionView.SourceCollection is ICollection<Store>)
{
availableItemsCollectionView.Cast<Store>().ToList().ForEach(x => SelectItem(x));
}
}
示例6: updateFilteredCounters
private void updateFilteredCounters(ICollectionView filteredList)
{
if (filteredList != null)
{
IEnumerable<LogItem> fltList = filteredList.Cast<LogItem>();
if (fltList != null)
{
ItemsFilterCount = fltList.Count();
ItemsDebugFilterCount = (from it in fltList
where it.Level.Equals("DEBUG", StringComparison.OrdinalIgnoreCase)
select it).Count();
ItemsInfoFilterCount = (from it in fltList
where it.Level.Equals("INFO", StringComparison.OrdinalIgnoreCase)
select it).Count();
ItemsWarnFilterCount = (from it in fltList
where it.Level.Equals("WARN", StringComparison.OrdinalIgnoreCase)
select it).Count();
ItemsErrorFilterCount = (from it in fltList
where it.Level.Equals("ERROR", StringComparison.OrdinalIgnoreCase)
select it).Count();
ItemsFatalFilterCount = (from it in fltList
where it.Level.Equals("FATAL", StringComparison.OrdinalIgnoreCase)
select it).Count();
}
}
else
{
ItemsFilterCount = 0;
ItemsDebugFilterCount = 0;
ItemsInfoFilterCount = 0;
ItemsWarnFilterCount = 0;
ItemsErrorFilterCount = 0;
ItemsFatalFilterCount = 0;
}
}
示例7: MainWindow
public MainWindow()
{
InitializeComponent();
discord = new DiscordClient(x =>
{
x.AppName = "OakBot";
x.AppUrl = "http://github.com/ocgineer/OakBot";
x.AppVersion = FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion;
x.UsePermissionsCache = false;
});
// Initialize instance
instance = this;
this.DataContext = this;
if (!Directory.Exists(Config.AppDataPath)) Directory.CreateDirectory(Config.AppDataPath);
if (!Directory.Exists(Config.AppDataPath + "\\Webserver")) Directory.CreateDirectory(Config.AppDataPath + "\\Webserver");
// Initialize config
Config.GetConfigFromDb();
LoadConfigToUI();
DatabaseUtils.LoadAllViewers();
DatabaseUtils.LoadAllQuotes();
// Enable sync between threads
BindingOperations.EnableCollectionSynchronization(colChatMessages, _lockChat);
BindingOperations.EnableCollectionSynchronization(colViewers, _lockViewers);
BindingOperations.EnableCollectionSynchronization(colDatabase, _lockDatabase);
BindingOperations.EnableCollectionSynchronization(colSongs, _lockSongs);
BindingOperations.EnableCollectionSynchronization(colGiveaways, _lockGiveaways);
// Create Event for collection changed
colChatMessages.CollectionChanged += colChatMessages_Changed;
// Link listViews with collections
//listViewChat.ItemsSource = colChatMessages;
listViewViewers.ItemsSource = colViewers;
// Database listView with filter
lvViewerDatabase.ItemsSource = colDatabase;
databaseView = CollectionViewSource.GetDefaultView(lvViewerDatabase.ItemsSource);
databaseView.Filter = DatabaseFilter;
lblFilterCnt.Content = databaseView.Cast<Viewer>().Count();
lvCommands.ItemsSource = colBotCommands;
lvQuotes.ItemsSource = colQuotes;
lvSongs.ItemsSource = colSongs;
lvGiveaways.ItemsSource = colGiveaways;
// Testing Commands
colBotCommands.Add(new UserCommand("!test", "Test received!", 30, 0, true));
colBotCommands.Add(new UserCommand(":yatb", "Yet Another Twitch Bot.", 30, 60, true));
colBotCommands.Add(new UserCommand("!who", "You are @[email protected]", 0, 0, true));
colBotCommands.Add(new UserCommand("!block", "@[email protected] Hello thur!", 0, 0, true));
colBotCommands.Add(new UserCommand("!followdate", "@[email protected], you are following since @[email protected]", 0, 0, true));
colBotCommands.Add(new UserCommand("!followdatetime", "@[email protected], you are following since @[email protected]", 0, 0, true));
colBotCommands.Add(new UserCommand("!vartest", "@[email protected] m8", 0, 0, true));
colBotCommands.Add(new UserCommand("!song", "Currently playing: @[email protected]!", 0, 0, true));
colBotCommands.Add(new UserCommand("Giveaway", "Just stop...", 0, 0, true, true));
colBotCommands.Add(new UserCommand("!slap", "@[email protected] slaps @[email protected] so hard, he bursts into pieces!", 0, 0, true));
colSongs.Add(new Song("https://www.youtube.com/watch?v=VEAy700YGuU"));
colSongs.Add(new Song("https://soundcloud.com/aivisura/steven-universe-strong-in-the-real-way-rebecca-sugar"));
string message = "Hello and welcome to the first OakBot Alpha ever to be released! I know it took some time, but I also have a private life, you know? ;)\n\n" +
"Anyways, this version has not many functions yet, but the ones that are listed here, are fully working.\n\n" +
"WORKING:\n" +
"- Twitch Chat\n" +
"- Commands\n" +
" - Song Requests (the controls are only working for YouTube at the moment)\n" +
" - Quotes\n" +
" - Follow Date\n" +
"- Discord Integration (user unspecific commands work without problems, while the user specific ones are yet to be handled)\n" +
"- Import from Ankhbot\n" +
"- Dashboard and Viewer related stuff\n\n" +
"IMPLEMENTED, BUT NOT FULLY WORKING:\n" +
"- Giveaways\n" +
"- Stream Currency Gain\n" +
"- The UI itself\n\n" +
"I know, there's much to do, but bear with me. I'm working as hard as I can c:";
MessageBox.Show(message, "OakBot Alpha 1");
// BackgroundTask Thread
BackgroundTasks bg = new BackgroundTasks(60, 120);
new Thread(new ThreadStart(bg.Run)) { IsBackground = true }.Start();
// Auto connect
if (Config.AutoConnectBot)
{
ConnectBot();
// Can only connect if Bot is connected
if (Config.AutoConnectStreamer)
{
ConnectStreamer();
//.........这里部分代码省略.........
示例8: SelectAllItems
public void SelectAllItems(ICollectionView availableItemsCollectionView)
{
var itemsList = availableItemsCollectionView.Cast<PropertyValue>().ToList();
itemsList.ForEach(SelectItem);
}
示例9: SelectAllItems
public void SelectAllItems(ICollectionView availableItemsCollectionView)
{
var itemVM = _returnItemVmFactory.GetViewModelInstance();
itemVM.IsBulkReturn = true;
var confirmation = new ConditionalConfirmation { Title = "Specify return reason".Localize(), Content = itemVM };
ReturnItemConfirmRequest.Raise(confirmation, (x) =>
{
if (x.Confirmed)
{
var itemsList = new List<ReturnBuilder.ReturnLineItem>(availableItemsCollectionView.Cast<ReturnBuilder.ReturnLineItem>());
foreach (var obj in itemsList)
{
ReturnBuilder.AddReturnItem(obj, obj.LineItem.Quantity, itemVM.SelectedReason);
}
OnPropertyChanged("ReturnTotal");
OnIsValidChanged();
}
});
}
示例10: GetNumberOfResults
private static int GetNumberOfResults(ICollectionView _view)
{
Debug.Assert(_view != null);
var items = _view.Cast<object>();
Debug.Assert(items != null);
return items.Count();
}