Beispiel #1
0
        /// <summary>
        /// Parse the database file.
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        private void LoadDatabase(TextReader reader)
        {
            itemList = new List <NamedPoint>();
            string line;

            while ((line = reader.ReadLine()) != null)
            {
                AddAndKeepSorted(NamedPoint.Parse(line));
            }
            CheckListSize();
        }
Beispiel #2
0
 private void AddAndKeepSorted(NamedPoint newItem)
 {
     // Add the newItem while keeping the list sorted
     for (int i = 0; i < itemList.Count; i++)
     {
         if (newItem.CompareTo(itemList[i]) < 0)
         {
             // The newItem is smaller, so insert it before item i
             itemList.Insert(i, newItem);
             // Found a place to put newItem, so stop processing
             return;
         }
     }
     // Didn't find a place to put newItem, so add it to the end
     if (itemList.Count < MAX_SIZE)
     {
         itemList.Add(newItem);
     }
 }
Beispiel #3
0
 public void AddItem(NamedPoint newItem)
 {
     AddAndKeepSorted(newItem);
     CheckListSize();
     SaveData();
 }
Beispiel #4
0
        /// <summary>
        /// Add a new item to the data
        /// </summary>
        /// <param name="name"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        public void AddItem(string name, int x, int y)
        {
            NamedPoint newItem = new NamedPoint(name, x, y);

            AddItem(newItem);
        }