public BaseMessageForm(string message, string header, MessagePicture pic) : this() { this.Text = header; this.richTextBox1.Text = message; this.SetImage(pic); }
public async Task MoveMsgAsync(CommandContext ctx, [Description("The Channel to move to")] DiscordChannel channel, [Description("Amount of Messages to move")] int msg) { if (msg < 1) { return; } IReadOnlyList <DiscordMessage> messagesList = await ctx.Channel.GetMessagesAsync(limit : msg); List <DiscordMessage> messages = messagesList.OrderBy(m => m.Timestamp).ToList(); int totalHeight = 0; List <MessagePicture> msgPicList = new List <MessagePicture>(); int imgWidth = 600; using (Graphics calcGraphics = Graphics.FromImage(new Bitmap(1, 1))) { foreach (var cmsg in messages) { var msgPic = new MessagePicture(cmsg, calcGraphics, imgWidth); msgPicList.Add(msgPic); totalHeight += msgPic.Height; } } Bitmap bmp = new Bitmap(imgWidth, totalHeight); using (Graphics graphics = Graphics.FromImage(bmp)) { graphics.Clear(Color.FromArgb(54, 57, 63)); graphics.SmoothingMode = SmoothingMode.HighSpeed; float cHeight = 0f; foreach (var msgPic in msgPicList) { msgPic.AddToImg(graphics, cHeight, imgWidth); cHeight += msgPic.Height; } } using (MemoryStream memory = new MemoryStream()) { var qualityEncoder = Encoder.Quality; var quality = (long)80; var ratio = new EncoderParameter(qualityEncoder, quality); var codecParams = new EncoderParameters(1); codecParams.Param[0] = ratio; var jpegCodecInfo = ImageCodecInfo.GetImageEncoders().First(e => e.MimeType == "image/jpeg"); bmp.Save(memory, jpegCodecInfo, codecParams); // Save to JPG memory.Position = 0; await channel.SendFileAsync(memory, "ChatArchive.jpeg"); } await ctx.Channel.DeleteMessagesAsync(messagesList); await ctx.RespondAsync($"I moved some Stuff to {channel.Mention}"); }
private void SetImage(MessagePicture pic) { this.pictureBox1.SuspendLayout(); this.pictureBox1.Image = imageList1.Images[(int)pic]; this.pictureBox1.ResumeLayout(); }