/// <summary> /// Outputs the specified text with the specified color. /// <br />2008-08-07 output to log file in batch mode /// </summary> /// <param name="color">The color.</param> /// <param name="text">The text.</param> private void output(Color color, string text) { //write the output text to log file in batch mode if (_isBatchMode) { lock (this) { using (StreamWriter sw = new StreamWriter(_outPath, true)) { sw.Write(text); sw.Close(); } return; } } if (this.InvokeRequired) { SetOutputCallback deleg = new SetOutputCallback(output); this.Invoke(deleg, new object[] { color, text }); } else { rtbOutput.SelectionStart = rtbOutput.Text.Length; rtbOutput.SelectionColor = color; rtbOutput.AppendText(text); } }
private void SetOutput(string text) { if (this.rtb_output.InvokeRequired) { SetOutputCallback d = new SetOutputCallback(SetOutput); this.Invoke(d, new object[] { text }); } else { this.rtb_output.Text = text; } }
internal void SetOutput(string text) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.txtOutput.InvokeRequired) { SetOutputCallback d = new SetOutputCallback(SetOutput); this.Invoke(d, new object[] { text }); } else { this.txtOutput.Text = text; } }
/// <summary> /// Adds the given string to the output textbox with timestamp and newline char. /// Uses the SetOutputCallback delegate if needed (for livestreamer.exe messages). /// This is needed since those messages are coming from another thread. /// </summary> /// <param name="text">The text to add to the output textbox.</param> private void AddOutput(string text) { //Debug.WriteLine("AddOutput:" + text); if (this.tbOutput.InvokeRequired) { SetOutputCallback d = new SetOutputCallback(AddOutput); this.Invoke(d, new object[] { text + "\n" }); } else { //if (text.Contains("[download]") && tbOutput.Text.Substring(text.LastIndexOf('\n')).Contains("[download]")) //{ // Debug.WriteLine("AddOutput: Contains [download]"); // tbOutput.Text = tbOutput.Text. Substring(0, text.LastIndexOf('\n')); //} string timestamp = DateTime.Now.ToString("[HH:mm:ss]"); tbOutput.AppendText(timestamp + text + "\n"); } }