I'm developing a sine cosine zedgraph control where user are allowed to select the .txt file contain data from the explorer then generate the graph. Here's the code:
private void GraphSetup()
{
// Lets generate sine and cosine wave
int i;
double[] x = new double[2000];
double[] y = new double[2000];
for(i=0; i<2000; i++)
{
GlobalDataClass.dDataArray[i, 0] = 0.0;
GlobalDataClass.dDataArray[i, 1] = 0.0;
}
GlobalDataClass.dDataArray[0, 0] = 0;
zedGraphControlStickiness.GraphPane.CurveList.Clear();
GraphPane StickinessPane = zedGraphControlStickiness.GraphPane;
StickinessPane.CurveList.Clear();
// PointPairList holds the data for plotting, X and Y arrays
PointPairList spl1 = new PointPairList(x, y);
// Add cruves to myPane object
LineItem myCurve1 = StickinessPane.AddCurve("Insertion Force", spl1, Color.Blue, SymbolType.None);
myCurve1.Line.Width = 2.0F;
StickinessPane.XAxis.Title.Text = "Sample ";
StickinessPane.YAxis.Title.Text = "Force ";
StickinessPane.Title.Text = "Pressure Measurement";
// zedGraphControlStickiness.AxisChange();
zedGraphControlStickiness.Invalidate();
zedGraphControlStickiness.Refresh();
}
public void ShowGraphData(long lTotalData)
{
double[] dx = new double[lTotalData];
double[] dy = new double[lTotalData];
for (long li = 0; li < lTotalData; li++)
{
dx[li] = GlobalDataClass.dDataArray[li, 0];
dy[li] = GlobalDataClass.dDataArray[li, 1];
}
zedGraphControlStickiness.GraphPane.CurveList.Clear();
GraphPane StickinessPane = zedGraphControlStickiness.GraphPane;
// PointPairList holds the data for plotting, X and Y arrays
PointPairList spl1 = new PointPairList(dx, dy);
// Add cruves to myPane object
LineItem ProductionCurve = StickinessPane.AddCurve("Insertion Force", spl1, Color.Blue, SymbolType.None);
ProductionCurve.Line.Width = 2.0F;
zedGraphControlStickiness.AxisChange();
zedGraphControlStickiness.Invalidate();
zedGraphControlStickiness.Refresh();
GlobalDataClass.iTotalReadingPoint = lTotalData;
}
private void GraphSetup()
{
// Lets generate sine and cosine wave
int i;
double[] x = new double[2000];
double[] y = new double[2000];
for(i=0; i<2000; i++)
{
GlobalDataClass.dDataArray[i, 0] = 0.0;
GlobalDataClass.dDataArray[i, 1] = 0.0;
}
GlobalDataClass.dDataArray[0, 0] = 0;
zedGraphControlStickiness.GraphPane.CurveList.Clear();
GraphPane StickinessPane = zedGraphControlStickiness.GraphPane;
StickinessPane.CurveList.Clear();
// PointPairList holds the data for plotting, X and Y arrays
PointPairList spl1 = new PointPairList(x, y);
// Add cruves to myPane object
LineItem myCurve1 = StickinessPane.AddCurve("Insertion Force", spl1, Color.Blue, SymbolType.None);
myCurve1.Line.Width = 2.0F;
StickinessPane.XAxis.Title.Text = "Sample ";
StickinessPane.YAxis.Title.Text = "Force ";
StickinessPane.Title.Text = "Pressure Measurement";
// zedGraphControlStickiness.AxisChange();
zedGraphControlStickiness.Invalidate();
zedGraphControlStickiness.Refresh();
}
public void ShowGraphData(long lTotalData)
{
double[] dx = new double[lTotalData];
double[] dy = new double[lTotalData];
for (long li = 0; li < lTotalData; li++)
{
dx[li] = GlobalDataClass.dDataArray[li, 0];
dy[li] = GlobalDataClass.dDataArray[li, 1];
}
zedGraphControlStickiness.GraphPane.CurveList.Clear();
GraphPane StickinessPane = zedGraphControlStickiness.GraphPane;
// PointPairList holds the data for plotting, X and Y arrays
PointPairList spl1 = new PointPairList(dx, dy);
// Add cruves to myPane object
LineItem ProductionCurve = StickinessPane.AddCurve("Insertion Force", spl1, Color.Blue, SymbolType.None);
ProductionCurve.Line.Width = 2.0F;
zedGraphControlStickiness.AxisChange();
zedGraphControlStickiness.Invalidate();
zedGraphControlStickiness.Refresh();
GlobalDataClass.iTotalReadingPoint = lTotalData;
}
And now i have like a button click that will allow user to open dialog file and select txt file contain and save it to my array.
private void load_data_from_PC_Click(object sender, EventArgs e)
{
//save data to array
}
Need help please.TQ