Skip to content

Commit

Permalink
Change output box to rich text so that it handles multi colours corre…
Browse files Browse the repository at this point in the history
…ctly
  • Loading branch information
crimdon committed Jan 24, 2017
1 parent 00b06b6 commit 85fb628
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
23 changes: 11 additions & 12 deletions DBAToolKit/Helpers/ShowOutput.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 15 additions & 16 deletions DBAToolKit/Helpers/ShowOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,29 @@ public ShowOutput()

public void Clear()
{
txtOutput.Clear();
rtOutput.Clear();
}

public void displayOutput(string message, bool errormessage = false)
{
if (errormessage)
{
txtOutput.BackColor = txtOutput.BackColor;
txtOutput.ForeColor = System.Drawing.Color.Red;
}
AppendText(message, Color.Red);
else
{
txtOutput.BackColor = txtOutput.BackColor;
txtOutput.ForeColor = System.Drawing.Color.Black;
}
AppendText(message, Color.Black);
}

private void AppendText(string text, Color color)
{
rtOutput.SelectionStart = rtOutput.TextLength;
rtOutput.SelectionLength = 0;

if (txtOutput.Text.Length == 0)
{
txtOutput.Text = message;
}
rtOutput.SelectionColor = color;
if (!string.IsNullOrWhiteSpace(rtOutput.Text))
rtOutput.AppendText("\r\n" + text);
else
{
txtOutput.AppendText("\r\n" + message);
}
rtOutput.AppendText(text);
rtOutput.SelectionColor = rtOutput.ForeColor;
rtOutput.ScrollToCaret();
}
}
}

0 comments on commit 85fb628

Please sign in to comment.