Exemplo n.º 1
0
        //Methods
        public virtual void Add(string key, Element value)
        {
            if (!mModifiable)
            {
                throw new CollectionNotModifiableException("This collection is not modifiable.");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value", "Element parameter cannot be null reference.");
            }
            if (key == null)
            {
                throw new ArgumentNullException("key", "Key may not be null.");
            }
            if (key == "")
            {
                throw new ArgumentException("Key may not be null string.", "key");
            }
            if (!mBaseType.IsInstanceOfType(value) && !value.GetType().IsSubclassOf(mBaseType))
            {
                throw new ArgumentException("Items added to this collection must be of or inherit from type '" + mBaseType.ToString());
            }

            //Key can be reset by removing and then readding to collection
            value.SetKey(key);
            Dictionary.Add(key, value);

            //Zordering now done outside the collection
            //Since multiple collections can contain the same reference eg layer
            OnInsert(key, value);
        }
Exemplo n.º 2
0
        public virtual Element CloneElement(Element element)
        {
            Element newElement = (Element)element.Clone();

            newElement.ActionElement = element;
            newElement.SetKey(element.Key);
            newElement.SetModel(element.Model);

            //Set the action shapes for the complex shape children
            if (element is ComplexShape)
            {
                ComplexShape complex    = (ComplexShape)element;
                ComplexShape newComplex = (ComplexShape)newElement;

                foreach (Solid solid in newComplex.Children.Values)
                {
                    solid.ActionElement = complex.Children[solid.Key];
                }
            }

            //Keep size of table
            if (element is Table)
            {
                Table table    = (Table)element;
                Table newTable = (Table)newElement;

                newTable.Size = table.Size;
            }

            return(newElement);
        }
Exemplo n.º 3
0
		//Methods
		public virtual void Add(string key, Element value )  
		{
			if (! mModifiable) throw new CollectionNotModifiableException("This collection is not modifiable.");
			if (value == null) throw new ArgumentNullException("value","Element parameter cannot be null reference.");
			if (key == null) throw new ArgumentNullException("key","Key may not be null.");
			if (key == "") throw new ArgumentException("Key may not be null string.","key");
			if (! mBaseType.IsInstanceOfType(value) && ! value.GetType().IsSubclassOf(mBaseType)) throw new ArgumentException("Items added to this collection must be of or inherit from type '" + mBaseType.ToString());

			//Key can be reset by removing and then readding to collection
			value.SetKey(key);
			Dictionary.Add(key, value );

			//Zordering now done outside the collection 
			//Since multiple collections can contain the same reference eg layer
			OnInsert(key,value);
		}