Ejemplo n.º 1
0
        void AddScrollView1(SampleViewport viewport, int x, int y)
        {
            var panel = new LayoutFarm.CustomWidgets.SimpleBox(200, 175);

            panel.NeedClipArea = true;
            panel.SetLocation(x + 30, y + 30);
            panel.BackColor = Color.LightGray;
            viewport.AddContent(panel);
            //-------------------------
            {
                //vertical scrollbar
                var vscbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200);
                vscbar.SetLocation(x + 10, y + 10);
                vscbar.MinValue    = 0;
                vscbar.MaxValue    = 170;
                vscbar.SmallChange = 20;
                viewport.AddContent(vscbar);
                //add relation between viewpanel and scroll bar
                var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(vscbar.SliderBox, panel);
            }
            //-------------------------
            {
                //horizontal scrollbar
                var hscbar = new LayoutFarm.CustomWidgets.ScrollBar(200, 15);
                hscbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                hscbar.SetLocation(x + 30, y + 10);
                hscbar.MinValue    = 0;
                hscbar.MaxValue    = 170;
                hscbar.SmallChange = 20;
                viewport.AddContent(hscbar);
                //add relation between viewpanel and scroll bar
                var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(hscbar.SliderBox, panel);
            }

            //add content to panel
            for (int i = 0; i < 10; ++i)
            {
                var box1 = new LayoutFarm.CustomWidgets.SimpleBox(400, 30);
                box1.HasSpecificWidth  = true;
                box1.HasSpecificHeight = true;
                box1.BackColor         = Color.OrangeRed;
                box1.SetLocation(i * 20, i * 40);
                panel.AddChild(box1);
            }
            //--------------------------
            panel.PerformContentLayout();
            panel.SetViewport(0, 0);
        }
Ejemplo n.º 2
0
        void AddScrollView1(SampleViewport viewport, int x, int y)
        {
            var panel = new LayoutFarm.CustomWidgets.SimpleBox(200, 175);
            panel.SetLocation(x + 30, y + 30);
            panel.BackColor = Color.LightGray;
            viewport.AddContent(panel);
            //-------------------------  
            {
                //vertical scrollbar
                var vscbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200);
                vscbar.SetLocation(x + 10, y + 10);
                vscbar.MinValue = 0;
                vscbar.MaxValue = 170;
                vscbar.SmallChange = 20;
                viewport.AddContent(vscbar);
                //add relation between viewpanel and scroll bar 
                var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(vscbar, panel);
            }
            //-------------------------  
            {
                //horizontal scrollbar
                var hscbar = new LayoutFarm.CustomWidgets.ScrollBar(200, 15);
                hscbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                hscbar.SetLocation(x + 30, y + 10);
                hscbar.MinValue = 0;
                hscbar.MaxValue = 170;
                hscbar.SmallChange = 20;
                viewport.AddContent(hscbar);
                //add relation between viewpanel and scroll bar 
                var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(hscbar, panel);
            }

            //add content to panel
            for (int i = 0; i < 10; ++i)
            {
                var box1 = new LayoutFarm.CustomWidgets.SimpleBox(400, 30);
                box1.HasSpecificWidth = true;
                box1.HasSpecificHeight = true;
                box1.BackColor = Color.OrangeRed;
                box1.SetLocation(i * 20, i * 40);
                panel.AddChild(box1);
            }
            //--------------------------   
            panel.PerformContentLayout();
            panel.SetViewport(0, 0);
        }
Ejemplo n.º 3
0
        public GridBox(int width, int height)
            : base(width, height)
        {
            //this grid box acts as viewport
            this.HasSpecificHeight = true;
            this.HasSpecificWidth  = true;
            this.NeedClipArea      = true;

            //scrollable content box is inside this grid box
            _scrollableViewPanel = new SimpleBox(this.Width, this.Height);



            this.AddChild(_scrollableViewPanel);

            {
                //vertical scrollbar
                var vscbar = new LayoutFarm.CustomWidgets.ScrollBar(15, this.Height);
                vscbar.SetLocation(this.Width - 15, 0);
                vscbar.MinValue    = 0;
                vscbar.MaxValue    = this.Height;
                vscbar.SmallChange = 20;
                this.AddChild(vscbar);
                //add relation between _scrollableViewPanel and scroll bar
                var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(vscbar.SliderBox, _scrollableViewPanel);
            }
            //-------------------------
            {
                //horizontal scrollbar
                var hscbar = new LayoutFarm.CustomWidgets.ScrollBar(150, 15);
                hscbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                hscbar.SetLocation(30, 10);
                hscbar.MinValue    = 0;
                hscbar.MaxValue    = this.Width - 20;
                hscbar.SmallChange = 20;
                this.AddChild(hscbar);
                //add relation between _scrollableViewPanel and scroll bar
                var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(hscbar.SliderBox, _scrollableViewPanel);
            }
            _scrollableViewPanel.PerformContentLayout();
        }
Ejemplo n.º 4
0
        void AddScrollView2(AppHost host, int x, int y)
        {
            var panel = new LayoutFarm.CustomWidgets.Box(800, 600);

            panel.HasSpecificWidthAndHeight = true;
            panel.NeedClipArea = true;
            panel.SetLocation(x + 10, y + 30);
            panel.BackColor         = Color.LightGray;
            panel.ContentLayoutKind = CustomWidgets.BoxContentLayoutKind.VerticalStack;
            host.AddChild(panel);
            //-------------------------
            //load images...

            //check folder before load
            string[] fileNames = new string[0];

            if (System.IO.Directory.Exists("../Data/imgs"))
            {
                fileNames = System.IO.Directory.GetFiles("../Data/imgs", "0*.jpg");
            }
            //select only
            int lastY = 0;


            int imgNo = 0;

            for (int i = 0; i < fileNames.Length * 4; ++i) //5 imgs
            {
                var imgbox = new LayoutFarm.CustomWidgets.ImageBox(36, 36);
                imgbox.BackColor = Color.OrangeRed;
                imgbox.SetLocation(0, lastY);
                imgbox.MouseUp += (s, e) =>
                {
                    if (e.Button == UIMouseButtons.Right)
                    {
                        //test remove this imgbox on right mouse click
                        panel.RemoveChild(imgbox);
                    }
                };

                ImageBinder imgBinder = host.CreateImageBinder(fileNames[imgNo]);
                imgbox.SetSize(imgBinder.Width, imgBinder.Height);
                imgbox.ImageBinder = imgBinder;


                lastY += imgbox.Height;
                panel.AddChild(imgbox);

                imgNo++;
                if (imgNo == fileNames.Length) //last img
                {
                    imgNo = 0;                 //reset
                }
            }
            //--------------------------
            //panel may need more
            panel.SetViewport(0, 0);

            //-------------------------
            {
                //vertical scrollbar
                var vscbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200);
                vscbar.SetLocation(x + 10, y + 10);
                vscbar.MinValue    = 0;
                vscbar.MaxValue    = lastY;
                vscbar.SmallChange = 20;
                host.AddChild(vscbar);
                //add relation between viewpanel and scroll bar
                var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(vscbar.SliderBox, panel);
            }
            //-------------------------
            {
                //horizontal scrollbar
                var hscbar = new LayoutFarm.CustomWidgets.ScrollBar(150, 15);
                hscbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                hscbar.SetLocation(x + 30, y + 10);
                hscbar.MinValue    = 0;
                hscbar.MaxValue    = panel.Width;//just init
                hscbar.SmallChange = 20;
                host.AddChild(hscbar);
                //add relation between viewpanel and scroll bar
                var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(hscbar.SliderBox, panel);
            }
        }
Ejemplo n.º 5
0
        void AddScrollView2(SampleViewport viewport, int x, int y)
        {
            var panel = new LayoutFarm.CustomWidgets.SimpleBox(800, 1000);

            panel.NeedClipArea = true;
            panel.SetLocation(x + 10, y + 30);
            panel.BackColor         = Color.LightGray;
            panel.ContentLayoutKind = CustomWidgets.BoxContentLayoutKind.VerticalStack;
            viewport.AddContent(panel);
            //-------------------------
            //load images...

            //check folder before load
            string[] fileNames = new string[0];

            if (System.IO.Directory.Exists("../../Data/imgs"))
            {
                fileNames = System.IO.Directory.GetFiles("../../Data/imgs", "0*.jpg");
            }
            //select only
            int         lastY  = 0;
            ImageBinder binder = viewport.GetImageBinder(fileNames[2]);

            for (int i = 0; i < fileNames.Length * 4; ++i) //5 imgs
            {
                var imgbox = new LayoutFarm.CustomWidgets.ImageBox(36, 400);
                imgbox.ImageBinder = binder;
                imgbox.BackColor   = Color.OrangeRed;
                imgbox.SetLocation(0, lastY);
                imgbox.MouseUp += (s, e) =>
                {
                    if (e.Button == UIMouseButtons.Right)
                    {
                        //test remove this imgbox on right mouse click
                        panel.RemoveChild(imgbox);
                    }
                };
                lastY += imgbox.Height + 5;
                panel.AddChild(imgbox);
            }
            //--------------------------
            //panel may need more
            panel.SetViewport(0, 0);
            //-------------------------
            {
                //vertical scrollbar
                var vscbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200);
                vscbar.SetLocation(x + 10, y + 10);
                vscbar.MinValue    = 0;
                vscbar.MaxValue    = lastY;
                vscbar.SmallChange = 20;
                viewport.AddContent(vscbar);
                //add relation between viewpanel and scroll bar
                var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(vscbar.SliderBox, panel);
            }
            //-------------------------
            {
                //horizontal scrollbar
                var hscbar = new LayoutFarm.CustomWidgets.ScrollBar(150, 15);
                hscbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                hscbar.SetLocation(x + 30, y + 10);
                hscbar.MinValue    = 0;
                hscbar.MaxValue    = 170;
                hscbar.SmallChange = 20;
                viewport.AddContent(hscbar);
                //add relation between viewpanel and scroll bar
                var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(hscbar.SliderBox, panel);
            }
            panel.PerformContentLayout();
        }
Ejemplo n.º 6
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();
            }
        }
Ejemplo n.º 7
0
 void AddScrollView2(SampleViewport viewport, int x, int y)
 {
     var panel = new LayoutFarm.CustomWidgets.SimpleBox(800, 600);
     panel.SetLocation(x + 30, y + 30);
     panel.BackColor = Color.LightGray;
     panel.ContentLayoutKind = CustomWidgets.BoxContentLayoutKind.VerticalStack;
     viewport.AddContent(panel);
     //-------------------------  
     //load images...
     int lastY = 0;
     for (int i = 0; i < 5; ++i)
     {
         var imgbox = new LayoutFarm.CustomWidgets.ImageBox(36, 400);
         //if (!System.IO.File.Exists("../../images/0" + (i + 1) + ".jpg"))
         //{
         //}
         ClientImageBinder binder = new ClientImageBinder("../../images/0" + (i + 1) + ".jpg");
         binder.SetOwner(imgbox);
         binder.SetLazyFunc(LazyImageLoad);
         //if use lazy img load func
         imageContentMan.AddRequestImage(binder);
         imgbox.ImageBinder = binder;
         imgbox.BackColor = Color.OrangeRed;
         imgbox.SetLocation(0, lastY);
         imgbox.MouseUp += (s, e) =>
         {
             if (e.Button == UIMouseButtons.Right)
             {
                 //test remove this imgbox on right mouse click
                 panel.RemoveChild(imgbox);
             }
         };
         lastY += imgbox.Height + 5;
         panel.AddChild(imgbox);
     }
     //--------------------------
     //panel may need more 
     panel.SetViewport(0, 0);
     //-------------------------  
     {
         //vertical scrollbar
         var vscbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200);
         vscbar.SetLocation(x + 10, y + 10);
         vscbar.MinValue = 0;
         vscbar.MaxValue = lastY;
         vscbar.SmallChange = 20;
         viewport.AddContent(vscbar);
         //add relation between viewpanel and scroll bar 
         var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(vscbar, panel);
     }
     //-------------------------  
     {
         //horizontal scrollbar
         var hscbar = new LayoutFarm.CustomWidgets.ScrollBar(150, 15);
         hscbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
         hscbar.SetLocation(x + 30, y + 10);
         hscbar.MinValue = 0;
         hscbar.MaxValue = 170;
         hscbar.SmallChange = 20;
         viewport.AddContent(hscbar);
         //add relation between viewpanel and scroll bar 
         var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(hscbar, panel);
     }
     panel.PerformContentLayout();
 }
Ejemplo n.º 8
0
        protected override void OnStart(AppHost host)
        {
            //----------------------------------------------------------------
            {
                var slideBox = new LayoutFarm.CustomWidgets.SliderBox(15, 200);
                slideBox.SetLocation(10, 400);
                slideBox.MinValue    = 0;
                slideBox.MaxValue    = 100;
                slideBox.SmallChange = 50;
                host.AddChild(slideBox);
                slideBox.ScrollValue = 150;
            }
            //----------------------------------------------------------------


            //----------------------------------------------------------------
            {
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200);
                scbar.SetLocation(10, 10);
                scbar.MinValue    = 0;
                scbar.MaxValue    = 100;
                scbar.SmallChange = 50;
                scbar.ScrollValue = 150;
                host.AddChild(scbar);
            }
            //----------------------------------------------------------------
            {
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200);
                scbar.SetLocation(30, 10);
                scbar.MinValue    = 0;
                scbar.MaxValue    = 100;
                scbar.SmallChange = 25;
                host.AddChild(scbar);
            }
            //----------------------------------------------------------------
            {
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200);
                scbar.SetLocation(50, 10);
                scbar.MinValue    = 0;
                scbar.MaxValue    = 1000;
                scbar.SmallChange = 100;
                host.AddChild(scbar);
            }
            //-------------------------------------
            {
                //horizontal scrollbar
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(200, 15);
                scbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                scbar.SetLocation(80, 10);
                scbar.MinValue    = 0;
                scbar.MaxValue    = 100;
                scbar.SmallChange = 50;
                host.AddChild(scbar);
            }
            {
                //horizontal scrollbar
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(200, 15);
                scbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                scbar.SetLocation(80, 40);
                scbar.MinValue    = 0;
                scbar.MaxValue    = 100;
                scbar.SmallChange = 25;
                host.AddChild(scbar);
            }

            {
                //horizontal scrollbar
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(200, 15);
                scbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                scbar.SetLocation(80, 80);
                scbar.MinValue    = 0;
                scbar.MaxValue    = 1000;
                scbar.SmallChange = 100;
                host.AddChild(scbar);
            }
        }
Ejemplo n.º 9
0
        protected override void OnStartDemo(SampleViewport viewport)
        {
            //----------------------------------------------------------------
            {
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200);
                scbar.SetLocation(10, 10);
                scbar.MinValue    = 0;
                scbar.MaxValue    = 100;
                scbar.SmallChange = 50;
                viewport.AddContent(scbar);
            }
            //----------------------------------------------------------------
            {
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200);
                scbar.SetLocation(30, 10);
                scbar.MinValue    = 0;
                scbar.MaxValue    = 100;
                scbar.SmallChange = 25;
                viewport.AddContent(scbar);
            }
            //----------------------------------------------------------------
            {
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200);
                scbar.SetLocation(50, 10);
                scbar.MinValue    = 0;
                scbar.MaxValue    = 1000;
                scbar.SmallChange = 100;
                viewport.AddContent(scbar);
            }
            //-------------------------------------
            {
                //horizontal scrollbar
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(200, 15);
                scbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                scbar.SetLocation(80, 10);
                scbar.MinValue    = 0;
                scbar.MaxValue    = 100;
                scbar.SmallChange = 50;
                viewport.AddContent(scbar);
            }
            {
                //horizontal scrollbar
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(200, 15);
                scbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                scbar.SetLocation(80, 40);
                scbar.MinValue    = 0;
                scbar.MaxValue    = 100;
                scbar.SmallChange = 25;
                viewport.AddContent(scbar);
            }

            {
                //horizontal scrollbar
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(200, 15);
                scbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                scbar.SetLocation(80, 80);
                scbar.MinValue    = 0;
                scbar.MaxValue    = 1000;
                scbar.SmallChange = 100;
                viewport.AddContent(scbar);
            }
        }
Ejemplo n.º 10
0
        protected override void OnStartDemo(SampleViewport viewport)
        {
            //----------------------------------------------------------------
            {
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200);
                scbar.SetLocation(10, 10);
                scbar.MinValue = 0;
                scbar.MaxValue = 100;
                scbar.SmallChange = 50;
                viewport.AddContent(scbar);
            }
            //----------------------------------------------------------------
            {
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200);
                scbar.SetLocation(30, 10);
                scbar.MinValue = 0;
                scbar.MaxValue = 100;
                scbar.SmallChange = 25;
                viewport.AddContent(scbar);
            }
            //----------------------------------------------------------------
            {
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200);
                scbar.SetLocation(50, 10);
                scbar.MinValue = 0;
                scbar.MaxValue = 1000;
                scbar.SmallChange = 100;
                viewport.AddContent(scbar);
            }
            //-------------------------------------
            {
                //horizontal scrollbar
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(200, 15);
                scbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                scbar.SetLocation(80, 10);
                scbar.MinValue = 0;
                scbar.MaxValue = 100;
                scbar.SmallChange = 50;
                viewport.AddContent(scbar);
            }
            {
                //horizontal scrollbar
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(200, 15);
                scbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                scbar.SetLocation(80, 40);
                scbar.MinValue = 0;
                scbar.MaxValue = 100;
                scbar.SmallChange = 25;
                viewport.AddContent(scbar);
            }

            {
                //horizontal scrollbar
                var scbar = new LayoutFarm.CustomWidgets.ScrollBar(200, 15);
                scbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                scbar.SetLocation(80, 80);
                scbar.MinValue = 0;
                scbar.MaxValue = 1000;
                scbar.SmallChange = 100;
                viewport.AddContent(scbar);
            }
        }
Ejemplo n.º 11
0
        void AddScrollView2(SampleViewport viewport, int x, int y)
        {
            var panel = new LayoutFarm.CustomWidgets.SimpleBox(400, 300);

            panel.SetLocation(x + 30, y + 30);
            panel.BackColor         = Color.LightGray;
            panel.ContentLayoutKind = CustomWidgets.BoxContentLayoutKind.VerticalStack;
            viewport.AddContent(panel);

            //-------------------------
            //load images...
            int lastY = 0;

            for (int i = 0; i < 5; ++i)
            {
                var imgbox = new LayoutFarm.CustomWidgets.ImageBox(36, 400);
                //if (!System.IO.File.Exists("../../images/0" + (i + 1) + ".jpg"))
                //{
                //}
                ClientImageBinder binder = new ClientImageBinder("../../images/0" + (i + 1) + ".jpg");
                binder.SetOwner(imgbox);
                binder.SetLazyFunc(LazyImageLoad);

                //if use lazy img load func
                imageContentMan.AddRequestImage(binder);

                imgbox.ImageBinder = binder;
                imgbox.BackColor   = Color.OrangeRed;
                imgbox.SetLocation(0, lastY);

                imgbox.MouseUp += (s, e) =>
                {
                    if (e.Button == UIMouseButtons.Right)
                    {
                        //test remove this imgbox on right mouse click
                        panel.RemoveChild(imgbox);
                    }
                };
                lastY += imgbox.Height + 5;
                panel.AddChild(imgbox);
            }
            //--------------------------
            //panel may need more
            panel.SetViewport(0, 0);

            //-------------------------
            {
                //vertical scrollbar
                var vscbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200);
                vscbar.SetLocation(x + 10, y + 10);
                vscbar.MinValue    = 0;
                vscbar.MaxValue    = lastY;
                vscbar.SmallChange = 20;
                viewport.AddContent(vscbar);
                //add relation between viewpanel and scroll bar
                var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(vscbar, panel);
            }
            //-------------------------
            {
                //horizontal scrollbar
                var hscbar = new LayoutFarm.CustomWidgets.ScrollBar(300, 15);
                hscbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                hscbar.SetLocation(x + 30, y + 10);
                hscbar.MinValue    = 0;
                hscbar.MaxValue    = 170;
                hscbar.SmallChange = 20;
                viewport.AddContent(hscbar);
                //add relation between viewpanel and scroll bar
                var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(hscbar, panel);
            }
            panel.PerformContentLayout();
        }