« Bow before Father Ulrich | Main | Why the clones will defeat the robots »
After a frustrating day of attempting to fix some bugs in MWF I decided to take the night off and hack up something that windows forms is missing. I (along with other many other people) have always wanted a gtk like layout system in windows forms. In fact most criticism of the winforms api is because of the lack of a nice automatic layout system. Below is a screenshot of a little demo app using my new packing controls. I will most likely release the code for this after the weekend, I want to write some more tests, and clean up the build though first.
A demo created with Wink is here
Code from my sample app:
using System; using System.Drawing; using System.Windows.Forms; using Mono.Winforms.Packing;
public class BasicPacking : Form {
public BasicPacking () { VBox vbox = new VBox ();
vbox.PackStart (Row (), false, true, 0); vbox.PackStart (CenterRow (), true, true, 0); vbox.PackStart (Row (), false, true, 0);
vbox.Dock = DockStyle.Fill; Controls.Add (vbox); }
private HBox Row () { HBox hbox = new HBox ();
Button button = new Button (); button.Text = "one"; hbox.PackStart (button, false, true, 0);
button = new Button (); button.Text = "two"; hbox.Controls.Add (button); // Can add Items in a winforms-ish way also
button = new Button (); button.Text = "three"; hbox.PackStart (button, false, true, 0);
return hbox; }
private HBox CenterRow () { HBox hbox = new HBox ();
Button button = new Button (); button.Text = "one"; hbox.PackStart (button, false, true, 0);
PictureBox pb = new PictureBox (); pb.Image = Image.FromFile ("roxy-sandy-scaled.jpg"); pb.SizeMode = PictureBoxSizeMode.StretchImage; hbox.PackStart (pb, true, true, 0);
button = new Button (); button.Text = "three"; hbox.PackStart (button, false, true, 0);
return hbox; }
public static void Main () { Application.Run (new BasicPacking ()); } }
NOTE: Can't you just see a postcard with that picture and
"Welcome to sunny sandy California" and maybe a little
paw print at the end? Man, if the programming thing doesn't
work out I think I could have an illustrious postcard making
career.