NetworkVis.UniversePadPoint.Render C# (CSharp) Method

Render() public method

public Render ( System.Windows.Controls.Canvas _parent, System.Windows.Controls.Canvas _childCanvas, double xx, double yy, double padsize, int tagid, string name ) : void
_parent System.Windows.Controls.Canvas
_childCanvas System.Windows.Controls.Canvas
xx double
yy double
padsize double
tagid int
name string
return void
        public void Render(Canvas _parent, Canvas _childCanvas, double xx, double yy, double padsize, int tagid, string name)
        {
            PadParent = _parent;
            ChildCanvas = _childCanvas;
            PadName = name;
            xpos = xx;
            ypos = yy;
            Padback = new Rectangle();
            ContextMenu cm = new ContextMenu();
            MenuItem mi = new MenuItem();
            mi.Header = "Add Comment...";
            mi.Click += new RoutedEventHandler(AddComment);
            cm.Items.Add(mi);
            MenuItem mi2 = new MenuItem();
            mi2.Header = "Add Link...";
            mi2.Click += new RoutedEventHandler(AddLink);
            cm.Items.Add(mi2);
            Padback.ContextMenu = cm;
            Padback.ToolTip = name;
            Padback.MouseEnter += new MouseEventHandler(Padback_Grow);
            Padback.MouseLeave += new MouseEventHandler(Padback_Shrink);
            Padback.MouseDown += new MouseButtonEventHandler(Padback_Selection);
            Padback.Fill = new SolidColorBrush(Colors.Blue);
            Padback.Width = padsize;
            Padback.Height = padsize;
            Padback.RadiusX = 2.5;
            Padback.RadiusY = 2.5;
            Padback.Stroke = new SolidColorBrush(Colors.Gray);
            Padback.StrokeThickness = 1;
            Padback.Tag = tagid.ToString();
            _parent.Children.Add(Padback);
            Canvas.SetLeft(Padback, xx);
            Canvas.SetTop(Padback, yy);
            Canvas.SetZIndex(Padback, 100);

            nodelabel.Content = name;
            nodelabel.Tag = "LABEL";
            nodelabel.Foreground = new SolidColorBrush(Colors.White);
            _parent.Children.Add(nodelabel);
            Canvas.SetLeft(nodelabel, xx-6);
            Canvas.SetTop(nodelabel, yy + 8);
            Canvas.SetZIndex(nodelabel, 100);


        }

Usage Example

Ejemplo n.º 1
0
        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);

            }

              
        }
All Usage Examples Of NetworkVis.UniversePadPoint::Render