SetVisualAttribute ( RunSetVisualAttributeCommandEventArgs e, Range selectedRange, String colorColumnName, String alphaColumnName ) { Debug.Assert(e != null); Debug.Assert(selectedRange != null); Debug.Assert(ExcelUtil.WorksheetIsActive(m_oWorksheet.InnerObject)); AssertValid(); if (e.VisualAttribute == VisualAttributes.Color && colorColumnName != null) { String sColor; // Get a color from the user. if (NodeXLWorkbookUtil.TryGetColor(out sColor)) { ExcelTableUtil.SetVisibleSelectedTableColumnData( m_oTable.InnerObject, selectedRange, colorColumnName, sColor); e.VisualAttributeSet = true; } } }
AutomateFolder ( String folderToAutomate, String workbookSettings ) { Debug.Assert(!String.IsNullOrEmpty(folderToAutomate)); Debug.Assert(!String.IsNullOrEmpty(workbookSettings)); foreach (String sFileName in Directory.GetFiles(folderToAutomate, "*.xlsx")) { String sFilePath = Path.Combine(folderToAutomate, sFileName); try { if (!NodeXLWorkbookUtil.FileIsNodeXLWorkbook(sFilePath)) { continue; } } catch (IOException) { // Skip any workbooks that are already open, or that have any // other problems that prevent them from being opened. continue; } AutomateOneWorkbookIndirect(sFilePath, workbookSettings); } }
TryRemoveAllGroups ( Microsoft.Office.Interop.Excel.Workbook oWorkbook ) { Debug.Assert(oWorkbook != null); NodeXLWorkbookUtil.ClearGroupTables(oWorkbook); return(true); }
TrySelectGroupsWithSelectedVertices ( Microsoft.Office.Interop.Excel.Workbook oWorkbook, Sheet2 oVertexWorksheet, Sheet5 oGroupWorksheet ) { Debug.Assert(oWorkbook != null); Debug.Assert(oVertexWorksheet != null); Debug.Assert(oGroupWorksheet != null); // For each selected vertex, get the vertex's group name from the // group-vertex worksheet and select that group in the group worksheet. ICollection <String> oSelectedVertexNames = oVertexWorksheet.GetSelectedVertexNames(); oGroupWorksheet.SelectGroups( NodeXLWorkbookUtil.GetGroupNamesByVertexName(oWorkbook, oSelectedVertexNames)); return(true); }
OnGroupTableSelectionChange() { AssertValid(); SheetHelper oSheetHelper = m_oGroupWorksheet.SheetHelper; if (IgnoreTableSelectionChange(oSheetHelper)) { return; } // Enable the "set visual attribute" buttons in the Ribbon. m_oThisWorkbook.EnableSetVisualAttributes(); LinkedList <Int32> oVertexRowIDsToSelect = new LinkedList <Int32>(); LinkedList <String> oCollapsedGroupNamesToSelect = new LinkedList <String>(); foreach (String sSelectedGroupName in oSheetHelper.GetSelectedStringColumnValues( GroupTableColumnNames.Name)) { if (m_oTaskPane.IsCollapsedGroup(sSelectedGroupName)) { oCollapsedGroupNamesToSelect.AddLast(sSelectedGroupName); } else { foreach (Int32 iVertexIDInGroup in NodeXLWorkbookUtil.GetVertexIDsInGroup( m_oThisWorkbook.InnerObject, sSelectedGroupName)) { oVertexRowIDsToSelect.AddLast(iVertexIDInGroup); } } } m_bIgnoreSelectionEvents = true; // Select the vertices in the graph, then defer the selection of the // corresponding rows in the edge and vertex worksheets until those // worksheets are activated. m_oTaskPane.SetSelectedVerticesByRowID(oVertexRowIDsToSelect); m_bUpdateEdgeSelectionOnActivation = true; m_bUpdateVertexSelectionOnActivation = true; // Select the vertices that represent collapsed groups. This has to be // done after selecting the other vertices, because selecting the other // vertices clears the selection. foreach (String sCollapsedSelectedGroupName in oCollapsedGroupNamesToSelect) { m_oTaskPane.SelectCollapsedGroup(sCollapsedSelectedGroupName); } m_bIgnoreSelectionEvents = false; }
ImportGraph ( IGraph sourceGraph, String [] edgeAttributes, String [] vertexAttributes, Boolean clearTablesFirst, Microsoft.Office.Interop.Excel.Workbook destinationNodeXLWorkbook ) { Debug.Assert(sourceGraph != null); Debug.Assert(destinationNodeXLWorkbook != null); if (clearTablesFirst) { NodeXLWorkbookUtil.ClearAllNodeXLTables(destinationNodeXLWorkbook); } // Get the required table that contains edge data. GetEdgeTable() // throws an exception if the table is missing. EdgeWorksheetReader oEdgeWorksheetReader = new EdgeWorksheetReader(); ListObject oEdgeTable = oEdgeWorksheetReader.GetEdgeTable(destinationNodeXLWorkbook); // Get the required columns. Range oVertex1NameColumnData = null; Range oVertex2NameColumnData = null; if ( !ExcelTableUtil.TryGetTableColumnData(oEdgeTable, EdgeTableColumnNames.Vertex1Name, out oVertex1NameColumnData) || !ExcelTableUtil.TryGetTableColumnData(oEdgeTable, EdgeTableColumnNames.Vertex2Name, out oVertex2NameColumnData) ) { ErrorUtil.OnMissingColumn(); } // Import the edges and their attributes into the workbook. ImportEdges(sourceGraph, edgeAttributes, oEdgeTable, oVertex1NameColumnData, oVertex2NameColumnData, !clearTablesFirst); // Populate the vertex worksheet with the name of each unique vertex in // the edge worksheet. (new VertexWorksheetPopulator()).PopulateVertexWorksheet( destinationNodeXLWorkbook, false); // Get the table that contains vertex data. ListObject oVertexTable; Range oVertexNameColumnData = null; Range oVisibilityColumnData = null; if ( !ExcelTableUtil.TryGetTable(destinationNodeXLWorkbook, WorksheetNames.Vertices, TableNames.Vertices, out oVertexTable) || !ExcelTableUtil.TryGetTableColumnData(oVertexTable, VertexTableColumnNames.VertexName, out oVertexNameColumnData) || !ExcelTableUtil.TryGetTableColumnData(oVertexTable, CommonTableColumnNames.Visibility, out oVisibilityColumnData) ) { ErrorUtil.OnMissingColumn(); } // Import isolated vertices and the attributes for all the graph's // vertices. ImportVertices(sourceGraph, vertexAttributes, oVertexTable, oVertexNameColumnData, oVisibilityColumnData); }
AggregateGraphMetricsInternal ( AggregateGraphMetricsAsyncArgs oAggregateGraphMetricsAsyncArgs, BackgroundWorker oBackgroundWorker, DoWorkEventArgs oDoWorkEventArgs ) { Debug.Assert(oAggregateGraphMetricsAsyncArgs != null); Debug.Assert(oBackgroundWorker != null); Debug.Assert(oDoWorkEventArgs != null); AssertValid(); List <OverallMetricsInfo> oOverallMetricsInfos = new List <OverallMetricsInfo>(); OverallMetricsReader oOverallMetricsReader = new OverallMetricsReader(); foreach (String sFilePath in Directory.GetFiles( oAggregateGraphMetricsAsyncArgs.SourceFolderPath, "*.xlsx")) { if (oBackgroundWorker.CancellationPending) { oDoWorkEventArgs.Cancel = true; return; } try { if (!NodeXLWorkbookUtil.FileIsNodeXLWorkbook(sFilePath)) { continue; } } catch (IOException) { // Skip any workbooks that are already open, or that have any // other problems that prevent them from being opened. continue; } oBackgroundWorker.ReportProgress(0, String.Format( "Reading \"{0}\"." , Path.GetFileName(sFilePath) )); OverallMetricsInfo oOverallMetricsInfo; for (Int32 iAttempt = 0; iAttempt < 2; iAttempt++) { // Have overall metrics already been calculated for the // workbook? if (TryGetGraphMetricsForOneNodeXLWorkbook(sFilePath, out oOverallMetricsInfo)) { // Yes. oOverallMetricsInfos.Add(oOverallMetricsInfo); break; } if (iAttempt == 0) { // No. Calculate them. TaskAutomator.AutomateOneWorkbookIndirect(sFilePath, oAggregateGraphMetricsAsyncArgs.WorkbookSettings); } } } if (oOverallMetricsInfos.Count > 0) { WriteOverallMetricsToNewWorkbook( oAggregateGraphMetricsAsyncArgs.Workbook.Application, oOverallMetricsInfos); } oBackgroundWorker.ReportProgress(0, String.Format( "Done. NodeXL workbooks aggregated: {0}." , oOverallMetricsInfos.Count )); }