Example #1
0
        public void SetBigrams(Tuple<string, string>[] bigrams)
        {
            this.Bigrams =
                bigrams.Aggregate(
                    new List<BigramItem>(),
                    (list, tup) =>
                    {
                        list.Add(new BigramItem(tup));

                        return list;
                    })
                    .ToArray();
        }
        public static MvcHtmlString SvgPolyLine(
            this HtmlHelper htmlHelper,
            Tuple<float, float>[] points,
            string id = null,
            string cssClass = null,
            string stroke = null,
            double strokeWidth = DefaultStrokeWidth,
            string fill = null,
            string styles = null)
        {
            var tagBuilder = new TagBuilder("polyline");

            string pointValues = points.Aggregate(string.Empty,
                                                  (x, p) =>
                                                  x + string.Format("{0}, {1} ", p.Item1.ToString(), p.Item2.ToString()));

            if (!string.IsNullOrWhiteSpace(pointValues))
            {
                tagBuilder.Attributes.Add("points", pointValues);
            }

            if (!string.IsNullOrWhiteSpace(id))
            {
                tagBuilder.Attributes.Add("id", htmlHelper.Encode(id));
            }

            if (!string.IsNullOrWhiteSpace(cssClass))
            {
                tagBuilder.Attributes.Add("class", htmlHelper.Encode(cssClass));
            }

            string style = string.Empty;
            style += !string.IsNullOrWhiteSpace(stroke) ? string.Format("stroke: {0};", stroke) : string.Empty;
            style += string.Format("stroke-width: {0};", strokeWidth);
            style += !string.IsNullOrWhiteSpace(fill) ? string.Format("fill: {0};", fill) : string.Empty;
            style += !string.IsNullOrWhiteSpace(styles) ? styles : string.Empty;

            if (!string.IsNullOrWhiteSpace(style))
            {
                tagBuilder.Attributes.Add("style", htmlHelper.Encode(style));
            }

            return MvcHtmlString.Create(tagBuilder.ToString(TagRenderMode.Normal));
        }