コード例 #1
0
 private void Log(string message)
 {
     LogTextBox.BeginInvoke(new MethodInvoker(() =>
     {
         LogTextBox.SelectionStart = 0;
         LogTextBox.SelectedText   = message + Environment.NewLine;
     }));
 }
コード例 #2
0
 private void LogMessage(string text)
 {
     if (!LogTextBox.IsDisposed)
     {
         if (LogTextBox.InvokeRequired)
         {
             Action d = new Action(() => LogMessage(text));
             LogTextBox.BeginInvoke(d);
         }
         else
         {
             LogTextBox.AppendText(text + "\r\n");
             LogTextBox.SelectionStart = LogTextBox.Text.Length;
             LogTextBox.ScrollToCaret();
         }
     }
 }
コード例 #3
0
        public void ServerLogFunc(IntPtr strLog)
        {
            StringBuilder str = new StringBuilder();

            str.Append("System : ");
            str.Append(Marshal.PtrToStringUni(strLog));
            str.Append("\r\n");

            if (LogTextBox.InvokeRequired)
            {
                LogTextBox.BeginInvoke(new MethodInvoker(delegate {
                    LogTextBox.AppendText(str.ToString());
                }));
            }
            else
            {
                LogTextBox.AppendText(str.ToString());
            }
        }
コード例 #4
0
        void WriteToLog(string text)
        {
            if (LogTextBox.InvokeRequired)
            {
                LogTextBox.BeginInvoke(new WriteToLogCallback(WriteToLog), text);
            }
            else
            {
                lock (this)
                {
                    LogTextBox.AppendText(string.Format("[{0}] {1}{2}", DateTime.Now.ToString("HH:mm:ss"), text, Environment.NewLine));

                    using (System.IO.StreamWriter SW = new System.IO.StreamWriter(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "HdBrStreamExtractor.txt"), true))
                    {
                        SW.WriteLine(string.Format("[{0}] {1}{2}", DateTime.Now.ToString("HH:mm:ss"), text, Environment.NewLine));
                        SW.Close();
                    }
                }
            }
        }
コード例 #5
0
 private void LogMessage(string text, Color color)
 {
     if (!LogTextBox.IsDisposed)
     {
         if (LogTextBox.InvokeRequired)
         {
             Action d = new Action(() => LogMessage(text, color));
             LogTextBox.BeginInvoke(d);
         }
         else
         {
             // Apply color and apped text.
             LogTextBox.SelectionStart  = LogTextBox.TextLength;
             LogTextBox.SelectionLength = 0;
             LogTextBox.SelectionColor  = color;
             LogTextBox.AppendText(text + "\r\n");
             LogTextBox.SelectionColor = LogTextBox.ForeColor;
             LogTextBox.SelectionStart = LogTextBox.Text.Length;
             LogTextBox.ScrollToCaret();
         }
     }
 }