Creates a button whose font can specified independent of any other ButtonItems.
Inheritance: DevComponents.DotNetBar.ButtonItem
コード例 #1
0
ファイル: DNBAdapter.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds a new menu item to a context menu specified by contextMenuName and inserts it
		/// before the item specified by insertBeforeItem. If insertBeforeItem is null, then
		/// the new menu item is added to the end of parentItemName's menu collection. This
		/// overload allows new menu items to be added as submenus to menus at the top level
		/// of the context menu. The parentMenuName can be the name of a menu item at any
		/// level within the hierarchy of the menus on the context menu.
		/// </summary>
		/// <param name="itemProps">Properties of the new menu item.</param>
		/// <param name="contextMenuName">Name of the context menu to which the item is added.
		/// </param>
		/// <param name="parentMenuName">Name of the menu item in the context menu under which
		/// the new item is added.</param>
		/// <param name="insertBeforeItem">Name of the context menu item before which the new
		/// menu item will be added.</param>
		/// ------------------------------------------------------------------------------------
		public void AddContextMenuItem(TMItemProperties itemProps, string contextMenuName,
			string parentMenuName, string insertBeforeItem)
		{
			ButtonItem contextMenu = null;

			// First, make sure we can find the context menu to which the item will be added.
			int i = m_dnbMngr.ContextMenus.IndexOf(contextMenuName);
			if (i >= 0)
				contextMenu = m_dnbMngr.ContextMenus[i] as ButtonItem;

			if (i < 0 || contextMenu == null)
				return;

			SilButtonItem item = new SilButtonItem();
			item.Name = itemProps.Name;
			itemProps.Update = true;
			SetItemProps(item, itemProps);

			// Get the menu under which the new menu item will be added.
			ButtonItem parentMenu = FindSubMenu(contextMenu, parentMenuName);
			Debug.Assert(parentMenu != null);
			if (parentMenu == null)
				return;

			// If an item to insert before isn't specified, then add the item to the item to the
			// parent item specified. Otherwise, insert before "insertBeforeItem".
			if (insertBeforeItem == null || insertBeforeItem.Trim() == string.Empty)
				parentMenu.SubItems.Add(item);
			else
			{
				i = parentMenu.SubItems.IndexOf(insertBeforeItem);
				if (i >= 0)
					parentMenu.SubItems.Insert(i, item);
			}
		}
コード例 #2
0
ファイル: DNBAdapter.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds a new submenu item to the menu specified by parentItemName and inserts it
		/// before the item specified by insertBeforeItem. If insertBeforeItem is null, then
		/// the new submenu item is added to the end of parentItemName's menu collection.
		/// </summary>
		/// <param name="itemProps">Properties of the new menu item.</param>
		/// <param name="parentItemName">Name of the menu item that will be added to.</param>
		/// <param name="insertBeforeItem">Name of the submenu item before which the new
		/// menu item will be added.</param>
		/// ------------------------------------------------------------------------------------
		public void AddMenuItem(TMItemProperties itemProps, string parentItemName, string insertBeforeItem)
		{
			SilButtonItem item = new SilButtonItem();
			item.Name = itemProps.Name;
			itemProps.Update = true;
			SetItemProps(item, itemProps);

			// If an item to insert before isn't specified, then add the item to the item to the
			// parent item specified. Otherwise, insert before "insertBeforeItem".
			if (insertBeforeItem == null || insertBeforeItem.Trim() == string.Empty)
				AddMenuItem(item, parentItemName);
			else
				InsertMenuItem(item, insertBeforeItem, false);
		}
コード例 #3
0
ファイル: DNBAdapter.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="itemProps"></param>
		/// ------------------------------------------------------------------------------------
		private void BuildWindowList()
		{
			string message = GetItemsCommandMessage(m_windowListItem);
			if (message == string.Empty || m_msgMediator == null)
				return;

			// Call the update handler in order to get back the list of window items.
			TMItemProperties itemProps = GetItemProps(m_windowListItem);
			WindowListInfo wndListInfo = new WindowListInfo();
			wndListInfo.WindowListItemProperties = itemProps;

			if (!m_msgMediator.SendMessage("Update" + message, wndListInfo))
				return;

			if (wndListInfo == null || wndListInfo.WindowListItemProperties == null)
				return;

			ButtonItem wndListParent = m_windowListItem.Parent as ButtonItem;
			if (wndListParent == null)
				return;

			ArrayList wndList = wndListInfo.WindowListItemProperties.List;
			if (wndList == null || wndList.Count == 0 || !wndListInfo.WindowListItemProperties.Update)
				return;

			// The window list only allows up to 10 items (i.e. 0 - 9) so make the
			// "More Windows..." option visible when there are more than 10.
			m_moreWindowItem.Visible = (wndList.Count > 10);

			m_htWndListIndices = new Hashtable();

			// Add the first window list item.
			string text = wndList[0] as string;
			if (text != null)
			{
				m_htWndListIndices[m_windowListItem] = 0;
				m_windowListItem.Text = "&1 " + text;
				m_windowListItem.Checked = (wndListInfo.CheckedItemIndex == 0);
			}

			// Get the index of the first item in the window list.
			int wndListIndex = wndListParent.SubItems.IndexOf(m_windowListItem);

			// Add the rest of the window list items, up to 9 more.
			for (int i = 1; i < wndList.Count && i < 10; i++)
			{
				text = wndList[i] as string;
				if (text != null)
				{
					SilButtonItem newItem = new SilButtonItem(m_windowListItem.Name + i,
						"&" + (i + 1).ToString() + " " + text);
					m_htWndListIndices[newItem] = i;
					newItem.Tag = m_windowListItem.Tag;
					newItem.Checked = (wndListInfo.CheckedItemIndex == i);
					wndListParent.SubItems.Add(newItem, wndListIndex + i);
				}
			}
		}
コード例 #4
0
ファイル: DNBAdapter.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void BuildToolbarList()
		{
			TMBarProperties[] barProps = BarInfoForViewMenu;

			// The only subitem on the toolbar menu should be a customize item. Therefore,
			// when adding the items for each of the toolbars, we start at the end of the
			// list and keep inserting items at the beginning.
			for (int i = barProps.Length - 1; i >= 0; i--)
			{
				SilButtonItem item = new SilButtonItem();
				item.Name = barProps[i].Name + kToolbarItemSuffix;
				item.Text = barProps[i].Text;
				item.Checked = barProps[i].Visible;
				item.Tag = m_toolbarListItem.Tag;
				m_toolbarListItem.SubItems.Add(item, 0);
			}
		}
コード例 #5
0
ファイル: DNBAdapter.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets a toolbar item with the specified name. If the item exists, then return the
		/// one found in the DNB manager. Otherwise, create a new one.
		/// </summary>
		/// <param name="node"></param>
		/// <param name="name"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		protected BaseItem GetToolbarItem(XmlNode node, string name)
		{
			BaseItem item;

			if (m_barReadFromSettingFile)
			{
				item = m_dnbMngr.GetItem(name, true);
				if (item != null)
					return item;
			}

			int type = GetIntFromAttribute(node, "type", 0);

			// Get nasty if the type in the XML definition is bad.
			if (type < 0 || type > 5)
				throw new Exception(type.ToString() + " is an invalid toolbar item type.");

			switch (type)
			{
				case 4:
					item = new ComboBoxItem(name);
					ComboBoxItem cboItem = item as ComboBoxItem;
					cboItem.ComboWidth = GetIntFromAttribute(node, "width", 25);

					bool ownerDraw = GetBoolFromAttribute(node, "dnboverridedrawing");
					cboItem.ComboBoxEx.DisableInternalDrawing = ownerDraw;

					// Setting the height to 1 will will force height to minimum (but it won't be 1).
					cboItem.ItemHeight = (!ownerDraw ? 1 : cboItem.ComboBoxEx.Font.Height + 1);
					break;

				case 5:
					item = new ControlContainerItem(name);
					item.CanCustomize = false;
					break;

				default:
					// The rest of the types are Button types with various ways of dealing
					// with items that have a popup component.
					item = new SilButtonItem(name);
				switch (type)
				{
					case 1: ((ButtonItem)item).PopupType = ePopupType.ToolBar; break;
					case 2:	((ButtonItem)item).PopupType = ePopupType.Menu;	break;
					case 3: ((ButtonItem)item).PopupType = ePopupType.Container; break;
				}

					break;
			}

			return item;
		}
コード例 #6
0
ファイル: DNBAdapter.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Builds all context menus, adding them to the DNB manager's list of context menus.
		/// </summary>
		/// <param name="node"></param>
		/// ------------------------------------------------------------------------------------
		private void ReadContextMenus(XmlNode node)
		{
			m_dnbMngr.ContextMenus.Clear();

			m_readingContextMenuDef = true;

			while (node != null)
			{
				string name = GetAttributeValue(node, "name");
				if (name != null)
				{
					SilButtonItem cmnu = new SilButtonItem(name);
					ReadMenuItems(node.FirstChild, cmnu, true);
					if (cmnu.SubItems.Count > 0)
					{
						// Make sure that if a command has different text for
						// context menus then we account for it.
						foreach (ButtonItem subItem in cmnu.SubItems)
						{
							CommandInfo cmndInfo = GetCommandInfo(subItem);
							if (cmndInfo != null && cmndInfo.ContextMenuText != null)
								subItem.Text = cmndInfo.ContextMenuText;
						}

						m_dnbMngr.ContextMenus.Add(cmnu);
					}
				}

				node = ReadOverJunk(node.NextSibling);
			}

			m_readingContextMenuDef = false;
		}