protected override void OnStart(AppHost host)
        {
            _appHost = host;
            {
                _animationBoard           = new Box(800, 800);
                _animationBoard.BackColor = PixelFarm.Drawing.Color.White;
                host.AddChild(_animationBoard);
            }
            //
            {
                List <PennerAnimationInfo> pennerAnimationList = LoadAllPennerAnimationList();
                ListView easingFuncs_List = new ListView(200, 850);
                easingFuncs_List.SetLocation(600, 20);
                host.AddChild(easingFuncs_List);
                easingFuncs_List.ListItemMouseEvent += (s, e) =>
                {
                    //do animation
                    PennerAnimationInfo animation = pennerAnimationList[easingFuncs_List.SelectedIndex];
                    //
                    GenerateAnimation(animation._generatorDelegate);
                };

                //add item
                foreach (PennerAnimationInfo pennerAnimation in pennerAnimationList)
                {
                    ListItem listItem = new ListItem(200, 20);
                    listItem.Text = pennerAnimation._name;
                    listItem.Tag  = pennerAnimation;
                    easingFuncs_List.AddItem(listItem);
                }
            }
        }
Exemple #2
0
        protected override void OnStart(AppHost host)
        {
            Box background_box = new Box(500, 500);

            background_box.BackColor = PixelFarm.Drawing.Color.Blue;
            host.AddChild(background_box);

            //RequestFont font = new RequestFont("Twitter Color Emoji", 20);
            RequestFont font = new RequestFont("Source Sans Pro", 20);

            for (int i = 0; i < 1; ++i)
            {
                TextFlowLabel label = new TextFlowLabel(300, 50);
                label.SetLocation(i * 55, i * 55);
                label.BackColor   = PixelFarm.Drawing.Color.Yellow;
                label.RequestFont = font;
                //label.Color = PixelFarm.Drawing.Color.Black;
                //label.Text = "ABC  DE FG\r\nHIJ KLM NOP\r\nQRSTUVWXZYZ\r\n0123456789";
                //label.Text = "ABCDEFG\r\nHIJKLMNOP\r\nQRSTUVWXZYZ\r\n0123456789";
                label.Text = " A 😁😁X 012345";
                //label.Text = "😁😁";
                //label.Text = "😁";
                //label.Text = "A😁";
                //label.Text = "A";
                host.AddChild(label);
            }
        }
Exemple #3
0
        protected override void OnStart(AppHost host)
        {
            Box background_box = new Box(250, 500);

            background_box.BackColor = PixelFarm.Drawing.Color.White;
            host.AddChild(background_box);

            //PixelFarm.Drawing.RequestFont font = new PixelFarm.Drawing.RequestFont("Source Sans Pro", 20);
            var font = new PixelFarm.Drawing.RequestFont("Source Sans Pro", 20);
            {
                Label label = new Label();
                label.TextColor = PixelFarm.Drawing.Color.Black;
                label.SetLocation(10, 20);
                label.SetFont(font);
                label.Text = "XY";
                host.AddChild(label);
            }
            {
                Label label = new Label();
                label.TextColor = PixelFarm.Drawing.Color.Black;
                label.SetFont(font);
                label.Text = "A12345";
                label.SetLocation(30, 20);
                host.AddChild(label);
            }
        }
        protected override void OnStart(AppHost host, IGameHTMLUI pcx)
        {
            ////==================================================
            //html box
            HtmlBoxes.HtmlHost htmlHost = HtmlHostCreatorHelper.CreateHtmlHost(host, null, null);
            var           htmlBox       = new HtmlBox(htmlHost, 800, 400);
            StringBuilder stbuilder     = new StringBuilder();

            stbuilder.Append("<html><head></head><body>");
            stbuilder.Append("<div>custom box1</div>");
            stbuilder.Append("<x id=\"my_custombox1\"></x>");
            stbuilder.Append("<div>custom box2</div>");
            stbuilder.Append("<x type=\"textbox\" id=\"my_custombox1\"></x>");
            stbuilder.Append("</body></html>");
            htmlBox.LoadHtmlString(stbuilder.ToString());
            host.AddChild(htmlBox);
            //==================================================

            //textbox
            var textbox = new LayoutFarm.CustomWidgets.TextBox(400, 100, true);

            textbox.SetLocation(0, 200);
            host.AddChild(textbox);
            textbox.Focus();
        }
        protected override void OnStart(AppHost host)
        {
            var textbox1 = new LayoutFarm.CustomWidgets.TextBox(400, 100, true);
            var style1   = new TextEditing.TextSpanStyle();

            style1.ReqFont = new PixelFarm.Drawing.RequestFont("tahoma", 14);
            //test with various font style
            style1.FontColor          = new PixelFarm.Drawing.Color(0, 0, 0);
            textbox1.DefaultSpanStyle = style1;
            host.AddChild(textbox1);
            //-------------------
            //this version we need to set a style font each textbox
            var textbox2 = new LayoutFarm.CustomWidgets.TextBox(400, 500, true);
            var style2   = new TextEditing.TextSpanStyle();

            style2.ReqFont            = new PixelFarm.Drawing.RequestFont("tahoma", 10);
            style2.FontColor          = new PixelFarm.Drawing.Color(0, 0, 0);
            textbox2.DefaultSpanStyle = style2;
            textbox2.SetLocation(20, 120);


            host.AddChild(textbox2);
            var textSplitter = new ContentTextSplitter();

            textbox2.TextSplitter = textSplitter;
            textbox2.Text         = "Hello World!";
        }
Exemple #6
0
        //
        protected override void OnStart(AppHost host)
        {
            _textbox = new LayoutFarm.CustomWidgets.TextBox(400, 300, true);
            _textbox.SetLocation(20, 20);
            var style1 = new TextEditing.TextSpanStyle();

            style1.ReqFont            = new PixelFarm.Drawing.RequestFont("tahoma", 14);
            style1.FontColor          = new PixelFarm.Drawing.Color(0, 0, 0);
            _textbox.DefaultSpanStyle = style1;

            var textSplitter = new CustomWidgets.ContentTextSplitter();

            _textbox.TextSplitter = textSplitter;
            _sgBox = new SuggestionWindowMx(300, 200);
            _sgBox.UserConfirmSelectedItem += new EventHandler(sgBox_UserConfirmSelectedItem);
            _sgBox.ListItemKeyboardEvent   += new EventHandler <UIKeyEventArgs>(sgBox_ListItemKeyboardEvent);
            _sgBox.Hide();
            //------------------------------------
            //create special text surface listener
            var textSurfaceListener = new LayoutFarm.TextEditing.TextSurfaceEventListener();

            textSurfaceListener.CharacterAdded      += (s, e) => UpdateSuggestionList();
            textSurfaceListener.CharacterRemoved    += (s, e) => UpdateSuggestionList();
            textSurfaceListener.PreviewArrowKeyDown += new EventHandler <TextEditing.TextDomEventArgs>(textSurfaceListener_PreviewArrowKeyDown);
            textSurfaceListener.PreviewEnterKeyDown += new EventHandler <TextEditing.TextDomEventArgs>(textSurfaceListener_PreviewEnterKeyDown);
            _textbox.TextEventListener = textSurfaceListener;
            //------------------------------------

            host.AddChild(_textbox);
            host.AddChild(_sgBox.GetPrimaryUI());
            //------------------------------------
            BuildSampleCountryList();
        }
Exemple #7
0
        protected override void OnStart(AppHost host)
        {
            var box1 = new LayoutFarm.CustomWidgets.Box(50, 50);

            box1.BackColor = Color.Red;
            box1.SetLocation(10, 10);
            //box1.dbugTag = 1;
            SetupActiveBoxProperties(box1);
            host.AddChild(box1);
            var box2 = new LayoutFarm.CustomWidgets.Box(30, 30);

            box2.SetLocation(50, 50);
            //box2.dbugTag = 2;
            SetupActiveBoxProperties(box2);
            host.AddChild(box2);
            _rectBoxController.Init();
            //------------

            host.AddChild(_rectBoxController);

            //foreach (var ui in rectBoxController.GetControllerIter())
            //{
            //    viewport.AddContent(ui);
            //}
        }
        protected override void OnStart(AppHost host)
        {
            var box1 = new LayoutFarm.CustomWidgets.Box(50, 50);

            box1.BackColor = Color.Red;
            box1.SetLocation(10, 10);
            //box1.dbugTag = 1;
            SetupActiveBoxProperties(box1);
            host.AddChild(box1);
            var box2 = new LayoutFarm.CustomWidgets.Box(30, 30);

            box2.SetLocation(50, 50);
            //box2.dbugTag = 2;
            SetupActiveBoxProperties(box2);
            host.AddChild(box2);
            _controllerBox1 = new UIControllerBox(40, 40);
            Color c = KnownColors.FromKnownColor(KnownColor.Yellow);

            _controllerBox1.BackColor = new Color(100, c.R, c.G, c.B);
            _controllerBox1.SetLocation(200, 200);
            //controllerBox1.dbugTag = 3;
            _controllerBox1.Visible = false;
            SetupControllerBoxProperties(_controllerBox1);
            host.AddChild(_controllerBox1);
        }
Exemple #9
0
        //
        protected override void OnStart(AppHost host)
        {
            _textbox = new LayoutFarm.CustomWidgets.TextBox(400, 30, false);
            _textbox.SetLocation(20, 20);
            var style2 = new TextEditing.TextSpanStyle();

            style2.ReqFont            = new PixelFarm.Drawing.RequestFont("tahoma", 14);
            style2.FontColor          = new PixelFarm.Drawing.Color(0, 0, 0);
            _textbox.DefaultSpanStyle = style2;

            var textSplitter = new LayoutFarm.CustomWidgets.ContentTextSplitter();

            _textbox.TextSplitter = textSplitter;
            _listbox = new CustomWidgets.ListBox(300, 200);
            _listbox.SetLocation(0, 40);
            _listbox.Visible = false;
            //------------------------------------
            //create special text surface listener
            var textSurfaceListener = new LayoutFarm.TextEditing.TextSurfaceEventListener();

            textSurfaceListener.CharacterAdded      += (s, e) => UpdateSuggestionList();
            textSurfaceListener.CharacterRemoved    += (s, e) => UpdateSuggestionList();
            textSurfaceListener.PreviewArrowKeyDown += new EventHandler <TextEditing.TextDomEventArgs>(textSurfaceListener_PreviewArrowKeyDown);
            textSurfaceListener.PreviewEnterKeyDown += new EventHandler <TextEditing.TextDomEventArgs>(textSurfaceListener_PreviewEnterKeyDown);
            _textbox.TextEventListener = textSurfaceListener;
            //------------------------------------
            host.AddChild(_textbox);
            host.AddChild(_listbox);
            //------------------------------------
            BuildSampleCountryList();
        }
        void Test1(AppHost host)
        {
            ListBox listBox1 = new ListBox(100, 200);

            listBox1.SetLocation(500, 20);
            host.AddChild(listBox1);


            Box hostBox = new Box(400, 600);

            hostBox.SetLocation(10, 10);
            hostBox.BackColor         = Color.White;
            hostBox.ContentLayoutKind = BoxContentLayoutKind.HorizontalStack;
            //hostBox.ContentLayoutKind = BoxContentLayoutKind.VerticalStack;
            //hostBox.ContentLayoutKind = BoxContentLayoutKind.HorizontalFlow;
            host.AddChild(hostBox);


            int boxX = 0;
            int boxY = 0;

            hostBox.SuspendGraphicsUpdate();
            for (int i = 0; i < 10; ++i)
            {
                Size s   = _sizes[i % _sizes.Length];
                var  box = new Box(s.Width, s.Height);
                box.BackColor           = _colors[i % _colors.Length];
                box.VerticalAlignment   = _vertAligns[i % _vertAligns.Length];
                box.HorizontalAlignment = _horAligns[i % _horAligns.Length];
                box.HasSpecificWidth    = _hasSpecificWidths[i % _hasSpecificWidths.Length];
                box.HasSpecificHeight   = _hasSpecificHeights[i % _hasSpecificHeights.Length];

                if (!box.HasSpecificHeight)
                {
                    box.BackColor = KnownColors.Black;
                }

                box.SetMargins(1);
                box.SetLocation(boxX, boxY);
                box.MouseDown += Box_MouseDown;
                hostBox.Add(box);
                boxY += 30;
                boxX += 20;
            }
            //temp1
            LayoutUpdateArgs updateArgs = new LayoutUpdateArgs();

            hostBox.PerformContentLayout(updateArgs);
            hostBox.ResumeGraphicsUpdate();
            hostBox.InvalidateGraphics();

            host.AddChild(hostBox);
        }
Exemple #11
0
        protected override void OnStart(AppHost host)
        {
            {
                string html = @"<html><head></head><body><div>OK1</div><div>OK2</div></body></html>";


                string testFilename = @"D:\projects\HtmlRenderer\Source\Test8_HtmlRenderer.Demo\Samples\0_acid1_dev\00.htm";
                //string testFilename = "..\\Test8_HtmlRenderer.Demo\\Samples\\0_acid1_dev\\00.htm";
                if (System.IO.File.Exists(testFilename))
                {
                    html = System.IO.File.ReadAllText(testFilename);
                }


                //html box1
                HtmlBoxes.HtmlHost htmlhost = HtmlHostCreatorHelper.CreateHtmlHost(host, null, null);
                //html box
                var htmlBox = new HtmlBox(htmlhost, 800, 600);
                htmlBox.SetLocation(0, 0);
                //htmlBox.PreferSoftwareRenderer = true;
                host.AddChild(htmlBox);

                htmlBox.LoadHtmlString(html);
                //==================================================
            }
            {
                //html box2

                HtmlBoxes.HtmlHost htmlhost = HtmlHostCreatorHelper.CreateHtmlHost(host, null, null);
                //html box
                var htmlBox = new HtmlBox(htmlhost, 800, 400);
#if DEBUG
                htmlBox.dbugPreferSoftwareRenderer = true;
#endif
                htmlBox.SetLocation(0, 610);//**
                host.AddChild(htmlBox);
                string html = @"<html><head></head><body><div>OK3</div><div>OK4</div></body></html>";
                htmlBox.LoadHtmlString(html);
                //==================================================
            }

            //{
            //    //textbox
            //    var textbox = new LayoutFarm.CustomWidgets.TextBox(400, 25, true);
            //    textbox.SetLocation(0, 0);
            //    host.AddChild(textbox);
            //    textbox.Focus();
            //}
        }
        void Test3(AppHost host)
        {
            Box hostBox = new Box(250, 600);

            hostBox.HasSpecificWidthAndHeight = false;
            //hostBox.HasSpecificHeight = true;
            hostBox.SetLocation(10, 10);
            hostBox.BackColor = Color.White;
            host.AddChild(hostBox);
            //hostBox.ContentLayoutKind = BoxContentLayoutKind.VerticalStack;
            //hostBox.ContentLayoutKind = BoxContentLayoutKind.HorizontalStack;

            List <Box> temp1 = new List <Box>();

            hostBox.ContentLayoutKind = BoxContentLayoutKind.HorizontalFlow;
            {
                int y = 0;
                hostBox.SuspendLayout();
                hostBox.SuspendGraphicsUpdate();
                for (int i = 0; i < 4; ++i)
                {
                    Box child1 = new Box(20, 20);
                    hostBox.Add(child1);
                    child1.BackColor = _colors[i % _colors.Length];
                    child1.SetLocation(20, y);
                    temp1.Add(child1);
                }
                hostBox.ResumeLayout();
                hostBox.ResumeGraphicsUpdate();
            }

            hostBox.RemoveChild(temp1[0]);
        }
Exemple #13
0
        protected override void OnStart(AppHost host)
        {
            _appHost = host;
            var comboBox1 = CreateComboBox(20, 20);

            host.AddChild(comboBox1);
            var comboBox2 = CreateComboBox(50, 50);

            host.AddChild(comboBox2);
            //------------
            var menuItem  = CreateMenuItem(50, 100);
            var menuItem2 = CreateMenuItem(5, 5);

            menuItem.AddSubMenuItem(menuItem2);
            host.AddChild(menuItem);
        }
        protected override void OnStart(AppHost host)
        {
            var listbox = new LayoutFarm.CustomWidgets.ListBox(300, 400);

            listbox.SetLocation(10, 10);
            listbox.BackColor = KnownColors.FromKnownColor(KnownColor.LightGray);
            //add list view to viewport
            host.AddChild(listbox);
            //add
            RequestFont listItemFont = new RequestFont("tahoma", 18);

            for (int i = 0; i < 10; ++i)
            {
                var listItem = new LayoutFarm.CustomWidgets.ListItem(400, 20);
                if ((i % 2) == 0)
                {
                    listItem.BackColor = KnownColors.FromKnownColor(KnownColor.OrangeRed);
                }
                else
                {
                    listItem.BackColor = KnownColors.FromKnownColor(KnownColor.Orange);
                }
                listItem.SetFont(listItemFont);
                listItem.Text = "A" + i;
                listbox.AddItem(listItem);
            }
        }
        protected override void OnStart(AppHost host)
        {
            //grid0
            {
                var gridView = new LayoutFarm.CustomWidgets.GridBox(100, 100);
                gridView.SetLocation(50, 50);
                gridView.BuildGrid(2, 4, CellSizeStyle.UniformCell);
                host.AddChild(gridView);
                gridView.MouseDown += (s1, e1) =>
                {
                };

                //--------
                var box1 = new Box(30, 30);
                box1.BackColor = Color.Blue;
                gridView.SetCellContent(box1, 1, 1);
                gridView.CellSizeStyle = CellSizeStyle.ColumnAndRow;
                //gridView.CellSizeStyle = CellSizeStyle.UniformWidth;
                gridView.SuspendLayout();
                GridColumn col = gridView.GetColumn(0);
                col.Width = 10;
                GridRow row = gridView.GetRow(0);
                row.Height = 50;
                gridView.ResumeLayout();
                //--------
                gridView.ClearAllCellContent();
                //--------
                gridView.BuildGrid(5, 3, CellSizeStyle.UniformCell);
                //gridView.InvalidateLayout();
            }
        }
        void AddScrollView1(AppHost host, int x, int y)
        {
            var panel = new LayoutFarm.CustomWidgets.Box(200, 175);

            panel.NeedClipArea = true;
            panel.SetLocation(x + 30, y + 30);
            panel.BackColor = Color.LightGray;
            host.AddChild(panel);
            //-------------------------
            {
                //vertical scrollbar
                var vscbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200);
                vscbar.SetLocation(x + 10, y + 10);
                vscbar.MinValue    = 0;
                vscbar.MaxValue    = 170; //just init
                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(200, 15);
                hscbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                hscbar.SetLocation(x + 30, y + 10);
                hscbar.MinValue    = 0;
                hscbar.MaxValue    = 170;//just init
                hscbar.SmallChange = 20;
                host.AddChild(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.Box(400, 30);
                box1.HasSpecificWidth  = true;
                box1.HasSpecificHeight = true;
                box1.BackColor         = Color.OrangeRed;
                box1.SetLocation(i * 20, i * 40);
                panel.AddChild(box1);
            }
            //--------------------------
            //panel.PerformContentLayout();
        }
Exemple #17
0
        protected override void OnStart(AppHost host)
        {
            var box_beh = new UIMouseBehaviour <Box>();
            {
                box_beh.GuestMsg += (s, e) =>
                {
                };
                box_beh.MouseDown += (s, e) =>
                {
                    e.MouseCursorStyle = MouseCursorStyle.Pointer;
                };
                box_beh.MouseUp += (s, e) =>
                {
                    e.MouseCursorStyle = MouseCursorStyle.Default;
                    //box.BackColor = Color.LightGray;
                    s.Source.BackColor = Color.FromArgb(50, KnownColors.FromKnownColor(KnownColor.DeepSkyBlue));
                };
                box_beh.MouseDrag += (s, e) =>
                {
                    Box box = s.Source;
                    box.BackColor = Color.FromArgb(180, KnownColors.FromKnownColor(KnownColor.GreenYellow));
                    Point pos = box.Position;
                    box.SetLocation(pos.X + e.XDiff, pos.Y + e.YDiff);
                    e.MouseCursorStyle = MouseCursorStyle.Pointer;
                    e.CancelBubbling   = true;
                };
            }

            //-------------
            {
                var box1 = new LayoutFarm.CustomWidgets.Box(50, 50);
                box1.BackColor = Color.Red;
                box1.SetLocation(10, 10);
                box_beh.AttachSharedBehaviorTo(box1);
                host.AddChild(box1);
            }
            //--------------------------------
            {
                var box2 = new LayoutFarm.CustomWidgets.Box(30, 30);
                box2.SetLocation(50, 50);
                //box2.dbugTag = 2;
                box_beh.AttachSharedBehaviorTo(box2);
                host.AddChild(box2);
            }
        }
Exemple #18
0
        protected override void OnStart(AppHost host)
        {
            Box background_box = new Box(250, 500);

            background_box.BackColor = PixelFarm.Drawing.Color.Blue;
            host.AddChild(background_box);

            //PixelFarm.Drawing.RequestFont font = new PixelFarm.Drawing.RequestFont("Source Sans Pro", 20);
            PixelFarm.Drawing.RequestFont font = new PixelFarm.Drawing.RequestFont("Source Sans Pro", 20);
            for (int i = 0; i < 10; ++i)
            {
                Label label = new Label();
                label.SetLocation(i * 20, i * 20);
                label.TextColor = PixelFarm.Drawing.Color.Black;
                label.SetFont(font);
                label.Text = "Lpppyf ABCDEFG HI0123 456789 ABD";
                host.AddChild(label);
            }
        }
Exemple #19
0
 protected override void OnStart(AppHost host)
 {
     {
         var box1 = new LayoutFarm.CustomWidgets.Box(50, 50);
         box1.BackColor = Color.Red;
         box1.SetLocation(10, 10);
         //box1.dbugTag = 1;
         SetupActiveBoxProperties(box1);
         host.AddChild(box1);
     }
     //--------------------------------
     {
         var box2 = new LayoutFarm.CustomWidgets.Box(30, 30);
         box2.SetLocation(50, 50);
         //box2.dbugTag = 2;
         SetupActiveBoxProperties(box2);
         host.AddChild(box2);
     }
 }
        public static void AddChild(this AppHost appHost, UIElement ui)
        {
#if DEBUG
            if (ui.ParentUI != null)
            {
                throw new System.NotSupportedException();
            }
#endif
            appHost.AddChild(ui.GetPrimaryRenderElement(appHost.RootGfx), ui);
        }
Exemple #21
0
        protected override void OnStart(AppHost host, IGameHTMLUI pcx)
        {
            htmlHost = HtmlHostCreatorHelper.CreateHtmlHost(host, null, null);
            ////==================================================
            //html box
            {
                HtmlBox lightHtmlBox = new HtmlBox(htmlHost, 800, 50);
                lightHtmlBox.SetLocation(50, 450);
                host.AddChild(lightHtmlBox);
                //light box can't load full html
                //all light boxs of the same lightbox host share resource with the host
                string html = @"<div>OK1</div><div>OK2</div>";
                //if you want to use full html-> use HtmlBox instead
                lightHtmlBox.LoadHtmlFragmentString(html);
            }
            //==================================================
            {
                HtmlBox lightHtmlBox2 = new HtmlBox(htmlHost, 800, 50);
                lightHtmlBox2.SetLocation(0, 60);
                host.AddChild(lightHtmlBox2);
                //light box can't load full html
                //all light boxs of the same lightbox host share resource with the host
                string html2 = @"<div>OK3</div><div>OK4</div>";
                //if you want to use ful l html-> use HtmlBox instead
                lightHtmlBox2.LoadHtmlFragmentString(html2);
            }
            //==================================================
            {
                HtmlBox lightHtmlBox3 = new HtmlBox(htmlHost, 800, 50);
                lightHtmlBox3.SetLocation(0, 100);
                host.AddChild(lightHtmlBox3);
                //fragment dom
                //create dom then to thie light box
                lightHtmlBox3.LoadHtmlDom(CreateSampleHtmlDoc());
            }
            //==================================================
            //textbox
            var textbox = new LayoutFarm.CustomWidgets.TextBox(400, 150, true);

            textbox.SetLocation(0, 200);
            host.AddChild(textbox);
            textbox.Focus();
        }
Exemple #22
0
 protected override void OnStart(AppHost host)
 {
     for (int i = 0; i < 10; ++i)
     {
         Label label = new Label(17, 50);
         label.SetLocation(i * 20, i * 20);
         label.Color = PixelFarm.Drawing.Color.Black;
         label.Text  = "ABCDEFGHIJKLMNOPQRSTUVWXZYZ0123456789";
         host.AddChild(label);
     }
 }
Exemple #23
0
        protected override void OnStart(AppHost host)
        {
            int x_pos = 0;

            //create behaviour for specific host, => LayoutFarm.CustomWidgets.Box
            var beh = new UIMouseBehaviour <LayoutFarm.CustomWidgets.Box, object>();

            beh.MouseEnter += (s, e) =>
            {
                LayoutFarm.CustomWidgets.Box box = s.Source;
                box.BackColor = _mouseEnterState;
#if DEBUG
                System.Diagnostics.Debug.WriteLine("mouse_enter:" + box.dbugId);
#endif
            };
            beh.MouseLeave += (s, e) =>
            {
                LayoutFarm.CustomWidgets.Box box = s.Source;
                box.BackColor = _normalState;
#if DEBUG
                System.Diagnostics.Debug.WriteLine("mouse_leave:" + box.dbugId);
#endif
            };
            beh.MouseHover += (s, e) =>
            {
                LayoutFarm.CustomWidgets.Box box = s.Source;
                box.BackColor = _hoverState;
#if DEBUG
                System.Diagnostics.Debug.WriteLine("mouse_hover:" + box.dbugId);
#endif
            };

            beh.MousePress += (s, e) =>
            {
                LayoutFarm.CustomWidgets.Box box = s.Source;
                Color back_color = box.BackColor;
                box.BackColor = new Color((byte)System.Math.Min(back_color.A + 10, 255), back_color.R, back_color.G, back_color.B);
#if DEBUG
                System.Diagnostics.Debug.WriteLine("mouse_press:" + box.dbugId);
#endif
            };

            for (int i = 0; i < 10; ++i)
            {
                var sampleButton = new LayoutFarm.CustomWidgets.Box(30, 30);
                sampleButton.BackColor = _normalState;
                sampleButton.SetLocation(x_pos, 10);

                beh.AttachSharedBehaviorTo(sampleButton);

                host.AddChild(sampleButton);
                x_pos += 30 + 5;
            }
        }
Exemple #24
0
        protected override void OnStart(AppHost host)
        {
            var sampleButton = new LayoutFarm.CustomWidgets.Box(30, 30);

            host.AddChild(sampleButton);
            int count = 0;

            sampleButton.MouseDown += new EventHandler <UIMouseEventArgs>((s, e2) =>
            {
                Console.WriteLine("click :" + (count++));
            });
        }
 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 #26
0
        protected override void OnStart(AppHost host)
        {
            int halfW = host.PrimaryScreenWidth / 2;
            int halfH = host.PrimaryScreenHeight / 2;

            _rootPanel = new Box(halfW, halfH);
            _rootPanel.SetLocation(0, 0);
            host.AddChild(_rootPanel);

            var addWidthBtn = new Box(100, 50);
            var label1      = new Label();

            label1.Text = "+";
            label1.TransparentForMouseEvents = true;
            addWidthBtn.Add(label1);
            addWidthBtn.MouseDown += AddWidthBtn_MouseDown;
            addWidthBtn.SetLocation(0, halfH + 50);
            host.AddChild(addWidthBtn);

            var minusWidthBtn = new Box(100, 50);

            var label2 = new Label();

            label2.Text = "-";
            label2.TransparentForMouseEvents = true;
            minusWidthBtn.Add(label2);
            minusWidthBtn.MouseDown += MinusWidthBtn_MouseDown;
            minusWidthBtn.SetLocation(120, halfH + 50);
            host.AddChild(minusWidthBtn);

            //Init1();
            //Init2();

            //Init2_1();
            Init2_2();
            //Init2_3();

            _rootPanel.LayoutInstance = _rootNode.ToLayoutInstance();
        }
Exemple #27
0
        protected override void OnStart(AppHost host)
        {
            var sampleButton = new LayoutFarm.CustomWidgets.Box(30, 30);

            host.AddChild(sampleButton);

            sampleButton.MouseDown += ((s, e2) =>
            {
                //click to create custom cursor
                if (!_showCustomCursor)
                {
                    if (_myCursor == null)
                    {
                        using (MemBitmap temp = new MemBitmap(16, 16))
                            using (Tools.BorrowAggPainter(temp, out AggPainter p))
                            {
                                //1. create a simple bitmap for our cursor
                                p.Clear(Color.FromArgb(0, Color.White));
                                p.FillRect(1, 1, 10, 10, Color.FromArgb(150, Color.Green));
                                p.FillRect(3, 3, 4, 4, Color.Yellow);
                                //-------
                                //create cursor file

                                CursorFile curFile = new CursorFile();

                                var iconBmp = new WindowBitmap(temp.Width, temp.Height);
                                iconBmp.RawBitmapData = MemBitmap.CopyImgBuffer(temp);

                                curFile.AddBitmap(iconBmp, 1, 1); //add bitmap with hotspot
                                curFile.Save("myicon.cur");       //save to temp file
                                _myCursor = UIPlatform.CreateCursor(new CursorRequest("myicon.cur", 16));
                            }
                    }
                    e2.CustomMouseCursor = _myCursor;
                    _showCustomCursor = true;
                }
                else
                {
                    _showCustomCursor = false;
                    e2.MouseCursorStyle = MouseCursorStyle.Default;
                }
            });

            sampleButton.MouseMove += ((s, e2) =>
            {
                if (_showCustomCursor && _myCursor != null)
                {
                    e2.CustomMouseCursor = _myCursor;
                }
            });
        }
Exemple #28
0
        protected override void OnStart(AppHost host)
        {
            {
                //html box1
                HtmlBoxes.HtmlHost htmlhost = HtmlHostCreatorHelper.CreateHtmlHost(host, null, null);
                //html box
                var htmlBox = new HtmlBox(htmlhost, 800, 400);
                htmlBox.SetLocation(0, 0);
                //htmlBox.PreferSoftwareRenderer = true;
                host.AddChild(htmlBox);
                string html = @"<html><head></head><body><div>OK1</div><div>OK2</div></body></html>";
                htmlBox.LoadHtmlString(html);
                //==================================================
            }
            {
                //html box2

                HtmlBoxes.HtmlHost htmlhost = HtmlHostCreatorHelper.CreateHtmlHost(host, null, null);
                //html box
                var htmlBox = new HtmlBox(htmlhost, 800, 400);
                htmlBox.PreferSoftwareRenderer = true;
                htmlBox.SetLocation(0, 420);//**
                host.AddChild(htmlBox);
                string html = @"<html><head></head><body><div>OK3</div><div>OK4</div></body></html>";
                htmlBox.LoadHtmlString(html);
                //==================================================
            }

            //{
            //    //textbox
            //    var textbox = new LayoutFarm.CustomWidgets.TextBox(400, 25, true);
            //    textbox.SetLocation(0, 0);
            //    host.AddChild(textbox);
            //    textbox.Focus();
            //}
        }
        protected override void OnStart(AppHost host)
        {
            var box1 = new LayoutFarm.CustomWidgets.Box(50, 50);

            box1.BackColor = Color.Red;
            box1.SetLocation(10, 10);
            host.AddChild(box1);
            //--------------------------------
            var box2 = new LayoutFarm.CustomWidgets.Box(30, 30);

            box2.SetLocation(50, 50);
            host.AddChild(box2);
            //1. mouse down
            box1.MouseDown += (s, e) =>
            {
                box1.BackColor = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue);
                box2.Visible   = false;
            };
            box1.MouseUp += (s, e) =>
            {
                box1.BackColor = Color.Red;
                box2.Visible   = true;
            };
        }
        protected override void OnStart(AppHost host, IGameHTMLUI pcx)
        {
            _host         = host;
            this.htmlhost = HtmlHostCreatorHelper.CreateHtmlHost(host, null, null);
            SetupHtmlMenuBox();
            //==================================================
            //box1 test area
            //html box
            this.testHtmlBox = new HtmlBox(htmlhost, 800, 400);
            testHtmlBox.SetLocation(30, 50);
            host.AddChild(testHtmlBox);
            string html = @"<html><head></head><body><div id='div1'>OK1</div><div>OK2</div></body></html>";

            testHtmlBox.LoadHtmlString(html);
            //==================================================
        }