Exemplo n.º 1
0
        private bool CheckShouldDraw(Manager.Message m)
        {
            switch (m.type)
            {
            case CLI.Manager.MessageType.NoHeader:
                return(true);

            case CLI.Manager.MessageType.User:
                return(DrawMessageTypes[0]);

            case CLI.Manager.MessageType.Log:
                return(DrawMessageTypes[1]);

            case CLI.Manager.MessageType.Note:
                return(DrawMessageTypes[2]);

            case CLI.Manager.MessageType.Warning:
                return(DrawMessageTypes[3]);

            case CLI.Manager.MessageType.Error:
                return(DrawMessageTypes[4]);

            default:
                return(false);
            }
        }
Exemplo n.º 2
0
        private string[] DivideMessageIntoRows(Graphics g, Manager.Message m, Font font, RectangleF rect)
        {
            float spaceSize = g.MeasureString(" ", font).Width;

            string[] words = m.message.Split(' ');

            List <string> lines    = new List <string>();
            string        currLine = "";

            float posX = messageHeaderWidth + GetMessageTypeWidth(g, m, false, 0);

            for (int i = 0; i < words.Length; i++)
            {
                float wordWidth = g.MeasureString(words[i], font).Width;
                if (posX + wordWidth > rect.Width)
                {
                    lines.Add(currLine);
                    currLine = "";
                    posX     = messageRowStart;
                }

                currLine += words[i] + " ";
                posX     += wordWidth + spaceSize;
            }

            lines.Add(currLine);

            return(lines.ToArray());
        }
Exemplo n.º 3
0
        private float GetMessageTypeWidth(Graphics g, Manager.Message m, bool draw, float posY)
        {
            if (m.type == Manager.MessageType.NoHeader)
            {
                return(0);
            }
            string text  = m.type.ToString() + ": ";
            float  width = g.MeasureString(text, Style.Fonts.Small).Width;

            if (!draw)
            {
                return(width);
            }

            Color color = GetTypeColor(m.type);

            using (Brush brush = new SolidBrush(color)) {
                g.DrawString(m.type.ToString() + ":", Style.Fonts.Small, brush, messageHeaderWidth + 5, posY);
            }

            return(width);
        }
Exemplo n.º 4
0
        private int DrawMessage(Graphics g, Manager.Message m, RectangleF rect)
        {
            Font messageFont = Style.Fonts.Small;

            string[] rows = DivideMessageIntoRows(g, m, messageFont, rect);
            if (rows == null)
            {
                return(0);
            }

            // draw time header

            float posY = rect.Y + rect.Height - (rows.Length * rowHeight);

            if (m.type != Manager.MessageType.NoHeader)
            {
                using (Pen pen = new Pen(Style.Colors.Primary.Dark2)) {
                    g.DrawLine(pen, rect.X, posY - 4, messageHeaderWidth, posY - 4);
                }

                string text = m.date.ToString("HH:mm:ss");
                using (Brush brush = new SolidBrush(Style.Colors.Primary.Dark1)) {
                    g.DrawString(text, Style.Fonts.Small, brush, rect.X + 5, posY);
                }
            }

            // draw type header

            float typeWidth = GetMessageTypeWidth(g, m, true, posY);

            // draw rows

            DrawMessageRows(g, rows, messageFont, messageHeaderWidth + typeWidth + 5, posY);

            return(rows.Length);
        }