Ejemplo n.º 1
0
 /// <summary>
 /// Clear log window contents
 /// </summary>
 public void Clear()
 {
     if (LogTextBox != null)
     {
         Utilities.CallActionSafelyAndWait(LogTextBox, new Action(() =>
         {
             LogTextBox.Clear();
             LogTextBox.ScrollToCaret();
         }));
     }
     if (DebugLogTextBox != null)
     {
         Utilities.CallActionSafelyAndWait(DebugLogTextBox, new Action(() =>
         {
             DebugLogTextBox.Clear();
             DebugLogTextBox.ScrollToCaret();
         }));
     }
 }
Ejemplo n.º 2
0
        private void WriteLineSafe(LogType type, string format, params object[] arg)
        {
            string text = String.Format(format, arg);
            string zoneText = "";
            string frontText, backText;

            if (text[0] == '[' && text[3] == ']' && text[4] == ' ')
            {
                zoneText = text.Substring(0, 5);
                text     = text.Substring(5);
            }
            int index = text.IndexOf(':');

            if (index >= 0)
            {
                frontText = text.Substring(0, index + 1);
                backText  = text.Substring(index + 1) + "\r\n";
            }
            else
            {
                frontText = string.Empty;
                backText  = text + "\r\n";
            }
            Color textColor = Color.Black;

            switch (type)
            {
            case LogType.Player:
                textColor = Color.Blue;
                break;

            case LogType.Opponent:
                textColor = Color.Red;
                break;

            case LogType.Debug:
            case LogType.DebugVerbose:
                textColor = Color.Gray;
                break;

            default:
                break;
            }

            if (DebugLogTextBox != null)
            {
                Utilities.CallActionSafelyAndWait(DebugLogTextBox, new Action(() =>
                {
                    if (!string.IsNullOrEmpty(frontText))
                    {
                        DebugLogTextBox.AppendText(zoneText + frontText, textColor, true);
                    }
                    DebugLogTextBox.AppendText(backText, textColor, false);
                    DebugLogTextBox.ScrollToCaret();
                }));
            }

            if (LogTextBox != null && type != LogType.Debug)
            {
                Utilities.CallActionSafelyAndWait(LogTextBox, new Action(() =>
                {
                    if (!string.IsNullOrEmpty(frontText))
                    {
                        LogTextBox.AppendText(frontText, textColor, true);
                    }
                    LogTextBox.AppendText(backText, textColor, false);
                    LogTextBox.ScrollToCaret();
                }));
            }
        }