예제 #1
0
            //get primary render element
            public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
            {
                if (!this.HasReadyRenderElement)
                {
                    int gridW = this.Width - 10;
                    int gridH = this.Height - 10;
                    if (gridW < 3)
                    {
                        gridW = 3;
                    }
                    if (gridH < 3)
                    {
                        gridH = 3;
                    }

                    gridBox = new LayoutFarm.CustomWidgets.GridView(gridW, gridH);
                    gridBox.SetLocation(5, 5);
                    gridBox.BuildGrid(3, 3, CellSizeStyle.UniformCell);
                    var renderE = base.GetPrimaryRenderElement(rootgfx);
                    renderE.AddChild(gridBox);
                    //------------------------------------------------------
                    renderE.AddChild(boxLeftTop);
                    renderE.AddChild(boxRightTop);
                    renderE.AddChild(boxLeftBottom);
                    renderE.AddChild(boxRightBottom);
                    //------------------------------------------------------
                }
                return(base.GetPrimaryRenderElement(rootgfx));
            }
 //get primary render element
 public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
 {
     if (!this.HasReadyRenderElement)
     {
         gridBox = new LayoutFarm.CustomWidgets.GridView(30, 30);
         gridBox.SetLocation(5, 5);
         gridBox.BuildGrid(3, 3, CellSizeStyle.UniformCell);
         var myRenderElement = base.GetPrimaryRenderElement(rootgfx) as LayoutFarm.CustomWidgets.CustomRenderBox;
         myRenderElement.AddChild(gridBox);
     }
     return(base.GetPrimaryRenderElement(rootgfx));
 }
예제 #3
0
        protected override void OnStart(AppHost host)
        {
            //grid0
            {
                var gridView = new LayoutFarm.CustomWidgets.GridView(100, 100);
                gridView.SetLocation(50, 50);
                gridView.BuildGrid(2, 4, CellSizeStyle.UniformCell);
                host.AddChild(gridView);
                gridView.MouseDown += (s1, e1) =>
                {
                };
            }
            //grid1
            {
                var gridView = new LayoutFarm.CustomWidgets.GridView(100, 100);
                gridView.SetLocation(200, 50);
                gridView.BuildGrid(2, 4, CellSizeStyle.UniformCell);
                host.AddChild(gridView);
                var simpleButton = new LayoutFarm.CustomWidgets.Box(20, 20);
                simpleButton.BackColor = KnownColors.FromKnownColor(KnownColor.OliveDrab);
                gridView.SetCellContent(simpleButton, 1, 1);
                gridView.MouseDown += (s1, e1) =>
                {
                };

                simpleButton.MouseDown += (s1, e1) =>
                {
                    var box = (LayoutFarm.CustomWidgets.Box)s1;
                    box.BackColor = KnownColors.FromKnownColor(KnownColor.OrangeRed);
                };
            }
            ////-----
            //grid2
            {
                var gridView = new LayoutFarm.CustomWidgets.GridView(200, 100);
                gridView.SetLocation(350, 50);
                gridView.BuildGrid(10, 8, CellSizeStyle.UniformCell);
                host.AddChild(gridView);
            }

            ////-----
            //grid3
            {
                var gridView = new LayoutFarm.CustomWidgets.GridView(200, 100);
                gridView.SetLocation(50, 250);
                gridView.BuildGrid(10, 8, CellSizeStyle.UniformCell);
                host.AddChild(gridView);
            }


            ////-----
            //grid4
            //{
            //    var gridView = new LayoutFarm.CustomWidgets.GridView(800, 400);
            //    gridView.SetLocation(10, 10);
            //    gridView.HasSpecificHeight = true;
            //    gridView.HasSpecificWidth = true;
            //    gridView.NeedClipArea = true;
            //    gridView.BuildGrid(4, 4, CellSizeStyle.UniformCell);



            //    var gridBox = new LayoutFarm.CustomWidgets.GridBox(400, 200);
            //    gridBox.SetLocation(300, 250);
            //    gridBox.SetGridView(gridView);
            //    viewport.AddContent(gridBox);
            //    gridBox.PerformContentLayout();
            //}
            ////-----
            //grid5
            {
                var gridView = new LayoutFarm.CustomWidgets.GridView(200, 100);
                gridView.SetLocation(50, 500);
                gridView.BuildGrid(10, 8, CellSizeStyle.UniformCell);
                host.AddChild(gridView);
            }

            {
                //grid 6
                var gridView = new LayoutFarm.CustomWidgets.GridView(200, 100);
                //gridView.HasSpecificHeight = true; //if not set ,scroll bar will not show scroll button
                //gridView.HasSpecificWidth = true;//if not set ,scroll bar will not show scroll button

                gridView.SetLocation(300, 500);
                gridView.NeedClipArea = true;
                gridView.BuildGrid(100, 4, 5, 20);
                host.AddChild(gridView);

                //manual sc-bar
                var vscbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 100);
                {
                    //add vrcbar for grid view
                    vscbar.SetLocation(gridView.Right + 10, gridView.Top);
                    vscbar.MinValue    = 0;
                    vscbar.MaxValue    = gridView.Height;
                    vscbar.SmallChange = 20;
                    host.AddChild(vscbar);

                    //add relation between viewpanel and scroll bar
                    var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(vscbar.SliderBox, gridView);
                }
                //
                var hscbar = new LayoutFarm.CustomWidgets.ScrollBar(200, 15);
                {
                    //horizontal scrollbar
                    hscbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                    hscbar.SetLocation(gridView.Left, gridView.Bottom + 10);
                    hscbar.MinValue    = 0;
                    hscbar.MaxValue    = gridView.Width;
                    hscbar.SmallChange = 2;
                    host.AddChild(hscbar);
                    //add relation between viewpanel and scroll bar
                    var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(hscbar.SliderBox, gridView);
                }

                //perform content layout again***
                //gridView.PerformContentLayout();
            }
        }
예제 #4
0
        protected override void OnStartDemo(SampleViewport viewport)
        {
            //grid0
            {
                var gridView = new LayoutFarm.CustomWidgets.GridView(100, 100);
                gridView.SetLocation(50, 50);
                gridView.BuildGrid(2, 4, CellSizeStyle.UniformCell);
                viewport.AddContent(gridView);
                gridView.MouseDown += (s1, e1) =>
                {
                };
            }
            //grid1
            {
                var gridView = new LayoutFarm.CustomWidgets.GridView(100, 100);
                gridView.SetLocation(200, 50);
                gridView.BuildGrid(2, 4, CellSizeStyle.UniformCell);
                viewport.AddContent(gridView);
                var simpleButton = new LayoutFarm.CustomWidgets.SimpleBox(20, 20);
                simpleButton.BackColor = KnownColors.FromKnownColor(KnownColor.OliveDrab);
                gridView.SetCellContent(simpleButton, 1, 1);
                gridView.MouseDown += (s1, e1) =>
                {
                };

                simpleButton.MouseDown += (s1, e1) =>
                {
                    var box = (LayoutFarm.CustomWidgets.SimpleBox)s1;
                    box.BackColor = KnownColors.FromKnownColor(KnownColor.OrangeRed);
                };
            }
            ////-----
            //grid2
            {
                var gridView = new LayoutFarm.CustomWidgets.GridView(200, 100);
                gridView.SetLocation(350, 50);
                gridView.BuildGrid(10, 8, CellSizeStyle.UniformCell);
                viewport.AddContent(gridView);
            }

            ////-----
            //grid3
            {
                var gridView = new LayoutFarm.CustomWidgets.GridView(200, 100);
                gridView.SetLocation(50, 250);
                gridView.BuildGrid(10, 8, CellSizeStyle.UniformCell);
                viewport.AddContent(gridView);
            }


            ////-----
            //grid4
            {
                var gridView = new LayoutFarm.CustomWidgets.GridView(800, 400);
                gridView.SetLocation(10, 10);
                gridView.HasSpecificHeight = true;
                gridView.HasSpecificWidth  = true;
                gridView.NeedClipArea      = true;
                gridView.BuildGrid(4, 4, CellSizeStyle.UniformCell);



                var gridBox = new LayoutFarm.CustomWidgets.GridBox(400, 200);
                gridBox.SetLocation(300, 250);
                gridBox.SetGridView(gridView);
                viewport.AddContent(gridBox);
                gridBox.PerformContentLayout();
            }
            ////-----
            //grid5
            {
                var gridView = new LayoutFarm.CustomWidgets.GridView(200, 100);
                gridView.SetLocation(50, 500);
                gridView.BuildGrid(10, 8, CellSizeStyle.ColumnAndRow);
                viewport.AddContent(gridView);
            }
        }