Example #1
0
        protected override void OnStart(TextWriter writer)
        {
            // Build the src
            StringBuilder src = new StringBuilder("http://placehold.it/" + Width);

            if (Height != null)
            {
                src.Append("x" + Height);
            }
            if (!string.IsNullOrWhiteSpace(BackgroundColor))
            {
                src.Append("/" + BackgroundColor.Replace("#", ""));
                if (!string.IsNullOrWhiteSpace(TextColor))
                {
                    src.Append("/" + TextColor.Replace("#", ""));
                }
            }
            else if (!string.IsNullOrWhiteSpace(TextColor))
            {
                throw new InvalidOperationException("BackgroundColor must be specified if TextColor is specified.");
            }
            if (!string.IsNullOrWhiteSpace(Format))
            {
                src.Append("." + Format);
            }
            if (!string.IsNullOrWhiteSpace(Text))
            {
                src.Append("&text=" + Text.Replace(' ', '+'));
            }
            MergeAttribute("src", src.ToString());

            base.OnStart(writer);
        }