Пример #1
0
        internal static void DrawItem(WeChatMessage msg, ViewHolder holder, Graphics g)
        {
            string path   = msg.fileName;
            bool   IsSend = msg.IsSend;

            if (!File.Exists(path))
            {
                TextHolder.DrawItem("获取图片失败", holder, g);
                return;
            }
            Image     image = Image.FromFile(path);
            Point     point = holder.bounds.Location;
            Rectangle rec   = new Rectangle();

            rec.Width  = image.Width;
            rec.Height = image.Height;
            rec.Y      = point.Y + 10;
            if (IsSend)
            {
                rec.X = holder.bounds.Width - 95 - rec.Width;
            }
            else
            {
                rec.X = 70;
            }
            g.DrawImage(image, rec, new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
            holder.bounds.Height = rec.Height + 10;
            image.Dispose();
        }
Пример #2
0
        internal static void DrawItem(API.Message msg, ViewHolder holder, Graphics g, Control owner)
        {
            if (holder.isMouseClick)
            {
                bounds = holder.bounds;
            }
            VoiceHolder.owner = owner;
            float Duration = msg.VoiceLength / 1000;//长度

            holder.UserData = msg;
            bool IsSend = msg.IsSend;

            //if (IsSend)
            //{
            //    animatedImage = Resources.img_play_voice;
            //}
            //else
            //{
            //    animatedImage = Resources.img_play_voice_mime;
            //}

            g.SmoothingMode = SmoothingMode.AntiAlias;
            Rectangle point = holder.bounds;

            Point[] points = TextHolder.GetPolygon(point, IsSend);
            int     Width  = 100;

            using (SolidBrush brushes = new SolidBrush(TriangleColor))
            {
                g.FillPolygon(brushes, points);

                Rectangle rect = Rectangle.Empty;
                if (IsSend)
                {
                    rect = new Rectangle(holder.bounds.Width - 95 - Width, point.Y + 10, Width + 15, Height + 15);
                }
                else
                {
                    rect = new Rectangle(70, point.Y + 10, Width + 15, Height + 15);
                }
                GraphicsUtils.FillRoundRectangle(g, brushes, rect, 4);
                ImageAnimator.UpdateFrames();
                g.DrawImage(animatedImage, rect.Location.X + Width / 2, rect.Location.Y + 7);

                brushes.Color = Color.FromArgb(153, 153, 153);
                if (IsSend)
                {
                    g.DrawString(Duration + "\"", font, brushes, holder.bounds.X + rect.Location.X - 40, rect.Location.Y + 20);
                }
                else
                {
                    g.DrawString(Duration + "\"", font, brushes, rect.Location.X + Width + 30, rect.Location.Y + 20);
                }
            }

            holder.bounds.Height = Height + 20;
            g.SmoothingMode      = SmoothingMode.None;
        }