Windows Forms presentation control



  • I need to put the information in the program as a text with pictures. Used standard RichTextBoxbut it's not a very good option. First of all, he keeps pictures uncompressed and if I have a lot of pictures, he eats a lot of memories. Second, it's not easy to put pictures in, and sometimes there's a problem with reflection. What other option is to make such information available Windows Forms (or Windows Presentation Foundation?



  • Keeping pictures in an uncompressed way, and if I have a lot of pictures...

    The size and other parameters of the picture can be changed. During loading, you create a new Bitmap and remove the downloaded image. WinForms is like this:

    using System.Drawing;
    using System.Windows.Forms;
    

    static Image LoadImage(string path, int width, int height) {
    var img = Image.FromFile(path);
    var res = new Bitmap(width, height);
    res.SetResolution(img.HorizontalResolution, img.VerticalResolution);
    using (var g = Graphics.FromImage(res)) {
    var dst = new Rectangle(0, 0, res.Width, res.Height);
    g.DrawImage(img, dst);
    }
    return res;
    }

    var f = new Form();
    new PictureBox() {
    Parent = f,
    Dock = DockStyle.Fill,
    Image = LoadImage(@"C:\Temp\Pic.png", 50, 50) };
    f.ShowDialog();




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2