Example #1
0
        protected override void WriteInternal(WriteStyle style, string value)
        {
            // TODO: How do we normalize this with the current design? Perhaps hold lines without a line end until we get one?

            // MSBuild ALWAYS is a "Writeline"
            value = value.Trim('\f', '\n', '\r');
            if (string.IsNullOrWhiteSpace(value)) { return; }

            if (style.HasFlag(WriteStyle.Error))
            {
                LogError(value);
            }
            else if (style.HasFlag(WriteStyle.Critical))
            {
                LogWarning(value);
            }
            else
            {
                MessageImportance importance = MessageImportance.Normal;
                if (style.HasFlag(WriteStyle.Bold) || style.HasFlag(WriteStyle.Important))
                {
                    importance = MessageImportance.High;
                }

                BuildMessageEventArgs message = new BuildMessageEventArgs(
                    message: value,
                    helpKeyword: null,
                    senderName: _taskName,
                    importance: importance);

                _buildEngine.LogMessageEvent(message);
            }
        }
Example #2
0
        protected override void WriteInternal(WriteStyle style, string value)
        {
            bool bold = style.HasFlag(WriteStyle.Bold);
            bool underline = style.HasFlag(WriteStyle.Underline);
            bool italic = style.HasFlag(WriteStyle.Italic);
            bool fixedWidth = style.HasFlag(WriteStyle.Fixed);

            // 1. Output Style start tags (if any) \f1 \ul \b \i
            // 2. Output escaped text
            // 3. Output Style end tags \f0 \ul0 \b0 \i0
            if (bold) { this.richText.Append(@"\b"); }
            if (fixedWidth) { this.richText.Append(@"\f1"); }
            if (underline) { this.richText.Append(@"\ul"); }
            if (italic) { this.richText.Append(@"\i"); }
            this.priorControlCharacter |= bold || italic || underline;

            this.richText.Append(this.Escape(value));

            if (bold) { this.richText.Append(@"\b0"); }
            if (fixedWidth) { this.richText.Append(@"\f0"); }
            if (underline) { this.richText.Append(@"\ul0"); }
            if (italic) { this.richText.Append(@"\i0"); }
            this.priorControlCharacter |= bold || italic || underline;

            // Perhaps bracket every Write to scope style? Then resetting fonts isn't necessary {}
        }
Example #3
0
        protected override void WriteInternal(WriteStyle style, string value)
        {
            bool bold       = style.HasFlag(WriteStyle.Bold);
            bool underline  = style.HasFlag(WriteStyle.Underline);
            bool italic     = style.HasFlag(WriteStyle.Italic);
            bool fixedWidth = style.HasFlag(WriteStyle.Fixed);

            // 1. Output Style start tags (if any) \f1 \ul \b \i
            // 2. Output escaped text
            // 3. Output Style end tags \f0 \ul0 \b0 \i0
            if (bold)
            {
                this.richText.Append(@"\b");
            }
            if (fixedWidth)
            {
                this.richText.Append(@"\f1");
            }
            if (underline)
            {
                this.richText.Append(@"\ul");
            }
            if (italic)
            {
                this.richText.Append(@"\i");
            }
            this.priorControlCharacter |= bold || italic || underline;

            this.richText.Append(this.Escape(value));

            if (bold)
            {
                this.richText.Append(@"\b0");
            }
            if (fixedWidth)
            {
                this.richText.Append(@"\f0");
            }
            if (underline)
            {
                this.richText.Append(@"\ul0");
            }
            if (italic)
            {
                this.richText.Append(@"\i0");
            }
            this.priorControlCharacter |= bold || italic || underline;

            // Perhaps bracket every Write to scope style? Then resetting fonts isn't necessary {}
        }
Example #4
0
        protected override void WriteInternal(WriteStyle style, string value)
        {
            this.htmlText.AppendFormat(
                @"<span style='font-size:11.0pt;font-family:Calibri,sans-serif;white-space:pre{0}'>",
                style.HasFlag(WriteStyle.Error) ? @";color:red" : String.Empty);

            this.AppendFormatedString(style, value);

            this.htmlText.Append(@"</span>");
        }
Example #5
0
        protected override void WriteInternal(WriteStyle style, string value)
        {
            _htmlText.AppendFormat(
                @"<span style='font-size:11.0pt;font-family:Calibri,sans-serif;white-space:pre{0}'>",
                style.HasFlag(WriteStyle.Error) ? @";color:red" : string.Empty);

            AppendFormatedString(style, value);

            _htmlText.Append(@"</span>");
        }
Example #6
0
 protected override void WriteInternal(WriteStyle style, string value)
 {
     if (style.HasFlag(WriteStyle.Underline))
     {
         this.Output.Append(Strings.Underline(value));
     }
     else
     {
         this.Output.Append(value);
     }
 }
Example #7
0
 protected override void WriteInternal(WriteStyle style, string value)
 {
     if (style.HasFlag(WriteStyle.Underline))
     {
         this.Output.Append(Strings.Underline(value));
     }
     else
     {
         this.Output.Append(value);
     }
 }
Example #8
0
 public void Write(WriteStyle style, string value)
 {
     if (style.HasFlag(WriteStyle.Error))
     {
         WriteInternal(style, String.Format(CultureInfo.CurrentUICulture, XTaskStrings.ErrorFormatString, value));
     }
     else
     {
         WriteInternal(style, value);
     }
 }
Example #9
0
 public void Write(WriteStyle style, string value)
 {
     if (style.HasFlag(WriteStyle.Error))
     {
         WriteInternal(style, String.Format(CultureInfo.CurrentUICulture, XTaskStrings.ErrorFormatString, value));
     }
     else
     {
         WriteInternal(style, value);
     }
 }
Example #10
0
        protected override void WriteInternal(WriteStyle style, string value)
        {
            // TODO: How do we normalize this with the current design? Perhaps hold lines without a line end until we get one?

            // MSBuild ALWAYS is a "Writeline"
            value = value.Trim('\f', '\n', '\r');
            if (String.IsNullOrWhiteSpace(value))
            {
                return;
            }

            if (style.HasFlag(WriteStyle.Error))
            {
                this.LogError(value);
            }
            else if (style.HasFlag(WriteStyle.Critical))
            {
                this.LogWarning(value);
            }
            else
            {
                MessageImportance importance = MessageImportance.Normal;
                if (style.HasFlag(WriteStyle.Bold) || style.HasFlag(WriteStyle.Important))
                {
                    importance = MessageImportance.High;
                }

                BuildMessageEventArgs message = new BuildMessageEventArgs(
                    message: value,
                    helpKeyword: null,
                    senderName: this.taskName,
                    importance: importance);

                this.buildEngine.LogMessageEvent(message);
            }
        }
Example #11
0
        protected override void WriteInternal(WriteStyle style, string value)
        {
            ConsoleColor color = _baseColor;

            foreach (var lookup in _colorTable)
            {
                if ((lookup.WriteStyle & style) != 0)
                {
                    color = lookup.ConsoleColor;
                    break;
                }
            }

            if (style.HasFlag(WriteStyle.Underline))
            {
                WriteColorUnderlined(color, value);
            }
            else
            {
                WriteColor(color, value);
            }
        }
Example #12
0
 protected void AppendFormatedString(WriteStyle style, string value)
 {
     if (style.HasFlag(WriteStyle.Bold)) this.htmlText.Append(@"<b>");
     if (style.HasFlag(WriteStyle.Italic)) this.htmlText.Append(@"<i>");
     if (style.HasFlag(WriteStyle.Critical)) this.htmlText.Append(@"<strong>");
     if (style.HasFlag(WriteStyle.Important)) this.htmlText.Append(@"<em>");
     if (style.HasFlag(WriteStyle.Underline)) this.htmlText.Append(@"<u>");
     if (style.HasFlag(WriteStyle.Fixed)) this.htmlText.Append(@"<pre>"); ;
     this.htmlText.Append(Strings.ReplaceLineEnds(WebUtility.HtmlEncode(value), @"<br>"));
     if (style.HasFlag(WriteStyle.Fixed)) this.htmlText.Append(@"</pre>"); ;
     if (style.HasFlag(WriteStyle.Underline)) this.htmlText.Append(@"</u>");
     if (style.HasFlag(WriteStyle.Important)) this.htmlText.Append(@"</em>");
     if (style.HasFlag(WriteStyle.Critical)) this.htmlText.Append(@"</strong>");
     if (style.HasFlag(WriteStyle.Italic)) this.htmlText.Append(@"</i>");
     if (style.HasFlag(WriteStyle.Bold)) this.htmlText.Append(@"</b>");
 }
Example #13
0
 protected void AppendFormatedString(WriteStyle style, string value)
 {
     if (style.HasFlag(WriteStyle.Bold))
     {
         _htmlText.Append(@"<b>");
     }
     if (style.HasFlag(WriteStyle.Italic))
     {
         _htmlText.Append(@"<i>");
     }
     if (style.HasFlag(WriteStyle.Critical))
     {
         _htmlText.Append(@"<strong>");
     }
     if (style.HasFlag(WriteStyle.Important))
     {
         _htmlText.Append(@"<em>");
     }
     if (style.HasFlag(WriteStyle.Underline))
     {
         _htmlText.Append(@"<u>");
     }
     if (style.HasFlag(WriteStyle.Fixed))
     {
         _htmlText.Append(@"<pre>");
     }
     ;
     _htmlText.Append(Strings.ReplaceLineEnds(WebUtility.HtmlEncode(value), @"<br>"));
     if (style.HasFlag(WriteStyle.Fixed))
     {
         _htmlText.Append(@"</pre>");
     }
     ;
     if (style.HasFlag(WriteStyle.Underline))
     {
         _htmlText.Append(@"</u>");
     }
     if (style.HasFlag(WriteStyle.Important))
     {
         _htmlText.Append(@"</em>");
     }
     if (style.HasFlag(WriteStyle.Critical))
     {
         _htmlText.Append(@"</strong>");
     }
     if (style.HasFlag(WriteStyle.Italic))
     {
         _htmlText.Append(@"</i>");
     }
     if (style.HasFlag(WriteStyle.Bold))
     {
         _htmlText.Append(@"</b>");
     }
 }