Ejemplo n.º 1
0
        private void Cancel_Click(object sender, EventArgs e)
        {
            try
            {
                if (PrevTBox.Text != "")
                {
                    ((WzCompressedIntProperty)fh.Data["prev"]).Value = int.Parse(PrevTBox.Text);
                    fh.Data["prev"].ParentImage.Changed = true;
                }
                if (NextTBox.Text != "")
                {
                    ((WzCompressedIntProperty)fh.Data["next"]).Value = int.Parse(NextTBox.Text);
                    fh.Data["next"].ParentImage.Changed = true;
                }

                if (ForceTBox.Text != "")
                {
                    if (ForceLbl.Text == "None")
                    {
                        WzCompressedIntProperty forceProperty = new WzCompressedIntProperty("force", int.Parse(ForceTBox.Text));
                        fh.Data.AddProperty(forceProperty);
                        fh.Data.ParentImage.Changed = true;
                    }
                    else
                    {
                        ((WzCompressedIntProperty)fh.Data["force"]).Value = int.Parse(ForceTBox.Text);
                        fh.Data["force"].ParentImage.Changed = true;
                    }
                }
                this.Close();
            }
            catch { MessageBox.Show("Input was invalid.\n Please provide valid values before confirming.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); }
        }
Ejemplo n.º 2
0
		/// <summary>
		/// Disposes the object
		/// </summary>
		public override void Dispose()
		{
			name = null;
			x.Dispose();
			x = null;
			y.Dispose();
			y = null;
		}
Ejemplo n.º 3
0
 /// <summary>
 /// Disposes the object
 /// </summary>
 public override void Dispose()
 {
     name = null;
     x.Dispose();
     x = null;
     y.Dispose();
     y = null;
 }
Ejemplo n.º 4
0
 private void CreateWzProp(IPropertyContainer parent, WzPropertyType propType, string propName, object value)
 {
     IWzImageProperty addedProp;
     switch (propType)
     {
         case WzPropertyType.ByteFloat:
             addedProp = new WzByteFloatProperty(propName);
             break;
         case WzPropertyType.Canvas:
             addedProp = new WzCanvasProperty(propName);
             ((WzCanvasProperty)addedProp).PngProperty = new WzPngProperty();
             break;
         case WzPropertyType.CompressedInt:
             addedProp = new WzCompressedIntProperty(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.UnsignedShort:
             addedProp = new WzUnsignedShortProperty(propName);
             break;
         case WzPropertyType.Vector:
             addedProp = new WzVectorProperty(propName);
             ((WzVectorProperty)addedProp).X = new WzCompressedIntProperty("X");
             ((WzVectorProperty)addedProp).Y = new WzCompressedIntProperty("Y");
             break;
         default:
             throw new NotSupportedException("not supported type");
     }
     addedProp.SetValue(value);
     parent.AddProperty(addedProp);
 }
Ejemplo n.º 5
0
		/// <summary>
		/// Creates a WzVectorProperty with the specified name, x and y
		/// </summary>
		/// <param name="name">The name of the property</param>
		/// <param name="x">The x value of the vector</param>
		/// <param name="y">The y value of the vector</param>
		public WzVectorProperty(string name, WzCompressedIntProperty x, WzCompressedIntProperty y)
		{
			this.name = name;
			this.x = x;
			this.y = y;
		}
        internal IWzImageProperty 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":
                    WzCompressedIntProperty compressedInt = new WzCompressedIntProperty(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":
                    WzUnsignedShortProperty shortProp = new WzUnsignedShortProperty(element.GetAttribute("name"), ushort.Parse(element.GetAttribute("value"), formattingInfo));
                    return shortProp;

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

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

                case "float":
                    WzByteFloatProperty floatProp = new WzByteFloatProperty(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);
        }
Ejemplo n.º 7
0
 private static void ParseXML(XmlElement element, IPropertyContainer wo)
 {
     foreach (XmlNode node in element)
     {
         if (!(node is XmlElement)) continue;
         XmlElement childElement = (XmlElement)node;
         if (childElement.Name == "imgdir")
         {
             WzSubProperty sub = new WzSubProperty(childElement.GetAttribute("name"));
             wo.AddProperty(sub);
             ParseXML(childElement, (IPropertyContainer)sub);
         }
         else if (childElement.Name == "canvas")
         {
             WzCanvasProperty canvas = new WzCanvasProperty(childElement.GetAttribute("name"));
             canvas.PngProperty = new WzPngProperty();
             MemoryStream pngstream = new MemoryStream(Convert.FromBase64String(childElement.GetAttribute("basedata")));
             canvas.PngProperty.SetPNG((Bitmap)Image.FromStream(pngstream, true, true));
             wo.AddProperty(canvas);
             ParseXML(childElement, (IPropertyContainer)canvas);
         }
         if (childElement.Name == "int")
         {
             WzCompressedIntProperty compressedInt = new WzCompressedIntProperty(childElement.GetAttribute("name"), int.Parse(childElement.GetAttribute("value"), formattingInfo));
             wo.AddProperty(compressedInt);
         }
         if (childElement.Name == "double")
         {
             WzDoubleProperty doubleProp = new WzDoubleProperty(childElement.GetAttribute("name"), double.Parse(childElement.GetAttribute("value"), formattingInfo));
             wo.AddProperty(doubleProp);
         }
         if (childElement.Name == "null")
         {
             WzNullProperty nullProp = new WzNullProperty(childElement.GetAttribute("name"));
             wo.AddProperty(nullProp);
         }
         if (childElement.Name == "sound")
         {
             WzSoundProperty sound = new WzSoundProperty(childElement.GetAttribute("name"));
             sound.SetDataUnsafe(Convert.FromBase64String(childElement.GetAttribute("basedata")));
             wo.AddProperty(sound);
         }
         if (childElement.Name == "string")
         {
             string str = childElement.GetAttribute("value").Replace("&lt;", "<").Replace("&amp;", "&").Replace("&gt;", ">").Replace("&apos;", "'").Replace("&quot;", "\"");
             WzStringProperty stringProp = new WzStringProperty(childElement.GetAttribute("name"), str);
             wo.AddProperty(stringProp);
         }
         if (childElement.Name == "short")
         {
             WzUnsignedShortProperty shortProp = new WzUnsignedShortProperty(childElement.GetAttribute("name"), ushort.Parse(childElement.GetAttribute("value"), formattingInfo));
             wo.AddProperty(shortProp);
         }
         if (childElement.Name == "uol")
         {
             WzUOLProperty uol = new WzUOLProperty(childElement.GetAttribute("name"), childElement.GetAttribute("value"));
             wo.AddProperty(uol);
         }
         if (childElement.Name == "vector")
         {
             WzVectorProperty vector = new WzVectorProperty(childElement.GetAttribute("name"), new WzCompressedIntProperty("x", Convert.ToInt32(childElement.GetAttribute("x"))), new WzCompressedIntProperty("y", Convert.ToInt32(childElement.GetAttribute("y"))));
             wo.AddProperty(vector);
         }
         if (childElement.Name == "float")
         {
             WzByteFloatProperty floatProp = new WzByteFloatProperty(childElement.GetAttribute("name"), float.Parse(childElement.GetAttribute("value"), formattingInfo));
             wo.AddProperty(floatProp);
         }
         if (childElement.Name == "extended")
         {
             WzConvexProperty convex = new WzConvexProperty(childElement.GetAttribute("name"));
             wo.AddProperty(convex);
             ParseXML(childElement, (IPropertyContainer)convex);
         }
     }
 }
Ejemplo n.º 8
0
        public override IWzImageProperty DeepClone()
        {
            WzCompressedIntProperty clone = (WzCompressedIntProperty)MemberwiseClone();

            return(clone);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates a WzVectorProperty with the specified name, x and y
 /// </summary>
 /// <param name="name">The name of the property</param>
 /// <param name="x">The x value of the vector</param>
 /// <param name="y">The y value of the vector</param>
 public WzVectorProperty(string name, WzCompressedIntProperty x, WzCompressedIntProperty y)
 {
     this.name = name;
     this.x    = x;
     this.y    = y;
 }