Exemplo n.º 1
0
        public static CustomProperty PropertyToGrid(Property p, PCCObject pcc)
        {
            string         cat = p.TypeVal.ToString();
            CustomProperty pg;

            switch (p.TypeVal)
            {
            case Type.BoolProperty:
                pg = new CustomProperty(pcc.Names[p.Name], cat, (p.Value.IntValue == 1), typeof(bool), false, true);
                break;

            case Type.FloatProperty:
                byte[] buff = BitConverter.GetBytes(p.Value.IntValue);
                float  f    = BitConverter.ToSingle(buff, 0);
                pg = new CustomProperty(pcc.Names[p.Name], cat, f, typeof(float), false, true);
                break;

            case Type.ByteProperty:
            case Type.NameProperty:
                NameProp pp = new NameProp();
                pp.name      = pcc.getNameEntry(p.Value.IntValue);
                pp.nameindex = p.Value.IntValue;
                pg           = new CustomProperty(pcc.Names[p.Name], cat, pp, typeof(NameProp), false, true);
                break;

            case Type.ObjectProperty:
                ObjectProp ppo = new ObjectProp();
                ppo.name      = pcc.getObjectName(p.Value.IntValue);
                ppo.nameindex = p.Value.IntValue;
                pg            = new CustomProperty(pcc.Names[p.Name], cat, ppo, typeof(ObjectProp), false, true);
                break;

            case Type.StructProperty:
                StructProp ppp = new StructProp();
                ppp.name      = pcc.getNameEntry(p.Value.IntValue);
                ppp.nameindex = p.Value.IntValue;
                byte[] buf = new byte[p.Value.Array.Count()];
                for (int i = 0; i < p.Value.Array.Count(); i++)
                {
                    buf[i] = (byte)p.Value.Array[i].IntValue;
                }
                List <int> buf2 = new List <int>();
                for (int i = 0; i < p.Value.Array.Count() / 4; i++)
                {
                    buf2.Add(BitConverter.ToInt32(buf, i * 4));
                }
                ppp.data = buf2.ToArray();
                pg       = new CustomProperty(pcc.Names[p.Name], cat, ppp, typeof(StructProp), false, true);
                break;

            default:
                pg = new CustomProperty(pcc.Names[p.Name], cat, p.Value.IntValue, typeof(int), false, true);
                break;
            }
            return(pg);
        }
Exemplo n.º 2
0
        public static CustomProperty PropertyToGrid(Property p, IMEPackage pcc)
        {
            string         cat = p.TypeVal.ToString();
            CustomProperty pg;
            NameProp       pp;

            switch (p.TypeVal)
            {
            case PropertyType.BoolProperty:
                pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, (p.Value.IntValue == 1), typeof(bool), false, true);
                break;

            case PropertyType.FloatProperty:
                pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, p.Value.FloatValue, typeof(float), false, true);
                break;

            case PropertyType.ByteProperty:
                if (p.Size != 8)
                {
                    pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, (byte)p.Value.IntValue, typeof(byte), false, true);
                }
                else
                {
                    pp           = new NameProp();
                    pp.name      = pcc.getNameEntry(p.Value.IntValue);
                    pp.nameindex = p.Value.IntValue;
                    pg           = new CustomProperty(pcc.getNameEntry(p.Name), cat, pp, typeof(NameProp), false, true);
                }
                break;

            case PropertyType.NameProperty:
                pp           = new NameProp();
                pp.name      = pcc.getNameEntry(p.Value.IntValue);
                pp.nameindex = p.Value.IntValue;
                pg           = new CustomProperty(pcc.getNameEntry(p.Name), cat, pp, typeof(NameProp), false, true);
                break;

            case PropertyType.ObjectProperty:
                ObjectProp ppo = new ObjectProp();
                ppo.objectName = pcc.getObjectName(p.Value.IntValue);
                ppo.index      = p.Value.IntValue;
                pg             = new CustomProperty(pcc.getNameEntry(p.Name), cat, ppo, typeof(ObjectProp), false, true);
                break;

            case PropertyType.StrProperty:
                pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, p.Value.StringValue, typeof(string), false, true);
                break;

            case PropertyType.ArrayProperty:
                pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, BitConverter.ToInt32(p.raw, 24) + " elements", typeof(string), false, true);
                break;

            case PropertyType.StructProperty:
                string structType = pcc.getNameEntry(p.Value.IntValue);
                switch (structType)
                {
                case "Color":
                    System.Drawing.Color color = System.Drawing.Color.FromArgb(BitConverter.ToInt32(p.raw, 32));
                    ColorProp            cp    = new ColorProp
                    {
                        name      = structType,
                        nameindex = p.Value.IntValue,
                        Alpha     = color.A,
                        Red       = color.R,
                        Green     = color.G,
                        Blue      = color.B
                    };
                    pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, cp, typeof(ColorProp), false, true);
                    break;

                case "Vector":
                    VectorProp vp = new VectorProp
                    {
                        name      = structType,
                        nameindex = p.Value.IntValue,
                        X         = BitConverter.ToSingle(p.raw, 32),
                        Y         = BitConverter.ToSingle(p.raw, 36),
                        Z         = BitConverter.ToSingle(p.raw, 40)
                    };
                    pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, vp, typeof(VectorProp), false, true);
                    break;

                case "Rotator":
                    RotatorProp rp = new RotatorProp
                    {
                        name      = structType,
                        nameindex = p.Value.IntValue,
                        Pitch     = BitConverter.ToInt32(p.raw, 32).ToDegrees(),
                        Yaw       = BitConverter.ToInt32(p.raw, 36).ToDegrees(),
                        Roll      = BitConverter.ToInt32(p.raw, 40).ToDegrees()
                    };
                    pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, rp, typeof(RotatorProp), false, true);
                    break;

                case "LinearColor":
                    LinearColorProp lcp = new LinearColorProp
                    {
                        name      = structType,
                        nameindex = p.Value.IntValue,
                        Red       = BitConverter.ToSingle(p.raw, 32),
                        Green     = BitConverter.ToSingle(p.raw, 36),
                        Blue      = BitConverter.ToSingle(p.raw, 40),
                        Alpha     = BitConverter.ToSingle(p.raw, 44)
                    };
                    pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, lcp, typeof(VectorProp), false, true);
                    break;

                default:
                    byte[] buf = new byte[p.Value.Array.Count()];
                    for (int i = 0; i < p.Value.Array.Count(); i++)
                    {
                        buf[i] = (byte)p.Value.Array[i].IntValue;
                    }
                    List <int> buf2 = new List <int>();
                    for (int i = 0; i < p.Value.Array.Count() / 4; i++)
                    {
                        buf2.Add(BitConverter.ToInt32(buf, i * 4));
                    }
                    StructProp ppp = new StructProp
                    {
                        name      = structType,
                        nameindex = p.Value.IntValue,
                        data      = buf2.ToArray()
                    };
                    pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, ppp, typeof(StructProp), false, true);
                    break;
                }

                break;

            default:
                pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, p.Value.IntValue, typeof(int), false, true);
                break;
            }
            return(pg);
        }
Exemplo n.º 3
0
        public static CustomProperty PropertyToGrid(Property p, PCCObject pcc)
        {
            string         cat = p.TypeVal.ToString();
            CustomProperty pg;

            switch (p.TypeVal)
            {
            case Type.BoolProperty:
                pg = new CustomProperty(pcc.Names[p.Name], cat, (p.Value.IntValue == 1), typeof(bool), false, true);
                break;

            case Type.FloatProperty:
                byte[] buff = BitConverter.GetBytes(p.Value.IntValue);
                float  f    = BitConverter.ToSingle(buff, 0);
                pg = new CustomProperty(pcc.Names[p.Name], cat, f, typeof(float), false, true);
                break;

            case Type.ByteProperty:
            case Type.NameProperty:
                NameProp pp = new NameProp();
                pp.name      = pcc.getNameEntry(p.Value.IntValue);
                pp.nameindex = p.Value.IntValue;
                pg           = new CustomProperty(pcc.Names[p.Name], cat, pp, typeof(NameProp), false, true);
                break;

            case Type.ObjectProperty:
                ObjectProp ppo = new ObjectProp();
                ppo.name      = pcc.getObjectName(p.Value.IntValue);
                ppo.nameindex = p.Value.IntValue;
                pg            = new CustomProperty(pcc.Names[p.Name], cat, ppo, typeof(ObjectProp), false, true);
                break;

            case Type.StrProperty:
                pg = new CustomProperty(pcc.Names[p.Name], cat, p.Value.StringValue, typeof(string), false, true);
                break;

            case Type.ArrayProperty:
                pg = new CustomProperty(pcc.Names[p.Name], cat, BitConverter.ToInt32(p.raw, 24) + " elements", typeof(string), false, true);
                break;

            case Type.StructProperty:
                string structType = pcc.getNameEntry(p.Value.IntValue);
                if (structType == "Color")
                {
                    ColorProp cp = new ColorProp();
                    cp.name      = structType;
                    cp.nameindex = p.Value.IntValue;
                    System.Drawing.Color color = System.Drawing.Color.FromArgb(BitConverter.ToInt32(p.raw, 32));
                    cp.Alpha = color.A;
                    cp.Red   = color.R;
                    cp.Green = color.G;
                    cp.Blue  = color.B;
                    pg       = new CustomProperty(pcc.Names[p.Name], cat, cp, typeof(ColorProp), false, true);
                }
                else if (structType == "Vector")
                {
                    VectorProp vp = new VectorProp();
                    vp.name      = structType;
                    vp.nameindex = p.Value.IntValue;
                    vp.X         = BitConverter.ToSingle(p.raw, 32);
                    vp.Y         = BitConverter.ToSingle(p.raw, 36);
                    vp.Z         = BitConverter.ToSingle(p.raw, 40);
                    pg           = new CustomProperty(pcc.Names[p.Name], cat, vp, typeof(VectorProp), false, true);
                }
                else if (structType == "Rotator")
                {
                    RotatorProp rp = new RotatorProp();
                    rp.name      = structType;
                    rp.nameindex = p.Value.IntValue;
                    rp.Pitch     = (float)BitConverter.ToInt32(p.raw, 32) * 360f / 65536f;
                    rp.Yaw       = (float)BitConverter.ToInt32(p.raw, 36) * 360f / 65536f;
                    rp.Roll      = (float)BitConverter.ToInt32(p.raw, 40) * 360f / 65536f;
                    pg           = new CustomProperty(pcc.Names[p.Name], cat, rp, typeof(RotatorProp), false, true);
                }
                else if (structType == "LinearColor")
                {
                    LinearColorProp lcp = new LinearColorProp();
                    lcp.name      = structType;
                    lcp.nameindex = p.Value.IntValue;
                    lcp.Red       = BitConverter.ToSingle(p.raw, 32);
                    lcp.Green     = BitConverter.ToSingle(p.raw, 36);
                    lcp.Blue      = BitConverter.ToSingle(p.raw, 40);
                    lcp.Alpha     = BitConverter.ToSingle(p.raw, 44);
                    pg            = new CustomProperty(pcc.Names[p.Name], cat, lcp, typeof(VectorProp), false, true);
                }
                else
                {
                    StructProp ppp = new StructProp();
                    ppp.name      = structType;
                    ppp.nameindex = p.Value.IntValue;
                    byte[] buf = new byte[p.Value.Array.Count()];
                    for (int i = 0; i < p.Value.Array.Count(); i++)
                    {
                        buf[i] = (byte)p.Value.Array[i].IntValue;
                    }
                    List <int> buf2 = new List <int>();
                    for (int i = 0; i < p.Value.Array.Count() / 4; i++)
                    {
                        buf2.Add(BitConverter.ToInt32(buf, i * 4));
                    }
                    ppp.data = buf2.ToArray();
                    pg       = new CustomProperty(pcc.Names[p.Name], cat, ppp, typeof(StructProp), false, true);
                }
                break;

            default:
                pg = new CustomProperty(pcc.Names[p.Name], cat, p.Value.IntValue, typeof(int), false, true);
                break;
            }
            return(pg);
        }
Exemplo n.º 4
0
 public static CustomProperty PropertyToGrid(Property p, PCCObject pcc)
 {
     string cat = p.TypeVal.ToString();
     CustomProperty pg;
     switch(p.TypeVal)
     {
         case Type.BoolProperty :
             pg = new CustomProperty(pcc.Names[p.Name], cat, (p.Value.IntValue == 1), typeof(bool), false, true);
             break;
         case Type.FloatProperty:
             byte[] buff = BitConverter.GetBytes(p.Value.IntValue);
             float f = BitConverter.ToSingle(buff, 0);
             pg = new CustomProperty(pcc.Names[p.Name], cat, f, typeof(float), false, true);
             break;
         case Type.ByteProperty:
         case Type.NameProperty:
             NameProp pp = new NameProp();
             pp.name = pcc.getNameEntry(p.Value.IntValue);
             pp.nameindex = p.Value.IntValue;
             pg = new CustomProperty(pcc.Names[p.Name], cat, pp, typeof(NameProp), false, true);
             break;
         case Type.ObjectProperty:
             ObjectProp ppo = new ObjectProp();
             ppo.name = pcc.getObjectName(p.Value.IntValue);
             ppo.nameindex = p.Value.IntValue;
             pg = new CustomProperty(pcc.Names[p.Name], cat, ppo, typeof(ObjectProp), false, true);
             break;
         case Type.StructProperty:
             StructProp ppp = new StructProp();
             ppp.name = pcc.getNameEntry(p.Value.IntValue);
             ppp.nameindex = p.Value.IntValue;
             byte[] buf = new byte[p.Value.Array.Count()];
             for (int i = 0; i < p.Value.Array.Count(); i++)
                 buf[i] = (byte)p.Value.Array[i].IntValue;
             List<int> buf2 = new List<int>();
             for (int i = 0; i < p.Value.Array.Count() / 4; i++)
                 buf2.Add(BitConverter.ToInt32(buf ,i * 4));
             ppp.data = buf2.ToArray();
             pg = new CustomProperty(pcc.Names[p.Name], cat, ppp, typeof(StructProp), false, true);
             break;                    
         default:
             pg = new CustomProperty(pcc.Names[p.Name],cat,p.Value.IntValue,typeof(int),false,true);
             break;
     }
     return pg;
 }
Exemplo n.º 5
0
        public static CustomProperty PropertyToGrid(Property p, IMEPackage pcc)
        {
            string cat = p.TypeVal.ToString();
            CustomProperty pg;
            NameProp pp;
            switch (p.TypeVal)
            {
                case PropertyType.BoolProperty :
                    pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, (p.Value.IntValue == 1), typeof(bool), false, true);
                    break;
                case PropertyType.FloatProperty: 
                    pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, p.Value.FloatValue, typeof(float), false, true);
                    break;
                case PropertyType.ByteProperty:
                    if (p.Size != 8)
                    {
                        pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, (byte)p.Value.IntValue, typeof(byte), false, true);
                    }
                    else
                    {

                        pp = new NameProp();
                        pp.name = pcc.getNameEntry(p.Value.IntValue);
                        pp.nameindex = p.Value.IntValue;
                        pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, pp, typeof(NameProp), false, true);
                    }
                    break;
                case PropertyType.NameProperty:
                    pp = new NameProp();
                    pp.name = pcc.getNameEntry(p.Value.IntValue);
                    pp.nameindex = p.Value.IntValue;
                    pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, pp, typeof(NameProp), false, true);
                    break;
                case PropertyType.ObjectProperty:
                    ObjectProp ppo = new ObjectProp();
                    ppo.objectName = pcc.getObjectName(p.Value.IntValue);
                    ppo.index = p.Value.IntValue;
                    pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, ppo, typeof(ObjectProp), false, true);
                    break;
                case PropertyType.StrProperty:
                    pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, p.Value.StringValue, typeof(string), false, true);
                    break;
                case PropertyType.ArrayProperty:
                    pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, BitConverter.ToInt32(p.raw,24) + " elements", typeof(string), false, true);
                    break;
                case PropertyType.StructProperty:
                    string structType = pcc.getNameEntry(p.Value.IntValue);
                    if(structType == "Color") {
                        ColorProp  cp = new ColorProp();
                        cp.name = structType;
                        cp.nameindex = p.Value.IntValue;
                        System.Drawing.Color color = System.Drawing.Color.FromArgb(BitConverter.ToInt32(p.raw, 32));
                        cp.Alpha = color.A;
                        cp.Red = color.R;
                        cp.Green = color.G;
                        cp.Blue = color.B;
                        pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, cp, typeof(ColorProp), false, true);
                    }
                    else if (structType == "Vector")
                    {
                        VectorProp vp = new VectorProp();
                        vp.name = structType;
                        vp.nameindex = p.Value.IntValue;
                        vp.X = BitConverter.ToSingle(p.raw, 32);
                        vp.Y = BitConverter.ToSingle(p.raw, 36);
                        vp.Z = BitConverter.ToSingle(p.raw, 40);
                        pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, vp, typeof(VectorProp), false, true);
                    }
                    else if (structType == "Rotator")
                    {
                        RotatorProp rp = new RotatorProp();
                        rp.name = structType;
                        rp.nameindex = p.Value.IntValue;
                        rp.Pitch = BitConverter.ToInt32(p.raw, 32) * 360f / 65536f;
                        rp.Yaw = BitConverter.ToInt32(p.raw, 36) * 360f / 65536f;
                        rp.Roll = BitConverter.ToInt32(p.raw, 40) * 360f / 65536f;
                        pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, rp, typeof(RotatorProp), false, true);
                    }
                    else if (structType == "LinearColor")
                    {
                        LinearColorProp lcp = new LinearColorProp();
                        lcp.name = structType;
                        lcp.nameindex = p.Value.IntValue;
                        lcp.Red = BitConverter.ToSingle(p.raw, 32);
                        lcp.Green = BitConverter.ToSingle(p.raw, 36);
                        lcp.Blue = BitConverter.ToSingle(p.raw, 40);
                        lcp.Alpha = BitConverter.ToSingle(p.raw, 44);
                        pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, lcp, typeof(VectorProp), false, true);
                    }
                    else {
                        StructProp ppp = new StructProp();
                        ppp.name = structType;
                        ppp.nameindex = p.Value.IntValue;
                        byte[] buf = new byte[p.Value.Array.Count()];
                        for (int i = 0; i < p.Value.Array.Count(); i++)
                            buf[i] = (byte)p.Value.Array[i].IntValue;
                        List<int> buf2 = new List<int>();
                        for (int i = 0; i < p.Value.Array.Count() / 4; i++)
                            buf2.Add(BitConverter.ToInt32(buf ,i * 4));
                        ppp.data = buf2.ToArray();
                        pg = new CustomProperty(pcc.getNameEntry(p.Name), cat, ppp, typeof(StructProp), false, true);
                    }
                    break;                    
                default:
                    pg = new CustomProperty(pcc.getNameEntry(p.Name),cat,p.Value.IntValue,typeof(int),false,true);
                    break;
            }
            return pg;
        }