I have some points (car stops) to represent on a time graph. These points are linked between them by lines. Points + Lines represent a Graph (that is a car schedule). The Graph can be modified by moving CarStops in time with the mouse.
I decided to implement Points and Lines as controls (thought that will be easier to move them on the panels).
I have two business object layers – Real BO (CarStop
) and GUI Control (CarStopControl
).
I associate then a CarStop
(Time, Station) to a CarStopControl
(X, Y) - CarStopControl subscribes to CarStop.Moved events.
Finally, a Car
object has some CarStop
s.
- How do I move controls? Simply:
Detect a mouse move on the panel and compute
dX
, transformdX
indTime
Car.Move(dTime)
– moves all the CarStops. WhenCarStop
moved, send event toCarStopControl
, and the latter change its coordinates. In this wayCarStopControl
seems to follow the mouse movements.
This is all.
The problem appeared when in Car.Move
there was a need to recreate the CarStop
collection – the links between CarStopControl
and CarStop
obviously became obsolete, car BO Car
and CarStop
does not care nor even know about CarStopControl
s.
The similar situation is when Car
itself could be replaced by a new Car
.
Had someone similar situations? Is there a "workaround" of +- quickly fix this problem?
Thanks.