I'm trying to draw a chart and trapped over a design issue. In the Chart-class I defined the shape of the area to be drawn in as a Rectangle:
class Chart
{
// ...
public Rectangle drawArea;
public void addAxisDesc(AxisDescription desc)
{
// ... add left Y-axis
// set the axis x-starting position to the start point of the drawing area
desc.shape.X = drawArea.X;
}
}
The Chart-class has the ability to add some axis description, whose shape is also defined by a Rectangle.
My goal is now to keep the values in desc.shape.X and drawArea.X the same. So if drawArea.X changes, desc.shape.X should be modyfied either.
I had a few ideas how to solve this problem, but none of them seemed really good to me:
Has anybody an idea how to solve this issue or maybe how the problem can be avoided at all?
I suggest you go with the event approach. This is the same approach WPF uses for Data Binding. There even exists an interface for that purpose: INotifyPropertyChanged
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.