Example #1
0
        // Display the points.
        private void pointsPictureBox_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

            // Draw the points.
#if USE_COLOR
            Root.DrawPoints(e.Graphics, Brushes.White, Pens.Blue, Radius);
#else
            Root.DrawPoints(e.Graphics, Brushes.White, Pens.Black, Radius);
#endif

            // Draw the selected point.
            if (PointIsSelected)
            {
#if USE_COLOR
                e.Graphics.FillEllipse(Brushes.LightGreen,
                                       SelectedPoint.X - Radius, SelectedPoint.Y - Radius,
                                       2 * Radius, 2 * Radius);
                e.Graphics.DrawEllipse(Pens.Green,
                                       SelectedPoint.X - Radius, SelectedPoint.Y - Radius,
                                       2 * Radius, 2 * Radius);
#else
                e.Graphics.FillEllipse(Brushes.Gray,
                                       SelectedPoint.X - Radius, SelectedPoint.Y - Radius,
                                       2 * Radius, 2 * Radius);
                e.Graphics.DrawEllipse(Pens.Black,
                                       SelectedPoint.X - Radius, SelectedPoint.Y - Radius,
                                       2 * Radius, 2 * Radius);
#endif
            }

            // Draw the quadtree if desired.
            if (drawBoxesCheckBox.Checked)
            {
                e.Graphics.SmoothingMode = SmoothingMode.None;
#if USE_COLOR
                Root.DrawAreas(e.Graphics, Pens.Red);
#else
                Root.DrawAreas(e.Graphics, Pens.Black);
#endif
            }
        }
Example #2
0
        // Draw the quadtree areas.
        public void DrawAreas(Graphics gr, Pen pen)
        {
            // Draw this quadtree node's area.
            gr.DrawRectangle(pen, Area.Left, Area.Top, Area.Width, Area.Height);

            // Draw the child nodes.
            if (NWchild != null)
            {
                NWchild.DrawAreas(gr, pen);
                NEchild.DrawAreas(gr, pen);
                SEchild.DrawAreas(gr, pen);
                SWchild.DrawAreas(gr, pen);
            }
        }