/// <summary> /// Logs text to the textbox on the main form. /// </summary> /// <param name="Text">The text to log.</param> /// <param name="Type">A Logging.logType enum value, indicating the log's type.</param> public void logText(string Text, Logging.logType Type) { if (this.InvokeRequired) { this.BeginInvoke(_Logger, Text, Type); } else { try { lock (this.txtLog) { switch (Type) { case Logging.logType.commonWarning: { StringBuilder Data = new StringBuilder(); Data.Append("Warning!" + Environment.NewLine); Data.Append("Time: " + DateTime.Now.ToShortTimeString() + Environment.NewLine); Data.Append("Description: " + Text + Environment.NewLine + Environment.NewLine); this.txtLog.SelectionColor = Color.Brown; this.txtLog.SelectedText = Data.ToString(); } break; case Logging.logType.reactorError: case Logging.logType.commonError: { StackFrame st = new StackTrace().GetFrame(2); StringBuilder Data = new StringBuilder(); Data.Append("ERROR!" + Environment.NewLine); Data.Append("Time: " + DateTime.Now.ToShortTimeString() + Environment.NewLine); Data.Append("Object: " + st.GetMethod().ReflectedType.Name + Environment.NewLine); Data.Append("Method: " + st.GetMethod().Name + Environment.NewLine); Data.Append("Description: " + Text + Environment.NewLine + Environment.NewLine); this.txtLog.SelectionColor = Color.DarkRed; this.txtLog.SelectedText = Data.ToString(); } break; default: { this.txtLog.AppendText("# "); this.txtLog.AppendText(Text); this.txtLog.AppendText(Environment.NewLine); } break; } this.txtLog.SelectionStart = this.txtLog.Text.Length; this.txtLog.ScrollToCaret(); this.txtLog.Refresh(); } } catch (Exception) { } } }
/// <summary> /// Logs text to the textbox on the main form. /// </summary> /// <param name="Text">The text to log.</param> /// <param name="Type">A Logging.logType enum value, indicating the log's type.</param> public void logText(string Text, Logging.logType Type) { if (this.InvokeRequired) { this.BeginInvoke(_Logger, Text, Type); } else { try { lock (this.txtLog) { switch (Type) { case Logging.logType.commonWarning: { this.txtLog.AppendText("Warning!" + Environment.NewLine); this.txtLog.AppendText("Time: " + DateTime.Now.ToShortTimeString() + Environment.NewLine); this.txtLog.AppendText("Description: " + Text + Environment.NewLine + Environment.NewLine); } break; case Logging.logType.reactorError: case Logging.logType.commonError: { StackFrame st = new StackTrace().GetFrame(2); this.txtLog.AppendText("ERROR!" + Environment.NewLine); this.txtLog.AppendText("Time: " + DateTime.Now.ToShortTimeString() + Environment.NewLine); this.txtLog.AppendText("Object: " + st.GetMethod().ReflectedType.Name + Environment.NewLine); this.txtLog.AppendText("Method: " + st.GetMethod().Name + Environment.NewLine); this.txtLog.AppendText("Description: " + Text + Environment.NewLine + Environment.NewLine); } break; default: { this.txtLog.AppendText("# "); this.txtLog.AppendText(Text); this.txtLog.AppendText(Environment.NewLine); } break; } } } catch (Exception) { } } }