protected override void OnStartDemo(SampleViewport viewport)
        {
            this.viewport = viewport;
            this.rootgfx = viewport.ViewportControl.RootGfx;
            //--------------------------------

            bgbox = new LayoutFarm.CustomWidgets.SimpleBox(800, 600);
            bgbox.BackColor = Color.White;
            bgbox.SetLocation(0, 0);
            SetupBackgroundProperties(bgbox);
            viewport.AddContent(bgbox);
            //user box1
            var box1 = new LayoutFarm.CustomWidgets.SimpleBox(150, 150);
            box1.BackColor = Color.Red;
            box1.SetLocation(10, 10);
            SetupActiveBoxProperties(box1);
            bgbox.AddChild(box1);
            var box2 = new LayoutFarm.CustomWidgets.SimpleBox(60, 60);
            box2.BackColor = Color.Yellow;
            box2.SetLocation(50, 50);
            SetupActiveBoxProperties(box2);
            bgbox.AddChild(box2);
            var box3 = new LayoutFarm.CustomWidgets.SimpleBox(60, 60);
            box3.BackColor = Color.OrangeRed;
            box3.SetLocation(200, 80);
            SetupActiveBoxProperties(box3);
            bgbox.AddChild(box3);
            selectionBox = new UISelectionBox(1, 1);
            selectionBox.Visible = false;
            selectionBox.BackColor = Color.FromArgb(80, Color.Green);
            viewport.AddContent(selectionBox);
            SetupSelectionBoxProperties(selectionBox);
        }
Пример #2
0
        LayoutFarm.CustomWidgets.MenuItem CreateMenuItem(int x, int y)
        {
            var mnuItem = new CustomWidgets.MenuItem(150, 20);

            mnuItem.SetLocation(x, y);
            //--------------------
            //1. create landing part
            var landPart = new LayoutFarm.CustomWidgets.SimpleBox(150, 20);

            landPart.BackColor = Color.OrangeRed;
            mnuItem.LandPart   = landPart;
            //--------------------------------------
            //add small px to land part
            //image
            //load bitmap with gdi+

            if (arrowBmp == null)
            {
                arrowBmp = this.viewport.GetImageBinder2("../../Data/imgs/arrow_open.png");
            }
            LayoutFarm.CustomWidgets.ImageBox imgBox = new CustomWidgets.ImageBox(arrowBmp.ImageWidth, arrowBmp.ImageHeight);
            imgBox.ImageBinder = arrowBmp;
            landPart.AddChild(imgBox);
            //--------------------------------------
            //if click on this image then
            imgBox.MouseDown += (s, e) =>
            {
                e.CancelBubbling = true;
                //1. maintenace parent menu***
                mnuItem.MaintenanceParentOpenState();
                //-----------------------------------------------
                if (mnuItem.IsOpened)
                {
                    mnuItem.Close();
                }
                else
                {
                    mnuItem.Open();
                }
            };
            imgBox.MouseUp += (s, e) =>
            {
                mnuItem.UnmaintenanceParentOpenState();
            };
            imgBox.LostMouseFocus += (s, e) =>
            {
                if (!mnuItem.MaintenceOpenState)
                {
                    mnuItem.CloseRecursiveUp();
                }
            };
            //--------------------------------------
            //2. float part
            var floatPart = new LayoutFarm.CustomWidgets.MenuBox(400, 100);

            floatPart.BackColor = Color.Gray;
            mnuItem.FloatPart   = floatPart;
            return(mnuItem);
        }
        protected override void OnStartDemo(SampleViewport viewport)
        {
            this.viewport = viewport;
            this.rootgfx  = viewport.ViewportControl.RootGfx;
            //--------------------------------

            bgbox           = new LayoutFarm.CustomWidgets.SimpleBox(800, 600);
            bgbox.BackColor = Color.White;
            bgbox.SetLocation(0, 0);
            SetupBackgroundProperties(bgbox);
            viewport.AddContent(bgbox);

            //user box1
            var box1 = new LayoutFarm.CustomWidgets.SimpleBox(150, 150);

            box1.BackColor = Color.Red;
            box1.SetLocation(10, 10);
            SetupActiveBoxProperties(box1);
            bgbox.AddChild(box1);


            var box2 = new LayoutFarm.CustomWidgets.SimpleBox(60, 60);

            box2.BackColor = Color.Yellow;
            box2.SetLocation(50, 50);
            SetupActiveBoxProperties(box2);
            bgbox.AddChild(box2);


            var box3 = new LayoutFarm.CustomWidgets.SimpleBox(60, 60);

            box3.BackColor = Color.OrangeRed;
            box3.SetLocation(200, 80);
            SetupActiveBoxProperties(box3);
            bgbox.AddChild(box3);

            selectionBox           = new UISelectionBox(1, 1);
            selectionBox.Visible   = false;
            selectionBox.BackColor = Color.FromArgb(80, Color.Green);
            viewport.AddContent(selectionBox);
            SetupSelectionBoxProperties(selectionBox);
        }
Пример #4
0
        LayoutFarm.CustomWidgets.ComboBox CreateComboBox(int x, int y)
        {
            var comboBox = new CustomWidgets.ComboBox(400, 20);

            comboBox.SetLocation(x, y);
            //--------------------
            //1. create landing part
            var landPart = new LayoutFarm.CustomWidgets.SimpleBox(400, 20);

            landPart.BackColor = Color.Green;
            comboBox.LandPart  = landPart;
            //--------------------------------------
            //add small px to land part
            //image
            //load bitmap with gdi+
            if (arrowBmp == null)
            {
                arrowBmp = LoadImage("../../Demo/arrow_open.png");
            }
            LayoutFarm.CustomWidgets.ImageBox imgBox = new CustomWidgets.ImageBox(arrowBmp.Image.Width, arrowBmp.Image.Height);
            imgBox.ImageBinder = arrowBmp;
            //--------------------------------------
            //2. float part
            var floatPart = new LayoutFarm.CustomWidgets.SimpleBox(400, 100);

            floatPart.BackColor = Color.Blue;
            comboBox.FloatPart  = floatPart;

            //--------------------------------------
            //if click on this image then
            imgBox.MouseDown += (s, e) =>
            {
                e.CancelBubbling = true;
                if (comboBox.IsOpen)
                {
                    comboBox.CloseHinge();
                }
                else
                {
                    comboBox.OpenHinge();
                }
            };
            imgBox.LostMouseFocus += (s, e) =>
            {
                if (comboBox.IsOpen)
                {
                    comboBox.CloseHinge();
                }
            };

            landPart.AddChild(imgBox);
            return(comboBox);
        }
Пример #5
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);
        }
Пример #6
0
 LayoutFarm.CustomWidgets.ComboBox CreateComboBox(int x, int y)
 {
     var comboBox = new CustomWidgets.ComboBox(400, 20);
     comboBox.SetLocation(x, y);
     //--------------------
     //1. create landing part
     var landPart = new LayoutFarm.CustomWidgets.SimpleBox(400, 20);
     landPart.BackColor = Color.Green;
     comboBox.LandPart = landPart;
     //--------------------------------------
     //add small px to land part
     //image
     //load bitmap with gdi+                
     if (arrowBmp == null)
     {
         arrowBmp = LoadImageBinder("../../Demo/arrow_open.png");
     }
     LayoutFarm.CustomWidgets.ImageBox imgBox = new CustomWidgets.ImageBox(arrowBmp.Image.Width, arrowBmp.Image.Height);
     imgBox.ImageBinder = arrowBmp;
     //--------------------------------------
     //2. float part
     var floatPart = new LayoutFarm.CustomWidgets.SimpleBox(400, 100);
     floatPart.BackColor = Color.Blue;
     comboBox.FloatPart = floatPart;
     //--------------------------------------
     //if click on this image then
     imgBox.MouseDown += (s, e) =>
     {
         e.CancelBubbling = true;
         if (comboBox.IsOpen)
         {
             comboBox.CloseHinge();
         }
         else
         {
             comboBox.OpenHinge();
         }
     };
     imgBox.LostMouseFocus += (s, e) =>
     {
         if (comboBox.IsOpen)
         {
             comboBox.CloseHinge();
         }
     };
     landPart.AddChild(imgBox);
     return comboBox;
 }
Пример #7
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);
        }
Пример #8
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();
        }
Пример #9
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();
 }
Пример #10
0
 LayoutFarm.CustomWidgets.MenuItem CreateMenuItem(int x, int y)
 {
     var mnuItem = new CustomWidgets.MenuItem(150, 20);
     mnuItem.SetLocation(x, y);
     //--------------------
     //1. create landing part
     var landPart = new LayoutFarm.CustomWidgets.SimpleBox(150, 20);
     landPart.BackColor = Color.OrangeRed;
     mnuItem.LandPart = landPart;
     //--------------------------------------
     //add small px to land part
     //image
     //load bitmap with gdi+        
     
     if (arrowBmp == null)
     {
         arrowBmp = LoadImageBinder("../../Demo/arrow_open.png");
     }
     LayoutFarm.CustomWidgets.ImageBox imgBox = new CustomWidgets.ImageBox(arrowBmp.ImageWidth, arrowBmp.ImageHeight);
     imgBox.ImageBinder = arrowBmp;
     landPart.AddChild(imgBox);
     //--------------------------------------
     //if click on this image then
     imgBox.MouseDown += (s, e) =>
     {
         e.CancelBubbling = true;
         //1. maintenace parent menu***
         mnuItem.MaintenanceParentOpenState();
         //-----------------------------------------------
         if (mnuItem.IsOpened)
         {
             mnuItem.Close();
         }
         else
         {
             mnuItem.Open();
         }
     };
     imgBox.MouseUp += (s, e) =>
     {
         mnuItem.UnmaintenanceParentOpenState();
     };
     imgBox.LostMouseFocus += (s, e) =>
     {
         if (!mnuItem.MaintenceOpenState)
         {
             mnuItem.CloseRecursiveUp();
         }
     };
     //--------------------------------------
     //2. float part
     var floatPart = new LayoutFarm.CustomWidgets.MenuBox(400, 100);
     floatPart.BackColor = Color.Gray;
     mnuItem.FloatPart = floatPart;
     return mnuItem;
 }
Пример #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();
        }