private void OnAddComponent( ComponentUiElement element, ComponentTypeUiElement addTypeElement )
 {
     //	TODO: AP: Switch to factory pattern
     object component = Activator.CreateInstance( addTypeElement.ComponentType );
     m_Aggregator.Add( element.Component, component );
     m_View.AddComponent( element, m_UiFactory.GetElement( element, component ) );
 }
 private void OnEditComponent( ComponentUiElement element )
 {
     Type[] allowedComponentTypes = m_Dependencies.GetAllowedComponentTypes( element.Component.GetType( ) );
     ComponentTypeUiElement[] allowedComponentTypeUiElements = new ComponentTypeUiElement[ allowedComponentTypes.Length ];
     for ( int i = 0; i < allowedComponentTypes.Length; ++i )
     {
         allowedComponentTypeUiElements[ i ] = m_UiFactory.GetTypeElement( allowedComponentTypes[ i ] );
     }
     m_View.ShowEditOptions( element, allowedComponentTypeUiElements );
 }
 /// <summary>
 /// Shows options for editing an element
 /// </summary>
 public void ShowEditOptions( ComponentUiElement component, ComponentTypeUiElement[] addTypes )
 {
     ContextMenuStrip strip = new ContextMenuStrip( );
     ToolStripMenuItem addSubMenu = ( ToolStripMenuItem )strip.Items.Add( "Add" );
     foreach ( ComponentTypeUiElement typeElement in addTypes )
     {
         ComponentTypeUiElement curTypeElement = typeElement;
         ToolStripItem addItem = addSubMenu.DropDownItems.Add( typeElement.Name, typeElement.Image );
         addItem.Click += delegate { AddToComponent( component, curTypeElement ); };
     }
     ToolStripItem removeItem = strip.Items.Add( "Remove" );
     removeItem.Click += delegate { RemoveSelectedComponent( component ); };
     strip.Show( this, m_LastClickLocation );
 }