public void MethodScaleControl () { Form f = new Form (); f.ShowInTaskbar = false; f.Show (); ScaleListBox gb = new ScaleListBox (); gb.Location = new Point (5, 10); f.Controls.Add (gb); Assert.AreEqual (new Rectangle (5, 10, 120, 95), gb.Bounds, "A1"); gb.PublicScaleControl (new SizeF (2.0f, 2.0f), BoundsSpecified.All); Assert.AreEqual (new Rectangle (10, 20, 236, 186), gb.Bounds, "A2"); gb.PublicScaleControl (new SizeF (.5f, .5f), BoundsSpecified.Location); Assert.AreEqual (new Rectangle (5, 10, 236, 186), gb.Bounds, "A3"); gb.PublicScaleControl (new SizeF (.5f, .5f), BoundsSpecified.Size); Assert.AreEqual (new Rectangle (5, 10, 120, 95), gb.Bounds, "A4"); gb.PublicScaleControl (new SizeF (3.5f, 3.5f), BoundsSpecified.Size); Assert.AreEqual (new Rectangle (5, 10, 410, 316), gb.Bounds, "A5"); gb.PublicScaleControl (new SizeF (2.5f, 2.5f), BoundsSpecified.Size); Assert.AreEqual (new Rectangle (5, 10, 1019, 797), gb.Bounds, "A6"); gb.PublicScaleControl (new SizeF (.2f, .2f), BoundsSpecified.Size); Assert.AreEqual (new Rectangle (5, 10, 207, 160), gb.Bounds, "A7"); f.Dispose (); }
public void GetScaledBoundsTest () { ScaleListBox c = new ScaleListBox (); Rectangle r = new Rectangle (100, 200, 300, 400); Assert.AreEqual (new Rectangle (200, 100, 596, 50), c.PublicGetScaledBounds (r, new SizeF (2f, .5f), BoundsSpecified.All), "A1"); Assert.AreEqual (new Rectangle (200, 100, 300, 96), c.PublicGetScaledBounds (r, new SizeF (2f, .5f), BoundsSpecified.Location), "A2"); Assert.AreEqual (new Rectangle (100, 200, 596, 50), c.PublicGetScaledBounds (r, new SizeF (2f, .5f), BoundsSpecified.Size), "A3"); Assert.AreEqual (new Rectangle (100, 200, 300, 50), c.PublicGetScaledBounds (r, new SizeF (2f, .5f), BoundsSpecified.Height), "A4"); Assert.AreEqual (new Rectangle (200, 200, 300, 96), c.PublicGetScaledBounds (r, new SizeF (2f, .5f), BoundsSpecified.X), "A5"); Assert.AreEqual (new Rectangle (100, 200, 300, 96), c.PublicGetScaledBounds (r, new SizeF (2f, .5f), BoundsSpecified.None), "A6"); Assert.AreEqual (new Rectangle (100, 200, 300, 96), c.PublicGetScaledBounds (r, new SizeF (1f, 1f), BoundsSpecified.All), "A6-2"); Assert.AreEqual (new Rectangle (200, 400, 596, 188), c.PublicGetScaledBounds (r, new SizeF (2f, 2f), BoundsSpecified.All), "A7"); Assert.AreEqual (new Rectangle (300, 600, 892, 280), c.PublicGetScaledBounds (r, new SizeF (3f, 3f), BoundsSpecified.All), "A8"); Assert.AreEqual (new Rectangle (400, 800, 1188, 372), c.PublicGetScaledBounds (r, new SizeF (4f, 4f), BoundsSpecified.All), "A9"); Assert.AreEqual (new Rectangle (50, 100, 152, 50), c.PublicGetScaledBounds (r, new SizeF (.5f, .5f), BoundsSpecified.All), "A10"); }