using System.Windows.Forms; using System.Drawing; using Imsl.Chart2D; public class SamplePick : FrameChart { private Chart chart; private double[] x = new double[]{0, 1, 2, 3}; private double[] y = new double[]{4, 1, 2, 5}; public SamplePick() { chart = this.Chart; AxisXY axis = new AxisXY(chart); Bar bar = new Bar(axis, x, y); bar.BarType = Bar.BAR_TYPE_VERTICAL; bar.SetLabels(new string[]{"A","B","C", "D"}); bar.FillColor = Color.Blue; // Add the event handler delegates bar.PickPerformed += new PickEventHandler(SamplePick_PickPerformed); this.Panel.MouseDown += new MouseEventHandler(SamplePick_MouseDown); } private void SamplePick_MouseDown(object sender, MouseEventArgs e) { chart.Pick(e); } private void SamplePick_PickPerformed(PickEventArgs param) { ChartNode node = param.Node; int count = node.GetIntegerAttribute("pick.count", 0); count++; node.SetAttribute("pick.count", (System.Object) (count)); // Change the bar's color depending on the number of times // it has been picked. Color color = ((count % 2 == 0) ? Color.Blue : Color.Red); node.FillColor = color; Refresh(); } public static void Main(string[] argv) { System.Windows.Forms.Application.Run(new SamplePick()); } }