Exemple #1
0
        protected override void OnStart(AppHost host)
        {
            PixelFarm.Drawing.ImageBinder imgBinder = host.LoadImageAndBind("../Data/imgs/favorites32.png");

            //GlobalRootGraphic.BlockGraphicsUpdate();
            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 * 32, 20);
                imgBox.MouseDown += (s, e) =>
                {
                    //test start animation
                    int nsteps = 40;
                    UIPlatform.RegisterTimerTask(20, timTask =>
                    {
                        imgBox.SetLocation(imgBox.Left, imgBox.Top + 10);
                        nsteps--;
                        if (nsteps <= 0)
                        {
                            timTask.RemoveSelf();
                        }
                    });
                };
                host.AddChild(imgBox);
            }
            //GlobalRootGraphic.ReleaseGraphicsUpdate();
        }
Exemple #2
0
        public void SetImageSource(PixelFarm.Drawing.ImageBinder imgBinder)
        {
            DomAttribute attr = this.OwnerDocument.CreateAttribute("src", imgBinder.ImageSource);

            SetDomAttribute(attr);
            //----
            if (_principalBox != null)
            {
                InternalSetImageBinder(_owner.GetImageBinder(attr.Value));
            }
        }
 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);
     }
 }
 internal void RequestImageAsync(PixelFarm.Drawing.ImageBinder binder, VgVisualElement imgRun, object requestFrom)
 {
     if (_imgReqHandler != null)
     {
         _imgReqHandler(binder, imgRun, requestFrom);
     }
     else
     {
         //ask for coment resource IO
         _imgReqHandler = VgResourceIO.VgImgIOHandler;
         if (_imgReqHandler != null)
         {
             _imgReqHandler(binder, imgRun, requestFrom);
         }
     }
 }
Exemple #5
0
        void InternalSetImageBinder(PixelFarm.Drawing.ImageBinder imgBinder)
        {
            if (_principalBox == null)
            {
                return;
            }

            //
            CssBoxImage boxImg = (CssBoxImage)_principalBox;

            //implementation specific...
            //if the binder is loaded , not need TempTranstionImageBinder
            boxImg.TempTranstionImageBinder = (imgBinder.State == PixelFarm.Drawing.BinderState.Loaded) ? null : boxImg.ImageBinder;
            boxImg.ImageBinder = imgBinder;
            boxImg.InvalidateGraphics();
        }
Exemple #6
0
        static void AssignStylesFromTranslatedAttributesHTML5(HtmlElement tag)
        {
            //some html attr contains css value
            if (tag.AttributeCount > 0)
            {
                foreach (var attr in tag.GetAttributeIterForward())
                {
                    //attr switch by wellknown property name
                    switch ((WebDom.WellknownName)attr.LocalNameIndex)
                    {
                    case WebDom.WellknownName.Align:
                    {
                        //deprecated in HTML4.1
                        //string value = attr.Value.ToLower();
                        //if (value == "left"
                        //    || value == "center"
                        //    || value == "right"
                        //    || value == "justify")
                        //{
                        //    WebDom.CssCodePrimitiveExpression propValue = new WebDom.CssCodePrimitiveExpression(
                        //        value, WebDom.CssValueHint.Iden);

                        //    box.CssTextAlign = UserMapUtil.GetTextAlign(propValue);
                        //}
                        //else
                        //{
                        //    WebDom.CssCodePrimitiveExpression propValue = new WebDom.CssCodePrimitiveExpression(
                        //     value, WebDom.CssValueHint.Iden);
                        //    box.VerticalAlign = UserMapUtil.GetVerticalAlign(propValue);
                        //}
                        //break;
                    }
                    break;

                    case WebDom.WellknownName.Background:
                        //deprecated in HTML4.1
                        //box.BackgroundImageBinder = new ImageBinder(attr.Value.ToLower());
                        break;

                    case WebDom.WellknownName.BackgroundColor:
                        //deprecated in HTML5
                        //box.BackgroundColor = CssValueParser.GetActualColor(attr.Value.ToLower());
                        break;

                    case WebDom.WellknownName.Border:
                    {
                        //not support in HTML5
                        //CssLength borderLen = TranslateLength(UserMapUtil.MakeBorderLength(attr.Value.ToLower()));
                        //if (!borderLen.HasError)
                        //{

                        //    if (borderLen.Number > 0)
                        //    {
                        //        box.BorderLeftStyle =
                        //            box.BorderTopStyle =
                        //            box.BorderRightStyle =
                        //            box.BorderBottomStyle = CssBorderStyle.Solid;
                        //    }

                        //    box.BorderLeftWidth =
                        //    box.BorderTopWidth =
                        //    box.BorderRightWidth =
                        //    box.BorderBottomWidth = borderLen;

                        //    if (tag.WellknownTagName == WellknownHtmlTagName.TABLE && borderLen.Number > 0)
                        //    {
                        //        //Cascades to the TD's the border spacified in the TABLE tag.
                        //        var borderWidth = CssLength.MakePixelLength(1);
                        //        ForEachCellInTable(box, cell =>
                        //        {
                        //            //for all cells
                        //            cell.BorderLeftStyle = cell.BorderTopStyle = cell.BorderRightStyle = cell.BorderBottomStyle = CssBorderStyle.Solid; // CssConstants.Solid;
                        //            cell.BorderLeftWidth = cell.BorderTopWidth = cell.BorderRightWidth = cell.BorderBottomWidth = borderWidth;
                        //        });

                        //    }

                        //}
                    }
                    break;

                    case WebDom.WellknownName.BorderColor:

                        //box.BorderLeftColor =
                        //    box.BorderTopColor =
                        //    box.BorderRightColor =
                        //    box.BorderBottomColor = CssValueParser.GetActualColor(attr.Value.ToLower());

                        break;

                    case WebDom.WellknownName.CellSpacing:

                        //html5 not support in HTML5, use CSS instead
                        //box.BorderSpacingHorizontal = box.BorderSpacingVertical = TranslateLength(attr);

                        break;

                    case WebDom.WellknownName.CellPadding:
                    {
                        //html5 not support in HTML5, use CSS instead ***

                        //                                CssLength len01 = UserMapUtil.ParseGenericLength(attr.Value.ToLower());
                        //                                if (len01.HasError && (len01.Number > 0))
                        //                                {
                        //                                    CssLength len02 = CssLength.MakePixelLength(len01.Number);
                        //                                    ForEachCellInTable(box, cell =>
                        //                                    {
                        //#if DEBUG
                        //                                        // cell.dbugBB = dbugTT++;
                        //#endif
                        //                                        cell.PaddingLeft = cell.PaddingTop = cell.PaddingRight = cell.PaddingBottom = len02;
                        //                                    });

                        //                                }
                        //                                else
                        //                                {
                        //                                    ForEachCellInTable(box, cell =>
                        //                                         cell.PaddingLeft = cell.PaddingTop = cell.PaddingRight = cell.PaddingBottom = len01);
                        //                                }
                    }
                    break;

                    case WebDom.WellknownName.Color:

                        //deprecate
                        // box.Color = CssValueParser.GetActualColor(attr.Value.ToLower());
                        break;

                    case WebDom.WellknownName.Dir:
                    {
                        WebDom.CssCodePrimitiveExpression propValue = new WebDom.CssCodePrimitiveExpression(
                            attr.Value.ToLower(), WebDom.CssValueHint.Iden);
                        //assign
                        var spec = tag.Spec;
                        spec.CssDirection = UserMapUtil.GetCssDirection(propValue);
                    }
                    break;

                    case WebDom.WellknownName.Face:
                        //deprecate
                        //box.FontFamily = CssParser.ParseFontFamily(attr.Value.ToLower());
                        break;

                    case WebDom.WellknownName.Height:
                    {
                        var spec = tag.Spec;
                        spec.Height = TranslateLength(attr);
                    }
                    break;

                    case WebDom.WellknownName.HSpace:
                        //deprecated
                        //box.MarginRight = box.MarginLeft = TranslateLength(attr);
                        break;

                    case WebDom.WellknownName.Nowrap:
                        //deprecate
                        //box.WhiteSpace = CssWhiteSpace.NoWrap;
                        break;

                    case WebDom.WellknownName.Size:
                    {
                        //deprecate
                        //switch (tag.WellknownTagName)
                        //{
                        //    case WellknownHtmlTagName.HR:
                        //        {
                        //            box.Height = TranslateLength(attr);
                        //        } break;
                        //    case WellknownHtmlTagName.FONT:
                        //        {
                        //            var ruleset = activeTemplate.ParseCssBlock("", attr.Value.ToLower());
                        //            foreach (WebDom.CssPropertyDeclaration propDecl in ruleset.GetAssignmentIter())
                        //            {
                        //                //assign each property
                        //                AssignPropertyValue(box, box.ParentBox, propDecl);
                        //            }
                        //            //WebDom.CssCodePrimitiveExpression prim = new WebDom.CssCodePrimitiveExpression(value,
                        //            //box.SetFontSize(value);
                        //        } break;
                        //}
                    }
                    break;

                    case WebDom.WellknownName.VAlign:
                    {
                        //w3.org
                        //valign for table display elements:
                        //col,colgroup,tbody,td,tfoot,th,thead,tr

                        WebDom.CssCodePrimitiveExpression propValue = new WebDom.CssCodePrimitiveExpression(
                            attr.Value.ToLower(), WebDom.CssValueHint.Iden);
                        tag.Spec.VerticalAlign = UserMapUtil.GetVerticalAlign(propValue);
                    }
                    break;

                    case WebDom.WellknownName.VSpace:
                        //deprecated
                        //box.MarginTop = box.MarginBottom = TranslateLength(attr);
                        break;

                    case WebDom.WellknownName.Width:
                    {
                        var spec = tag.Spec;
                        spec.Width = TranslateLength(attr);
                    }
                    break;

                    case WellknownName.Src:
                    {
                        var cssBoxImage = HtmlElement.InternalGetPrincipalBox(tag) as CssBoxImage;
                        if (cssBoxImage != null)
                        {
                            string imgsrc;
                            //ImageBinder imgBinder = null;
                            if (tag.TryGetAttribute(WellknownName.Src, out imgsrc))
                            {
                                CssBoxImage cssBoxImage1 = HtmlElement.InternalGetPrincipalBox(tag) as CssBoxImage;
                                PixelFarm.Drawing.ImageBinder imgbinder1 = cssBoxImage1.ImageBinder;
                                if (imgbinder1.ImageSource != imgsrc)
                                {
                                    //var clientImageBinder = new ClientImageBinder(imgsrc);
                                    //imgbinder1 = clientImageBinder;
                                    //clientImageBinder.SetOwner(tag);
                                    cssBoxImage1.ImageBinder = new PixelFarm.Drawing.ImageBinder(imgsrc);
                                }
                            }
                            else
                            {
                                //var clientImageBinder = new ClientImageBinder(null);
                                //imgBinder = clientImageBinder;
                                //clientImageBinder.SetOwner(tag);
                            }
                        }
                    }
                    break;
                    }
                }
            }
        }
Exemple #7
0
 void ImgBinderLoadImg(PixelFarm.Drawing.ImageBinder reqImgBinder, VgVisualElement vgVisualE, object o)
 {
     PixelFarm.Drawing.Image img = _host.LoadImage(reqImgBinder.ImageSource);
     reqImgBinder.SetLocalImage(img);
     reqImgBinder.State = PixelFarm.Drawing.BinderState.Loaded;
 }
Exemple #8
0
 public PixelFarm.Drawing.ImageBinder GetImageBinder(string imgurl)
 {
     PixelFarm.Drawing.ImageBinder imgBinder = new PixelFarm.Drawing.ImageBinder(imgurl);
     Host.ChildRequestImage(imgBinder, null);
     return(imgBinder);
 }