WorksheetContextMenuManager_RequestVertexCommandEnable ( Object sender, RequestVertexCommandEnableEventArgs e ) { AssertValid(); // Get the vertex corresponding to the row the user right-clicked in // the vertex worksheet. This can be null. IVertex oClickedVertex = WorksheetContextMenuManagerRowIDToVertex(e.VertexRowID); Boolean bEnableSelectAllVertices, bEnableDeselectAllVertices, bEnableSelectAdjacentVertices, bEnableDeselectAdjacentVertices, bEnableSelectIncidentEdges, bEnableDeselectIncidentEdges, bEnableEditVertexAttributes, bEnableSelectSubgraphs; GetVertexCommandEnableFlags(oClickedVertex, out bEnableSelectAllVertices, out bEnableDeselectAllVertices, out bEnableSelectAdjacentVertices, out bEnableDeselectAdjacentVertices, out bEnableSelectIncidentEdges, out bEnableDeselectIncidentEdges, out bEnableEditVertexAttributes, out bEnableSelectSubgraphs ); e.EnableSelectAllVertices = bEnableSelectAllVertices; e.EnableDeselectAllVertices = bEnableDeselectAllVertices; e.EnableSelectAdjacentVertices = bEnableSelectAdjacentVertices; e.EnableDeselectAdjacentVertices = bEnableDeselectAdjacentVertices; e.EnableSelectIncidentEdges = bEnableSelectIncidentEdges; e.EnableDeselectIncidentEdges = bEnableDeselectIncidentEdges; e.EnableEditVertexAttributes = bEnableEditVertexAttributes; e.EnableSelectSubgraphs = bEnableSelectSubgraphs; }
AddVertexContextMenuItems ( Microsoft.Office.Interop.Excel.Range oClickedRange ) { Debug.Assert(oClickedRange != null); AssertValid(); Int32 iClickedVertexID; CommandBarPopup oTopLevelPopup; // Add a top-level NodeXL popup menu item. PrepareToAddChildMenuItems(oClickedRange, m_oVertexTable, CommonTableColumnNames.ID, out iClickedVertexID, out oTopLevelPopup); // Add child menu items. CommandBarButton oSelectAllVerticesButton = AddContextMenuItem( oTopLevelPopup, "Select &All Vertices", iClickedVertexID, new _CommandBarButtonEvents_ClickEventHandler( oSelectAllVerticesButton_Click) ); CommandBarButton oDeselectAllVerticesButton = AddContextMenuItem( oTopLevelPopup, "&Deselect All Vertices", iClickedVertexID, new _CommandBarButtonEvents_ClickEventHandler( oDeselectAllVerticesButton_Click) ); CommandBarButton oSelectAdjacentVerticesOfVertexButton = AddContextMenuItem(oTopLevelPopup, "Select Ad&jacent Vertices", iClickedVertexID, new _CommandBarButtonEvents_ClickEventHandler( oSelectAdjacentVerticesOfVertexButton_Click) ); CommandBarButton oDeselectAdjacentVerticesOfVertexButton = AddContextMenuItem(oTopLevelPopup, "Deselect Adjace&nt Vertices", iClickedVertexID, new _CommandBarButtonEvents_ClickEventHandler( oDeselectAdjacentVerticesOfVertexButton_Click) ); CommandBarButton oSelectIncidentEdgesButton = AddContextMenuItem( oTopLevelPopup, "Select &Incident Edges", iClickedVertexID, new _CommandBarButtonEvents_ClickEventHandler( oSelectIncidentEdgesButton_Click) ); CommandBarButton oDeselectIncidentEdgesButton = AddContextMenuItem( oTopLevelPopup, "Deselec&t Incident Edges", iClickedVertexID, new _CommandBarButtonEvents_ClickEventHandler( oDeselectIncidentEdgesButton_Click) ); CommandBarButton oSelectSubgraphsButton = AddContextMenuItem( oTopLevelPopup, "Select S&ubgraphs...", iClickedVertexID, new _CommandBarButtonEvents_ClickEventHandler( oSelectSubgraphsButton_Click) ); CommandBarButton oEditVertexAttributesButton = AddContextMenuItem( oTopLevelPopup, "&Edit Selected Vertex Properties...", iClickedVertexID, new _CommandBarButtonEvents_ClickEventHandler( oEditVertexAttributesButton_Click) ); oEditVertexAttributesButton.BeginGroup = true; // The custom menu items are disabled by default. To enable them, the // RequestVertexCommandEnable event must be handled. RequestVertexCommandEnableEventHandler oRequestVertexCommandEnable = this.RequestVertexCommandEnable; if (oRequestVertexCommandEnable == null) { return; } RequestVertexCommandEnableEventArgs oEventArgs = new RequestVertexCommandEnableEventArgs(iClickedVertexID); oRequestVertexCommandEnable(this, oEventArgs); oSelectAllVerticesButton.Enabled = oEventArgs.EnableSelectAllVertices; oDeselectAllVerticesButton.Enabled = oEventArgs.EnableDeselectAllVertices; oSelectAdjacentVerticesOfVertexButton.Enabled = oEventArgs.EnableSelectAdjacentVertices; oDeselectAdjacentVerticesOfVertexButton.Enabled = oEventArgs.EnableDeselectAdjacentVertices; oSelectIncidentEdgesButton.Enabled = oEventArgs.EnableSelectIncidentEdges; oDeselectIncidentEdgesButton.Enabled = oEventArgs.EnableDeselectIncidentEdges; oEditVertexAttributesButton.Enabled = oEventArgs.EnableEditVertexAttributes; oSelectSubgraphsButton.Enabled = oEventArgs.EnableSelectSubgraphs; // Add a "set color" menu item if the clicked range is a color cell. AddSetColorContextMenuItem(m_oVertexTable, oClickedRange, VertexTableColumnNames.Color, VertexTableColumnNames.LabelFillColor); }