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


C# ObservableCollection.AddRange方法代码示例

本文整理汇总了C#中System.Collections.ObservableCollection.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.AddRange方法的具体用法?C# ObservableCollection.AddRange怎么用?C# ObservableCollection.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.ObservableCollection的用法示例。


在下文中一共展示了ObservableCollection.AddRange方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SelectMetaDataWindowVM

        public SelectMetaDataWindowVM(BookRelationType bookRelationType, string metaDataId)
        {
            this.bookRelationType = bookRelationType;

            bookRelationItems = new ObservableCollection<BookRelationItem>();
            bookRelationItems.AddRange(BookRelationItem.All);
            this.allObjects = new ObservableCollection<ITitleProvider>();
            this.objects = new ObservableCollection<ITitleProvider>();
            this.metaDataId = metaDataId;
        }
开发者ID:Easy-DDI-Organizer,项目名称:EDO,代码行数:10,代码来源:SelectMetaDataWindowVM.cs

示例2: PerformSearch

        public void PerformSearch()
        {
            try
            {
                logger.Debug("Searching for projects with Name=\"{0}\" Left=\"{1}\" Right=\"{2}\"", SearchName, SearchLeftDate, SearchRightDate);
                SearchHeader = "Search Settings - Searching";
                logger.Info("Starting the search!");
                databaseService.SearchProjects(SearchName, SearchNumber, SearchLeftDate, SearchRightDate).ContinueWith((Task<IList<Project>> task) =>
                {
                    logger.Info("Search finished!");
                    var results = task.Result;
                    DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        try
                        {
                            _searchResults = new ObservableCollection<HistorySearchResult>();
                            _searchResults.AddRange(results.OrderBy(x => x.Created).Select(x => new HistorySearchResult(x)));
                            OnPropertyChanged(nameof(SearchResults));

                            IsSearching = false;
                            SearchHeader = string.Format("Search Settings - {0} results", SearchResults.Count);
                            logger.Debug("Finisehd search with {0} results.", SearchResults.Count);
                        }
                        catch (Exception exp)
                        {
                            logger.Error(exp, "Search failed.");
                        }
                    });
                });
                logger.Info("Search have been started!");
            }
            catch (Exception exp)
            {
                logger.Error(exp, "Search failed. (Outter)");
            }
        }
开发者ID:audioview2016,项目名称:AudioView2,代码行数:36,代码来源:HistoryViewModel.cs

示例3: CreateMenuButtons

        private ObservableCollection<ScreenMenuItemButton> CreateMenuButtons(ScreenMenuCategory category, int pageNo, string tag)
        {
            SelectedCategory = category;

            var screenMenuItems = AppServices.DataAccessService.GetMenuItems(category, pageNo, tag);
            var result = new ObservableCollection<ScreenMenuItemButton>();
            var items = screenMenuItems.Select(x => new ScreenMenuItemButton(x, MenuItemCommand, category));
            if (category.SortType == 1) items = items.OrderByDescending(x => x.UsageCount);
            result.AddRange(items);
            return result;
        }
开发者ID:hpbaotho,项目名称:sambapos,代码行数:11,代码来源:MenuItemSelectorViewModel.cs

示例4: Init

        public void Init(Model model) {
            InitializeComponent();

            OnCompleted += () => {
                disposables.Dispose();
            };

            var availableActions = new ObservableCollection<Action1>();
            var includedActions = new ObservableCollection<Action1>();

            var applyCommand = new DelegateCommand(
                () => {
                    model.trigger.Configuration.TopicExpression = GetTopicExression();
                    if (string.IsNullOrEmpty(model.trigger.Configuration.TopicExpression.Any.First().InnerText))
                        model.trigger.Configuration.TopicExpression = null;
                    if (string.IsNullOrEmpty(model.trigger.Configuration.ContentExpression.Any.First().InnerText))
                        model.trigger.Configuration.ContentExpression = null;
                    model.trigger.Configuration.ActionToken = includedActions.Select(a => a.Token).ToArray();

                    Success(new Result.Apply(model));
                },
                () => true
            );
            applyButton.Command = applyCommand;

            var cancelCommand = new DelegateCommand(
                () => Success(new Result.Cancel(model)),
                () => true
            );
            cancelButton.Command = cancelCommand;

            FixModel(model);

            { // token
                valueToken.CreateBinding(TextBlock.TextProperty, model.trigger, x => x.Token);
                if (string.IsNullOrEmpty(model.trigger.Token)) {
                    captionToken.Visibility = Visibility.Collapsed;
                    valueToken.Visibility = Visibility.Collapsed;
                }
            }

            { // topic filter
                var concreteSetTopics = GetConcreteSetTopics(model.topicSet);
                concreteSetTopics.Insert(0, string.Empty);

                var topicExpr = model.trigger.Configuration.TopicExpression.Any.First().InnerText;
                var topicExprParts = topicExpr.Split(new char[] { '|' });
                foreach (var part in topicExprParts) {
                    var control = CreateTopicExprControl(concreteSetTopics, part);
                    valuesTopicExpr.Items.Add(control);
                }

                var addTopicExprPartCommand = new DelegateCommand(
                    executeMethod: () => {
                        var control = CreateTopicExprControl(concreteSetTopics, string.Empty);
                        valuesTopicExpr.Items.Add(control);
                    },
                    canExecuteMethod: () => valuesTopicExpr.Items.Count <= 32
                );
                addTopicExprPartButton.Command = addTopicExprPartCommand;
            }

            { // content filter
                valueContentExpr.CreateBinding(TextBox.TextProperty, model.trigger.Configuration.ContentExpression
                    , m => m.Any.First().InnerText
                    , (m, v) => m.Any = new XmlNode[] { new XmlDocument().CreateTextNode(v) });
            }

            { // actions
                var addActionCommand = new DelegateCommand(
                () => {
                    var actions = (listAvailableActions.SelectedItems ?? new ArrayList()).Select(i => (Action1)i).ToList();
                    availableActions.RemoveRange(actions);
                    includedActions.AddRange(actions);
                },
                () => (listAvailableActions.SelectedItems ?? new ArrayList()).Count > 0
            );
                addActionButton.Command = addActionCommand;

                var removeActionCommand = new DelegateCommand(
                    () => {
                        var actions = (listIncludedActions.SelectedItems ?? new ArrayList()).Select(i => (Action1)i).ToList();
                        includedActions.RemoveRange(actions);
                        availableActions.AddRange(actions);
                    },
                    () => (listIncludedActions.SelectedItems ?? new ArrayList()).Count > 0
                );
                removeActionButton.Command = removeActionCommand;

                includedActions.AddRange(model.trigger.Configuration.ActionToken.Select(token => model.actions.First(a => a.Token == token)).ToList());
                availableActions.AddRange(model.actions.Except(includedActions).ToList());
                listAvailableActions.ItemsSource = availableActions;
                listIncludedActions.ItemsSource = includedActions;

                listIncludedActions.SelectionChanged += delegate { removeActionCommand.RaiseCanExecuteChanged(); };
                listAvailableActions.SelectionChanged += delegate { addActionCommand.RaiseCanExecuteChanged(); };
            }

            Localization();
        }
开发者ID:zzilla,项目名称:ONVIF-Device-Manager,代码行数:100,代码来源:ActionTriggerModifyView.xaml.cs

示例5: UpdateFilters

        private void UpdateFilters()
        {
            Log.Debug("Updating filters");

            if (_filterSchemes != null)
            {
                _filterSchemes.Schemes.CollectionChanged -= OnFilterSchemesCollectionChanged;
            }

            _filterSchemes = _filterSchemeManager.FilterSchemes;

            if (_filterSchemes != null)
            {
                _filterSchemes.Schemes.CollectionChanged += OnFilterSchemesCollectionChanged;
            }

            var newSchemes = new ObservableCollection<FilterScheme>();

            if (RawCollection == null)
            {
                _targetType = null;
            }
            else
            {
                _targetType = CollectionHelper.GetTargetType(RawCollection);
                if (_targetType != null)
                {
                    newSchemes.AddRange((from scheme in _filterSchemes.Schemes
                                         where scheme.TargetType != null && _targetType.IsAssignableFromEx(scheme.TargetType)
                                         select scheme));
                }
            }

            newSchemes.Insert(0, NoFilterFilter);

            if (AvailableSchemes == null || !Catel.Collections.CollectionHelper.IsEqualTo(AvailableSchemes, newSchemes))
            {
                AvailableSchemes = newSchemes;

                var selectedFilter = _filterService.SelectedFilter ?? NoFilterFilter;
                SelectedFilterScheme = selectedFilter;
            }
        }
开发者ID:dmitry-shechtman,项目名称:Orc.FilterBuilder,代码行数:43,代码来源:FilterBuilderViewModel.cs

示例6: CommpareAdd

        private static void CommpareAdd(ObservableCollection<Item> collection, ObservableCompositeCollection<Item> compositeCollection)
        {
            var data = CreateData();

            var stopwatch = Stopwatch.StartNew();

            var t1 = stopwatch.Elapsed;

            collection.AddRange(data.SelectMany(list => list));

            var t2 = stopwatch.Elapsed;
            compositeCollection.Content.AddRange(data);

            var t3 = stopwatch.Elapsed;

            stopwatch.Stop();

            var compositeTime = t3 - t2;
            var plainTime = t2 - t1;
            var factor = compositeTime.TotalSeconds / plainTime.TotalSeconds;

            Debug.WriteLine("composite: {0} / plain {1} = {2}", compositeTime, plainTime, factor);
            Debug.WriteLine("{0} elements.", compositeCollection.Count);

            Assert.IsTrue(factor < 2);
            Assert.IsTrue(collection.SequenceEqual(compositeCollection));
        }
开发者ID:tom-englert,项目名称:TomsToolbox,代码行数:27,代码来源:ObservableCompositeCollectionTest.cs


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