Exemple #1
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.Box(400, 20);

            landPart.BackColor = Color.Green;
            comboBox.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;
            //--------------------------------------
            //2. float part
            var floatPart = new LayoutFarm.CustomWidgets.Box(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);
        }
Exemple #2
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);
        }
 protected override void OnStart(AppHost host)
 {
     PixelFarm.Drawing.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);
     }
 }
Exemple #4
0
        protected override void OnStart(AppHost host)
        {
            var treeView = new LayoutFarm.CustomWidgets.TreeView(300, 400);

            treeView.SetLocation(10, 10);
            treeView.BackColor = KnownColors.FromKnownColor(KnownColor.LightGray);
            host.AddChild(treeView);
            //prepare node icon

            ImageBinder nodeOpen = host.LoadImageAndBind("../Data/imgs/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);
                    }
                }
            }
        }
        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);
            //-------------------------------------------------------------------
        }