Beispiel #1
0
        public void AddLog(string author, string message, string timestamp = null)
        {
            if (timestamp == null)
            {
                DateTime now  = DateTime.Now;
                int      num  = now.Hour;
                string   str1 = num.ToString("00");
                string   str2 = ":";
                num = now.Minute;
                string str3 = num.ToString("00");
                timestamp = str1 + str2 + str3;
            }
            string str = new IRCSystem.IRCLogEntry()
            {
                Author = author, Message = message, Timestamp = timestamp
            }.Serialize();

            if (this.ActiveLogFile.data.Length > 1)
            {
                str = "\n#" + str;
            }
            this.ActiveLogFile.data += str;
            ++this.messagesAddedSinceLastView;
            if (this.LogAdded == null)
            {
                return;
            }
            this.LogAdded(author, message);
        }
Beispiel #2
0
 public static IRCSystem.IRCLogEntry Deserialize(string entry)
 {
     IRCSystem.IRCLogEntry ircLogEntry = new IRCSystem.IRCLogEntry();
     string[] strArray = entry.Split(IRCSystem.IRCLogEntry.SplitDelmiter, StringSplitOptions.None);
     ircLogEntry.Timestamp = strArray[0];
     ircLogEntry.Author    = strArray[1];
     ircLogEntry.Message   = strArray[2].Replace("&dsr", "//");
     return(ircLogEntry);
 }
Beispiel #3
0
        private int DrawLogEntry(IRCSystem.IRCLogEntry log, Rectangle startingDest, SpriteBatch sb, Dictionary <string, Color> HighlightKeywords, int lineHeight, int linesRemaining, int yNotToPass, bool needsNewMessagesLineDraw, out Rectangle dest)
        {
            dest = startingDest;
            int num1 = 55;
            int val1 = 76;
            int num2 = 4;

            if (Settings.ActiveLocale != "en-us")
            {
                val1 = 78;
            }
            if (GuiData.ActiveFontConfig.name.ToLower() == "medium")
            {
                val1 = 92;
            }
            else if (GuiData.ActiveFontConfig.name.ToLower() == "large")
            {
                val1 = 115;
            }
            string str     = "<" + log.Author + ">";
            int    num3    = (int)((double)GuiData.tinyfont.MeasureString(str).X + (double)num2);
            int    num4    = Math.Max(val1, (int)((double)GuiData.tinyfont.MeasureString(str).X + (double)num2));
            int    width   = dest.Width - (num1 + num2 + num4);
            string message = log.Message;

            string[] strArray = new string[1] {
                message
            };
            if (!log.Message.StartsWith("!ATTACHMENT:"))
            {
                strArray = Utils.SuperSmartTwimForWidth(message, width, GuiData.tinyfont).Split(Utils.newlineDelim, StringSplitOptions.None);
            }
            Rectangle dest1         = new Rectangle(dest.X + num1 + num2 + num4, dest.Y, dest.Width - (num1 + num2 + num4), dest.Height);
            Rectangle dest2         = new Rectangle(dest.X, dest.Y, num1 + num4, dest.Height);
            Color     defaultColor1 = Color.LightBlue;

            if (HighlightKeywords.ContainsKey(log.Author))
            {
                defaultColor1 = HighlightKeywords[log.Author];
            }
            Color defaultColor2 = Color.Lerp(Color.White, defaultColor1, 0.22f);

            if (needsNewMessagesLineDraw)
            {
                int       length = strArray.Length;
                Rectangle destinationRectangle = new Rectangle(dest.X, dest.Y + dest.Height - lineHeight * length + 1, dest.Width, 1);
                sb.Draw(Utils.white, destinationRectangle, Color.White * 0.5f);
            }
            for (int index = strArray.Length - 1; index >= 0 && linesRemaining > 0; --index)
            {
                if (index == 0)
                {
                    this.DrawLine("[" + log.Timestamp + "] ", dest2, sb, Color.White);
                    int x = dest2.X;
                    dest2.X = dest2.X + dest2.Width - num3;
                    this.DrawLine(str, dest2, sb, defaultColor1);
                    dest2.X = x;
                }
                this.DrawLine(strArray[index], dest1, sb, defaultColor2);
                dest.Height -= lineHeight;
                dest1.Height = dest.Height;
                dest2.Height = dest.Height;
                --linesRemaining;
                if (dest.Y + dest.Height - 6 <= yNotToPass)
                {
                    needsNewMessagesLineDraw = false;
                    break;
                }
            }
            Rectangle destinationRectangle1 = dest1;

            destinationRectangle1.Width  = 1;
            destinationRectangle1.X     -= 5;
            destinationRectangle1.Height = lineHeight * strArray.Length + 4;
            destinationRectangle1.Y      = dest1.Y + dest1.Height + 2;
            sb.Draw(Utils.white, destinationRectangle1, Color.White * 0.12f);
            return(strArray.Length);
        }