Ejemplo n.º 1
0
        private void PrintLog(String log)
        {
            if (this.LogBox.InvokeRequired)
            {
                printDelegate printInvoke = new printDelegate(PrintLog);
                this.LogBox.Invoke(printInvoke, log);
            }
            else
            {
                if (LogBox.Lines.Length > 3000)
                {
                    int      index     = LogBox.Text.IndexOf("\n");
                    int      moreLines = this.LogBox.Lines.Length - 500;
                    string[] lines     = this.LogBox.Lines;
                    Array.Copy(lines, moreLines, lines, 0, 500);
                    Array.Resize(ref lines, 500);
                    this.LogBox.Lines = lines;
                }
                log = Regex.Replace(String.Format("{0}|{1}\n", DateTime.Now.ToString("hh:mm:ss"), log), @"[\r\n]+", "\r\n");
                //this.LogBox.SelectionColor = color;
                this.LogBox.AppendText(log);
                byte[] LogByte = this.SerialPort_IoT.Encoding.GetBytes(log);


                LogBox.ScrollToCaret();
            }
        }
Ejemplo n.º 2
0
 private void PrintLog(String log)
 {
     if (this.LogBox.InvokeRequired)
     {
         printDelegate printInvoke = new printDelegate(PrintLog);
         this.LogBox.Invoke(printInvoke, log);
     }
     else
     {
         log = Regex.Replace(String.Format("{0}|{1}\n", DateTime.Now.ToString("hh:mm:ss.fff"), log), @"[\r\n]+", "\r\n");
         this.LogBox.AppendText(log);
         byte[] LogByte = this.SerialPort.Encoding.GetBytes(log);
         if (this.CheckBox_SaveLog.Checked)
         {
             using (FileStream SaveFileWrite = new FileStream(@SavePath, FileMode.Append))
             {
                 SaveFileWrite.Write(LogByte, 0, LogByte.Length);
             }
         }
         if (LogBox.Lines.Length > 100)
         {
             int    index     = LogBox.Text.IndexOf("\n");
             String newString = LogBox.Text.Remove(0, index + 2);
             LogBox.Clear();
             LogBox.AppendText(newString);
         }
     }
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Program p = new Program();

            method = new printDelegate(p.print);
            p.useDelegate(method);
            Console.WriteLine("Hello World!");
            Console.Read();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Create new PrintEngine with selected name and printAction
 /// </summary>
 /// <param name="name"></param>
 /// <param name="printAction"></param>
 public PrintEngine(string name, printDelegate printAction)
 {
     this.name  = name;
     this.print = printAction;
     PrintEngines.list.Add(name, this);
     // Set default print engine
     if (PrintEngines.Default == null)
     {
         PrintEngines.Default = this;
     }
 }
Ejemplo n.º 5
0
 private void print(string str)
 {
     if (textBox2.InvokeRequired)
     {
         printDelegate pe = new printDelegate(print);
         Invoke(pe, (object)str);
     }
     else
     {
         textBox2.AppendText(str + "\r\n");
     }
 }
Ejemplo n.º 6
0
 private void PrintTextStatus(string text)
 {
     if (OutputBox.InvokeRequired)
     {
         printDelegate pd = new printDelegate(PrintTextStatus);
         this.Invoke(pd, new object[] { text });
     }
     else
     {
         OutputBox.AppendText(text);
         OutputBox.SelectionStart = OutputBox.Text.Length;
         OutputBox.ScrollToCaret();
     }
 }
Ejemplo n.º 7
0
 public void PrintNumber(printDelegate printDelegate, int number)
 {
     number += 250;
     printDelegate(number);
 }
Ejemplo n.º 8
0
 public void useDelegate(printDelegate d)
 {
 }