Exemplo n.º 1
0
		public int Add(BaseItem item)
		{
			item.SetOwner(m_Owner);
			item.Visible=false;
			item.Displayed=false;
			return List.Add(item);
		}
Exemplo n.º 2
0
		public void Add(BaseItem objItem)
		{
			if(objItem==null)
				throw new System.ArgumentNullException("Item must be valid value");
			if(objItem.Name==null || objItem.Name=="")
			{
				// Auto assign item name
				objItem.Name="item_"+objItem.Id.ToString();
			}
			if(m_Items.ContainsKey(objItem.Name))
			{
				throw new System.InvalidOperationException("Item with this name already exists");
			}
			
			if(objItem.Parent!=null)
				throw new System.InvalidOperationException("Item already has a Parent. Remove item from Parent first.");
				
			objItem.SetOwner(m_Owner);
			objItem.GlobalItem=true;

			m_Items.Add(objItem.Name,objItem);
		}
Exemplo n.º 3
0
		public void Remove(BaseItem objItemToRemove)
		{
			if(m_Items.ContainsKey(objItemToRemove.Name))
			{
				m_Items.Remove(objItemToRemove.Name);
				objItemToRemove.SetOwner(null);
				((IOwner)m_Owner).RemoveShortcutsFromItem(objItemToRemove);
				//objItemToRemove.GlobalItem=false;
				return;
			}
			
			string sItemName=objItemToRemove.Name;
			foreach(DictionaryEntry o in m_Items)
			{
				BaseItem objItem=o.Value as BaseItem;
				// Name out of sync case
				if(objItem==objItemToRemove)
				{
					m_Items.RemoveAt(m_Items.IndexOfValue(objItem));
					objItemToRemove.SetOwner(null);
					((IOwner)m_Owner).RemoveShortcutsFromItem(objItemToRemove);
                    return;
				}
				if(objItem.SubItems.Count>0)
				{
					if(RemoveItem(sItemName,objItem))
					{
						//objItemToRemove.GlobalItem=false;
						return;
					}
				}
			}

			// This will throw exception...
			m_Items.Remove(objItemToRemove.Name);
			objItemToRemove.SetOwner(null);
		}