コード例 #1
0
ファイル: WpTextThread.cs プロジェクト: AbabeiAndrei/WProject
        private void DrawChatMessage(ChatMessage msg, Graphics gfx, ref int lastx)
        {
            int mleft = msg.Send ? HORIZONTAL_MESSAGE_PADDING : START_MESSAGE_PADDING;
            int mwidth = pnlThread.Width - HORIZONTAL_MESSAGE_PADDING - START_MESSAGE_PADDING*2;

            var ms = gfx.MeasureString(msg.Message, Font, new Size(mwidth - START_MESSAGE_PADDING*2, int.MaxValue));
            
            Brush mbkbrush = new SolidBrush(msg.Send ? SendMessageColor : ReciveMessageColor);

            Rectangle mrect = new Rectangle(mleft, lastx + 2, mwidth, (int) ms.Height + INFO_LINE_HEIGHT);
            Rectangle mrectText = new Rectangle(mleft, lastx + 2, mwidth, (int) ms.Height);

            gfx.FillRectangle(mbkbrush, mrect);
            gfx.DrawString(msg.Message, Font, Brushes.Black, mrectText);

            if(!msg.Send)
                gfx.DrawString(msg.SendBy, _smallInfoFont, Brushes.Black, mleft, mrectText.Bottom + 1);

            var msend = msg.GetWhenSend();

            var mssend = gfx.MeasureString(msend, _smallInfoFont);

            gfx.DrawString(msend, _smallInfoFont, Brushes.Black, mrect.Right - mssend.Width - 2, mrectText.Bottom + 1);

            _toolTips.Add(new Rectangle(mrect.Right - (int)mssend.Width - 2, 
                                        mrectText.Bottom + 1,
                                        (int) mssend.Width,
                                        (int) mssend.Height),
                           msg.DateTime.ToString(CultureInfo.DefaultThreadCurrentCulture));

            lastx += START_MESSAGE_PADDING + (int)ms.Height + INFO_LINE_HEIGHT + PaddingBetweenMessages;
        }
コード例 #2
0
ファイル: WpTextThread.cs プロジェクト: AbabeiAndrei/WProject
        private int CalculateMessageHeight(ChatMessage msg, Graphics gfx)
        {
            var mmsgHeight = gfx.MeasureString(msg.Message,
                                               Font,
                                               new SizeF(pnlThread.Width -
                                                         HORIZONTAL_MESSAGE_PADDING -
                                                         START_MESSAGE_PADDING*3,
                                                         int.MaxValue));

            return (int)mmsgHeight.Height + INFO_LINE_HEIGHT;
        }