Ejemplo n.º 1
0
        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")));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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")));
        }
Ejemplo n.º 4
0
 protected override void OnLayout(LayoutEventArgs levent)
 {
     AdjustFormScrollbars(true);
     if (LayoutEngine.Layout(this, levent) && Parent != null)
     {
         Parent.PerformLayout(levent.AffectedControl, levent.AffectedProperty);
     }
 }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 public void PerformLayout()
 {
     if (isPerformingLayout)
     {
         return;
     }
     isPerformingLayout = true;
     LayoutEngine.Layout(this);
     isPerformingLayout = false;
 }
Ejemplo n.º 7
0
        /// ------------------------------------------------------------------------------------
        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"));
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        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;
                }
            }
        }
Ejemplo n.º 10
0
 private void UpdateLayout()
 {
     LayoutEngine.Layout(this, new LayoutEventArgs(this, "DisplayRectangle"));
 }
Ejemplo n.º 11
0
 internal void RequestLayout()
 {
     LayoutEngine.Layout(this, new LayoutEventArgs(this, "DisplayRectangle"));
 }
Ejemplo n.º 12
0
        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.");
        }
Ejemplo n.º 13
0
 public void DoLayout(string affectedProperty)
 {
     LayoutEngine.Layout(this, new LayoutEventArgs(this, affectedProperty));
 }
Ejemplo n.º 14
0
 protected virtual void OnExtendOrientationChanged()
 {
     LayoutEngine.Layout(this, new LayoutEventArgs(this, "ExtendOrientation"));
 }
Ejemplo n.º 15
0
 protected virtual void OnCellSizeChanged()
 {
     LayoutEngine.Layout(this, new LayoutEventArgs(this, "CellSize"));
 }
Ejemplo n.º 16
0
 protected virtual void OnLayout(LayoutEventArgs e)
 {
     bool parentNeedsLayout = LayoutEngine.Layout(this, e);
 }
Ejemplo n.º 17
0
 public void ForceAutoSize()
 {
     LayoutEngine.Layout(this, new LayoutEventArgs(this, "AutoSizeMode"));
 }