Ejemplo n.º 1
0
 /// <summary>
 /// Removes the menu item at the specified index from this menu. </summary>
 /// <param name="index"> the position of the item to be removed. </param>
 public virtual void Remove(int index)
 {
     lock (TreeLock)
     {
         MenuItem mi = GetItem(index);
         Items.RemoveAt(index);
         MenuPeer peer = (MenuPeer)this.Peer_Renamed;
         if (peer != null)
         {
             mi.RemoveNotify();
             mi.Parent_Renamed = null;
             peer.DelItem(index);
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds the specified menu item to this menu. If the
 /// menu item has been part of another menu, removes it
 /// from that menu.
 /// </summary>
 /// <param name="mi">   the menu item to be added </param>
 /// <returns>      the menu item added </returns>
 /// <seealso cref=         java.awt.Menu#insert(java.lang.String, int) </seealso>
 /// <seealso cref=         java.awt.Menu#insert(java.awt.MenuItem, int) </seealso>
 public virtual MenuItem Add(MenuItem mi)
 {
     lock (TreeLock)
     {
         if (mi.Parent_Renamed != null)
         {
             mi.Parent_Renamed.remove(mi);
         }
         Items.Add(mi);
         mi.Parent_Renamed = this;
         MenuPeer peer = (MenuPeer)this.Peer_Renamed;
         if (peer != null)
         {
             mi.AddNotify();
             peer.AddItem(mi);
         }
         return(mi);
     }
 }