Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
        public static API.Message ToMessage(this API.InteractionResponse model, IDiscordInteraction interaction)
        {
            if (model.Data.IsSpecified)
            {
                var data         = model.Data.Value;
                var messageModel = new API.Message
                {
                    IsTextToSpeech  = data.TTS,
                    Content         = (data.Content.IsSpecified && data.Content.Value == null) ? Optional <string> .Unspecified : data.Content,
                    Embeds          = data.Embeds,
                    AllowedMentions = data.AllowedMentions,
                    Components      = data.Components,
                    Flags           = data.Flags,
                };

                if (interaction is IApplicationCommandInteraction command)
                {
                    messageModel.Interaction = new API.MessageInteraction
                    {
                        Id   = command.Id,
                        Name = command.Data.Name,
                        Type = InteractionType.ApplicationCommand,
                        User = new API.User
                        {
                            Username      = command.User.Username,
                            Avatar        = command.User.AvatarId,
                            Bot           = command.User.IsBot,
                            Discriminator = command.User.Discriminator,
                            PublicFlags   = command.User.PublicFlags.HasValue ? command.User.PublicFlags.Value : Optional <UserProperties> .Unspecified,
                            Id            = command.User.Id,
                        }
                    };
                }

                return(messageModel);
            }

            return(new API.Message
            {
                Id = interaction.Id,
            });
        }
Ejemplo n.º 3
0
 public RpcMessage(DiscordRpcClient discord, API.Message model)
     : base(null, model.Author.IsSpecified ? new User(model.Author.Value) : null, model)
 {
     Discord = discord;
 }