Lightweight winform graphic that replaces Control

I am interested in creating a drawing element that is ultralight. That way I can create millions of these objects without the headboard associated with the class System.Windows.Forms.Control.

This class inherits from the class System.ComponentModel.Componentand has (I guess) only a constructor and method paint(object sender, PaintEventArgs e). However, I do not know how the class System.Windows.Forms.Controlperforms or facilitates the actual screen drawing.

How can I replicate a paint / draw function using a valid drawing context similar to a class System.Windows.Forms.Control?

+1
source share
1 answer

, . , , - , ( System.Windows.Forms.Control), MyDrawingObject, . (List, Array - ) MyDrawingObjects .

, - , , . My Ball :

class Ball
{
    public float Radius {get; set;}
    public int Color {get; set;}
    public float Weight {get; set;}
    public Point Position {get; set;}

    ...
}

:

class MyDrawingBoard : System.Windows.Forms.Control
{
    List<Ball> MyBalls = new List<Ball>();

    override void OnPaint(object sender, PaintEventArgs e)
    {
         foreach(var b in MyBalls)
         {
             e.Graphics.DrawEllipse()...
         }
    }
}

, ClipRectangle, List . .

+2

Source: https://habr.com/ru/post/1614330/


All Articles