Exemple #1
0
        public void propagateToBackingMatchers(MyBindingList <IMatcher <IComparable> > matchers, GeneralMatcherVM parent)
        {
            Console.WriteLine("At matcher");
            if (backingMatcher == null)
            {
                // if new matcher was removed before being applied
                if (removed)
                {
                    return;
                }

                // if matcher is new
                backingMatcher = createBackingMatcher();
                updateBackingMatcher(backingMatcher, parent);
                matchers.Add(backingMatcher);
            }
            else
            {
                if (removed)
                {
                    // if existing matcher is removed
                    matchers.Remove(backingMatcher);
                }
                else
                {
                    // if existing matcher was changed
                    updateBackingMatcher(backingMatcher, parent);
                }
            }
        }
        public SettingsPreFilterVM(MyBindingList <LineFilter> filters)
        {
            this.filters = filters;

            FilterVMs        = new MyBindingList <FilterVM>();
            FilterVMsRemoved = new MyBindingList <FilterVM>();

            FilterVMs.ListChanged += (sender, args) =>
            {
                IsListVisible = FilterVMs.Count > 0;
            };

            Action <FilterVM> removeFromUI = filter =>
            {
                FilterVMs.Remove(filter);
                FilterVMsRemoved.Add(filter);
            };

            AddStartsWithFilter = new DelegateCommand(_ =>
            {
                FilterVM filter = new FilterVM(LineFilterType.StartsWith, removeFromUI);
                FilterVMs.Add(filter);
            });
            AddMatchesRegexFilter = new DelegateCommand(_ =>
            {
                FilterVM filter = new FilterVM(LineFilterType.MatchesRegex, removeFromUI);
                FilterVMs.Add(filter);
            });
        }
        public SettingsMatcherVM(MatcherChain matcherChain)
        {
            this.matcherChain = matcherChain;

            MatcherVMs        = new MyBindingList <GeneralMatcherVM>();
            MatcherVMsRemoved = new MyBindingList <GeneralMatcherVM>();

            Action <GeneralMatcherVM> removeFromUI = matcherVM =>
            {
                MatcherVMs.Remove(matcherVM);
                MatcherVMsRemoved.Add(matcherVM);
                matcherVM.IsLevel = false;
            };

            AddMatcher = new DelegateCommand(_ =>
            {
                GeneralMatcherVM matcher = new GeneralMatcherVM(removeFromUI, cleanUpSetLevel);
                matcher.Name             = "Matcher #" + (MatcherVMs.Count + 1);
                MatcherVMs.Add(matcher);
            });
        }
        public SettingsLevelVM()
        {
            Levels = new MyBindingList <LevelVM>();

            Action <LevelVM> onRemove = levelVM =>
            {
                Levels.Remove(levelVM);
            };

            AddLevel = new DelegateCommand(_ =>
            {
                Levels.Add(new LevelVM(onRemove)
                {
                    Color = Colors.Black,
                    Name  = "",
                    Show  = true
                });
            });

            addDefaultLevels(onRemove);
        }
Exemple #5
0
        public void propagateToBackingFilters(MyBindingList <LineFilter> filters)
        {
            if (backingFilter == null)
            {
                // if new filter was removed before being applied
                if (removed)
                {
                    return;
                }

                // if filter is new
                switch (type)
                {
                case LineFilterType.MatchesRegex:
                    backingFilter = new MatchesRegexFilter();
                    break;

                case LineFilterType.StartsWith:
                    backingFilter = new StartsWithFilter();
                    break;
                }
                backingFilter.Pattern = FilterPattern;
                filters.Add(backingFilter);
            }
            else
            {
                if (removed)
                {
                    // if existing filter is removed
                    filters.Remove(backingFilter);
                }
                else
                {
                    // if existing filter was changed
                    backingFilter.Pattern = FilterPattern;
                }
            }
        }