Exemple #1
0
        private void DrawTree(Graphics drawingAreaGraphics)
        {
            drawingAreaGraphics.Clear(Color.White);
            drawingAreaGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            // Get width / height of node surface
            int nodeSurfaceWidth, nodeSurfaceHeight;

            NodeSurface.GetDimensions(out nodeSurfaceWidth, out nodeSurfaceHeight);

            // Draw node surfaces
            for (int i = 0; i < m_nodeSurfaces.Count; i++)
            {
                NodeSurface currNodeSurface = m_nodeSurfaces[i];
                int         xPos, yPos;
                currNodeSurface.GetPosition(out xPos, out yPos);
                xPos -= nodeSurfaceWidth / 2;
                yPos -= nodeSurfaceHeight / 2;
                drawingAreaGraphics.DrawImage(currNodeSurface.GetBitmapImage(), xPos, yPos);
            }

            // Draw Draw Node Connector
            for (int i = 0; i < m_lines.Count; i++)
            {
                Line line = m_lines[i];
                Pen  pen = new Pen(Brushes.Black, 4.0f);
                int  portWidth, portHeight;
                NodeSurface.GetPortDimensions(out portWidth, out portHeight);
                Point[] points = new Point[]
                {
                    new Point(line.StartX, line.StartY - (portHeight / 2)),
                    new Point(line.StartX, line.StartY + 5),
                    new Point(line.EndX, line.EndY - 5),
                    new Point(line.EndX, line.EndY + (portHeight / 2))
                };
                drawingAreaGraphics.DrawLines(pen, points);
            }
        }