public SearchMetadata Create(string searchText, bool useRegex, int index, bool filter)
        {
            if (searchText == null)
            {
                throw new ArgumentNullException(nameof(searchText));
            }

            //maybe key on useRegex as well as text
            var association = _textAssociationCollection.Lookup(searchText);

            string icon;
            Hue    hue;

            if (association.HasValue)
            {
                icon = association.Value.Icon;
                hue  = _defaultColourSelector.Lookup(new HueKey(association.Value.Swatch, association.Value.Hue));
            }
            else
            {
                icon = _defaultIconSelector.GetIconFor(searchText, useRegex);
                hue  = _defaultColourSelector.Select(searchText);
            }


            return(new SearchMetadata(index, searchText,
                                      filter,
                                      true,
                                      useRegex,
                                      true,
                                      hue,
                                      icon));
        }
Пример #2
0
        private async void ShowIconSelector()
        {
            var dialogResult = await DialogHost.Show(IconSelector, ParentId);

            var result = (IconSelectorResult)dialogResult;

            if (result == IconSelectorResult.UseDefault)
            {
                //Use default
                var icon = _defaultIconSelector.GetIconFor(Text, UseRegex);
                IconKind = icon.ParseEnum <PackIconKind>().ValueOr(() => PackIconKind.ArrowRightBold);
            }
            else if (result == IconSelectorResult.UseSelected)
            {
                IconKind = IconSelector.Selected.Type;
            }
        }
Пример #3
0
        public SearchMetadata Create([NotNull] string searchText, bool useRegex, int index, bool filter)
        {
            if (searchText == null)
            {
                throw new ArgumentNullException(nameof(searchText));
            }

            var icon = _defaultIconSelector.GetIconFor(searchText, useRegex);
            var hue  = _defaultColourSelector.Select(searchText);

            return(new SearchMetadata(index, searchText,
                                      filter,
                                      true,
                                      useRegex,
                                      true,
                                      hue,
                                      icon));
        }
Пример #4
0
        public SearchMetadata Create(string searchText, bool useRegex, int index, bool filter, bool isGlobal = false)
        {
            if (searchText == null)
            {
                throw new ArgumentNullException(nameof(searchText));
            }

            var isExclusion = false;

            if (!useRegex)
            {
                var withNegation = searchText.WithNegation();
                isExclusion = withNegation.IsNegation;
                searchText  = withNegation.Text;
            }

            var    association = _textAssociationCollection.Lookup(searchText);
            string icon;
            Hue    hue;

            if (association.HasValue)
            {
                icon = association.Value.Icon;
                hue  = _defaultColourSelector.Lookup(new HueKey(association.Value.Swatch, association.Value.Hue));
            }
            else
            {
                icon = _defaultIconSelector.GetIconFor(searchText, useRegex);
                hue  = _defaultColourSelector.Select(searchText);
            }

            return(new SearchMetadata(index, searchText,
                                      isExclusion ? false: filter,
                                      HighlightingMode.Text,
                                      useRegex,
                                      true,
                                      hue,
                                      icon,
                                      isGlobal,
                                      isExclusion));
        }