本文整理汇总了C#中IVertex.TryGetValue方法的典型用法代码示例。如果您正苦于以下问题:C# IVertex.TryGetValue方法的具体用法?C# IVertex.TryGetValue怎么用?C# IVertex.TryGetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVertex
的用法示例。
在下文中一共展示了IVertex.TryGetValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssertValid
PreDrawVertex
(
IVertex vertex
)
{
Debug.Assert(vertex != null);
AssertValid();
// Check whether the vertex represents a collapsed group.
Object oCollapsedGroupAsObject;
if ( vertex.TryGetValue(ReservedMetadataKeys.CollapsedGroupInfo,
typeof(GroupInfo), out oCollapsedGroupAsObject) )
{
// Yes. Get the group information.
m_oCollapsedGroupVertex = vertex;
m_oCollapsedGroup = (GroupInfo)oCollapsedGroupAsObject;
if ( String.IsNullOrEmpty(m_oCollapsedGroup.CollapsedAttributes) )
{
// No attributes were specified for the collapsed group. Set
// attributes on the collapsed group vertex that will cause it
// to be drawn in a default manner.
m_oCollapsedGroupAttributes = new CollapsedGroupAttributes();
SetDefaultAttributesOnCollapsedGroup();
}
else
{
m_oCollapsedGroupAttributes =
CollapsedGroupAttributes.FromString(
m_oCollapsedGroup.CollapsedAttributes);
SetSpecifiedAttributesOnCollapsedGroup();
}
}
else
{
m_oCollapsedGroupVertex = null;
m_oCollapsedGroup = null;
m_oCollapsedGroupAttributes = null;
}
}
示例2: TryDrawVertex
//*************************************************************************
// Method: TryDrawVertex()
//
/// <summary>
/// Draws a vertex after moving it if necessary.
/// </summary>
///
/// <param name="vertex">
/// The vertex to draw.
/// </param>
///
/// <param name="graphDrawingContext">
/// Provides access to objects needed for graph-drawing operations.
/// </param>
///
/// <param name="vertexDrawingHistory">
/// Where a <see cref="VertexDrawingHistory" /> object that retains
/// information about how the vertex was drawn gets stored if true is
/// returned.
/// </param>
///
/// <returns>
/// true if the vertex was drawn, false if the vertex is hidden.
/// </returns>
///
/// <remarks>
/// This method should be called repeatedly while a graph is being drawn,
/// once for each of the graph's vertices. The <see
/// cref="IVertex.Location" /> property on all of the graph's vertices must
/// be set by ILayout.LayOutGraph before this method is called.
///
/// <para>
/// If the vertex falls outside the graph rectangle, it gets moved before
/// being drawn.
/// </para>
///
/// </remarks>
//*************************************************************************
public Boolean TryDrawVertex(
IVertex vertex,
GraphDrawingContext graphDrawingContext,
out VertexDrawingHistory vertexDrawingHistory
)
{
AssertValid();
vertexDrawingHistory = null;
CheckDrawVertexArguments(vertex, graphDrawingContext);
// If the vertex is hidden, do nothing.
VisibilityKeyValue eVisibility = GetVisibility(vertex);
if (eVisibility == VisibilityKeyValue.Hidden)
{
return (false);
}
// Check for a per-vertex label.
Object oLabelAsObject;
String sLabel = null;
if ( vertex.TryGetValue(ReservedMetadataKeys.PerVertexLabel,
typeof(String), out oLabelAsObject) )
{
sLabel = (String)oLabelAsObject;
if ( String.IsNullOrEmpty(sLabel) )
{
sLabel = null;
}
else
{
sLabel = TruncateLabel(sLabel);
}
}
Boolean bDrawAsSelected = GetDrawAsSelected(vertex);
Point oLocation = WpfGraphicsUtil.PointFToWpfPoint(vertex.Location);
DrawingVisual oDrawingVisual = new DrawingVisual();
VertexShape eShape = GetShape(vertex);
VertexLabelDrawer oVertexLabelDrawer =
new VertexLabelDrawer(m_eLabelPosition);
using ( DrawingContext oDrawingContext = oDrawingVisual.RenderOpen() )
{
if (eShape == VertexShape.Label)
{
if (sLabel != null)
{
// Draw the vertex as a label.
vertexDrawingHistory = DrawLabelShape(vertex,
graphDrawingContext, oDrawingContext, oDrawingVisual,
eVisibility, bDrawAsSelected, sLabel);
return (true);
//.........这里部分代码省略.........
示例3: GetRadius
//*************************************************************************
// Method: GetRadius()
//
/// <summary>
/// Gets the radius of a vertex.
/// </summary>
///
/// <param name="oVertex">
/// The vertex to get the radius for.
/// </param>
///
/// <returns>
/// The radius of the vertex.
/// </returns>
//*************************************************************************
protected Double GetRadius(
IVertex oVertex
)
{
Debug.Assert(oVertex != null);
AssertValid();
// Start with the default radius.
Double dRadius = m_dRadius;
Object oPerVertexRadiusAsObject;
// Check for a per-vertex radius. Note that the radius is stored as a
// Single in the vertex's metadata to reduce memory usage.
if ( oVertex.TryGetValue(ReservedMetadataKeys.PerVertexRadius,
typeof(Single), out oPerVertexRadiusAsObject) )
{
dRadius = (Double)(Single)oPerVertexRadiusAsObject;
if (dRadius < MinimumRadius || dRadius > MaximumRadius)
{
throw new FormatException( String.Format(
"{0}: The vertex with the ID {1} has an out-of-range"
+ " ReservedMetadataKeys.PerVertexRadius value. Valid"
+ " values are between {2} and {3}."
,
this.ClassName,
oVertex.ID,
MinimumRadius,
MaximumRadius
) );
}
}
return (dRadius * m_dGraphScale);
}
示例4: GetShape
//*************************************************************************
// Method: GetShape()
//
/// <summary>
/// Gets the shape of a vertex.
/// </summary>
///
/// <param name="oVertex">
/// The vertex to get the shape for.
/// </param>
///
/// <returns>
/// The shape of the vertex.
/// </returns>
//*************************************************************************
protected VertexShape GetShape(
IVertex oVertex
)
{
Debug.Assert(oVertex != null);
AssertValid();
// Start with the default shape.
VertexShape eShape = m_eShape;
Object oPerVertexShapeAsObject;
// Check for a per-vertex shape.
if ( oVertex.TryGetValue(ReservedMetadataKeys.PerVertexShape,
typeof(VertexShape), out oPerVertexShapeAsObject) )
{
eShape = (VertexShape)oPerVertexShapeAsObject;
}
return (eShape);
}
示例5: GetLabelFontSize
//*************************************************************************
// Method: GetLabelFontSize()
//
/// <summary>
/// Gets the font size to use for a vertex with the shape Label.
/// </summary>
///
/// <param name="oVertex">
/// The vertex to get the label font size for.
/// </param>
///
/// <returns>
/// The label font size to use, in WPF units.
/// </returns>
//*************************************************************************
protected Double GetLabelFontSize(
IVertex oVertex
)
{
Debug.Assert(oVertex != null);
AssertValid();
// Start with the default font size.
Double dLabelFontSize = m_dFontSize;
Object oPerVertexLabelFontSizeAsObject;
// Check for a per-vertex font size. Note that the font size is stored
// as a Single in the vertex's metadata to reduce memory usage.
if ( oVertex.TryGetValue(ReservedMetadataKeys.PerVertexLabelFontSize,
typeof(Single), out oPerVertexLabelFontSizeAsObject) )
{
dLabelFontSize = (Double)(Single)oPerVertexLabelFontSizeAsObject;
if (dLabelFontSize <= 0)
{
throw new FormatException( String.Format(
"{0}: The vertex with the ID {1} has a non-positive"
+ " ReservedMetadataKeys.PerVertexLabelFontSize value."
,
this.ClassName,
oVertex.ID
) );
}
}
return (dLabelFontSize * m_dGraphScale);
}
示例6: typeof
TryGetVertexDrawingHistory
(
IVertex oVertex,
out VertexDrawingHistory oVertexDrawingHistory
)
{
Debug.Assert(oVertex != null);
oVertexDrawingHistory = null;
Object oVertexDrawingHistoryAsObject;
if ( !oVertex.TryGetValue(ReservedMetadataKeys.VertexDrawingHistory,
typeof(VertexDrawingHistory), out oVertexDrawingHistoryAsObject) )
{
return (false);
}
oVertexDrawingHistory =
(VertexDrawingHistory)oVertexDrawingHistoryAsObject;
return (true);
}
示例7: VertexIsLocked
//*************************************************************************
// Method: VertexIsLocked()
//
/// <summary>
/// Returns a flag indicating whether the vertex is locked.
/// </summary>
///
/// <param name="oVertex">
/// The vertex to check.
/// </param>
///
/// <returns>
/// true if the vertex is locked.
/// </returns>
///
/// <remarks>
/// A locked vertex's location should not be modified by the layout,
/// although the vertex may be included in layout calculations.
/// </remarks>
//*************************************************************************
protected Boolean VertexIsLocked(
IVertex oVertex
)
{
Debug.Assert(oVertex != null);
AssertValid();
Object oLockVertexLocation;
return (oVertex.TryGetValue(ReservedMetadataKeys.LockVertexLocation,
typeof(Boolean), out oLockVertexLocation) &&
(Boolean)oLockVertexLocation);
}
示例8: AssertValid
GetLabelPosition
(
IVertex oVertex
)
{
Debug.Assert(oVertex != null);
AssertValid();
// Start with the default position.
VertexLabelPosition eLabelPosition = m_eLabelPosition;
// Check for a per-vertex label position.
Object oPerVertexLabelPositionAsObject;
if ( oVertex.TryGetValue(ReservedMetadataKeys.PerVertexLabelPosition,
typeof(VertexLabelPosition), out oPerVertexLabelPositionAsObject) )
{
eLabelPosition =
(VertexLabelPosition)oPerVertexLabelPositionAsObject;
}
return (eLabelPosition);
}
示例9: AssertValid
TryDrawVertex
(
IVertex vertex,
GraphDrawingContext graphDrawingContext,
out VertexDrawingHistory vertexDrawingHistory
)
{
AssertValid();
vertexDrawingHistory = null;
CheckDrawVertexArguments(vertex, graphDrawingContext);
if (graphDrawingContext.GraphRectangleMinusMarginIsEmpty)
{
return (false);
}
// If the vertex is hidden, do nothing.
VisibilityKeyValue eVisibility = GetVisibility(vertex);
if (eVisibility == VisibilityKeyValue.Hidden)
{
return (false);
}
// Check whether the vertex represents a collapsed group and perform
// collapsed group tasks if necessary.
CollapsedGroupDrawingManager oCollapsedGroupDrawingManager =
new CollapsedGroupDrawingManager();
oCollapsedGroupDrawingManager.PreDrawVertex(vertex);
// Check for a per-vertex label.
Object oLabelAsObject;
String sLabel = null;
if ( vertex.TryGetValue(ReservedMetadataKeys.PerVertexLabel,
typeof(String), out oLabelAsObject) )
{
sLabel = (String)oLabelAsObject;
if ( String.IsNullOrEmpty(sLabel) )
{
sLabel = null;
}
else
{
sLabel = TruncateLabel(sLabel);
}
}
Boolean bDrawAsSelected = GetDrawAsSelected(vertex);
Point oLocation = WpfGraphicsUtil.PointFToWpfPoint(vertex.Location);
DrawingVisualPlus oDrawingVisual = new DrawingVisualPlus();
VertexShape eShape = GetShape(vertex);
VertexLabelDrawer oVertexLabelDrawer =
new VertexLabelDrawer(m_eLabelPosition, m_btBackgroundAlpha);
using ( DrawingContext oDrawingContext = oDrawingVisual.RenderOpen() )
{
if (eShape == VertexShape.Label)
{
if (sLabel != null)
{
// Draw the vertex as a label.
vertexDrawingHistory = DrawLabelShape(vertex,
graphDrawingContext, oDrawingContext, oDrawingVisual,
eVisibility, bDrawAsSelected, sLabel,
oCollapsedGroupDrawingManager);
}
else
{
// Default to something usable.
eShape = VertexShape.Disk;
}
}
else if (eShape == VertexShape.Image)
{
Object oImageSourceAsObject;
if (vertex.TryGetValue(ReservedMetadataKeys.PerVertexImage,
typeof(ImageSource), out oImageSourceAsObject)
)
{
// Draw the vertex as an image.
vertexDrawingHistory = DrawImageShape(vertex,
graphDrawingContext, oDrawingContext, oDrawingVisual,
eVisibility, bDrawAsSelected, sLabel,
(ImageSource)oImageSourceAsObject, oVertexLabelDrawer,
oCollapsedGroupDrawingManager);
}
else
//.........这里部分代码省略.........