/// <summary>
 /// Removes an item from the selected items collection.
 /// </summary>
 /// <param name="item">The item to be removed.</param>
 public void Remove(UiElementInfo item) {
    if(_items.Contains(item)) {
       _items.Remove(item);
       if(CollectionChanged != null) {
          CollectionChanged(this, new EventArgs());
       }
    }
 }
예제 #2
0
 protected override void RegisterForContextMenu(List<Command> contextCommands, 
    UiElementInfo info) {
    if(   info.IsAssemblyItem
       || info.IsFixtureItem
       || info.IsMethodItem) {
       contextCommands.Add(this);
    }
 }
 /// <summary>
 /// Adds an item to the selected items collection.
 /// </summary>
 /// <param name="item">The item to add.</param>
 public void Add(UiElementInfo item) {
    if(   item != null
       && !_items.Contains(item) ) {
       _items.Add(item);
       if(CollectionChanged != null) {
          CollectionChanged(this, new EventArgs());
       }
    }
 }
예제 #4
0
 /// <summary>
 /// Removes an item from the selected items collection.
 /// </summary>
 /// <param name="item">The item to be removed.</param>
 public void Remove(UiElementInfo item)
 {
     if (_items.Contains(item))
     {
         _items.Remove(item);
         if (CollectionChanged != null)
         {
             CollectionChanged(this, new EventArgs());
         }
     }
 }
예제 #5
0
 /// <summary>
 /// Adds an item to the selected items collection.
 /// </summary>
 /// <param name="item">The item to add.</param>
 public void Add(UiElementInfo item)
 {
     if (item != null &&
         !_items.Contains(item))
     {
         _items.Add(item);
         if (CollectionChanged != null)
         {
             CollectionChanged(this, new EventArgs());
         }
     }
 }
예제 #6
0
      /// <summary>
      /// Fills the context menu.
      /// </summary>
      /// <param name="menu">The context menu to be filled.</param>
      /// <param name="type">The type the commands should operate on.</param>
      /// <remarks>The menu items for a context menu have to be created each
      /// time when a context menu is about to be displayed. When the context
      /// menu is destroyed all menu items it it are destroyed with it. 
      /// Therefore it's not possible to reuse the menu item that is created
      /// during startup for the main menu. [20Mar2006, ml]</remarks>
      public static void FillContextMenu(ContextMenu menu, UiElementInfo info) {
         // Phase 1: collect all commands interested in 'info'
         List<Command> contextCommands = new List<Command>();
         foreach(Command command in _commands) {
            command.RegisterForContextMenu(contextCommands, info);
         }

         contextCommands.Sort(delegate(Command cmd1, Command cmd2) {
            return cmd1.ContextMenuPosition.CompareTo(cmd2.ContextMenuPosition);
         });

         // Phase 2: create menu items for each interested command
         foreach(Command command in contextCommands) {
            if(command._insertLeadingSeparator) {
               menu.MenuItems.Add(new MenuItem("-"));
            }
            menu.MenuItems.Add(CreateMenuItemFor(command));
            menu.Popup += new EventHandler(command.OnUiUpdate);
         }
      }
예제 #7
0
 protected override void RegisterForContextMenu(List<Command> contextCommands,
    UiElementInfo info) {
    contextCommands.Add(this);
 }
예제 #8
0
 /// <summary>
 /// Determines if the given item exists in this collection or not.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Contains(UiElementInfo item)
 {
     return(_items.Contains(item));
 }
 /// <summary>
 /// Determines if the given item exists in this collection or not.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Contains(UiElementInfo item) {
    return _items.Contains(item);
 }
예제 #10
0
 public CsUnitControlEventArgs(ContextMenuStrip menu, UiElementInfo elementInfo)
 {
     _menu        = menu;
     _elementInfo = elementInfo;
 }
예제 #11
0
 public CsUnitControlEventArgs(ContextMenuStrip menu, UiElementInfo elementInfo) {
    _menu = menu;
    _elementInfo = elementInfo;
 }
예제 #12
0
 /// <summary>
 /// When implemented by a command, it can determine whether it wants its
 /// menu item to appear in a context menu depending on the UiElementInfo.
 /// </summary>
 /// <param name="contextCommands">A list to which the command can add itself.</param>
 /// <param name="info">Information about the element the user is pointing to.</param>
 /// <remarks>The default implementation does nothing.</remarks>
 protected virtual void RegisterForContextMenu(List<Command> contextCommands,
    UiElementInfo info) {
 }