public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo info, object value) { if (value is string) { try { string tmp = (string)value; int tmpx, tmpy, tmpz; tmp = tmp.Replace(" ", ""); string[] coords = tmp.Split(','); if (coords.Count() != 3) { throw null; } if (!(Helper.IntTryParse(coords[0], out tmpx) && Helper.IntTryParse(coords[1], out tmpy) && Helper.IntTryParse(coords[2], out tmpz) && (tmpz == 1 || tmpz == 0))) { throw null; } FakeShields p = new FakeShields(true); p.Front = tmpx; p.Rear = tmpy; p.hasFrequency = tmpz == 1; return(p); } catch { } // if we got this far, complain that we // couldn't parse the string // throw new ArgumentException("Can not convert '" + (string)value + "' to FakeShields"); } return(base.ConvertFrom(context, info, value)); }
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destType) { if (destType == typeof(string) && value is FakeShields) { FakeShields p = (FakeShields)value; return(p.Front.ToString() + ", " + p.Rear.ToString() + ", " + (p.hasFrequency ? "1" : "0")); } return(base.ConvertTo(context, culture, value, destType)); }
//COPIER public override void Copy(bool excludeCoordinates, params MapObjectNamed[] source) { bool same, found; if (source.Count() == 0) return; //meshFileName string tmp1 = ""; same = true; found = false; foreach (MapObjectNamed item in source) if (item.IsPropertyAvailable("meshFileName")) if (!found) { found = true; tmp1 = ((MapObjectNamed_genericMesh)item)._meshFileName; } else same = same && (((MapObjectNamed_genericMesh)item)._meshFileName != tmp1); if (found && same) this._meshFileName = tmp1; //textureFileName string tmp2 = ""; same = true; found = false; foreach (MapObjectNamed item in source) if (item.IsPropertyAvailable("textureFileName")) if (!found) { found = true; tmp2 = ((MapObjectNamed_genericMesh)item)._textureFileName; } else same = same && (((MapObjectNamed_genericMesh)item)._textureFileName != tmp2); if (found && same) this._textureFileName = tmp2; //hullRace string tmp5 = ""; same = true; found = false; foreach (MapObjectNamed item in source) if (item.IsPropertyAvailable("hullRace")) if (!found) { found = true; tmp5 = ((MapObjectNamed_genericMesh)item)._hullRace; } else same = same && (((MapObjectNamed_genericMesh)item)._hullRace != tmp5); if (found && same) this._hullRace = tmp5; //hullType string tmp6 = ""; same = true; found = false; foreach (MapObjectNamed item in source) if (item.IsPropertyAvailable("hullType")) if (!found) { found = true; tmp6 = ((MapObjectNamed_genericMesh)item)._hullType; } else same = same && (((MapObjectNamed_genericMesh)item)._hullType != tmp6); if (found && same) this._hullType = tmp6; //fakeShields FakeShields tmp3 = new FakeShields(true); same = true; found = false; foreach (MapObjectNamed item in source) if (item.IsPropertyAvailable("fakeShields")) if (!found) { found = true; tmp3 = ((MapObjectNamed_genericMesh)item)._fakeShields; } else same = same && (((MapObjectNamed_genericMesh)item)._fakeShields != tmp3); if (found && same) this._fakeShields = tmp3; //Color Color tmp4 = new Color(); same = true; found = false; foreach (MapObjectNamed item in source) if (item.IsPropertyAvailable("color")) if (!found) { found = true; tmp4 = ((MapObjectNamed_genericMesh)item)._color; } else same = same && (((MapObjectNamed_genericMesh)item)._color != tmp4); if (found && same) this._color = tmp4; base.Copy(excludeCoordinates, source); }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo info, object value) { if (value is string) { try { string tmp = (string)value; int tmpx, tmpy, tmpz; tmp = tmp.Replace(" ", ""); string[] coords = tmp.Split(','); if (coords.Count() != 3) throw null; if (!(Helper.IntTryParse(coords[0], out tmpx) && Helper.IntTryParse(coords[1], out tmpy) && Helper.IntTryParse(coords[2], out tmpz)&& (tmpz==1||tmpz==0))) throw null; FakeShields p = new FakeShields(true); p.Front = tmpx; p.Rear = tmpy; p.hasFrequency = tmpz==1; return p; } catch { } // if we got this far, complain that we // couldn't parse the string // throw new ArgumentException("Can not convert '" + (string)value + "' to FakeShields"); } return base.ConvertFrom(context, info, value); }
//CONSTRUCTOR public MapObjectNamed_genericMesh(int posX = 0, int posY = 0, int posZ = 0, bool makeSelected = false, int angle = 0, string name = "", string _hull_Race = "", string _hull_Type="") : base(posX, posY, posZ, makeSelected, angle, name) { this._meshFileName = ""; this._textureFileName = ""; this._hullRace = _hull_Race; this._hullType = _hull_Type; this._fakeShields = new FakeShields(true); this._color = Color.FromArgb(255,0,255); }