Long ago I built a trace class to manage a list of measurement points:
public class TraceXYZ : CollectionBase, ICloneable { … }
Much later, after TraceXYZ
was used pervasively throughout my software, I started using the excellent graphing package, ZedGraph. So, I added a TraceXYZ
method .toLineItem()
that returned a LineItem
compatible with the zedGraph GraphPane‘s CurveList property.
As I increasingly use this feature I’m discovering it can be rather clunky in applications where I need to update a TraceXYZ
object and have the modified values shown in a zedGraph pane. As it currently exists, I have to keep track of the TraceXYZ
’s associated LineItem
in the CurveList
, remove it and then create and add a new LineItem
reflecting the modified TraceXYZ
.
Far preferable would be a capability allowing CurveList
operate directly on a TraceXYZ
, but since I already inherit from CollectionBase
, I can’t also inherit from a LineItem
too. More, there is no associated interfaces I can find (such as ILineItem
) in zedGraph that would allow me to implement the functionality.
Finally, I recoded the guts of TraceXYZ
to use a list of zedGraph PointPair
objects and then tried to copy them by reference into a LineItem
so modifications to the original point in TraceXYZ
would be reflected in the zedGraph pane. This didn’t work, however. Apparently the CurveList.AddPoint() method does a clone of points and they are no longer referenced to the originals in TraceXYZ
.
So… Any thoughts how I could accomplish something like this? Ideally, as an example I’d like to be able to do something like the following:
TraceXYZ trace = new TraceXYZ();
... populate trace points ...
pane.CurveList.Add( trace );
zedGraph.AxisChange( );
zedGraph.Refresh( );
trace[index].Y = aNewValue;
zedGraph.AxisChange( );
zedGraph.Refresh( );
and have the new value of Y be reflected in the zedGraph pane.
(Since I use TraceXYZ
extensively, reforming it to inherit from LineItem
a significant, risky effort that is only a last resort.)