/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handles the building window list.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		void HandleBuildingWindowList(object sender, CancelEventArgs e)
		{
			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;

			ToolStripMenuItem wndListParent = m_windowListItem.OwnerItem as ToolStripMenuItem;
			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 kMaxWindowListItems items (i.e. 0 - 9)
			// so make the "More Windows..." option visible when there are more.
			m_moreWindowItem.Visible = (wndList.Count > kMaxWindowListItems);

			// Before adding the window list items, first make sure
			// any old items are removed from the windows menu.
			ClearWindowListFromWindowMenu(m_windowListItem.OwnerItem as ToolStripMenuItem);

			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.DropDownItems.IndexOf(m_windowListItem);

			// Add the rest of the window list items, up to kMaxWindowListItems - 1 more.
			for (int i = 1; i < wndList.Count && i < kMaxWindowListItems; i++)
			{
				text = wndList[i] as string;
				if (text != null)
				{
					ToolStripMenuItem newItem = ToolStripItemExtender.CreateMenuItem();
					newItem.Text = "&" + (i + 1).ToString() + " " + text;
					newItem.Name = m_windowListItem.Name + i;
					m_htWndListIndices[newItem] = i;
					newItem.Tag = m_windowListItem.Tag;
					newItem.Checked = (wndListInfo.CheckedItemIndex == i);
					newItem.Click += HandleItemClicks;
					wndListParent.DropDownItems.Add(newItem);
				}
			}
		}
Exemple #2
0
		/// ------------------------------------------------------------------------------------
		/// <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);
				}
			}
		}