Inheritance: LayoutFarm.UI.UIBox
Example #1
0
        public IUIElement CreateElement(string elemName)
        {
            switch (elemName)
            {
            default:
                return(Wrap(new CustomWidgets.SimpleBox(10, 10)));

            case UIElemNameConst.simple_box:
                return(Wrap(new CustomWidgets.SimpleBox(10, 10)));

            case UIElemNameConst.h_scroll_bar:
            {
                var scBar = new CustomWidgets.ScrollBar(10, 10);
                scBar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
                return(Wrap(scBar));
            }

            case UIElemNameConst.v_scroll_bar:
            {
                var scBar = new CustomWidgets.ScrollBar(10, 10);
                scBar.ScrollBarType = CustomWidgets.ScrollBarType.Vertical;
                return(Wrap(scBar));
            }

            case UIElemNameConst.textbox:
            {
                var textBox = new CustomWidgets.TextBox(10, 10, false);
                return(Wrap(textBox));
            }
            }
        }
Example #2
0
        protected override void OnStartDemo(SampleViewport viewport)
        {
            ////==================================================
            //html box
            var           htmlHost  = HtmlHostCreatorHelper.CreateHtmlHost(viewport, 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());
            viewport.AddContent(htmlBox);
            //==================================================

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

            textbox.SetLocation(0, 200);
            viewport.AddContent(textbox);
            textbox.Focus();
        }
 public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
 {
     if (!this.HasReadyRenderElement)
     {
         //first time
         RenderElement baseRenderElement = base.GetPrimaryRenderElement(rootgfx);
         //1. add place holder first
         placeHolder = new CustomTextRun(rootgfx, this.Width - 4, this.Height - 4);
         placeHolder.Text = placeHolderText;
         placeHolder.SetLocation(1, 1);
         placeHolder.TextColor = Color.FromArgb(180, Color.LightGray);
         baseRenderElement.AddChild(placeHolder);
         //2. textbox 
         myTextBox = new TextBox(this.Width - 4, this.Height - 4, multiline);
         myTextBox.BackgroundColor = Color.Transparent;
         myTextBox.SetLocation(2, 2);
         textEvListener = new Text.TextSurfaceEventListener();
         myTextBox.TextEventListener = textEvListener;
         textEvListener.KeyDown += new EventHandler<Text.TextDomEventArgs>(textEvListener_KeyDown);
         baseRenderElement.AddChild(myTextBox);
         return baseRenderElement;
     }
     else
     {
         return base.GetPrimaryRenderElement(rootgfx);
     }
 }
        protected override void OnStart(AppHost host)
        {
            {
                var reqFont1 = new PixelFarm.Drawing.RequestFont("Sarabun", 14);
                var textbox1 = new LayoutFarm.CustomWidgets.TextBox(400, 100, true);
                var style1   = new TextEditing.TextSpanStyle();
                style1.ReqFont = reqFont1;
                //test with various font style
                style1.FontColor          = new PixelFarm.Drawing.Color(0, 0, 0);
                textbox1.DefaultSpanStyle = style1;
                host.AddChild(textbox1);
            }
            //-------------------
            //{
            //    var reqFont2 = new PixelFarm.Drawing.RequestFont("Sarabun", 10);
            //    //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 = reqFont2;
            //    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!";
            //}
        }
        protected override void OnStartDemo(SampleViewport viewport)
        {
            var textbox1 = new LayoutFarm.CustomWidgets.TextBox(400, 100, true);
            var style1   = new Text.TextSpanStyle();

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

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


            viewport.AddContent(textbox2);
            var textSplitter = new ContentTextSplitter();

            textbox2.TextSplitter = textSplitter;
            textbox2.Text         = "Hello World!";
        }
 protected override void OnStartDemo(SampleViewport viewport)
 {
     var textbox1 = new LayoutFarm.CustomWidgets.TextBox(400, 100, true);
     var style1 = new Text.TextSpanStyle();
     style1.FontInfo = new PixelFarm.Drawing.RequestFont("tahoma", 10);// viewport.P.GetFont("tahoma", 10, PixelFarm.Drawing.FontStyle.Regular);
     textbox1.DefaultSpanStyle = style1;
     viewport.AddContent(textbox1);
     var textbox2 = new LayoutFarm.CustomWidgets.TextBox(400, 500, true);
     textbox2.SetLocation(20, 120);
     viewport.AddContent(textbox2);
     var textSplitter = new ContentTextSplitter(); 
     textbox2.TextSplitter = textSplitter;
     textbox2.Text = "Hello World!";
 }
Example #7
0
        protected override void OnStartDemo(SampleViewport viewport)
        {
            var htmlhost = HtmlHostCreatorHelper.CreateHtmlHost(viewport, null, null);
            ////==================================================
            //html box
            var htmlBox = new HtmlBox(htmlhost, 800, 400);
            htmlBox.SetLocation(30, 30);
            viewport.AddContent(htmlBox);
            string html = @"<html><head></head><body><div>OK1</div><div>OK2</div></body></html>";
            htmlBox.LoadHtmlString(html);
            //================================================== 

            //textbox
            var textbox = new LayoutFarm.CustomWidgets.TextBox(400, 100, true);
            textbox.SetLocation(0, 200);
            viewport.AddContent(textbox);
            textbox.Focus();
        }
Example #8
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();
        }
 protected override void OnStartDemo(SampleViewport viewport)
 {
     htmlHost = HtmlHostCreatorHelper.CreateHtmlHost(viewport, null, null);
     ////==================================================
     //html box
     {
         HtmlBox lightHtmlBox = new HtmlBox(htmlHost, 800, 50);
         lightHtmlBox.SetLocation(50, 450);
         viewport.AddContent(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);
         viewport.AddContent(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);
         viewport.AddContent(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);
     viewport.AddContent(textbox);
     textbox.Focus();
 }
Example #10
0
        protected override void OnStartDemo(SampleViewport viewport)
        {
            var htmlhost = HtmlHostCreatorHelper.CreateHtmlHost(viewport, null, null);
            ////==================================================
            //html box
            var htmlBox = new HtmlBox(htmlhost, 800, 400);

            htmlBox.SetLocation(30, 30);
            viewport.AddContent(htmlBox);
            string html = @"<html><head></head><body><div>OK1</div><div>OK2</div></body></html>";

            htmlBox.LoadHtmlString(html);
            //==================================================

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

            textbox.SetLocation(0, 200);
            viewport.AddContent(textbox);
            textbox.Focus();
        }
        protected override void OnStartDemo(SampleViewport viewport)
        {
            //--------------------------------
            {
                //background element
                var bgbox = new LayoutFarm.CustomWidgets.SimpleBox(800, 600);
                bgbox.BackColor = Color.White;
                bgbox.SetLocation(0, 0);
                SetupBackgroundProperties(bgbox);
                viewport.AddContent(bgbox);
            }
            //--------------------------------
            //ninespace compartment
            ninespaceBox = new UINinespaceBox(800, 600);
            viewport.AddContent(ninespaceBox);
            ninespaceBox.SetSize(800, 600);
            //--------------------------------
            //test add some content to the ninespace box


            textbox  = new LayoutFarm.CustomWidgets.TextBox(400, 30, false);
            listView = new CustomWidgets.ListView(300, 200);
            listView.SetLocation(0, 40);
            listView.Visible = false;
            //------------------------------------
            //create special text surface listener
            var textSurfaceListener = new LayoutFarm.Text.TextSurfaceEventListener();

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

            //------------------------------------
            BuildSampleCountryList();
            ninespaceBox.LeftSpace.AddChild(textbox);
            ninespaceBox.RightSpace.AddChild(listView);
        }
        protected override void OnStartDemo(SampleViewport viewport)
        {
            //--------------------------------
            {
                //background element
                var bgbox = new LayoutFarm.CustomWidgets.SimpleBox(800, 600);
                bgbox.BackColor = Color.White;
                bgbox.SetLocation(0, 0);
                SetupBackgroundProperties(bgbox);
                viewport.AddContent(bgbox);
            }
            //--------------------------------
            //ninespace compartment
            ninespaceBox = new UINinespaceBox(800, 600);
            viewport.AddContent(ninespaceBox);
            ninespaceBox.SetSize(800, 600);
            //--------------------------------
            //test add some content to the ninespace box


            textbox = new LayoutFarm.CustomWidgets.TextBox(400, 30, false);
            listView = new CustomWidgets.ListView(300, 200);
            listView.SetLocation(0, 40);
            listView.Visible = false;
            //------------------------------------
            //create special text surface listener
            var textSurfaceListener = new LayoutFarm.Text.TextSurfaceEventListener();
            textSurfaceListener.CharacterAdded += (s, e) => UpdateSuggestionList();
            textSurfaceListener.CharacterRemoved += (s, e) => UpdateSuggestionList();
            textSurfaceListener.PreviewArrowKeyDown += new EventHandler<Text.TextDomEventArgs>(textSurfaceListener_PreviewArrowKeyDown);
            textSurfaceListener.PreviewEnterKeyDown += new EventHandler<Text.TextDomEventArgs>(textSurfaceListener_PreviewEnterKeyDown);
            textbox.TextEventListener = textSurfaceListener;
            //------------------------------------ 

            //------------------------------------ 
            BuildSampleCountryList();
            ninespaceBox.LeftSpace.AddChild(textbox);
            ninespaceBox.RightSpace.AddChild(listView);
        }
Example #13
0
        protected override void OnStartDemo(SampleViewport viewport)
        {
            ////==================================================
            //html box
            var htmlHost = HtmlHostCreatorHelper.CreateHtmlHost(viewport, 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());
            viewport.AddContent(htmlBox);
            //==================================================  

            //textbox
            var textbox = new LayoutFarm.CustomWidgets.TextBox(400, 100, true);
            textbox.SetLocation(0, 200);
            viewport.AddContent(textbox);
            textbox.Focus();
        }