public void LayoutEngine_Layout_NullContainer_ThrowsArgumentNullException() { using var control = new FlowLayoutPanel(); LayoutEngine engine = control.LayoutEngine; Assert.Throws <ArgumentNullException>("container", () => engine.Layout(null, new LayoutEventArgs(control, "affectedProperty"))); }
public void LayoutEngine_Layout_ValidContainerBottomUp_Success() { using var control = new FlowLayoutPanel { FlowDirection = FlowDirection.BottomUp }; control.SuspendLayout(); using var child1 = new Control { Margin = Padding.Empty, Size = new Size(10, 20) }; using var child2 = new Control { Margin = new Padding(1, 2, 3, 4), Size = new Size(10, 20) }; using var largeChild = new Control { Margin = Padding.Empty, Size = new Size(100, 200) }; using var emptyChild = new Control { Size = Size.Empty }; using var emptyChildWithMargin = new Control { Margin = new Padding(1, 2, 3, 4), Size = Size.Empty }; using var child3 = new Control { Margin = Padding.Empty, Size = new Size(50, 100) }; using var child4 = new Control { Margin = Padding.Empty, Size = new Size(10, 20) }; control.Controls.Add(child1); control.Controls.Add(child2); control.Controls.Add(largeChild); control.Controls.Add(emptyChild); control.Controls.Add(emptyChildWithMargin); control.Controls.Add(child3); control.Controls.Add(child4); LayoutEngine engine = control.LayoutEngine; engine.Layout(control, null); Assert.Equal(new Rectangle(0, 80, 10, 20), child1.Bounds); Assert.Equal(new Rectangle(1, 56, 10, 20), child2.Bounds); Assert.Equal(new Rectangle(14, -100, 100, 200), largeChild.Bounds); Assert.Equal(new Rectangle(117, 97, 0, 0), emptyChild.Bounds); Assert.Equal(new Rectangle(115, 90, 0, 0), emptyChildWithMargin.Bounds); Assert.Equal(new Rectangle(120, 0, 50, 100), child3.Bounds); Assert.Equal(new Rectangle(170, 80, 10, 20), child4.Bounds); }
public void LayoutEngine_Layout_InvalidContainer_Nop() { using var control = new FlowLayoutPanel(); LayoutEngine engine = control.LayoutEngine; Assert.Throws <NotSupportedException>(() => engine.Layout("container", new LayoutEventArgs(control, "affectedProperty"))); }
protected override void OnLayout(LayoutEventArgs levent) { AdjustFormScrollbars(true); if (LayoutEngine.Layout(this, levent) && Parent != null) { Parent.PerformLayout(levent.AffectedControl, levent.AffectedProperty); } }
public void LayoutEngine_Layout_ValidContainerLeftToRight_Success() { using var control = new FlowLayoutPanel(); control.SuspendLayout(); using var child1 = new Control { Margin = Padding.Empty, Size = new Size(10, 20) }; using var child2 = new Control { Margin = new Padding(1, 2, 3, 4), Size = new Size(10, 20) }; using var largeChild = new Control { Margin = Padding.Empty, Size = new Size(100, 200) }; using var emptyChild = new Control { Size = Size.Empty }; using var emptyChildWithMargin = new Control { Margin = new Padding(1, 2, 3, 4), Size = Size.Empty }; using var child3 = new Control { Margin = Padding.Empty, Size = new Size(50, 100) }; using var child4 = new Control { Margin = Padding.Empty, Size = new Size(10, 20) }; control.Controls.Add(child1); control.Controls.Add(child2); control.Controls.Add(largeChild); control.Controls.Add(emptyChild); control.Controls.Add(emptyChildWithMargin); control.Controls.Add(child3); control.Controls.Add(child4); LayoutEngine engine = control.LayoutEngine; engine.Layout(control, null); Assert.Equal(new Rectangle(0, 0, 10, 20), child1.Bounds); Assert.Equal(new Rectangle(11, 2, 10, 20), child2.Bounds); Assert.Equal(new Rectangle(24, 0, 100, 200), largeChild.Bounds); Assert.Equal(new Rectangle(127, 3, 0, 0), emptyChild.Bounds); Assert.Equal(new Rectangle(131, 2, 0, 0), emptyChildWithMargin.Bounds); Assert.Equal(new Rectangle(134, 0, 50, 100), child3.Bounds); Assert.Equal(new Rectangle(184, 0, 10, 20), child4.Bounds); }
public void PerformLayout() { if (isPerformingLayout) { return; } isPerformingLayout = true; LayoutEngine.Layout(this); isPerformingLayout = false; }
/// ------------------------------------------------------------------------------------ public void SetUiFonts() { chkRegEx.Font = FontHelper.UIFont; cboFindWhat.Font = App.PhoneticFont; chkMatchCase.Font = FontHelper.UIFont; chkMatchEntireWord.Font = FontHelper.UIFont; chkStartsWith.Font = FontHelper.UIFont; chkReverseSearch.Font = FontHelper.UIFont; lblSearchColumns.Font = FontHelper.UIFont; lblFindWhat.Font = FontHelper.UIFont; gbOptions.Font = FontHelper.UIFont; LayoutEngine.Layout(this, new LayoutEventArgs(tblLayoutFindWhat, "Height")); }
public void DemoTest() { //The MapData and IConfiguration come from external sources. MapData input = UnitTestHelper.GetSampleMapData(); IConfiguration config = UnitTestHelper.GetTestConfig(); //Usage is extremely simple. //create a new engine with configuration data LayoutEngine layoutEngine = new LayoutEngine(config); Console.WriteLine("MAPDATA INFO BEFORE LAYOUT:"); DisplayMapdataInfo(input); // process layout request for some data MapData ret = layoutEngine.Layout(input); Console.WriteLine("MAPDATA INFO AFTER LAYOUT:"); DisplayMapdataInfo(ret); }
protected virtual void OnLayout(LayoutEventArgs e) { if (Initialized && !_state[s_stateInLayout]) { _state[s_stateInLayout] = true; try { Margin = DefaultMargin; CachedBoundsMode = true; try { // dont layout in the constructor that's just tacky. bool parentNeedsLayout = LayoutEngine.Layout(this, e); } finally { CachedBoundsMode = false; } ToolStripPanelCell cell = RowManager.GetNextVisibleCell(Cells.Count - 1, /*forward*/ false); if (cell is null) { ApplyCachedBounds(); } else if (Orientation == Orientation.Horizontal) { OnLayoutHorizontalPostFix(); } else { OnLayoutVerticalPostFix(); } } finally { _state[s_stateInLayout] = false; } } }
private void UpdateLayout() { LayoutEngine.Layout(this, new LayoutEventArgs(this, "DisplayRectangle")); }
internal void RequestLayout() { LayoutEngine.Layout(this, new LayoutEventArgs(this, "DisplayRectangle")); }
public void TestStressLayoutEngine() { LayoutEngine engine = new LayoutEngine(StressTestsHelper.CreateConfig()); long start = Environment.TickCount; for (int i = 1; i <= Times; ++i) { MapData md = engine.Layout(StressTestsHelper.CreateMapData()); IList <int> ids = new List <int>(); // check results Assert.AreEqual(3, md.Links.Count, "Layout should be correct."); ids.Add((int)md.Links[0].Id); ids.Add((int)md.Links[1].Id); ids.Add((int)md.Links[2].Id); Assert.IsTrue(ids.Contains(-51), "Layout should be correct."); Assert.IsTrue(ids.Contains(-52), "Layout should be correct."); Assert.IsTrue(ids.Contains(-53), "Layout should be correct."); ids.Clear(); ILink link = md.Links[0]; Assert.AreEqual(2, link.Nodes.Count, "Layout should be correct."); ids.Add((int)link.Nodes[0].Id); ids.Add((int)link.Nodes[1].Id); Assert.IsTrue(ids.Contains(1), "Layout should be correct."); Assert.IsTrue(ids.Contains(-101), "Layout should be correct."); ids.Clear(); Assert.AreEqual(2, link.Nodes.Count, "Layout should be correct."); ids.Add((int)link.Ports[0].Id); ids.Add((int)link.Ports[1].Id); Assert.IsTrue(ids.Contains(1), "Layout should be correct."); Assert.IsTrue(ids.Contains(-51), "Layout should be correct."); ids.Clear(); link = md.Links[1]; Assert.AreEqual(2, link.Nodes.Count, "Layout should be correct."); ids.Add((int)link.Nodes[0].Id); ids.Add((int)link.Nodes[1].Id); Assert.IsTrue(ids.Contains(-101), "Layout should be correct."); Assert.IsTrue(ids.Contains(-102), "Layout should be correct."); ids.Clear(); Assert.AreEqual(2, link.Nodes.Count, "Layout should be correct."); ids.Add((int)link.Ports[0].Id); ids.Add((int)link.Ports[1].Id); Assert.IsTrue(ids.Contains(-51), "Layout should be correct."); Assert.IsTrue(ids.Contains(-52), "Layout should be correct."); ids.Clear(); link = md.Links[2]; Assert.AreEqual(2, link.Nodes.Count, "Layout should be correct."); ids.Add((int)link.Nodes[0].Id); ids.Add((int)link.Nodes[1].Id); Assert.IsTrue(ids.Contains(-102), "Layout should be correct."); Assert.IsTrue(ids.Contains(100), "Layout should be correct."); ids.Clear(); Assert.AreEqual(2, link.Nodes.Count, "Layout should be correct."); ids.Add((int)link.Ports[0].Id); ids.Add((int)link.Ports[1].Id); Assert.IsTrue(ids.Contains(-52), "Layout should be correct."); Assert.IsTrue(ids.Contains(50), "Layout should be correct."); Assert.AreEqual("layout", md.Header.Lifecycle, "Layout should be correct."); } Console.WriteLine("Total time : " + (Environment.TickCount - start) + "ms."); }
public void DoLayout(string affectedProperty) { LayoutEngine.Layout(this, new LayoutEventArgs(this, affectedProperty)); }
protected virtual void OnExtendOrientationChanged() { LayoutEngine.Layout(this, new LayoutEventArgs(this, "ExtendOrientation")); }
protected virtual void OnCellSizeChanged() { LayoutEngine.Layout(this, new LayoutEventArgs(this, "CellSize")); }
protected virtual void OnLayout(LayoutEventArgs e) { bool parentNeedsLayout = LayoutEngine.Layout(this, e); }
public void ForceAutoSize() { LayoutEngine.Layout(this, new LayoutEventArgs(this, "AutoSizeMode")); }