Using a pre-existing trace class with CurveList
<p>Long ago I built a trace class to manage a list of measurement points:</p>

<pre><code>public class TraceXYZ : CollectionBase, ICloneable { … }
</code></pre>

<p>Much later, after <code>TraceXYZ</code> was used pervasively throughout my software, I started using the excellent graphing package, ZedGraph.  So, I added a <code>TraceXYZ</code> method <code>.toLineItem()</code> that returned a <code>LineItem</code> compatible with the zedGraph GraphPane‘s CurveList property.</p>

<p>As I increasingly use this feature I’m discovering it can be rather clunky in applications where I need to update a <code>TraceXYZ</code> object and have the modified values shown in a zedGraph pane.  As it currently exists, I have to keep track of the <code>TraceXYZ</code>’s  associated <code>LineItem</code> in the <code>CurveList</code>, remove it and then create and add a new <code>LineItem</code> reflecting the modified <code>TraceXYZ</code>.</p>

<p>Far preferable would be a capability allowing <code>CurveList</code> operate directly on a <code>TraceXYZ</code>, but since I already inherit from <code>CollectionBase</code>, I can’t also inherit from a <code>LineItem</code> too.  More, there is no associated interfaces I can find (such as <code>ILineItem</code>) in zedGraph that would allow me to implement the functionality.  </p>

<p>Finally, I recoded the guts of <code>TraceXYZ</code> to use a list of zedGraph <code>PointPair</code> objects and then tried to copy them by reference into a <code>LineItem</code> so modifications to the original point in <code>TraceXYZ</code> 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 <code>TraceXYZ</code>.</p>

<p>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:</p>

<pre><code>TraceXYZ trace = new TraceXYZ();

... populate trace points ...


pane.CurveList.Add( trace );
zedGraph.AxisChange( );
zedGraph.Refresh( );

trace[index].Y = aNewValue;

zedGraph.AxisChange( );
zedGraph.Refresh( );
</code></pre>

<p>and have the new value of Y be reflected in the zedGraph pane.</p>

<p>(Since I use <code>TraceXYZ</code> extensively, reforming it to inherit from <code>LineItem</code> a significant, risky effort that is only a last resort.) </p>