本文整理汇总了C#中ObservableCollection.Cast方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.Cast方法的具体用法?C# ObservableCollection.Cast怎么用?C# ObservableCollection.Cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.Cast方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFolderKeywordByDirId
public FolderKeyword GetFolderKeywordByDirId(ObservableCollection<BaseTreeViewItem> items, int dirId) {
foreach (var folderKeyword in items.Cast<FolderKeyword>()) {
if (folderKeyword.FolderIdList.Any(fid => fid == dirId)) return folderKeyword;
var fk = GetFolderKeywordByDirId(folderKeyword.Items, dirId);
if (fk != null) return fk;
}
return null;
}
示例2: Delete
private void Delete(ObservableCollection<object> shelvesetModels)
{
var messageBoxResult = MessageBox.Show("Delete Shelveset\r\n\r\nAre you sure you want to delete the selected item? This operation is permanent.", "Team Pilgrim", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
if (messageBoxResult != MessageBoxResult.Yes) return;
foreach (var shelvesetModel in shelvesetModels.Cast<ShelvesetModel>())
{
teamPilgrimServiceModelProvider.TryDeleteShelveset(ProjectCollectionServiceModel.TfsTeamProjectCollection, shelvesetModel.Shelveset.Name, shelvesetModel.Shelveset.OwnerName);
}
FindShelvesetsCommand.Execute(null);
}
示例3: UndoPendingChange
private void UndoPendingChange(ObservableCollection<object> collection)
{
teamPilgrimVsService.UndoChanges(_workspaceServiceModel.Workspace, collection.Cast<PendingChangeModel>().Select(model => model.Change).ToArray());
}
示例4: CompareWithWorkspace
private void CompareWithWorkspace(ObservableCollection<object> collection)
{
teamPilgrimVsService.CompareChangesetChangesWithWorkspaceVersions(_workspaceServiceModel.Workspace, collection.Cast<PendingChangeModel>().Select(model => model.Change).ToArray());
}
示例5: ViewWorkItem
private void ViewWorkItem(ObservableCollection<object> collection)
{
foreach (var workItemModel in collection.Cast<WorkItemModel>())
{
OpenWorkItemHelperWrapper.OpenWorkItem(workItemModel.WorkItem, collection.Count == 1);
}
}
示例6: MainViewModel
public MainViewModel(KeyHooker hookerKey, MouseHooker hookerMouse, KeySenderInput keySenderInput, MouseSenderInput mouseSenderInput)
{
mHookerKey = hookerKey;
mHookerKey.SetHook();
mHookerMouse = hookerMouse;
mHookerMouse.SetHook();
mKeySenderInput = keySenderInput;
mMouseSenderInput = mouseSenderInput;
mStopMacroBranch = new Branch<IInput>(mInputEqualityComparer);
mMacrosModeBranch = new Branch<IInput>(mInputEqualityComparer);
Settings.Default.Setting = Settings.Default.Setting ?? new AppSettings(mInputEqualityComparer);
AppSettings settings = Settings.Default.Setting;
mTreeRoot = settings.TreeRoot;
mTreeSequence = settings.TreeSequence;
MacrosCollection = settings.MacrosCollection;
StopMacroCollection = settings.SequenceStopMacro;
MacrosModeCollection = settings.SequenceMacrosMode;
SequenceCollection = settings.Sequence;
MacroCollection = settings.Macro;
mSequenceReader = new HookNotRepeatReader(mHookerKey, SequenceCollection);
ObservableCollection<IInput> tempCollection = new ObservableCollection<IInput>(MacroCollection.Cast<IInput>());
tempCollection.CollectionChanged += ReadMacro_CollectionChanged;
mMacroReader = new MultiHookNotRepeatReader(new List<IHooker> { mHookerKey, mHookerMouse }, tempCollection);
mStopMacroReader = new HookNotRepeatReader(mHookerKey, StopMacroCollection);
mMacrosModeReader = new HookNotRepeatReader(mHookerKey, MacrosModeCollection);
RecordSequenceCommand = new RelayCommand(RecordSequence);
RecordMacroCommand = new RelayCommand(RecordMacro);
CreateMacrosCommand = new RelayCommand(CreateMacros);
CleanRowsSequenceCommand = new RelayCommand(CleanSequence);
CleanRowsMacroCommand = new RelayCommand(CleanMacro);
CleanRowsMacrosCommand = new RelayCommand(CleanMacros);
DeleteRowSequenceCommand = new RelayCommand<IInput>(RemoveSequence);
DeleteRowMacroCommand = new RelayCommand<InputDelay>(RemoveMacro);
DeleteRowMacrosCommand = new RelayCommand<Macros>(RemoveMacros);
StopRecordStopMacroCommand = new RelayCommand(StopRecordStopMacro);
StartRecordStopMacroCommand = new RelayCommand(StartRecordStopMacro);
StartRecordMacrosModeCommand = new RelayCommand(StartRecordMacrosMode);
StopRecordMacrosModeCommand = new RelayCommand(StopRecordMacrosMode);
SetDefaultDelayCommand = new RelayCommand(SetDefaultDelay);
StopAllRecordCommand = new RelayCommand(StopAllRecord);
mCancellationState = new CancelState<IInput>(mInputEqualityComparer);
StateWalker<IInput> machineWalker = new StateWalker<IInput>(mTreeRoot);
mHookerKey.Hooked += arg =>
{
State<IInput> currentState = machineWalker.WalkStates(arg);
return currentState is FunctionState<IInput>
? (bool)((FunctionState<IInput>)currentState).ExecuteFunction()
: currentState is CancellationFunctionState<IInput>
? (bool)((CancellationFunctionState<IInput>)currentState).ExecuteFunction(mCancellationState.CancelToken)
: true;
};
}
示例7: GetLongItems
public static ObservableCollection<ThingBase> GetLongItems(string path)
{
ObservableCollection<DirectoryThing> directories = null;
try
{
directories = new ObservableCollection<DirectoryThing>(from item in Microsoft.Experimental.IO.LongPathDirectory.EnumerateDirectories(path)
select new DirectoryThing(item));
}
catch (UnauthorizedAccessException exception)
{
return null;
}
ObservableCollection<ThingBase> children = new ObservableCollection<ThingBase>();
ObservableCollection<FileThing> files = null;
try
{
files = new ObservableCollection<FileThing>(from item in LongPathDirectory.EnumerateFiles(path)
select new FileThing(item));
}
catch (UnauthorizedAccessException exception)
{
}
ObservableCollection<ThingBase> things = new ObservableCollection<ThingBase>(directories.Cast<ThingBase>().Union(files.Cast<ThingBase>()));
foreach (var item in directories)
{
var childItems = GetLongItems(item.FullName);
if (null != childItems)
foreach (var i in childItems)
{
things.Add(i);
}
}
return things;
}
示例8: GetItems
public static ObservableCollection<ThingBase> GetItems(string path)
{
try
{
DirectoryInfo info = null;
try
{
info = new DirectoryInfo(path);
}
catch (PathTooLongException exeption)
{
return GetLongItems(path);
}
ObservableCollection<DirectoryThing> directories = null;
try
{
directories = new ObservableCollection<DirectoryThing>(from item in info.EnumerateDirectories()
select new DirectoryThing(item, path));
}
catch (UnauthorizedAccessException exception)
{
return null;
}
ObservableCollection<ThingBase> children = new ObservableCollection<ThingBase>();
ObservableCollection<FileThing> files = null;
try
{
files = new ObservableCollection<FileThing>(from item in info.EnumerateFiles()
select new FileThing(item, path));
}
catch (UnauthorizedAccessException exception)
{
}
ObservableCollection<ThingBase> things = new ObservableCollection<ThingBase>(directories.Cast<ThingBase>().Union(files.Cast<ThingBase>()));
foreach (var item in directories)
{
var childItems = GetItems(item.FullName);
if (null != childItems)
foreach (var i in childItems)
{
things.Add(i);
}
}
return things;
}
catch (Exception exception)
{
}
return null;
}