Ejemplo n.º 1
0
        public static void Printf(LogWndOpt opt, string format, params object[] args)
        {
            string formatted = string.Format(format, args);

            foreach (LoggingHandler Caster in Receivers.GetInvocationList())
            {
                ISynchronizeInvoke SyncInvoke = Caster.Target as ISynchronizeInvoke;
                try
                {
                    if (SyncInvoke != null && SyncInvoke.InvokeRequired)
                    {
                        SyncInvoke.Invoke(Caster, new object[] { opt, formatted });
                    }
                    else
                    {
                        Caster(opt, formatted);
                    }
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine("UsLogging.Printf() failed. \n");
                    Console.WriteLine("{0}:\n", ex.ToString());
                }
            }
        }
Ejemplo n.º 2
0
 public void LogIntoFile(LogWndOpt opt, string text)
 {
     if (_file != null)
     {
         _file.WriteLine(text);
     }
 }
Ejemplo n.º 3
0
        private void Impl_PrintLogToWnd(LogWndOpt opt, string text)
        {
            m_loggingPanel.Dispatcher.Invoke(new Action(() =>
            {
                string time    = string.Format("[color=Gray]{0}[/color]", DateTime.Now.ToLongTimeString());
                string content = "";
                switch (opt)
                {
                case LogWndOpt.Info:
                    content = string.Format("{0} {1}\r\n", time, text);
                    break;

                case LogWndOpt.Bold:
                    content = string.Format("{0} [b]{1}[/b]\r\n", time, text);
                    break;

                case LogWndOpt.Error:
                    content = string.Format("{0} [color=Red]{1}[/color]\r\n", time, text);
                    break;

                default:
                    break;
                }
                bb_logging.BBCode += content;
                m_loggingPanel.ScrollToBottom();
            }));
        }
Ejemplo n.º 4
0
        private void Impl_PrintLogToWnd(LogWndOpt opt, string text)
        {
            m_loggingPanel.Dispatcher.Invoke(new Action(() =>
            {
                string time    = string.Format("[color=Gray]{0}[/color]", DateTime.Now.ToLongTimeString());
                string content = "";
                switch (opt)
                {
                case LogWndOpt.Info:
                    content = string.Format("{0} {1}\r\n", time, text);
                    break;

                case LogWndOpt.Bold:
                    content = string.Format("{0} [b]{1}[/b]\r\n", time, text);
                    break;

                case LogWndOpt.Error:
                    content = string.Format("{0} [color=Red]{1}[/color]\r\n", time, text);
                    break;

                case LogWndOpt.NetLog:
                    content = string.Format("{0} ([color=SeaGreen]{1}[/color]) {2}\r\n", time, cb_targetIP.Text, text);
                    break;

                default:
                    break;
                }
                bb_logging.BBCode += content;

                while (bb_logging.BBCode.Length >= 1024 * 256)
                {
                    bb_logging.BBCode.Substring(bb_logging.BBCode.IndexOf('\n') + 1);
                }

                m_loggingPanel.ScrollToBottom();
            }));
        }
Ejemplo n.º 5
0
 public void LogIntoFile(LogWndOpt opt, string text)
 {
     if (_file != null)
     {
         _file.WriteLine(text);
     }
 }
Ejemplo n.º 6
0
 public static void Printf(LogWndOpt opt, string format, params object[] args)
 {
     string formatted = string.Format(format, args);
     foreach (LoggingHandler Caster in Receivers.GetInvocationList())
     {
         ISynchronizeInvoke SyncInvoke = Caster.Target as ISynchronizeInvoke;
         try
         {
             if (SyncInvoke != null && SyncInvoke.InvokeRequired)
                 SyncInvoke.Invoke(Caster, new object[] { opt, formatted });
             else
                 Caster(opt, formatted);
         }
         catch (System.Exception ex)
         {
             Console.WriteLine("UsLogging.Printf() failed. \n");
             Console.WriteLine("{0}:\n", ex.ToString());
         }
     }
 }
Ejemplo n.º 7
0
        private void Impl_PrintLogToWnd(LogWndOpt opt, string text)
        {
            m_loggingPanel.Dispatcher.Invoke(new Action(() =>
            {
                string time = string.Format("[color=Gray]{0}[/color]", DateTime.Now.ToLongTimeString());
                string content = "";
                switch (opt)
                {
                    case LogWndOpt.Info:
                        content = string.Format("{0} {1}\r\n", time, text);
                        break;
                    case LogWndOpt.Bold:
                        content = string.Format("{0} [b]{1}[/b]\r\n", time, text);
                        break;
                    case LogWndOpt.Error:
                        content = string.Format("{0} [color=Red]{1}[/color]\r\n", time, text);
                        break;
                    case LogWndOpt.NetLog:
                        content = string.Format("{0} ([color=SeaGreen]{1}[/color]) {2}\r\n", time, cb_targetIP.Text, text);
                        break;
                    default:
                        break;
                }
                bb_logging.BBCode += content;

                while (bb_logging.BBCode.Length >= 1024 * 256)
                {
                    bb_logging.BBCode.Substring(bb_logging.BBCode.IndexOf('\n') + 1);
                }

                m_loggingPanel.ScrollToBottom();
            }));
        }