Esempio n. 1
0
        public void AddExample(Gesture p)
        {
            bool success = true;

            try
            {
                // first, ensure that p's name is right
                string name = ParseName(p.Name);
                if (name != _name)
                {
                    throw new ArgumentException("Prototype name does not equal the name of the category to which it was added.");
                }

                // second, ensure that it doesn't already exist
                for (int i = 0; i < prototypes.Count; i++)
                {
                    if (p.FullName() == prototypes[i].FullName())
                    {
                        throw new ArgumentException("Prototype name was added more than once to its category.");
                    }
                }
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
                success = false;
            }
            if (success)
            {
                prototypes.Add(p);
            }
        }