Esempio n. 1
0
        static Box CreateBoxFromYogaNode(YogaNode node, Action <YogaNode, Box> decor)
        {
            CustomWidgets.Box fb0 = new CustomWidgets.Box(100, 100)
            {
                LayoutInstance = node.ToLayoutInstance()
            };
            decor(node, fb0);

            foreach (YogaNode child in node)
            {
                fb0.Add(CreateBoxFromYogaNode(child, decor));
            }
            return(fb0);
        }
Esempio n. 2
0
        protected override void OnStart(AppHost host)
        {
            var box_beh = new UIMouseBehaviour <Box>();
            {
                box_beh.GuestMsg += (s, e) =>
                {
                };
                box_beh.MouseDown += (s, e) =>
                {
                    e.MouseCursorStyle = MouseCursorStyle.Pointer;
                };
                box_beh.MouseUp += (s, e) =>
                {
                    e.MouseCursorStyle = MouseCursorStyle.Default;
                    //box.BackColor = Color.LightGray;
                    s.Source.BackColor = Color.FromArgb(50, KnownColors.FromKnownColor(KnownColor.DeepSkyBlue));
                };
                box_beh.MouseDrag += (s, e) =>
                {
                    Box box = s.Source;
                    box.BackColor = Color.FromArgb(180, KnownColors.FromKnownColor(KnownColor.GreenYellow));
                    Point pos = box.Position;
                    box.SetLocation(pos.X + e.XDiff, pos.Y + e.YDiff);
                    e.MouseCursorStyle = MouseCursorStyle.Pointer;
                    e.CancelBubbling   = true;
                };
            }

            //-------------
            {
                var box1 = new LayoutFarm.CustomWidgets.Box(50, 50);
                box1.BackColor = Color.Red;
                box1.SetLocation(10, 10);
                box_beh.AttachSharedBehaviorTo(box1);
                host.AddChild(box1);
            }
            //--------------------------------
            {
                var box2 = new LayoutFarm.CustomWidgets.Box(30, 30);
                box2.SetLocation(50, 50);
                //box2.dbugTag = 2;
                box_beh.AttachSharedBehaviorTo(box2);
                host.AddChild(box2);
            }
        }
Esempio n. 3
0
        protected override void OnStart(AppHost host)
        {
            var sampleButton = new LayoutFarm.CustomWidgets.Box(30, 30);

            host.AddChild(sampleButton);
            int count = 0;

            var boxspec = new CustomRenderBoxSpec();

            boxspec.BackColor    = PixelFarm.Drawing.Color.Red;
            boxspec.BorderColor  = PixelFarm.Drawing.Color.Black;
            sampleButton.BoxSpec = boxspec;


            sampleButton.MouseDown += (s, e2) =>
            {
                Console.WriteLine("click :" + (count++));
            };
        }
Esempio n. 4
0
        protected override void OnStart(AppHost host)
        {
            int halfW = host.PrimaryScreenWidth / 2;
            int halfH = host.PrimaryScreenHeight / 2;

            _rootPanel = new Box(halfW, halfH);
            _rootPanel.SetLocation(0, 0);
            host.AddChild(_rootPanel);

            var addWidthBtn = new Box(100, 50);
            var label1      = new Label();

            label1.Text = "+";
            label1.TransparentForMouseEvents = true;
            addWidthBtn.Add(label1);
            addWidthBtn.MouseDown += AddWidthBtn_MouseDown;
            addWidthBtn.SetLocation(0, halfH + 50);
            host.AddChild(addWidthBtn);

            var minusWidthBtn = new Box(100, 50);

            var label2 = new Label();

            label2.Text = "-";
            label2.TransparentForMouseEvents = true;
            minusWidthBtn.Add(label2);
            minusWidthBtn.MouseDown += MinusWidthBtn_MouseDown;
            minusWidthBtn.SetLocation(120, halfH + 50);
            host.AddChild(minusWidthBtn);

            //Init1();
            //Init2();

            //Init2_1();
            Init2_2();
            //Init2_3();

            _rootPanel.LayoutInstance = _rootNode.ToLayoutInstance();
        }
Esempio n. 5
0
        protected override void OnStart(AppHost host)
        {
            //grid0
            {
                var gridView = new LayoutFarm.CustomWidgets.GridBox(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.GridBox(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.GridBox(200, 100);
                gridView.SetLocation(350, 50);
                gridView.BuildGrid(10, 8, CellSizeStyle.UniformCell);
                host.AddChild(gridView);
            }

            ////-----
            //grid3
            {
                var gridView = new LayoutFarm.CustomWidgets.GridBox(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.GridBox(200, 100);
                gridView.SetLocation(50, 500);
                gridView.BuildGrid(10, 8, CellSizeStyle.UniformCell);
                host.AddChild(gridView);
            }

            {
                //grid 6
                var gridView = new LayoutFarm.CustomWidgets.GridBox(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();
            }
        }
Esempio n. 6
0
        void Init2()
        {
            YogaConfig config = new YogaConfig();

            _rootNode = new YogaNode(config)
            {
                FlexDirection = YogaFlexDirection.Column,
                Width         = _rootPanel.Width,
                Height        = _rootPanel.Height,
                Padding       = 20,
                AlignItems    = YogaAlign.Stretch
            };

            var _root_child0 = new YogaNode(config)
            {
                FlexDirection  = YogaFlexDirection.Row,
                Width          = _rootNode.Width,
                Height         = 100,
                AlignItems     = YogaAlign.Center,
                AlignSelf      = YogaAlign.Center,
                Flex           = 1,
                FlexShrink     = 1,
                StyleDirection = YogaDirection.RightToLeft
            };

            _rootNode.Insert(0, _root_child0);

            YogaNode c1r0_child0 = new YogaNode(config)
            {
                Width      = 100,
                Height     = 100,
                FlexShrink = 1
            };

            _root_child0.Insert(0, c1r0_child0);

            YogaNode c1r0_child1 = new YogaNode(config)
            {
                Width            = 100,
                Height           = 100,
                MarginHorizontal = 20,
                FlexGrow         = 1,
                FlexShrink       = 1
            };

            _root_child0.Insert(1, c1r0_child1);

            YogaNode c1r0_child2 = new YogaNode(config)
            {
                Width      = 100,
                Height     = 100,
                FlexShrink = 1
            };

            _root_child0.Insert(2, c1r0_child2);

            YogaNode root_child1 = new YogaNode(config)
            {
                Width            = 100,
                Height           = 100,
                MarginHorizontal = 20,
                FlexGrow         = 1,
                FlexShrink       = 1
            };

            _rootNode.Insert(1, root_child1);

            //YogaNode root_child2 = new YogaNode(config);
            //root_child2.Width = 100;
            //root_child2.Height = 100;
            //root_child2.FlexShrink = 1;
            //root.Insert(2, root_child2);

            _rootNode.StyleDirection = YogaDirection.LeftToRight;
            _rootNode.CalculateLayout();

            CustomWidgets.Box fb0 = new CustomWidgets.Box(100, 100)
            {
                BackColor = PixelFarm.Drawing.Color.Yellow, LayoutInstance = _root_child0.ToLayoutInstance()
            };
            _rootPanel.Add(fb0);

            CustomWidgets.Box fb0_child0 = new CustomWidgets.Box(100, 100)
            {
                BackColor = PixelFarm.Drawing.Color.Blue, LayoutInstance = c1r0_child0.ToLayoutInstance()
            };
            fb0.Add(fb0_child0);

            CustomWidgets.Box fb0_child1 = new CustomWidgets.Box(100, 100)
            {
                BackColor = PixelFarm.Drawing.Color.Blue, LayoutInstance = c1r0_child1.ToLayoutInstance()
            };
            fb0.Add(fb0_child1);

            CustomWidgets.Box fb0_child2 = new CustomWidgets.Box(100, 100)
            {
                BackColor = PixelFarm.Drawing.Color.Blue, LayoutInstance = c1r0_child2.ToLayoutInstance()
            };
            fb0.Add(fb0_child2);

            CustomWidgets.Box fb1 = new CustomWidgets.Box(100, 100)
            {
                BackColor = PixelFarm.Drawing.Color.Red, LayoutInstance = root_child1.ToLayoutInstance()
            };
            _rootPanel.Add(fb1);

            _rootPanel.UpdateLayout();
        }
Esempio n. 7
0
        void Init1()
        {
            YogaConfig config = new YogaConfig();

            _rootNode = new YogaNode(config)
            {
                FlexDirection = YogaFlexDirection.Row,
                Width         = _rootPanel.Width,
                Height        = _rootPanel.Height,
                Padding       = 20,
                AlignItems    = YogaAlign.Center
            };

            YogaNode root_child0 = new YogaNode(config)
            {
                Width      = 100,
                Height     = 100,
                FlexShrink = 1
            };

            _rootNode.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config)
            {
                Width            = 100,
                Height           = 100,
                MarginHorizontal = 20,
                FlexGrow         = 1,
                FlexShrink       = 1
            };

            _rootNode.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config)
            {
                Width      = 100,
                Height     = 100,
                FlexShrink = 1
            };

            _rootNode.Insert(2, root_child2);

            _rootNode.StyleDirection = YogaDirection.LeftToRight;
            _rootNode.CalculateLayout();

            CustomWidgets.Box fb0 = new CustomWidgets.Box(100, 100)
            {
                BackColor = PixelFarm.Drawing.Color.Blue, LayoutInstance = root_child0.ToLayoutInstance()
            };
            _rootPanel.Add(fb0);

            CustomWidgets.Box fb1 = new CustomWidgets.Box(100, 100)
            {
                BackColor = PixelFarm.Drawing.Color.Red, LayoutInstance = root_child1.ToLayoutInstance()
            };
            _rootPanel.Add(fb1);

            CustomWidgets.Box fb2 = new CustomWidgets.Box(100, 100)
            {
                BackColor = PixelFarm.Drawing.Color.Blue, LayoutInstance = root_child2.ToLayoutInstance()
            };
            _rootPanel.Add(fb2);

            _rootPanel.UpdateLayout();
        }
Esempio n. 8
0
 public RectBoxController()
 {
     _groundBox              = new Box(10, 10);
     _groundBox.BackColor    = Color.Transparent;//***
     _groundBox.NeedClipArea = false;
 }