private void Cancel_Click(object sender, EventArgs e) { try { if (PrevTBox.Text != "") { ((WzIntProperty)fh.Data["prev"]).Value = int.Parse(PrevTBox.Text); fh.Data["prev"].ParentImage.Changed = true; } if (NextTBox.Text != "") { ((WzIntProperty)fh.Data["next"]).Value = int.Parse(NextTBox.Text); fh.Data["next"].ParentImage.Changed = true; } if (ForceTBox.Text != "") { if (ForceLbl.Text == "None") { WzIntProperty forceProperty = new WzIntProperty("force", int.Parse(ForceTBox.Text)); fh.Data.AddProperty(forceProperty); fh.Data.ParentImage.Changed = true; } else { ((WzIntProperty)fh.Data["force"]).Value = int.Parse(ForceTBox.Text); fh.Data["force"].ParentImage.Changed = true; } } this.Close(); } catch { MessageBox.Show(HaRepacker.Properties.Resources.FHMapperInvalidInput, HaRepacker.Properties.Resources.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// Disposes the object /// </summary> public override void Dispose() { name = null; x.Dispose(); x = null; y.Dispose(); y = null; }
public override WzImageProperty DeepClone() { WzIntProperty clone = new WzIntProperty(name, val); return(clone); }
/// <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, WzIntProperty x, WzIntProperty y) { this.name = name; this.x = x; this.y = y; }
/// <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, float x, float y) { this.name = name; this.x = new WzIntProperty(string.Empty, (int)x); this.y = new WzIntProperty(string.Empty, (int)y); }
/// <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, int x, int y) { this.name = name; this.x = new WzIntProperty(string.Empty, x); this.y = new WzIntProperty(string.Empty, y); }
public override WzImageProperty DeepClone() { WzIntProperty clone = new WzIntProperty(name, val); return clone; }
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); }
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); }
public ObjectInfo Add(Bitmap bmp, string name) { if (!IsNameValid(name)) throw new NameAlreadyUsedException(); Point origin = new Point(bmp.Width / 2, bmp.Height / 2); WzSubProperty prop = new WzSubProperty(); WzCanvasProperty canvasProp = new WzCanvasProperty(); canvasProp.PngProperty = new WzPngProperty(); canvasProp.PngProperty.SetPNG(bmp); canvasProp["origin"] = new WzVectorProperty("", new WzIntProperty("X", origin.X), new WzIntProperty("Y", origin.Y)); canvasProp["z"] = new WzIntProperty("", 0); prop["0"] = canvasProp; ObjectInfo oi = new ObjectInfo(bmp, origin, oS, l0, l1, name, prop); newObjects.Add(oi); newObjectsData.Add(name, SaveImageToBytes(bmp)); SerializeObjects(); l1prop[name] = prop; return oi; }