Exemplo n.º 1
0
        public static void WriteLine(String Text, SortedDictionary <int, Color> ColourArgs)
        {
            String Time = "(" + System.DateTime.Now.ToLongTimeString() + ")";

            if (pHasConsole)
            {
                Console.WriteLine(Time + " " + Text);
            }
            Text = Text.Replace('[', '(').Replace(']', ')');
            ArrayList Store = new ArrayList();

            Store.Add(Color.Yellow);
            Store.Add(Time + " ");
            if (ColourArgs != null)
            {
                Color RollingColour = Color.White;
                int   LastI         = 0;
                foreach (int i in ColourArgs.Keys)
                {
                    if (i - LastI > 0)
                    {
                        String Seg = Text.Substring(LastI, i - LastI);
                        Store.Add(RollingColour);
                        Store.Add(Seg);
                    }
                    RollingColour = ColourArgs[i];
                    LastI         = i;
                }
                if (LastI < Text.Length)
                {
                    Store.Add(RollingColour);
                    Store.Add(Text.Remove(0, LastI));
                }
            }
            else
            {
                Store.Add(Color.White);
                Store.Add(Text);
            }
            object[] ThisEntry = Store.ToArray();
            InternalLog.Add(ThisEntry);
            ConsoleWrittenTo?.Invoke(Text);
            try
            {
                Monitor.Enter(CWriteLockObj);
                pLastLogLine = Text;
            }
            finally { Monitor.Exit(CWriteLockObj); }
        }