PictureBox.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // System.Windows.Forms.PictureBox
  3. //
  4. // Author:
  5. // Joel Basson ([email protected])
  6. //
  7. //
  8. using System.Drawing;
  9. using System.Drawing.Printing;
  10. using System.ComponentModel;
  11. namespace System.Windows.Forms {
  12. /// <summary>
  13. /// Represents a Windows PictureBox control.
  14. ///
  15. /// </summary>
  16. public class PictureBox: Control{
  17. bool stretch;
  18. int height, width, dwidth, dheight;
  19. Gdk.Pixbuf pic1, pic2;
  20. string filevalue;
  21. public PictureBox () : base ()
  22. {
  23. }
  24. internal override Gtk.Widget CreateWidget () {
  25. Gtk.Image ibox = new Gtk.Image();
  26. //cbox.Add (label.Widget);
  27. return ibox;
  28. }
  29. public string File {
  30. set {
  31. filevalue = value;
  32. Gdk.Pixbuf pic1 = new Gdk.Pixbuf(filevalue);
  33. ((Gtk.Image)Widget).Pixbuf = pic1;
  34. }
  35. }
  36. public bool Stretch {
  37. get {
  38. return stretch;
  39. }
  40. set {
  41. if (value){
  42. Gdk.Pixbuf pic1 = new Gdk.Pixbuf(filevalue);
  43. height = pic1.Height;
  44. width = pic1.Width;
  45. dheight = ((Gtk.Image)Widget).HeightRequest;
  46. dwidth = ((Gtk.Image)Widget).WidthRequest;
  47. ((Gtk.Image)Widget).Pixbuf = pic1.ScaleSimple(dwidth, dheight, Gdk.InterpType.Bilinear);
  48. stretch = value;
  49. }
  50. else{
  51. Gdk.Pixbuf pic1 = new Gdk.Pixbuf(filevalue);
  52. ((Gtk.Image)Widget).Pixbuf = pic1;
  53. stretch = value;
  54. }
  55. }
  56. }
  57. }
  58. }