public override WzImageProperty DeepClone()
        {
            WzFloatProperty clone = new WzFloatProperty(name, val);

            return(clone);
        }
Beispiel #2
0
 public override WzImageProperty DeepClone()
 {
     WzFloatProperty clone = new WzFloatProperty(name, val);
     return clone;
 }
Beispiel #3
0
 private void CreateWzProp(IPropertyContainer parent, WzPropertyType propType, string propName, object value)
 {
     WzImageProperty addedProp;
     switch (propType)
     {
         case WzPropertyType.Float:
             addedProp = new WzFloatProperty(propName);
             break;
         case WzPropertyType.Canvas:
             addedProp = new WzCanvasProperty(propName);
             ((WzCanvasProperty)addedProp).PngProperty = new WzPngProperty();
             break;
         case WzPropertyType.Int:
             addedProp = new WzIntProperty(propName);
             break;
         case WzPropertyType.Double:
             addedProp = new WzDoubleProperty(propName);
             break;
         /*case WzPropertyType.Sound:
             addedProp = new WzSoundProperty(propName);
             break;*/
         case WzPropertyType.String:
             addedProp = new WzStringProperty(propName);
             break;
         case WzPropertyType.Short:
             addedProp = new WzShortProperty(propName);
             break;
         case WzPropertyType.Vector:
             addedProp = new WzVectorProperty(propName);
             ((WzVectorProperty)addedProp).X = new WzIntProperty("X");
             ((WzVectorProperty)addedProp).Y = new WzIntProperty("Y");
             break;
         default:
             throw new NotSupportedException("not supported type");
     }
     addedProp.SetValue(value);
     parent.AddProperty(addedProp);
 }
Beispiel #4
0
        internal WzImageProperty ParsePropertyFromXMLElement(XmlElement element)
        {
            switch (element.Name)
            {
                case "imgdir":
                    WzSubProperty sub = new WzSubProperty(element.GetAttribute("name"));
                    foreach (XmlElement subelement in element)
                        sub.AddProperty(ParsePropertyFromXMLElement(subelement));
                    return sub;

                case "canvas":
                    WzCanvasProperty canvas = new WzCanvasProperty(element.GetAttribute("name"));
                    if (!element.HasAttribute("basedata")) throw new NoBase64DataException("no base64 data in canvas element with name " + canvas.Name);
                    canvas.PngProperty = new WzPngProperty();
                    MemoryStream pngstream = new MemoryStream(Convert.FromBase64String(element.GetAttribute("basedata")));
                    canvas.PngProperty.SetPNG((Bitmap)Image.FromStream(pngstream, true, true));
                    foreach (XmlElement subelement in element)
                        canvas.AddProperty(ParsePropertyFromXMLElement(subelement));
                    return canvas;

                case "int":
                    WzIntProperty compressedInt = new WzIntProperty(element.GetAttribute("name"), int.Parse(element.GetAttribute("value"), formattingInfo));
                    return compressedInt;

                case "double":
                    WzDoubleProperty doubleProp = new WzDoubleProperty(element.GetAttribute("name"), double.Parse(element.GetAttribute("value"), formattingInfo));
                    return doubleProp;

                case "null":
                    WzNullProperty nullProp = new WzNullProperty(element.GetAttribute("name"));
                    return nullProp;

                case "sound":
                    if (!element.HasAttribute("basedata") || !element.HasAttribute("basehead") || !element.HasAttribute("length")) throw new NoBase64DataException("no base64 data in sound element with name " + element.GetAttribute("name"));
                    WzSoundProperty sound = new WzSoundProperty(element.GetAttribute("name"),
                        int.Parse(element.GetAttribute("length")),
                        Convert.FromBase64String(element.GetAttribute("basehead")),
                        Convert.FromBase64String(element.GetAttribute("basedata")));
                    return sound;

                case "string":
                    WzStringProperty stringProp = new WzStringProperty(element.GetAttribute("name"), element.GetAttribute("value"));
                    return stringProp;

                case "short":
                    WzShortProperty shortProp = new WzShortProperty(element.GetAttribute("name"), short.Parse(element.GetAttribute("value"), formattingInfo));
                    return shortProp;

                case "long":
                    WzLongProperty longProp = new WzLongProperty(element.GetAttribute("name"), long.Parse(element.GetAttribute("value"), formattingInfo));
                    return longProp;

                case "uol":
                    WzUOLProperty uol = new WzUOLProperty(element.GetAttribute("name"), element.GetAttribute("value"));
                    return uol;

                case "vector":
                    WzVectorProperty vector = new WzVectorProperty(element.GetAttribute("name"), new WzIntProperty("x", Convert.ToInt32(element.GetAttribute("x"))), new WzIntProperty("y", Convert.ToInt32(element.GetAttribute("y"))));
                    return vector;

                case "float":
                    WzFloatProperty floatProp = new WzFloatProperty(element.GetAttribute("name"), float.Parse(element.GetAttribute("value"), formattingInfo));
                    return floatProp;

                case "extended":
                    WzConvexProperty convex = new WzConvexProperty(element.GetAttribute("name"));
                    foreach (XmlElement subelement in element)
                        convex.AddProperty(ParsePropertyFromXMLElement(subelement));
                    return convex;
            }
            throw new InvalidDataException("unknown XML prop " + element.Name);
        }