2013-02-25 29 views
1

我想創建一個2維圖並在該圖上顯示2^40000個點。現在明顯地顯示所有這些是不可能的。沒有人會擁有那麼多的記憶。所以,我想只顯示某些時間點,例如2^7左右,並允許平移設施,因此當用戶平移時,它會加載並顯示下一個點。在C#winforms中顯示2^40000點

所以,問題是:

1)這可能在WinForms?

2)如何在用戶平移屏幕時得到通知。任何代碼示例將不勝感激。

+4

1)是的。 2)使用鼠標或鍵盤事件。 – 2013-02-25 08:31:33

+2

感謝上帝,你發佈的評論,而不是回答:) – Jack 2013-02-25 08:33:02

+3

@傑克我認爲'MD.Unicorn'評論是一個合理的答案你的問題 – 2013-02-25 08:34:44

回答

0

使用ZedGraph可能

using System; 
using System.Drawing; 
using System.Threading; 
using System.Windows.Forms; 
using ZedGraph; 

namespace GraphTest 
{ 
    public partial class Form1 : Form 
    { 
     private readonly Fill _flip = new Fill(Color.White); 
     private readonly PointPairList _mPointsListSample; 
     private readonly GraphPane _myPane; 

     public Form1() 
     { 
      InitializeComponent(); 

      _myPane = zedGraphControl1.GraphPane; 
      _myPane.YAxis.Title.Text = "Sample"; 
      _myPane.YAxis.Title.FontSpec.Size = 5f; 
      _myPane.YAxis.Scale.FontSpec.Size = 5f; 
      _myPane.XAxis.Scale.FontSpec.Size = 5f; 
      _mPointsListSample = new PointPairList(); 

      _myPane.Chart.Fill = new Fill(Color.White, Color.Black, 45F); 
      _myPane.Fill = new Fill(Color.White, Color.Black, 45F); 

      _myPane.XAxis.MajorGrid.IsVisible = true; 
      _myPane.XAxis.Scale.Min = 0; 
      _myPane.XAxis.Scale.Max = Convert.ToInt32(Math.Pow(2, 7)); 


      _myPane.YAxis.Title.FontSpec.FontColor = Color.Pink; 
      _myPane.YAxis.Scale.Align = AlignP.Inside; 
      _myPane.YAxis.Scale.Min = 0; 
      _myPane.YAxis.Scale.Max = 500; 



     } 

     private void Form1_Shown(object sender, EventArgs e) 
     { 
      var limit = new Random(); 
      bool flag = true; 
      while (true) 
      { 
       if (flag) 
       { 
        for (int i = 0; i < Convert.ToInt32(Math.Pow(2, 7)); i++) 
        { 
         _mPointsListSample.Add(i, limit.Next(500)); 
         Thread.Sleep(50); 
         Application.DoEvents(); 
         DrawGraph(); 
         flag = false; 
        } 
       } 
       if (!flag) 
       { 
        for (int i = 0; i < Convert.ToInt32(Math.Pow(2, 7) - 1); i++) 
         _mPointsListSample[i].Y = _mPointsListSample[i + 1].Y; 
        _mPointsListSample.Insert(Convert.ToInt32(Math.Pow(2, 7) - 1), Convert.ToInt32(Math.Pow(2, 7) - 1), limit.Next(500)); 
        _mPointsListSample.RemoveAt(Convert.ToInt32(Math.Pow(2, 7))); 
        Thread.Sleep(50); 
        Application.DoEvents(); 
        DrawGraph(); 
       } 
      } 
     } 

     private void DrawGraph() 
     { 
      _myPane.CurveList.Clear(); 
      // Fabricate some data values 
      LineItem myCurve = _myPane.AddCurve("Sample", _mPointsListSample, Color.Red, SymbolType.Circle); 
      myCurve.Symbol.Fill = _flip; 
      myCurve.Line.IsVisible=false; 
      zedGraphControl1.AxisChange(); 
      zedGraphControl1.Refresh(); 
     } 
    } 
} 

我希望它可以幫助你預計2^7繪製使用二維圖形的所有值,在winform withrange。

+0

Hes詢問是否可以在平移時繪製點數...您的答案一次繪製所有內容,對於一組2^40000分 – 2013-02-25 16:58:52

+4

哇這個代碼必須真正執行所有那些thread.Sleep()和Application.DoEvents(),這種場景的理想選擇。 – 2013-02-25 21:38:29

+0

它是有用的評論或代碼是有用的?但沒有人投票回答 – 2013-02-28 05:47:39