示例#1
0
        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)))
                    {
                        throw null;
                    }
                    Coordinates3DUnbound p = new Coordinates3DUnbound(true, tmpx, tmpy, tmpz, false);
                    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 Position");
            }

            return(base.ConvertFrom(context, info, value));
        }
示例#2
0
        //CONSTRUCTOR
        public MapObjectNameless(int?nposX = null, int posY = 0, int posZ = 0, string type = "")
        {
            int posX = nposX ?? Space.MaxX;

            _type = MapObjectNamelessType.nothing;
            TypeToString_Display = type;
            _coordinatesStart    = new Coordinates3DUnbound(true, posX, posY, posZ, true);
            _coordinatesEnd      = this._coordinatesStart;
            _count   = 1;
            Imported = false;
        }
示例#3
0
 public override object ConvertTo(
     ITypeDescriptorContext context,
     CultureInfo culture,
     object value,
     Type destType)
 {
     if (destType == typeof(string) && value is Coordinates3DUnbound)
     {
         Coordinates3DUnbound p = (Coordinates3DUnbound)value;
         // simply build the string as "Last, First (Age)"
         return(p.X.ToString() + ", " + p.Y.ToString() + ", " + p.Z.ToString());
     }
     return(base.ConvertTo(context, culture, value, destType));
 }
示例#4
0
 //COPIER
 public void Copy(bool excludeStartCoordinate, MapObjectNameless source)
 {
     if (source == null)
     {
         return;
     }
     if (!excludeStartCoordinate)
     {
         this._coordinatesStart = source._coordinatesStart;
     }
     this._coordinatesEnd = this._coordinatesStart + source._coordinatesEnd - source._coordinatesStart;
     this._aEnd           = source._aEnd;
     this._aStart         = source._aStart;
     this._count          = source._count;
     this._radius         = source._radius;
     this._randomRange    = source._randomRange;
     this._randomSeed     = source._randomSeed;
     if (this._type == MapObjectNamelessType.nothing)
     {
         this._type = source._type;
     }
 }
示例#5
0
        //FROM XML
        public void FromXml(XmlNode item)
        {
            bool end_C_specified = false;
            bool end_A_specified = false;

            foreach (XmlAttribute att in item.Attributes)
            {
                switch (att.Name)
                {
                case "startX":
                    _coordinatesStart.X = Helper.StringToDouble(att.Value);
                    break;

                case "startY":
                    _coordinatesStart.Y = Helper.StringToDouble(att.Value);
                    break;

                case "startZ":
                    _coordinatesStart.Z = Helper.StringToDouble(att.Value);
                    break;

                case "endX":
                    _coordinatesEnd.X = Helper.StringToDouble(att.Value);
                    end_C_specified   = true;
                    break;

                case "endY":
                    _coordinatesEnd.Y = Helper.StringToDouble(att.Value);
                    end_C_specified   = true;
                    break;

                case "endZ":
                    _coordinatesEnd.Z = Helper.StringToDouble(att.Value);
                    end_C_specified   = true;
                    break;

                case "startAngle":
                    A_Start_deg = Helper.StringToDouble(att.Value);
                    break;

                case "endAngle":
                    A_End_deg       = Helper.StringToDouble(att.Value);
                    end_A_specified = true;
                    break;

                case "randomSeed":
                    _randomSeed = Helper.StringToInt(att.Value);
                    break;

                case "count":
                    _count = Helper.StringToInt(att.Value);
                    break;

                case "radius":
                    _radius = Helper.StringToInt(att.Value);
                    break;

                case "randomRange":
                    _randomRange = Helper.StringToInt(att.Value);
                    break;
                }
            }
            if (!end_A_specified)
            {
                _aEnd = _aStart;
            }
            if (!end_C_specified)
            {
                _coordinatesEnd = _coordinatesStart;
            }
        }