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);
            });
        }
Example #2
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);
                }
            }
        }
Example #3
0
        public SectionChooseDialog(MyBindingList <SectionObjectRec> sections, SectionObjectRec defaultSection)
        {
            InitializeComponent();
            this.Icon = OutOfPhase.Properties.Resources.Icon2;

            DpiChangeHelper.ScaleFont(this, Program.Config.AdditionalUIZoom);

            string nullSection = "(None)";

            displayList.Add(nullSection);
            foreach (SectionObjectRec section in sections)
            {
                displayList.Add(section);
            }

            myListBoxSections.SetUnderlying(displayList, GetDisplayText);
            myListBoxSections.SelectItem(defaultSection != null ? (object)defaultSection : (object)nullSection, true /*clearOtherSelections*/);
            myListBoxSections.DoubleClick2 += MyListBoxSections_DoubleClick;
        }
    public Form1()
    {
        InitializeComponent();
        bs = new BindingSource();
        MyBindingList <BackingObject> backing_objects = new MyBindingList <BackingObject>();

        backing_objects.Add(new BackingObject {
            PrimaryKey = 1, Name = "Fred", Hidden = "Fred 1"
        });
        bs.DataSource            = backing_objects;
        dataGridView1.DataSource = bs;
    }
Example #5
0
        public SearchResultGroupVM(string groupKey, string rootDir, List <FileInfo> files)
        {
            GroupHeader = groupKey;
            var filesTemp = new MyBindingList <SearchResultFileVM>();

            foreach (FileInfo file in files)
            {
                string filePath = file.FullName;
                filePath = filePath.Substring(rootDir.Length);
                filePath = filePath.Substring(0, filePath.Length - file.Name.Length);
                filesTemp.Add(new SearchResultFileVM(filePath, file.Name, groupKey, file));
            }

            Files = filesTemp;
        }
Example #6
0
        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);
            });
        }
Example #7
0
        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);
        }
Example #8
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;
                }
            }
        }
Example #9
0
 /// <summary>
 /// Mark for re-matching.
 /// </summary>
 private void markDirty(LogAtom atom)
 {
     dirty.Add(atom);
 }
        private void RebuildScrollingList()
        {
            object selection = myListBoxSections.SelectedItem;

            displayList.Clear();

            TrackObjectRec[] tracks = new List <TrackObjectRec>(document.TrackList).ToArray();

            /* set stable sort subkey */
            for (int i = 0; i < tracks.Length; i++)
            {
                tracks[i].AuxVal = i;
            }

            Array.Sort(
                tracks,
                delegate(TrackObjectRec left, TrackObjectRec right)
            {
                return(Synthesizer.SynthStateRec.CompareTracksOnSection(left, right, document.SectionList));
            });

            SectionObjectRec section  = null;
            bool             firstTry = true;

            for (int i = 0; i < tracks.Length; i++)
            {
                TrackObjectRec track = tracks[i];

                /* create the section name header */
                if (firstTry || (section != track.Section))
                {
                    firstTry = false;
                    section  = track.Section;
                    if (section == null)
                    {
                        displayList.Add((string)"(Default)");
                    }
                    else
                    {
                        displayList.Add(section);
                    }
                }

                /* add the track item */
                displayList.Add(track);
            }

            /* add any sections we missed */
            for (int j = 0; j < document.SectionList.Count; j++)
            {
                section = document.SectionList[j];

                bool referenced = false;
                for (int i = 0; !referenced && (i < tracks.Length); i++)
                {
                    TrackObjectRec track = document.TrackList[i];
                    if (track.Section == section)
                    {
                        referenced = true;
                    }
                }

                if (!referenced)
                {
                    displayList.Add(section);
                }
            }

            for (int i = 0; i < displayList.Count; i++)
            {
                if (selection == displayList[i])
                {
                    myListBoxSections.SelectItem(i, true /*clearOtherSelections*/);
                }
            }
        }