@loaded
create a special type dynamic array. In this series;
Single point, Line, Polyline, Polygon, Text, etc. You must transfer your objects to the array.
Yes, that what I called Model.
Create a function for drawing;
In this function, draw all the objects in the array to the bitmap,
When the drawing is finished, transfer the bitmap to the Image object.
As the software develops, of course; you will be faced with performance issues. For this, drawing processes;
I strongly recommend you do this in thread.
Yes, this I called View.
The user will use the screen to drag and drop;
-MouseDown, MouseMove, MouseUp procedures From MouseMove
Or used in enlarging, reducing operations,mousewheel
This I called Controller.
Controller is always driven by user actions. Mouse/Keyboard events.
Perform the drawing, triggering this function within the procedure.
So, as I understood correctly, you call Model from Controller, then initiate a thread do call View?
My concern here is that, if Model called from Mouse/Keyboard events, it may slow down user input, make it delay when while Model is processing.
Imagine a situation your Model has 10000 objects, that will result creating 100000 graphical primitives (points, lines, etc).
Time of processing of Model can be 5 sec.
Time of processing of View that draws primitives to bitmap, can take another 5 sec, but this is done in thread.
So, each time user moves a point on screen, it will block Controller for 5 sec and no other interaction will be possible.
And user will see visual response after View done, after 5 sec. But this will not lock repainting other controls by system.
@ furious programming
please read the example above. What do you think, if whole rendering (Model+View) process is called from inside onPaint, that may delay repaints of other controls on screen, if system decides to repaint them.
Also it delays to process other events. It blocks whole Application event queue. For example it will not refresh ProgressBar, or capture click Cancel button.
This is how it is now in my program, by the way.