コード例 #1
0
		public void AddCopy(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");
			BaseItem objCopy=objItem.Copy();
			objCopy.SetOwner(m_Owner);
			objCopy.GlobalItem=true;
			m_Items.Add(objCopy.Name,objCopy);
		}
コード例 #2
0
		private void AutoCategorizeItem(BaseItem item)
		{
			if(item.Category!="" && item.Name!="" && !m_DotNetBar.Items.Contains(item.Name))
				m_DotNetBar.Items.Add(item.Copy());
			foreach(BaseItem i in item.SubItems)
				AutoCategorizeItem(i);
		}
コード例 #3
0
ファイル: DNBAdapter.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// At this point, the item passed to this method has not been added to any toolbar or
		/// menu. Before doing so, we need to add it to the DNB Manager because that internally
		/// (to the DNB manager) assigns the item to its category and makes it available for
		/// customization purposes through DNB's customize dialog. But, only add an item if
		/// there is a category for the item and if the item is not a ControlContainerItem.
		/// We don't allow ControlContainerItems because it appears DotNetBar's customize
		/// dialog doesn't allow dragging new copies of ControlContainerItems to user-defined
		/// toolbars. And if they don't allow that, I don't want them in the list appearing
		/// like they should be able to be dragged to new toolbars. This means a DotNetBar
		/// manager may only have one (visible - See comments in
		/// HandleControlContainerLoadRequests) instance of application-defined toolbar items.
		/// </summary>
		/// <param name="node"></param>
		/// <param name="item"></param>
		/// <param name="isMenuItem"></param>
		/// ------------------------------------------------------------------------------------
		private void AddToCustomizationCollection(XmlNode node, BaseItem item, bool isMenuItem)
		{
			if (!(item is ButtonItem) || item.Category == null ||
				item.Category == string.Empty || m_readingContextMenuDef)
			{
				return;
			}

			string replaceItemCmdId = GetAttributeValue(node, "replacecustomizeitem");
			bool addToCustomizeList = GetBoolFromAttribute(node, "customizeitem", true);

			// Only add menu items unless a toolbar item's XML definition contains one of the
			// attributes: customizeitem or replacecustomizeitem.
			if ((!isMenuItem && replaceItemCmdId == null) || !addToCustomizeList)
				return;

			// If this item should replace another in the customization item collection,
			// find the item it should replace and get rid of it.
			if (replaceItemCmdId != null)
			{
				for (int i = 0; i < m_dnbMngr.Items.Count; i++)
				{
					if (replaceItemCmdId == (m_dnbMngr.Items[i].Tag as string))
					{
						m_dnbMngr.Items.Remove(m_dnbMngr.Items[i]);
						break;
					}
				}
			}

			BaseItem itemCopy = item.Copy();

			// Check if the text for the copy should be different from the original's.
			CommandInfo cmdInfo = GetCommandInfo(item);
			if (cmdInfo.TextAlt != null)
				itemCopy.Text = cmdInfo.TextAlt;

			// If the item already exists (for some odd reason) in the manager's collection
			// then remove it first since the manager doesn't like two items with the same name.
			if (m_dnbMngr.Items.Contains(itemCopy.Name))
				m_dnbMngr.Items.Remove(itemCopy.Name);

			m_dnbMngr.Items.Add(itemCopy);
		}