Here is a slightly modified version of the above code. It's the version I'm putting into the documentation.
-- Tony
using System;
using System.Windows.Forms;
using System.Drawing;
using Microsoft.NetMap.Visualization;
using Microsoft.NetMap.Core;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
netMapControl1.BeginUpdate();
// The default vertex drawer draws all vertices with the same
// color, radius, and shape. Replace it with one that will vary
// the appearance of each vertex based on metadata values stored in
// the vertices. (Note that there are also PerVertexWithLabel and
// PerVertexWithImage drawers that do the same thing and more.)
netMapControl1.VertexDrawer = new PerVertexDrawer();
// Replace the default edge drawer with one that will vary the
// color and width of each edge based on metadata values
// stored in the edges. (Note that there are also
// PerEdgeWithLabel and PerEdgeWithImage drawers that do the
// same thing and more.)
netMapControl1.EdgeDrawer = new PerEdgeDrawer();
// Get the graph's vertex collection.
IVertexCollection oVertices = netMapControl1.Graph.Vertices;
// Add three vertices.
IVertex oVertexA = oVertices.Add();
IVertex oVertexB = oVertices.Add();
IVertex oVertexC = oVertices.Add();
// Customize their appearance.
oVertexA.SetValue(ReservedMetadataKeys.PerColor, Color.Blue);
oVertexA.SetValue(ReservedMetadataKeys.PerVertexRadius, 15F);
oVertexB.SetValue(ReservedMetadataKeys.PerColor, Color.Orange);
oVertexB.SetValue(ReservedMetadataKeys.PerVertexRadius, 20F);
oVertexB.SetValue(ReservedMetadataKeys.PerVertexShape,
VertexDrawer.VertexShape.Sphere);
// Get the graph's edge collection.
IEdgeCollection oEdges = netMapControl1.Graph.Edges;
// Connect the vertices with directed edges.
IEdge oEdge1 = oEdges.Add(oVertexA, oVertexB, true);
IEdge oEdge2 = oEdges.Add(oVertexB, oVertexC, true);
IEdge oEdge3 = oEdges.Add(oVertexC, oVertexA, true);
// Customize their appearance.
oEdge1.SetValue(ReservedMetadataKeys.PerColor, Color.Chartreuse);
oEdge1.SetValue(ReservedMetadataKeys.PerEdgeWidth, 3);
oEdge2.SetValue(ReservedMetadataKeys.PerEdgeWidth, 5);
oEdge3.SetValue(ReservedMetadataKeys.PerColor, Color.ForestGreen);
netMapControl1.EndUpdate();
}
}
}