當前位置: 首頁>>代碼示例>>C#>>正文


C# LineItem.GetRange方法代碼示例

本文整理匯總了C#中ZedGraph.LineItem.GetRange方法的典型用法代碼示例。如果您正苦於以下問題:C# LineItem.GetRange方法的具體用法?C# LineItem.GetRange怎麽用?C# LineItem.GetRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ZedGraph.LineItem的用法示例。


在下文中一共展示了LineItem.GetRange方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BUT_run_Click

        private void BUT_run_Click(object sender, EventArgs e)
        {
            Utilities.FFT2 fft = new FFT2();

            using (OpenFileDialog ofd = new OpenFileDialog())
            {

                ofd.Filter = "*.wav|*.wav";

                ofd.ShowDialog();

                if (!File.Exists(ofd.FileName))
                    return;

                var st = File.OpenRead(ofd.FileName);

                int bins = 10;

                double[] buffer = new double[1 << bins];

                int a = 0;

                while (st.Position < st.Length)
                {
                    byte[] temp = new byte[2];
                    var read = st.Read(temp, 0, temp.Length);

                    var val = (double)BitConverter.ToInt16(temp, 0);

                    buffer[a] = val;

                    a++;

                    if (a == (1 << bins))
                    {
                        var fftanswer = fft.rin(buffer, (uint)bins);

                        var freqt = fft.FreqTable(buffer.Length, 1000);

                        ZedGraph.PointPairList ppl = new ZedGraph.PointPairList();

                        for (int b = 0; b < fftanswer.Length; b++)
                        {
                            ppl.Add(freqt[b], fftanswer[b]);
                        }

                        double xMin, xMax, yMin, yMax;

                        var curve = new LineItem("FFT", ppl, Color.Red, SymbolType.Diamond);

                        curve.GetRange(out xMin, out xMax, out yMin, out  yMax, true, false, zedGraphControl1.GraphPane);

                        zedGraphControl1.GraphPane.XAxis.Title.Text = "Freq Hz";
                        zedGraphControl1.GraphPane.YAxis.Title.Text = "Amplitude";
                        zedGraphControl1.GraphPane.Title.Text = "FFT";
                        zedGraphControl1.GraphPane.CurveList.Clear();
                        zedGraphControl1.GraphPane.CurveList.Add(curve);

                        zedGraphControl1.Invalidate();
                        zedGraphControl1.AxisChange();

                        zedGraphControl1.Refresh();

                        int width = Console.WindowWidth - 1;
                        int height = Console.WindowHeight - 1;

                        int r = 1;
                        foreach (var ff in fftanswer)
                        {
                            int col = (int)((r / (double)fftanswer.Length) * width);
                            int row = (int)((ff * 0.2) + 0.5);

                            //Console.SetCursorPosition(col, height - row);
                            Console.Write("*");
                            r++;
                        }

                        // 50% overlap
                        st.Seek(-(1 << bins) / 2, SeekOrigin.Current);
                        a = 0;
                        buffer = new double[buffer.Length];
                        //Console.Clear();
                    }
                }
            }
        }
開發者ID:marcoarruda,項目名稱:MissionPlanner,代碼行數:86,代碼來源:fftui.cs


注:本文中的ZedGraph.LineItem.GetRange方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。