当前位置: 首页>>代码示例>>C#>>正文


C# ObservableCollection.Cast方法代码示例

本文整理汇总了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;
 }
开发者ID:martin-holy,项目名称:PictureManager,代码行数:8,代码来源:FolderKeywords.cs

示例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);
        }
开发者ID:BruceMellows,项目名称:TeamPilgrim,代码行数:12,代码来源:UnshelveServiceModel.cs

示例3: UndoPendingChange

 private void UndoPendingChange(ObservableCollection<object> collection)
 {
     teamPilgrimVsService.UndoChanges(_workspaceServiceModel.Workspace, collection.Cast<PendingChangeModel>().Select(model => model.Change).ToArray());
 }
开发者ID:StanleyGoldman,项目名称:TeamPilgrim,代码行数:4,代码来源:ShelveServiceModel.cs

示例4: CompareWithWorkspace

 private void CompareWithWorkspace(ObservableCollection<object> collection)
 {
     teamPilgrimVsService.CompareChangesetChangesWithWorkspaceVersions(_workspaceServiceModel.Workspace, collection.Cast<PendingChangeModel>().Select(model => model.Change).ToArray());
 }
开发者ID:StanleyGoldman,项目名称:TeamPilgrim,代码行数:4,代码来源:ShelveServiceModel.cs

示例5: ViewWorkItem

 private void ViewWorkItem(ObservableCollection<object> collection)
 {
     foreach (var workItemModel in collection.Cast<WorkItemModel>())
     {
         OpenWorkItemHelperWrapper.OpenWorkItem(workItemModel.WorkItem, collection.Count == 1);
     }
 }
开发者ID:BruceMellows,项目名称:TeamPilgrim,代码行数:7,代码来源:WorkspaceServiceModel.cs

示例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;
            };
        }
开发者ID:EmptyBucket,项目名称:MacroKey,代码行数:59,代码来源:MainViewModel.cs

示例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;
        }
开发者ID:anotherdeveloper,项目名称:FileManager,代码行数:42,代码来源:FileMethods.cs

示例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;
        }
开发者ID:anotherdeveloper,项目名称:FileManager,代码行数:62,代码来源:FileMethods.cs


注:本文中的ObservableCollection.Cast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。