Treefrog.Framework.Model.ObjectInstance.ToXProxy C# (CSharp) Метод

ToXProxy() публичный статический Метод

public static ToXProxy ( ObjectInstance inst ) : LevelX.ObjectInstanceX
inst ObjectInstance
Результат Treefrog.Framework.Model.Proxy.LevelX.ObjectInstanceX
        public static LevelX.ObjectInstanceX ToXProxy(ObjectInstance inst)
        {
            if (inst == null)
                return null;

            List<CommonX.PropertyX> props = new List<CommonX.PropertyX>();
            foreach (Property prop in inst.PropertyManager.CustomProperties)
                props.Add(Property.ToXmlProxyX(prop));

            return new LevelX.ObjectInstanceX() {
                Uid = inst.Uid,
                Class = inst.ObjectClass.Uid,
                X = inst.X,
                Y = inst.Y,
                Rotation = MathEx.RadToDeg(inst.Rotation),
                Properties = (props.Count > 0) ? props : null,
            };
        }

Usage Example

Пример #1
0
        public static LevelX.ObjectLayerX ToXmlProxyX(ObjectLayer layer)
        {
            if (layer == null)
            {
                return(null);
            }

            List <LevelX.ObjectInstanceX> objs = new List <LevelX.ObjectInstanceX>();

            foreach (ObjectInstance inst in layer.Objects)
            {
                objs.Add(ObjectInstance.ToXProxy(inst));
            }

            List <CommonX.PropertyX> props = new List <CommonX.PropertyX>();

            foreach (Property prop in layer.PropertyManager.CustomProperties)
            {
                props.Add(Property.ToXmlProxyX(prop));
            }

            return(new LevelX.ObjectLayerX()
            {
                Name = layer.Name,
                Opacity = layer.Opacity,
                Visible = layer.IsVisible,
                RasterMode = layer.RasterMode,
                GridColor = layer.GridColor.ToArgbHex(),
                GridWidth = layer.GridWidth,
                GridHeight = layer.GridHeight,
                Objects = objs.Count > 0 ? objs : null,
                Properties = props.Count > 0 ? props : null,
            });
        }