static ImageBinder LoadImageBinder(string filename)
 {
     ImageBinder binder = new ClientImageBinder(filename);
     binder.SetImage(DemoBase.LoadBitmap(filename));
     binder.State = ImageBinderState.Loaded;
     return binder;
 }
        protected override void OnStartDemo(SampleViewport viewport)
        {
            SetupImageList();
            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 = new ClientImageBinder(null);
            imgBinder.SetImage(LoadBitmap("../../Demo/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);
            //-------------------------------------------------------------------

        }
Beispiel #3
0
        public ImageBinder GetImageBinder2(string src)
        {
            ClientImageBinder clientImgBinder = new ClientImageBinder(src);

            clientImgBinder.SetImage(LoadBitmap(src));
            clientImgBinder.State = ImageBinderState.Loaded;
            return(clientImgBinder);
        }
Beispiel #4
0
        public ImageBinder GetImageBinder(string src)
        {
            ClientImageBinder clientImgBinder = new ClientImageBinder(src);

            clientImgBinder.SetLazyLoaderFunc(LazyImageLoad);
            //if use lazy img load func
            imageContentMan.AddRequestImage(clientImgBinder);
            return(clientImgBinder);
        }
Beispiel #5
0
        static ImageBinder LoadImage(string filename)
        {
            System.Drawing.Bitmap gdiBmp = new System.Drawing.Bitmap(filename);
            Bitmap      bmp    = new Bitmap(gdiBmp.Width, gdiBmp.Height, gdiBmp);
            ImageBinder binder = new ClientImageBinder(null);

            binder.SetImage(bmp);
            binder.State = ImageBinderState.Loaded;
            return(binder);
        }
        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 = new ClientImageBinder(null);
            nodeOpen.SetImage(LoadBitmap("../../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);
                    }
                }
            }
        }
 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();
 }
        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();
        }