Esempio n. 1
0
		/// <summary>
		/// Adds a MenuItem to the collection.  If the ViewState is being tracked, the
		/// MenuItem's TrackViewState() method is called and the item is set to dirty, so
		/// that we don't lose any settings made prior to the Add() call.
		/// </summary>
		/// <param name="item">The MenuItem to add to the collection</param>
		/// <returns>The ordinal position of the added item.</returns>
		public virtual int Add(MenuItem item)
		{
			int result = menuItems.Add(item);

			return result;
		}
Esempio n. 2
0
		/// <summary>
		/// Iterate through the object array passed in.  For each element in the object array
		/// passed-in, a new MenuItem instance is created, added to the collection, and populated
		/// by calling LoadViewState().
		/// </summary>
		/// <param name="savedState">The object array returned by the SaveViewState() method in
		/// the previous page visit.</param>
		void IStateManager.LoadViewState(object savedState)
		{
			if (savedState != null)
			{
				object [] state = (object[]) savedState;

				// Create an ArrayList of the precise size
				menuItems = new ArrayList(state.Length);

				for (int i = 0; i < state.Length; i++)
				{
					MenuItem mi = new MenuItem();		// create MenuItem
					((IStateManager) mi).TrackViewState();	// Indicate that it needs to track its view state

					// Add the MenuItem to the collection
					menuItems.Add(mi);

					if (state[i] != null)
					{
						// Load its state via LoadViewState()
						((IStateManager) menuItems[i]).LoadViewState(state[i]);
					}
				}
			}
		}
Esempio n. 3
0
		/// <summary>
		/// Removes a specified MenuItem from the collection.
		/// </summary>
		/// <param name="item">The MenuItem instance to remove.</param>
		public void Remove(MenuItem item)
		{
			menuItems.Remove(item);
		}
Esempio n. 4
0
		/// <summary>
		/// Inserts a MenuItem instance at a particular location in the collection.
		/// </summary>
		/// <param name="index">The ordinal location to insert the item.</param>
		/// <param name="item">The MenuItem to insert.</param>
		public virtual void Insert(int index, MenuItem item)
		{
			menuItems.Insert(index, item);
		}
Esempio n. 5
0
		/// <summary>
		/// Returns the ordinal index of a MenuItem, if it exists; if the item does not exist,
		/// -1 is returned.
		/// </summary>
		/// <param name="item">The MenuItem to search for.</param>
		/// <returns>The ordinal position of the item in the collection.</returns>
		public virtual int IndexOf(MenuItem item)
		{
			return menuItems.IndexOf(item);
		}
Esempio n. 6
0
		/// <summary>
		/// Determines if a particular MenuItem exists within the collection.
		/// </summary>
		/// <param name="item">The MenuItem instance to check for.</param>
		/// <returns>A Boolean - true if the MenuItem is in the collection, false otherwise.</returns>
		public virtual bool Contains(MenuItem item)
		{
			return menuItems.Contains(item);
		}