示例#1
0
 public bool Modify(Travel hTravel, int iIndex = -1)
 {
     if (iIndex == -1)
     {
         this._hTravelList.Add(hTravel);
         return(true);
     }
     if (iIndex < 0 || iIndex >= this._hTravelList.Count)
     {
         return(false);
     }
     if (hTravel == null)
     {
         this._hTravelList.RemoveAt(iIndex);
     }
     else
     {
         this._hTravelList.Insert(iIndex, hTravel);
     }
     return(true);
 }
示例#2
0
        protected bool _Open(string zFile)
        {
            List <Travel> list      = this._hTravelList;
            bool          lockTaken = false;

            try
            {
                Monitor.Enter((object)list, ref lockTaken);
                this._hTravelList.Clear();
                try
                {
                    XmlTextReader xmlTextReader = new XmlTextReader(zFile);
                    this._hTravelDocument = new XmlDocument();
                    this._hTravelDocument.Load((XmlReader)xmlTextReader);
                    XmlElement documentElement = this._hTravelDocument.DocumentElement;
                    this._bReverse  = documentElement.HasAttribute("Reverse") && documentElement.GetAttribute("Reverse").Equals("True", StringComparison.InvariantCultureIgnoreCase);
                    this._iCurrent  = 0;
                    this._hPrevious = (Travel)null;
                    for (int index = 0; index < documentElement.ChildNodes.Count; ++index)
                    {
                        XmlElement hElement = (XmlElement)documentElement.ChildNodes[index];
                        this._hTravelList.Add(new Travel(this._GetElement(hElement, "Name"), new Vector3D(float.Parse(this._GetElement(hElement, "X"), (IFormatProvider)CultureInfo.InvariantCulture), float.Parse(this._GetElement(hElement, "Y"), (IFormatProvider)CultureInfo.InvariantCulture), float.Parse(this._GetElement(hElement, "Z"), (IFormatProvider)CultureInfo.InvariantCulture)), bool.Parse(this._GetElement(hElement, "Flying")), this._GetElement(hElement, "Type"), this._GetElement(hElement, "Param")));
                    }
                    xmlTextReader.Close();
                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
            finally
            {
                if (lockTaken)
                {
                    Monitor.Exit((object)list);
                }
            }
        }
示例#3
0
 public Travel GetNext()
 {
     if (this._hTravelList.Count == 0)
     {
         return((Travel)null);
     }
     this._hPrevious = this._hTravelList[this._iCurrent];
     if (this._bBackward)
     {
         if (this._iCurrent == 1)
         {
             this._bBackward = false;
         }
         this._iCurrent = this._iCurrent - 1;
     }
     else if (this._iCurrent == this._hTravelList.Count - 1)
     {
         if (this._bReverse)
         {
             this._iCurrent  = this._iCurrent - 1;
             this._bBackward = true;
         }
         else
         {
             this._iCurrent = 0;
         }
     }
     else
     {
         this._iCurrent = this._iCurrent + 1;
     }
     if (this._iCurrent == -1)
     {
         this._iCurrent = 0;
     }
     return(this._hTravelList[this._iCurrent]);
 }