C# richTextBoxæ¾ç¤ºä¸åé¢è²æå
#region æ¥å¿è®°å½ãæ¯æå
¶ä»çº¿ç¨è®¿é®
public delegate void LogAppendDelegate(Color color, string text);
/// <summary>
/// 追å æ¾ç¤ºææ¬
/// </summary>
/// <param name="color">ææ¬é¢è²</param>
/// <param name="text">æ¾ç¤ºææ¬</param>
public void LogAppend(Color color, string text)
{
richTextBoxRemote.AppendText("/n");
richTextBoxRemote.SelectionColor = color;
richTextBoxRemote.AppendText(text);
}
/// <summary>
/// æ¾ç¤ºé误æ¥å¿
/// </summary>
/// <param name="text"></param>
public void LogError(string text)
{
LogAppendDelegate la = new LogAppendDelegate(LogAppend);
richTextBoxRemote.Invoke(la, Color.Red, DateTime.Now.ToString("HH:mm:ss ") + text);
}
/// <summary>
/// æ¾ç¤ºè¦åä¿¡æ¯
/// </summary>
/// <param name="text"></param>
public void LogWarning(string text)
{
LogAppendDelegate la = new LogAppendDelegate(LogAppend);
richTextBoxRemote.Invoke(la, Color.Violet, DateTime.Now.ToString("HH:mm:ss ") + text);
}
/// <summary>
/// æ¾ç¤ºä¿¡æ¯
/// </summary>
/// <param name="text"></param>
public void LogMessage(string text)
{
LogAppendDelegate la = new LogAppendDelegate(LogAppend);
richTextBoxRemote.Invoke(la, Color.Black, DateTime.Now.ToString("HH:mm:ss ") + text);
}
#endregion
追é®ç»ç¹è¯¦ç»ç注é好ä¸å¥½ï¼å°±è¿æ ·åå¾é¾æ好ä¸å¥½ããã
追çå
³é®ä»£ç å°±ä¸è¡ã richTextBoxRemote.SelectionColor = color;
ï¼å追å æå
追é®å¯é®é¢æ¯è¥å¨æ¾ç¤ºå
¶ä»é¢è²çå符串åé¢æåï¼é£ä¸ªåä¹æ¯é£ç§é¢è²ããã