本文整理汇总了C#中IGraph.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# IGraph.SetValue方法的具体用法?C# IGraph.SetValue怎么用?C# IGraph.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraph
的用法示例。
在下文中一共展示了IGraph.SetValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MarkGraphAsLaidOut
//*************************************************************************
// Method: MarkGraphAsLaidOut()
//
/// <summary>
/// Marks a graph as having been laid out.
/// </summary>
///
/// <param name="graph">
/// Graph that was laid out.
/// </param>
///
/// <remarks>
/// This should be called after <paramref name="graph" /> has been
/// successfully laid out. It adds a metadata key to the graph.
/// </remarks>
//*************************************************************************
public static void MarkGraphAsLaidOut(
IGraph graph
)
{
Debug.Assert(graph != null);
graph.SetValue(ReservedMetadataKeys.LayoutBaseLayoutComplete, null);
}
示例2: AssertValid
LayOutComponentInBin
(
IGraph oGraph,
ICollection<IVertex> oVerticesInComponent,
Rectangle oBinRectangle
)
{
Debug.Assert(oGraph != null);
Debug.Assert(oVerticesInComponent != null);
AssertValid();
oGraph.SetValue(ReservedMetadataKeys.LayOutTheseVerticesOnly,
oVerticesInComponent);
// Force the FruchtermanReingoldLayout class to randomize the vertices.
LayoutMetadataUtil.MarkGraphAsNotLaidOut(oGraph);
ILayout oLayout = new FruchtermanReingoldLayout();
oLayout.Margin = BinMargin;
LayoutContext oLayoutContext = new LayoutContext(oBinRectangle);
oLayout.LayOutGraph(oGraph, oLayoutContext);
}
示例3: IntergroupEdgeCalculator
OnLayoutUsingGroupsEnd
(
IGraph graph,
IList<GroupInfo> laidOutGroups,
Double groupRectanglePenWidth,
IntergroupEdgeStyle intergroupEdgeStyle
)
{
Debug.Assert(graph != null);
Debug.Assert(laidOutGroups != null);
Debug.Assert(groupRectanglePenWidth >= 0);
List<IntergroupEdgeInfo> oCombinedIntergroupEdges = null;
if (intergroupEdgeStyle == IntergroupEdgeStyle.Combine)
{
// Get a collection of IntergroupEdgeInfo objects, one for the
// edges between each pair of groups and one for the edges within
// each group.
IEnumerable<IntergroupEdgeInfo> oAllIntergroupEdges =
( new IntergroupEdgeCalculator() ).CalculateGraphMetrics(
graph, laidOutGroups, false);
// Filter out the objects for the edges within each group.
oCombinedIntergroupEdges = new List<IntergroupEdgeInfo>(
oAllIntergroupEdges.Where(
oIntergroupEdge =>
oIntergroupEdge.Group1Index != oIntergroupEdge.Group2Index
) );
}
if (intergroupEdgeStyle == IntergroupEdgeStyle.Hide ||
intergroupEdgeStyle == IntergroupEdgeStyle.Combine)
{
// Intergroup edges need to be hidden.
Boolean bEdgeHidden = false;
Int32 iLaidOutGroups = laidOutGroups.Count;
// The key is an IVertex.ID and the value is the zero-based index
// of the laid-out group the vertex belongs to.
Dictionary<Int32, Int32> oGroupIndexDictionary =
GroupUtil.GetGroupIndexDictionary(laidOutGroups);
for (Int32 iGroupIndex = 0; iGroupIndex < iLaidOutGroups;
iGroupIndex++)
{
GroupInfo oGroup = laidOutGroups[iGroupIndex];
foreach (IVertex oVertex in oGroup.Vertices)
{
foreach (IEdge oIncidentEdge in oVertex.IncidentEdges)
{
if ( IncidentEdgeShouldBeHidden(oIncidentEdge, oVertex,
iGroupIndex, oGroupIndexDictionary) )
{
HideEdge(oIncidentEdge);
bEdgeHidden = true;
}
}
}
}
if (bEdgeHidden)
{
graph.SetValue(ReservedMetadataKeys.IntergroupEdgesHidden,
null);
}
}
graph.SetValue( ReservedMetadataKeys.GroupLayoutDrawingInfo,
new GroupLayoutDrawingInfo(laidOutGroups, groupRectanglePenWidth,
oCombinedIntergroupEdges) );
}
示例4: AssertValid
//.........这里部分代码省略.........
// Remove the vertex and its incident edges from the
// graph and dictionaries.
RemoveVertex(oVertex, oReadWorkbookContext, oGraph);
}
continue;
case Visibility.Hide:
// If the vertex is part of an edge, hide it and its
// incident edges. Otherwise, skip the vertex row.
if (oVertex == null)
{
continue;
}
HideVertex(oVertex);
break;
case Visibility.Show:
// Show the vertex using the specified attributes
// regardless of whether it is part of an edge.
if (oVertex == null)
{
oVertex = CreateVertex(sVertexName, oVertices,
oVertexNameDictionary);
}
oVertex.SetValue(
ReservedMetadataKeys.VertexHasVisibilityOfShow, null);
break;
default:
Debug.Assert(false);
break;
}
Debug.Assert(oVertex != null);
// If ReadWorkbookContext.FillIDColumns is true, add the vertex to
// the vertex row ID dictionary and set the vertex's Tag to the row
// ID.
oReadWorkbookContext.AddToRowIDDictionary(oRow, oVertex, false);
if (bReadAllEdgeAndVertexColumns)
{
// All columns except the vertex name should be read and stored
// as metadata on the vertex.
ReadAllColumns( oExcelTableReader, oRow, oVertex,
oColumnNamesToExclude);
continue;
}
// Layout and z-order.
if ( ReadLayoutAndZOrder(oRow, oVertex) )
示例5: AssertValid
ReadGroupTables
(
ListObject oGroupTable,
ListObject oGroupVertexTable,
ReadWorkbookContext oReadWorkbookContext,
IGraph oGraph
)
{
Debug.Assert(oGroupTable != null);
Debug.Assert(oGroupVertexTable != null);
Debug.Assert(oReadWorkbookContext != null);
Debug.Assert(oGraph != null);
AssertValid();
// If a required column is missing, do nothing.
ListColumn oColumn;
if (
!ExcelTableUtil.TryGetTableColumn(oGroupTable,
GroupTableColumnNames.Name, out oColumn)
||
!ExcelTableUtil.TryGetTableColumn(oGroupTable,
GroupTableColumnNames.VertexColor, out oColumn)
||
!ExcelTableUtil.TryGetTableColumn(oGroupTable,
GroupTableColumnNames.VertexShape, out oColumn)
||
!ExcelTableUtil.TryGetTableColumn(oGroupVertexTable,
GroupVertexTableColumnNames.GroupName, out oColumn)
||
!ExcelTableUtil.TryGetTableColumn(oGroupVertexTable,
GroupVertexTableColumnNames.VertexName, out oColumn)
)
{
return;
}
// These are the names of the groups that should be skipped or hidden.
HashSet<String> oSkippedGroupNames = new HashSet<String>();
HashSet<String> oHiddenGroupNames = new HashSet<String>();
// Create a dictionary from the group table. The key is the group name
// and the value is an ExcelTemplateGroupInfo object for the group.
Dictionary<String, ExcelTemplateGroupInfo> oGroupNameDictionary =
ReadGroupTable(oGroupTable, oReadWorkbookContext,
oSkippedGroupNames, oHiddenGroupNames);
// Read the group vertex table and set the color and shape of each
// group vertex in the graph.
ReadGroupVertexTable(oGroupVertexTable, oReadWorkbookContext,
oGroupNameDictionary, oGraph);
// Now that the groups and the vertices they contain are known, skip
// and hide those groups that should be skipped or hidden.
SkipAndHideGroups(oReadWorkbookContext, oGroupNameDictionary,
oSkippedGroupNames, oHiddenGroupNames, oGraph);
if (oGroupNameDictionary.Count > 0)
{
// Save the group information on the graph.
Debug.Assert( oGroupNameDictionary.Values is
ICollection<ExcelTemplateGroupInfo> );
oGraph.SetValue(ReservedMetadataKeys.GroupInfo,
oGroupNameDictionary.Values.ToArray() );
}
}
示例6: ReadGroupTables
//*************************************************************************
// Method: ReadGroupTables()
//
/// <summary>
/// Reads the group tables and add the contents to a graph.
/// </summary>
///
/// <param name="oGroupTable">
/// Table that contains the group data.
/// </param>
///
/// <param name="oGroupVertexTable">
/// Table that contains the group vertex data.
/// </param>
///
/// <param name="oReadWorkbookContext">
/// Provides access to objects needed for converting an Excel workbook to a
/// NodeXL graph.
/// </param>
///
/// <param name="oGraph">
/// Graph to add group data to.
/// </param>
//*************************************************************************
protected void ReadGroupTables(
ListObject oGroupTable,
ListObject oGroupVertexTable,
ReadWorkbookContext oReadWorkbookContext,
IGraph oGraph
)
{
Debug.Assert(oGroupTable != null);
Debug.Assert(oGroupVertexTable != null);
Debug.Assert(oReadWorkbookContext != null);
Debug.Assert(oGraph != null);
AssertValid();
// If a required column is missing, do nothing.
ListColumn oColumn;
if (
!ExcelUtil.TryGetTableColumn(oGroupTable,
GroupTableColumnNames.Name, out oColumn)
||
!ExcelUtil.TryGetTableColumn(oGroupTable,
GroupTableColumnNames.VertexColor, out oColumn)
||
!ExcelUtil.TryGetTableColumn(oGroupTable,
GroupTableColumnNames.VertexShape, out oColumn)
||
!ExcelUtil.TryGetTableColumn(oGroupVertexTable,
GroupVertexTableColumnNames.GroupName, out oColumn)
||
!ExcelUtil.TryGetTableColumn(oGroupVertexTable,
GroupVertexTableColumnNames.VertexName, out oColumn)
)
{
return;
}
// Create a dictionary from the group table. The key is the group name
// and the value is a GroupInformation object for the group.
Dictionary<String, GroupInformation> oGroupNameDictionary =
ReadGroupTable(oGroupTable, oReadWorkbookContext);
// Read the group vertex table and set the color and shape of each
// group vertex in the graph.
ReadGroupVertexTable(oGroupVertexTable, oReadWorkbookContext,
oGroupNameDictionary, oGraph);
// Save the group information on the graph.
Debug.Assert( oGroupNameDictionary.Values is
ICollection<GroupInformation> );
oGraph.SetValue(ReservedMetadataKeys.GroupInformation,
oGroupNameDictionary.Values);
}
示例7: AssertValid
SaveGraphMLAttributeNames
(
IGraph oGraph,
Dictionary<String, GraphMLAttribute> oGraphMLAttributeDictionary
)
{
Debug.Assert(oGraph != null);
Debug.Assert(oGraphMLAttributeDictionary != null);
AssertValid();
List<String> oVertexKeys = new List<String>();
List<String> oEdgeKeys = new List<String>();
foreach (GraphMLAttribute oGraphMLAttribute in
oGraphMLAttributeDictionary.Values)
{
List<String> oListToAddTo = oGraphMLAttribute.IsForVertex ?
oVertexKeys : oEdgeKeys;
oListToAddTo.Add(oGraphMLAttribute.Name);
}
oGraph.SetValue( ReservedMetadataKeys.AllVertexMetadataKeys,
oVertexKeys.ToArray() );
oGraph.SetValue( ReservedMetadataKeys.AllEdgeMetadataKeys,
oEdgeKeys.ToArray() );
}
示例8: AssertValid
TransformLayoutCore
(
IGraph graph,
LayoutContext originalLayoutContext,
LayoutContext newLayoutContext
)
{
Debug.Assert(graph != null);
Debug.Assert(originalLayoutContext != null);
Debug.Assert(newLayoutContext != null);
AssertValid();
// Transform the graph's vertex locations.
Matrix oTransformationMatrix = LayoutUtil.GetRectangleTransformation(
originalLayoutContext.GraphRectangle,
newLayoutContext.GraphRectangle
);
base.TransformLayoutCore(graph, originalLayoutContext,
newLayoutContext);
// Tranform the geometry metadata added by LayOutGraphCore().
Object oValue;
if ( graph.TryGetValue(
ReservedMetadataKeys.SugiyamaComputedRadius, typeof(Single),
out oValue) )
{
// Transforming the radius in the x-direction only isn't ideal, but
// doing the transform properly would involve drawing the vertex as
// an ellipse.
PointF oTransformedRadius = LayoutUtil.TransformPointF(
new PointF( (Single)oValue, 0 ), oTransformationMatrix
);
graph.SetValue(
ReservedMetadataKeys.SugiyamaComputedRadius,
oTransformedRadius.X
);
}
foreach (IEdge oEdge in graph.Edges)
{
if ( !oEdge.TryGetValue(
ReservedMetadataKeys.SugiyamaCurvePoints, typeof( PointF [] ),
out oValue
) )
{
continue;
}
PointF [] aoCurvePoints = ( PointF [] )oValue;
oTransformationMatrix.TransformPoints(aoCurvePoints);
oEdge.SetValue(ReservedMetadataKeys.SugiyamaCurvePoints,
aoCurvePoints);
PointF oEndpoint = (PointF)oEdge.GetRequiredValue(
ReservedMetadataKeys.SugiyamaEndpoint, typeof(PointF)
);
oEdge.SetValue(
ReservedMetadataKeys.SugiyamaEndpoint,
LayoutUtil.TransformPointF(oEndpoint, oTransformationMatrix)
);
}
}
示例9: AssertValid
//.........这里部分代码省略.........
if (eVisibility == Visibility.Skip)
{
// Skip the edge an continue to the next edge.
continue;
}
// Create the specified vertices or retrieve them from the
// dictionary.
IVertex oVertex1 = VertexNameToVertex(
sVertex1Name, oVertices, oVertexNameDictionary);
IVertex oVertex2 = VertexNameToVertex(
sVertex2Name, oVertices, oVertexNameDictionary);
// Add an edge connecting the vertices.
IEdge oEdge = oEdges.Add(oVertex1, oVertex2, bGraphIsDirected);
// If ReadWorkbookContext.FillIDColumns is true, add the edge to
// the edge row ID dictionary and set the edge's Tag to the row ID.
oReadWorkbookContext.AddToRowIDDictionary(oRow, oEdge, true);
if (bReadAllEdgeAndVertexColumns)
{
// All columns except the vertex names should be read and
// stored as metadata on the edge.
ReadAllColumns(oExcelTableReader, oRow, oEdge,
oColumnNamesToExclude);
continue;
}
if (eVisibility == Visibility.Hide)
{
// Hide the edge and continue to the next edge.
oEdge.SetValue(ReservedMetadataKeys.Visibility,
VisibilityKeyValue.Hidden);
continue;
}
// Alpha.
Boolean bAlphaIsZero = ReadAlpha(oRow, oEdge);
if (bAlphaIsZero)
{
continue;
}
// Color.
ReadColor(oRow, EdgeTableColumnNames.Color, oEdge,
ReservedMetadataKeys.PerColor,
oReadWorkbookContext.ColorConverter2);
// Width.
ReadWidth(oRow, oReadWorkbookContext.EdgeWidthConverter, oEdge);
// Style.
ReadStyle(oRow, oReadWorkbookContext.EdgeStyleConverter, oEdge);
// Label.
if (oReadWorkbookContext.ReadEdgeLabels)
{
ReadCellAndSetMetadata(oRow, EdgeTableColumnNames.Label, oEdge,
ReservedMetadataKeys.PerEdgeLabel);
ReadColor(oRow, EdgeTableColumnNames.LabelTextColor, oEdge,
ReservedMetadataKeys.PerEdgeLabelTextColor,
oReadWorkbookContext.ColorConverter2);
ReadLabelFontSize(oRow, oReadWorkbookContext.FontSizeConverter,
oEdge);
}
// Weight.
if (oReadWorkbookContext.ReadEdgeWeights)
{
ReadEdgeWeight(oRow, oEdge);
}
}
if (bReadAllEdgeAndVertexColumns)
{
// Store the edge column names on the graph.
oGraph.SetValue( ReservedMetadataKeys.AllEdgeMetadataKeys,
FilterColumnNames(oExcelTableReader, oColumnNamesToExclude) );
}
}
示例10: ReadWorksheet
//*************************************************************************
// Method: ReadWorksheet()
//
/// <summary>
/// Reads the vertex worksheet and adds the contents to a graph.
/// </summary>
///
/// <param name="workbook">
/// Workbook containing the graph data.
/// </param>
///
/// <param name="readWorkbookContext">
/// Provides access to objects needed for converting an Excel workbook to a
/// NodeXL graph.
/// </param>
///
///
/// <param name="graph">
/// Graph to add vertex data to.
/// </param>
///
/// <remarks>
/// If the vertex worksheet in <paramref name="workbook" /> contains valid
/// vertex data, the vertices in <paramref name="graph" /> are marked with
/// metadata; any isolated vertices are added to <paramref
/// name="graph" /> and <paramref
/// name="readWorkbookContext" />.VertexNameDictionary; and any
/// skipped vertices (and their incident edges) are removed from <paramref
/// name="graph" />, <paramref
/// name="readWorkbookContext" />.VertexNameDictionary, and
/// <paramref name="readWorkbookContext" />.EdgeRowIDDictionary.
/// Otherwise, a <see cref="WorkbookFormatException" /> is thrown.
/// </remarks>
//*************************************************************************
public void ReadWorksheet(
Microsoft.Office.Interop.Excel.Workbook workbook,
ReadWorkbookContext readWorkbookContext,
IGraph graph
)
{
Debug.Assert(workbook != null);
Debug.Assert(readWorkbookContext != null);
Debug.Assert(graph != null);
AssertValid();
// Attempt to get the optional table that contains vertex data.
ListObject oVertexTable;
if ( ExcelUtil.TryGetTable(workbook, WorksheetNames.Vertices,
TableNames.Vertices, out oVertexTable) )
{
// The code that reads the table can handle hidden rows, but not
// hidden columns. Temporarily show all hidden columns in the
// table.
ExcelHiddenColumns oHiddenColumns =
ExcelColumnHider.ShowHiddenColumns(oVertexTable);
Boolean bLayoutOrderSet, bToolTipSet;
try
{
ReadVertexTable(oVertexTable, readWorkbookContext, graph,
out bLayoutOrderSet, out bToolTipSet);
}
finally
{
ExcelColumnHider.RestoreHiddenColumns(oVertexTable,
oHiddenColumns);
}
if (bLayoutOrderSet)
{
// The layout order was specified for at least one vertex.
// The ByMetadataVertexSorter used by SortableLayoutBase
// requires that if layout order is set on one vertex, it must
// be set on all vertices. This isn't required in the Excel
// template, though, so set a default layout order for each
// vertex that doesn't already specify one.
SetUnsetVertexOrders(graph);
// The layout order is ignored unless this key is added to the
// graph.
graph.SetValue(
ReservedMetadataKeys.SortableLayoutOrderSet, null);
}
if (bToolTipSet)
{
graph.SetValue(ReservedMetadataKeys.ToolTipSet, null);
}
}
}
示例11: ReadWorksheet
//*************************************************************************
// Method: ReadWorksheet()
//
/// <summary>
/// Reads per-workbook settings that are stored directly on an <see
/// cref="IGraph" /> object.
/// </summary>
///
/// <param name="workbook">
/// Workbook containing the graph data.
/// </param>
///
/// <param name="readWorkbookContext">
/// Provides access to objects needed for converting an Excel workbook to a
/// NodeXL graph.
/// </param>
///
/// <param name="graph">
/// Graph to add data to.
/// </param>
//*************************************************************************
public void ReadWorksheet(
Microsoft.Office.Interop.Excel.Workbook workbook,
ReadWorkbookContext readWorkbookContext,
IGraph graph
)
{
Debug.Assert(workbook != null);
Debug.Assert(readWorkbookContext != null);
Debug.Assert(graph != null);
AssertValid();
Nullable<Color> oBackColor = this.BackColor;
if (oBackColor.HasValue)
{
graph.SetValue(ReservedMetadataKeys.GraphBackColor,
oBackColor.Value);
// (Note that if there is no per-workbook background color, the
// GraphDrawer.BackColor property will be used instead.)
}
String sBackgroundImageUri = this.BackgroundImageUri;
if ( !String.IsNullOrEmpty(sBackgroundImageUri) )
{
System.Windows.Media.ImageSource oImage = ( new WpfImageUtil() ).
GetImageSynchronousIgnoreDpi(sBackgroundImageUri);
graph.SetValue(ReservedMetadataKeys.GraphBackgroundImage, oImage);
// (Note that if there is no per-workbook background image, no
// background image will be drawn.)
}
}