Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
        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));
            }
        }
Ejemplo n.º 3
0
        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!";
        }
        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!";
        }
Ejemplo n.º 5
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();

        }
 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!";
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 9
0
 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();
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 11
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();
        }