Example #1
0
        public virtual ImageBinder LoadImageAndBind(string src)
        {
            ImageBinder clientImgBinder = new ImageBinder(src);

            clientImgBinder.SetLocalImage(LoadImage(src));
            return(clientImgBinder);
        }
Example #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.Box(150, 20);

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

            if (_arrowBmp == null)
            {
                _arrowBmp = _appHost.LoadImageAndBind("../Data/imgs/arrow_open.png");
            }
            LayoutFarm.CustomWidgets.ImageBox imgBox = new CustomWidgets.ImageBox(_arrowBmp.Width, _arrowBmp.Height);
            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);
        }
Example #3
0
        static void LoadRawImg(ImageBinder binder, VgVisualElement vg, object o)
        {
            string imgsrc = binder.ImageSource;

            if (imgsrc != null)
            {
            }
        }
Example #4
0
        public ImageBinder CreateImageBinder(string src)
        {
            ImageBinder clientImgBinder = new ImageBinder(src);

            clientImgBinder.SetImageLoader(binder =>
            {
                Image img = this.LoadImage(binder.ImageSource);
                binder.SetLocalImage(img);
            });
            return(clientImgBinder);
        }
Example #5
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);
        }
Example #6
0
        protected override void OnStart(AppHost host)
        {
            ImageBinder imgBinder = host.LoadImageAndBind("../Data/imgs/favorites32.png");

            for (int i = 0; i < 100; ++i)
            {
                //share 1 img binder with multiple img boxes
                var imgBox = new CustomWidgets.ImageBox(imgBinder.Width, imgBinder.Height);
                imgBox.ImageBinder = imgBinder;
                imgBox.SetLocation(i * 10, i * 10);
                host.AddChild(imgBox);
            }
        }
        protected override void OnStartDemo(SampleViewport viewport)
        {

            ImageBinder imgBinder = viewport.GetImageBinder2("../../Data/imgs/favorites32.png");
            for (int i = 0; i < 100; ++i)
            {
                //share 1 img binder with multiple img boxes
                var imgBox = new CustomWidgets.ImageBox(imgBinder.Image.Width, imgBinder.Image.Height);
                imgBox.ImageBinder = imgBinder;
                imgBox.SetLocation(i * 10, i * 10);
                viewport.AddContent(imgBox);
            }
        }
Example #8
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;
 }
Example #9
0
        VgVisualElement CreateTestRenderVx_FromImg(string filename)
        {
            ImageBinder imgBinder = _appHost.LoadImageAndBind(filename);

            var spec = new SvgImageSpec()
            {
                ImageSrc = filename,
                Width    = new Css.CssLength(imgBinder.Width, Css.CssUnitOrNames.Pixels),
                Height   = new Css.CssLength(imgBinder.Height, Css.CssUnitOrNames.Pixels),
            };

            VgVisualDoc     renderRoot = new VgVisualDoc(_vgVisualDocHost);
            VgVisualElement vgimg      = new VgVisualElement(WellknownSvgElementName.Image, spec, renderRoot);

            vgimg.ImageBinder = imgBinder;
            return(vgimg);
        }
Example #10
0
        protected override void OnStartDemo(SampleViewport viewport)
        {
            var treeView = new LayoutFarm.CustomWidgets.TreeView(300, 400);

            treeView.SetLocation(10, 10);
            treeView.BackColor = KnownColors.FromKnownColor(KnownColor.LightGray);
            viewport.AddContent(treeView);

            //prepare node icon
            ImageBinder nodeOpen = LoadImage("../../Demo/arrow_open.png");

            //add
            for (int i = 0; i < 10; ++i)
            {
                var childLevel0 = new LayoutFarm.CustomWidgets.TreeNode(400, 40);

                childLevel0.BackColor = ((i % 2) == 0) ?
                                        KnownColors.FromKnownColor(KnownColor.Blue) :
                                        KnownColors.FromKnownColor(KnownColor.Yellow);
                treeView.AddItem(childLevel0);
                childLevel0.NodeIconImage = nodeOpen;
                for (int n = 0; n < 4; ++n)
                {
                    var childLevel1 = new LayoutFarm.CustomWidgets.TreeNode(400, 20);
                    childLevel1.BackColor = ((n % 2) == 0) ?
                                            KnownColors.FromKnownColor(KnownColor.Green) :
                                            KnownColors.FromKnownColor(KnownColor.YellowGreen);
                    childLevel0.AddChildNode(childLevel1);
                    childLevel1.NodeIconImage = nodeOpen;

                    for (int m = 0; m < 5; ++m)
                    {
                        var childLevel2 = new LayoutFarm.CustomWidgets.TreeNode(400, 20);
                        childLevel2.BackColor = ((m % 2) == 0) ?
                                                KnownColors.FromKnownColor(KnownColor.OrangeRed) :
                                                KnownColors.FromKnownColor(KnownColor.Wheat);
                        childLevel2.NodeIconImage = nodeOpen;
                        childLevel1.AddChildNode(childLevel2);
                    }
                }
            }
        }
Example #11
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();
        }
Example #12
0
 void LazyImageLoad(ImageBinder binder)
 {
     //load here as need
     imageContentMan.AddRequestImage(binder);
 }
 void LazyImageLoad(ImageBinder binder)
 {
     //load here as need
     imageContentMan.AddRequestImage(binder);
 }
        protected override void OnStartDemo(SampleViewport viewport)
        {
            SetupImageList(viewport);
            for (int i = 1; i < 5; ++i)
            {
                var textbox = new LayoutFarm.CustomWidgets.SimpleBox(30, 30);
                textbox.SetLocation(i * 40, i * 40);
                viewport.AddContent(textbox);
            }
            //--------------------
            //image box
            //load bitmap with gdi+
            ImageBinder imgBinder = viewport.GetImageBinder2("../../Data/imgs/favorites32.png");

            var imgBox = new CustomWidgets.ImageBox(imgBinder.Image.Width, imgBinder.Image.Height);

            imgBox.ImageBinder = imgBinder;
            viewport.AddContent(imgBox);
            //--------------------
            //checked box
            int boxHeight = 20;
            int boxY      = 50;

            //multiple select
            for (int i = 0; i < 4; ++i)
            {
                var statedBox = new LayoutFarm.CustomWidgets.CheckBox(20, boxHeight);
                statedBox.SetLocation(10, boxY);
                boxY += boxHeight + 5;
                viewport.AddContent(statedBox);
            }
            //-------------------------------------------------------------------------
            //single select
            boxY += 50;
            for (int i = 0; i < 4; ++i)
            {
                var statedBox = new LayoutFarm.CustomWidgets.CheckBox(20, boxHeight);
                statedBox.SetLocation(10, boxY);
                boxY += boxHeight + 5;
                viewport.AddContent(statedBox);
                statedBox.WhenChecked += (s, e) =>
                {
                    var selectedBox = (LayoutFarm.CustomWidgets.CheckBox)s;
                    if (selectedBox != currentSingleCheckedBox)
                    {
                        if (currentSingleCheckedBox != null)
                        {
                            currentSingleCheckedBox.Checked = false;
                        }
                        currentSingleCheckedBox = selectedBox;
                    }
                };
            }
            //-------------------------------------------------------------------
            //test canvas
            var canvasBox = new MyDrawingCanvas(300, 300);

            canvasBox.SetLocation(400, 150);
            viewport.AddContent(canvasBox);
            //-------------------------------------------------------------------
        }
Example #15
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;
 }
Example #16
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);
            }
        }
        protected override void OnStart(AppHost host)
        {
            //SetupImageList(host);
            for (int i = 1; i < 5; ++i)
            {
                var textbox = new LayoutFarm.CustomWidgets.Box(30, 30);
                textbox.SetLocation(i * 40, i * 40);
                host.AddChild(textbox);
            }
            //--------------------
            //image box
            //load bitmap with gdi+
            ImageBinder imgBinder = host.LoadImageAndBind("../Data/imgs/favorites32.png");

            var imgBox = new CustomWidgets.ImageBox(imgBinder.Width, imgBinder.Height);

            imgBox.ImageBinder = imgBinder;
            host.AddChild(imgBox);
            //--------------------
            //checked box
            int boxHeight = 20;
            int boxY      = 50;

            //multiple select
            for (int i = 0; i < 4; ++i)
            {
                var statedBox = new LayoutFarm.CustomWidgets.CheckBox(20, boxHeight);
                statedBox.SetLocation(10, boxY);
                boxY += boxHeight + 5;
                host.AddChild(statedBox);
            }
            //-------------------------------------------------------------------------
            //single select
            boxY += 50;
            for (int i = 0; i < 4; ++i)
            {
                var statedBox = new LayoutFarm.CustomWidgets.CheckBox(20, boxHeight);
                statedBox.SetLocation(10, boxY);
                boxY += boxHeight + 5;
                host.AddChild(statedBox);
                statedBox.CheckChanged += (s, e) =>
                {
                    var selectedBox = (LayoutFarm.CustomWidgets.CheckBox)s;
                    if (selectedBox != _currentSingleCheckedBox)
                    {
                        if (_currentSingleCheckedBox != null)
                        {
                            _currentSingleCheckedBox.Checked = false;
                        }
                        _currentSingleCheckedBox = selectedBox;
                    }
                };
            }
            //-------------------------------------------------------------------
            //test canvas
            var canvasBox = new MyDrawingCanvas(300, 300);

            canvasBox.SetLocation(400, 150);
            host.AddChild(canvasBox);
            //-------------------------------------------------------------------
        }