Ejemplo n.º 1
0
        static EdgeObject ParseObject(JObject obj)
        {
            var        type = (EdgeObjectType)Enum.Parse(typeof(EdgeObjectType), (string)obj ["type"], true);
            EdgeObject edgeObject;

            switch (type)
            {
            case EdgeObjectType.Image:
                edgeObject = new EdgeImage {
                    ImageName = HttpUtility.UrlDecode((string)obj ["fill"] [1]),
                };
                break;

            case EdgeObjectType.Text:
                edgeObject = new EdgeText {
                    Text = (string)obj ["text"],
                    Font = ParseFont((JArray)obj ["font"]),
                };
                break;

            default:
                edgeObject = new EdgeObject();
                break;
            }
            bool autoWidth;
            bool autoHeight;

            edgeObject.Name       = (string)obj ["id"];
            edgeObject.Rect       = ParseRect((JArray)obj ["rect"], out autoWidth, out autoHeight);
            edgeObject.AutoWidth  = autoWidth;
            edgeObject.AutoHeight = autoHeight;
            edgeObject.Hidden     = Parsehidden(obj);
            edgeObject.Opacity    = ParseOpacity(obj);
            return(edgeObject);
        }
Ejemplo n.º 2
0
        public static UIView ToUIView(this EdgeObject obj)
        {
            UIView view;

            if (obj is EdgeImage)
            {
                var img = obj as EdgeImage;
                view = new UIImageView(UIImage.FromBundle(img.ImageName));
            }
            else if (obj is EdgeText)
            {
                var txt = obj as EdgeText;
                view = new UILabel()
                {
                    Text      = txt.Text,
                    Font      = txt.Font.ToFont(),
                    TextColor = txt.Font.Color.ToColor(),
                };
            }
            else
            {
                view = new UIView();
            }

            view.Frame = obj.Rect;
            if (view.Frame.Size == SizeF.Empty && (obj.AutoHeight || obj.AutoHeight))
            {
                view.SizeToFit();
            }
            view.Hidden = obj.Hidden;
            view.Alpha  = obj.Opacity;
            return(view);
        }
Ejemplo n.º 3
0
 static EdgeObject ParseObject(JObject obj)
 {
     var type = (EdgeObjectType)Enum.Parse (typeof(EdgeObjectType), (string)obj ["type"], true);
     EdgeObject edgeObject;
     switch (type) {
     case EdgeObjectType.Image:
         edgeObject = new EdgeImage {
             ImageName = HttpUtility.UrlDecode ((string)obj ["fill"] [1]),
         };
         break;
     case EdgeObjectType.Text:
         edgeObject = new EdgeText {
             Text = (string)obj ["text"],
             Font = ParseFont ((JArray)obj ["font"]),
         };
         break;
     default:
         edgeObject = new EdgeObject ();
         break;
     }
     bool autoWidth;
     bool autoHeight;
     edgeObject.Name = (string)obj ["id"];
     edgeObject.Rect = ParseRect ((JArray)obj ["rect"], out autoWidth, out autoHeight);
     edgeObject.AutoWidth = autoWidth;
     edgeObject.AutoHeight = autoHeight;
     edgeObject.Hidden = Parsehidden (obj);
     edgeObject.Opacity = ParseOpacity (obj);
     return edgeObject;
 }