Ejemplo n.º 1
0
        public override string ToString()
        {
            string token = QueryToken.Follow(q => q.Parent).Reverse().Select(a => a.ToString().ToOmniboxPascal()).ToString(".");

            if (Syntax == null || Syntax.Completion == FilterSyntaxCompletion.Token || CanFilter.HasText())
            {
                return(token);
            }

            string oper = FilterValueConverter.ToStringOperation(Operation !.Value);

            if ((Syntax.Completion == FilterSyntaxCompletion.Operation && Value == null) ||
                (Value as string == DynamicQueryOmniboxResultGenerator.UnknownValue))
            {
                return(token + oper);
            }

            return(token + oper + DynamicQueryOmniboxResultGenerator.ToStringValue(Value));
        }
Ejemplo n.º 2
0
        public override void RenderLines(DynamicQueryOmniboxResult result, InlineCollection lines)
        {
            lines.AddMatch(result.QueryNameMatch);


            foreach (var item in result.Filters)
            {
                lines.Add(" ");

                QueryToken last = null;
                if (item.QueryTokenMatches != null)
                {
                    foreach (var tokenMatch in item.QueryTokenMatches)
                    {
                        if (last != null)
                        {
                            lines.Add(".");
                        }

                        lines.AddMatch(tokenMatch);

                        last = (QueryToken)tokenMatch.Value;
                    }
                }

                if (item.QueryToken != last)
                {
                    if (last != null)
                    {
                        lines.Add(".");
                    }

                    lines.Add(new Run(item.QueryToken.Key)
                    {
                        Foreground = Brushes.Gray
                    });
                }

                if (item.CanFilter.HasText())
                {
                    lines.Add(new Run(item.CanFilter)
                    {
                        Foreground = Brushes.Red
                    });
                }
                else if (item.Operation != null)
                {
                    lines.Add(new Bold(new Run(FilterValueConverter.ToStringOperation(item.Operation.Value))));

                    if ((item.Value as string) == DynamicQueryOmniboxResultGenerator.UnknownValue)
                    {
                        lines.Add(new Run(OmniboxMessage.Unknown.NiceToString())
                        {
                            Foreground = Brushes.Red
                        });
                    }
                    else if (item.ValueMatch != null)
                    {
                        lines.AddMatch(item.ValueMatch);
                    }
                    else if (item.Syntax != null && item.Syntax.Completion == FilterSyntaxCompletion.Complete)
                    {
                        lines.Add(new Bold(new Run(DynamicQueryOmniboxResultGenerator.ToStringValue(item.Value))));
                    }
                    else
                    {
                        lines.Add(new Run(DynamicQueryOmniboxResultGenerator.ToStringValue(item.Value))
                        {
                            Foreground = Brushes.Gray
                        });
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public override MvcHtmlString RenderHtml(DynamicQueryOmniboxResult result)
        {
            MvcHtmlString html = result.QueryNameMatch.ToHtml();

            FindOptions findOptions = new FindOptions(result.QueryName);

            foreach (var item in result.Filters)
            {
                html = html.Concat(new MvcHtmlString(" "));

                QueryToken last = null;
                if (item.QueryTokenMatches != null)
                {
                    foreach (var tokenMatch in item.QueryTokenMatches)
                    {
                        html = html.Concat("{0}{1}".FormatHtml(
                                               last != null ? "." : "",
                                               tokenMatch.ToHtml()));

                        last = (QueryToken)tokenMatch.Value;
                    }
                }

                if (item.QueryToken != last)
                {
                    html = html.Concat("{0}{1}".FormatHtml(
                                           last != null ? "." : "",
                                           ColoredSpan(item.QueryTokenOmniboxPascal, "gray")));
                }

                if (item.CanFilter.HasText())
                {
                    html = html.Concat(ColoredSpan(item.CanFilter, "red"));
                }
                else if (item.Operation != null)
                {
                    html = html.Concat(new HtmlTag("b").InnerHtml(
                                           new MvcHtmlString(FilterValueConverter.ToStringOperation(item.Operation.Value))).ToHtml());

                    if (item.Value as string == DynamicQueryOmniboxResultGenerator.UnknownValue)
                    {
                        html = html.Concat(ColoredSpan(OmniboxMessage.Unknown.NiceToString(), "red"));
                    }
                    else if (item.ValueMatch != null)
                    {
                        html = html.Concat(item.ValueMatch.ToHtml());
                    }
                    else if (item.Syntax != null && item.Syntax.Completion == FilterSyntaxCompletion.Complete)
                    {
                        html = html.Concat(new HtmlTag("b").InnerHtml(new MvcHtmlString(DynamicQueryOmniboxResultGenerator.ToStringValue(item.Value))).ToHtml());
                    }
                    else
                    {
                        html = html.Concat(ColoredSpan(DynamicQueryOmniboxResultGenerator.ToStringValue(item.Value), "gray"));
                    }
                }
            }

            html = Icon().Concat(html);

            return(html);
        }