Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# C正弦余弦ZedGraph_C#_Zedgraph_Trigonometry - Fatal编程技术网

C# C正弦余弦ZedGraph

C# C正弦余弦ZedGraph,c#,zedgraph,trigonometry,C#,Zedgraph,Trigonometry,我正在开发一个正弦-余弦zedgraph控件,允许用户从浏览器中选择包含数据的.txt文件,然后生成图形。代码如下: 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&

我正在开发一个正弦-余弦zedgraph控件,允许用户从浏览器中选择包含数据的.txt文件,然后生成图形。代码如下:

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;

    }
需要帮助。TQ

来自。删除了“所有文件”选项

Stream myStream = null;
OpenFileDialog openFileDialog1 = new OpenFileDialog();

openFileDialog1.InitialDirectory = "c:\\" ;
openFileDialog1.Filter = "txt files (*.txt)|*.txt" ;
openFileDialog1.FilterIndex = 2 ;
openFileDialog1.RestoreDirectory = true ;

if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
    try
    {
        if ((myStream = openFileDialog1.OpenFile()) != null)
        {
            using (myStream)
            {
                // Insert code to read the stream here.
            }
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
    }
}
从。删除了“所有文件”选项

Stream myStream = null;
OpenFileDialog openFileDialog1 = new OpenFileDialog();

openFileDialog1.InitialDirectory = "c:\\" ;
openFileDialog1.Filter = "txt files (*.txt)|*.txt" ;
openFileDialog1.FilterIndex = 2 ;
openFileDialog1.RestoreDirectory = true ;

if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
    try
    {
        if ((myStream = openFileDialog1.OpenFile()) != null)
        {
            using (myStream)
            {
                // Insert code to read the stream here.
            }
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
    }
}
从。删除了“所有文件”选项

Stream myStream = null;
OpenFileDialog openFileDialog1 = new OpenFileDialog();

openFileDialog1.InitialDirectory = "c:\\" ;
openFileDialog1.Filter = "txt files (*.txt)|*.txt" ;
openFileDialog1.FilterIndex = 2 ;
openFileDialog1.RestoreDirectory = true ;

if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
    try
    {
        if ((myStream = openFileDialog1.OpenFile()) != null)
        {
            using (myStream)
            {
                // Insert code to read the stream here.
            }
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
    }
}
从。删除了“所有文件”选项

Stream myStream = null;
OpenFileDialog openFileDialog1 = new OpenFileDialog();

openFileDialog1.InitialDirectory = "c:\\" ;
openFileDialog1.Filter = "txt files (*.txt)|*.txt" ;
openFileDialog1.FilterIndex = 2 ;
openFileDialog1.RestoreDirectory = true ;

if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
    try
    {
        if ((myStream = openFileDialog1.OpenFile()) != null)
        {
            using (myStream)
            {
                // Insert code to read the stream here.
            }
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
    }
}
希望这对你有帮助

您可以在事件中使用代码

// Create an instance of the open file dialog box.
        OpenFileDialog openFileDialog1 = new OpenFileDialog();

        // Set filter options and filter index.
        openFileDialog1.Filter = "Text Files (.txt)|*.txt|All Files (*.*)|*.*";
        openFileDialog1.FilterIndex = 1;

        openFileDialog1.Multiselect = true;

        // Call the ShowDialog method to show the dialog box.
        bool? userClickedOK = openFileDialog1.ShowDialog();

        // Process input if the user clicked OK.
        if (userClickedOK == true)
        {
            // Open the selected file to read.
            System.IO.Stream fileStream = openFileDialog1.File.OpenRead();

            using (System.IO.StreamReader reader = new System.IO.StreamReader(fileStream))
            {
                // Read the first line from the file and write it the textbox.
                tbResults.Text = reader.ReadLine();
            }
            fileStream.Close();
        }
希望这对你有帮助

您可以在事件中使用代码

// Create an instance of the open file dialog box.
        OpenFileDialog openFileDialog1 = new OpenFileDialog();

        // Set filter options and filter index.
        openFileDialog1.Filter = "Text Files (.txt)|*.txt|All Files (*.*)|*.*";
        openFileDialog1.FilterIndex = 1;

        openFileDialog1.Multiselect = true;

        // Call the ShowDialog method to show the dialog box.
        bool? userClickedOK = openFileDialog1.ShowDialog();

        // Process input if the user clicked OK.
        if (userClickedOK == true)
        {
            // Open the selected file to read.
            System.IO.Stream fileStream = openFileDialog1.File.OpenRead();

            using (System.IO.StreamReader reader = new System.IO.StreamReader(fileStream))
            {
                // Read the first line from the file and write it the textbox.
                tbResults.Text = reader.ReadLine();
            }
            fileStream.Close();
        }
希望这对你有帮助

您可以在事件中使用代码

// Create an instance of the open file dialog box.
        OpenFileDialog openFileDialog1 = new OpenFileDialog();

        // Set filter options and filter index.
        openFileDialog1.Filter = "Text Files (.txt)|*.txt|All Files (*.*)|*.*";
        openFileDialog1.FilterIndex = 1;

        openFileDialog1.Multiselect = true;

        // Call the ShowDialog method to show the dialog box.
        bool? userClickedOK = openFileDialog1.ShowDialog();

        // Process input if the user clicked OK.
        if (userClickedOK == true)
        {
            // Open the selected file to read.
            System.IO.Stream fileStream = openFileDialog1.File.OpenRead();

            using (System.IO.StreamReader reader = new System.IO.StreamReader(fileStream))
            {
                // Read the first line from the file and write it the textbox.
                tbResults.Text = reader.ReadLine();
            }
            fileStream.Close();
        }
希望这对你有帮助

您可以在事件中使用代码

// Create an instance of the open file dialog box.
        OpenFileDialog openFileDialog1 = new OpenFileDialog();

        // Set filter options and filter index.
        openFileDialog1.Filter = "Text Files (.txt)|*.txt|All Files (*.*)|*.*";
        openFileDialog1.FilterIndex = 1;

        openFileDialog1.Multiselect = true;

        // Call the ShowDialog method to show the dialog box.
        bool? userClickedOK = openFileDialog1.ShowDialog();

        // Process input if the user clicked OK.
        if (userClickedOK == true)
        {
            // Open the selected file to read.
            System.IO.Stream fileStream = openFileDialog1.File.OpenRead();

            using (System.IO.StreamReader reader = new System.IO.StreamReader(fileStream))
            {
                // Read the first line from the file and write it the textbox.
                tbResults.Text = reader.ReadLine();
            }
            fileStream.Close();
        }

的副本,也在您的.Duplicate of中建议,也在您的.Duplicate of中建议,也在您的.Duplicate of中建议,也在您的.working中建议。但是如果我的文本文件像x一样,y数组ex:1,31 2,32 3,32 4,30 5,26如何将其保存到我的函数以创建图形?工作。但是如果我的文本文件具有类似于x的格式,y数组ex:1,31 2,32 3,32 4,30 5,26如何将其保存到我的函数以创建图形?工作。但是如果我的文本文件具有类似于x的格式,y数组ex:1,31 2,32 3,32 4,30 5,26如何将其保存到函数中以创建图形?工作正常。但是如果我的文本文件具有类似x的y数组ex:1,31 2,32 3,32 4,30 5,26,如何将其保存到函数中以创建图形?