Ejemplo n.º 1
0
 void Logger_OnLog(THOK.MCP.LogEventArgs args)
 {
     if (InvokeRequired)
     {
         BeginInvoke(new LogEventHandler(Logger_OnLog), args);
     }
     else
     {
         lock (lbLog)
         {
             string msg = string.Format("[{0}] {1} {2}", args.LogLevel, DateTime.Now, args.Message);
             lbLog.Items.Insert(0, msg);
             WriteLoggerFile(msg);
         }
     }
 }
Ejemplo n.º 2
0
        void Logger_OnLog(THOK.MCP.LogEventArgs args)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new LogEventHandler(Logger_OnLog), args);
            }
            else
            {
                lock (lbLogMain)
                {
                    if (args.Message.IndexOf("Crane BOX:Connected") >= 0)
                    {
                        Control ctlStart    = this.buttonArea.Controls.Find("btnStart", true)[0];
                        Control ctlStop     = this.buttonArea.Controls.Find("btnStop", true)[0];
                        Control ctlSimulate = this.buttonArea.Controls.Find("btnSimulate", true)[0];
                        if (!ctlStop.Enabled && !ctlSimulate.Enabled)
                        {
                            ctlStart.Enabled = true;
                        }
                    }

                    if (args.Message.IndexOf("Crane BOX:Disconnected") >= 0)
                    {
                        Control ctlStop     = this.buttonArea.Controls.Find("btnStop", true)[0];
                        Control ctlSimulate = this.buttonArea.Controls.Find("btnSimulate", true)[0];
                        if (ctlStop.Enabled)
                        {
                            //if (context.Processes["CraneProcess"] != null)
                            //    context.Processes["CraneProcess"].Suspend();
                            ctlStop.Enabled     = false;
                            ctlSimulate.Enabled = true;
                        }
                    }
                    string msg = string.Format("[{0}] {1} {2}", args.LogLevel, DateTime.Now, args.Message);
                    //lbLog.Items.Insert(0, msg);
                    lbLogMain.Items.Insert(0, msg);
                    WriteLoggerFile(msg);
                }
            }
        }