private void Draw_Universe(string netid)
{
string SQL;
string NodeName;
int NodeID, FromID, ToID, EdgeID;
double xx2, yy2, size, xx, yy;
double px, py;
int comments;
Random rnd = new Random();
Graph oGraph = new Graph(GraphDirectedness.Directed);
IVertexCollection oVertices = oGraph.Vertices;
IEdgeCollection oEdges = oGraph.Edges;
// Nuke the Display
UniverseBackground.Children.Clear();
// Add the Whiskers Programmatically
Add_Whiskers();
SQL = "select id, nodename,x,y from nodes where networkid = '" + netid + "'";
OleDbCommand aCommand = new OleDbCommand(SQL, localengine.RepositoryConnection);
try
{
//create the datareader object to connect to table
OleDbDataReader aReader = aCommand.ExecuteReader();
//Iterate throuth the database
while (aReader.Read())
{
NodeID = aReader.GetInt32(0);
NodeName = aReader.GetString(1);
ListBoxItem li = new ListBoxItem();
li.Content = NodeName;
li.Tag = NodeID.ToString();
NodeList.Items.Add(li);
px = (double)aReader.GetInt32(2);
py = (double)aReader.GetInt32(3);
UniversePadPoint p2 = new UniversePadPoint();
p2.PadName = NodeName;
xx2 = px;
yy2 = py;
xx2 = xx2 + 0;
yy2 = yy2 + 0;
// BUG p2.WhiskX = XWhisker;
// BUG p2.WhiskY = YWhisker;
size = (double)10;
p2.SetDrillFeature(DrillDetailLabel, DrillDetailList, localengine.RepositoryConnection);
p2.Render(UniverseBackground, FieldBackground, xx2, yy2, size, (int)NodeID, NodeName);
Ellipse re = new Ellipse();
re.Width = rnd.NextDouble() * 80;
re.Height = re.Width;
re.Opacity = 0.25;
re.Tag = "METRIC";
re.Fill = new SolidColorBrush(Colors.Blue);
UniverseBackground.Children.Add(re);
Canvas.SetLeft(re, xx2 - (re.Width / 2) + 5);
Canvas.SetTop(re, yy2 - (re.Width / 2) + 5);
}
aReader.Close();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
// Connect the edges
SQL = "SELECT e.edgeid, e.fromid, n1.x, n1.y, e.toid, n2.x, n2.y ";
SQL = SQL + "FROM Edges e, Nodes n1, Nodes n2 ";
SQL = SQL + "where e.networkid = '" + netid + "' and n1.networkid = '" + netid + "' and n2.networkid = '" + netid + "' ";
SQL = SQL + " and n1.id = e.fromid and n2.id = e.toid ";
aCommandEdge = new OleDbCommand(SQL, localengine.RepositoryConnection);
try
{
//create the datareader object to connect to table
aReaderEdge = aCommandEdge.ExecuteReader();
//Iterate throuth the database
while (aReaderEdge.Read())
{
EdgeID = aReaderEdge.GetInt32(0);
FromID = aReaderEdge.GetInt32(1);
ToID = aReaderEdge.GetInt32(4);
xx = aReaderEdge.GetInt32(2);
yy = aReaderEdge.GetInt32(3);
xx2 = aReaderEdge.GetInt32(5);
yy2 = aReaderEdge.GetInt32(6);
Line l = new Line();
l.X1 = xx + 5;
l.Y1 = yy + 5;
l.X2 = xx2 + 5;
l.Y2 = yy2 + 5;
l.Tag = "EDGE(" + FromID.ToString() + ":" + ToID.ToString() + ")";
l.ToolTip = l.Tag;
l.Stroke = new SolidColorBrush(Colors.Gray);
UniverseBackground.Children.Add(l);
}
//aReaderEdge.Close();
}
catch (Exception eEdgedDraw)
{
MessageBox.Show(eEdgedDraw.Message);
}
}