SetLocations <TLocationInfo>
(
IEnumerable <TLocationInfo> oLocationInfo,
System.Drawing.Rectangle oGraphRectangle,
TryGetRowIDAndLocation <TLocationInfo> oTryGetRowIDAndLocation,
Dictionary <Int32, Int32> oRowIDDictionary,
Range oXColumnData,
Range oYColumnData,
Object [,] aoLockedColumnValues
)
{
Debug.Assert(oLocationInfo != null);
Debug.Assert(oTryGetRowIDAndLocation != null);
Debug.Assert(oRowIDDictionary != null);
Debug.Assert(oXColumnData != null);
Debug.Assert(oYColumnData != null);
AssertValid();
Int32 iRowNumberOneBased;
Object [,] aoXValues = ExcelUtil.GetRangeValues(oXColumnData);
Object [,] aoYValues = ExcelUtil.GetRangeValues(oYColumnData);
// This is the row number of the table's first data row.
Int32 iDataBodyRangeRowOneBased = oXColumnData.Row;
// Create an object that converts a location between coordinates used
// in the NodeXL graph and coordinates used in the worksheet.
VertexLocationConverter oVertexLocationConverter =
new VertexLocationConverter(oGraphRectangle);
foreach (TLocationInfo oOneLocationInfo in oLocationInfo)
{
Int32 iRowID;
PointF oLocationToSet;
if (
!oTryGetRowIDAndLocation(oOneLocationInfo, out iRowID,
out oLocationToSet)
||
!oRowIDDictionary.TryGetValue(iRowID, out iRowNumberOneBased)
)
{
continue;
}
Int32 iRowToWriteOneBased =
iRowNumberOneBased - iDataBodyRangeRowOneBased + 1;
if (
aoLockedColumnValues != null
&&
VertexIsLocked(aoLockedColumnValues, iRowToWriteOneBased)
)
{
continue;
}
// Convert the location to workbook coordinates before writing it
// to the X and Y column cells.
Single fWorkbookX, fWorkbookY;
oVertexLocationConverter.GraphToWorkbook(oLocationToSet,
out fWorkbookX, out fWorkbookY);
aoXValues[iRowToWriteOneBased, 1] = fWorkbookX;
aoYValues[iRowToWriteOneBased, 1] = fWorkbookY;
}
// Write the X and Y columns.
oXColumnData.set_Value(Missing.Value, aoXValues);
oYColumnData.set_Value(Missing.Value, aoYValues);
}