我正在使用 ZedGraph 库以 DevExpress Ribbon 表单显示数据。我使用 ShowDialog 方法调用表单并在使用后将其丢弃。但是,当我在处理表单后尝试再次显示数据时,它没有出现。
GraphPane zed1Graph;
LineItem zed1PosLineItem;
LineItem zed1ForceLineItem;
LineItem zed1RefLineItem;
LineItem zed1PPLLineItem;
public PointPairList zed1RefRPPL = new PointPairList();
public RollingPointPairList zed1PosRPPL = new RollingPointPairList(2000);
public RollingPointPairList zed1ForceRPPL = new RollingPointPairList(2000);
public PointPairList zed1RefPPL = new PointPairList();
public void zed1GraphPrepare()
{
zed1Graph = zgc1.GraphPane;
zed1Graph.Title.Text = "Actuator1";
zed1Graph.Title.FontSpec.IsBold = false;
zed1Graph.Title.FontSpec.FontColor = System.Drawing.Color.Red;
zed1Graph.YAxis.Scale.Min = 0;
zed1Graph.XAxis.Scale.Max = 10;
zed1Graph.XAxis.Scale.MinorStep = 1;
zed1Graph.XAxis.Scale.MajorStep = 1;
zed1Graph.XAxis.MajorGrid.IsVisible = true;
zed1Graph.YAxis.MajorGrid.IsVisible = true;
zed1Graph.XAxis.MajorGrid.Color = System.Drawing.Color.Black;
zed1Graph.Y2Axis.IsVisible = true;
zed1Graph.XAxis.Title.Text = "Zaman";
zed1Graph.YAxis.Title.Text = "Pos(mm)";
zed1Graph.Y2Axis.Title.Text = "Kuvvet(N)";
zed1Graph.Y2Axis.Title.FontSpec.FontColor = System.Drawing.Color.Blue;
zed1PosLineItem = zed1Graph.AddCurve("Pos(mm)", zed1PosRPPL, System.Drawing.Color.Black, SymbolType.None);
zed1ForceLineItem = zed1Graph.AddCurve("Kuvvet(N)", zed1ForceRPPL, System.Drawing.Color.Blue, SymbolType.None);
zed1ForceLineItem.IsY2Axis = true;
zed1RefLineItem = zed1Graph.AddCurve("Ref", zed1RefRPPL, System.Drawing.Color.Red, SymbolType.None);
zed1PPLLineItem = zed1Graph.AddCurve("Ref", zed1RefPPL, System.Drawing.Color.Red, SymbolType.None);
zed1PPLLineItem.Label.IsVisible = false;
zgc1.ContextMenuBuilder +=
new ZedGraphControl.ContextMenuBuilderEventHandler(zgc1ContextMenuBuilder);
}
我创建了一个不同的类并使用 PaintPointList 作为静态成员变量来解决这个问题。
class DorkEksenGraphData
{
public static RollingPointPairList zed1RefRPPL = new RollingPointPairList(2000);
public static RollingPointPairList zed1PosRPPL = new RollingPointPairList(2000);
public static RollingPointPairList zed1ForceRPPL = new RollingPointPairList(2000);
public static PointPairList zed1RefPPL = new PointPairList();
}