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


C# ObservableCollection.RemoveRange方法代码示例

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


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

示例1: 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


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