コード例 #1
0
ファイル: Form1.cs プロジェクト: mixail167/ProjectsCSharp
        // 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
            }
        }
コード例 #2
0
 // Draw the points in this quadtree node.
 public void DrawPoints(Graphics gr, Brush brush, Pen pen, float radius)
 {
     // See if this node has children.
     if (Points == null)
     {
         // Make the children draw themselves.
         NWchild.DrawPoints(gr, brush, pen, radius);
         NEchild.DrawPoints(gr, brush, pen, radius);
         SEchild.DrawPoints(gr, brush, pen, radius);
         SWchild.DrawPoints(gr, brush, pen, radius);
     }
     else
     {
         // Draw the points in this node.
         foreach (PointF point in Points)
         {
             gr.FillEllipse(brush, point.X - radius, point.Y - radius,
                            2 * radius, 2 * radius);
             gr.DrawEllipse(pen, point.X - radius, point.Y - radius,
                            2 * radius, 2 * radius);
         }
     }
 }