2013-09-23 30 views
3

我一直在網上搜索這個問題,並通過了文檔,但沒有找到解決方案。如何在Zedgraph中選擇和放大Masterpane

在我的代碼中,我創建了一個MasterPane並使用了13個GraphPanes,問題是如果有很多圖,細節變得難以區分,因此我想選擇(通過單擊)圖並放大它。具體的功能來實現這個目標。如果不是,那麼要遵循哪些步驟。

預先感謝您

回答

3


即使晚了,我希望它會幫助別人。
這個想法是使用MasterPan PaneList集合。
我在窗口中添加了幾個按鈕,並從中進行控制,另一種方法
是在MasterPan類中使用FindPane方法,並通過單擊來完成此操作。
我將展示兩種方式。
代碼如下:

// graphSystem Class 
    MasterPane masterPane; 
    PaneList plist = new PaneList(); 

    private void InitGraphs() 
    { 
     //Zedgraph control 
     var zgc = Apprefs.Zedgraph; 
     //MasterPan 
     masterPane = zgc.CreateMasterPan(Title, System.Drawing.Color.White); 

     // CreateMultiGraph is my own API to create Graph 
     zgc.CreateMultiGraph("Graph1", 1, "G1xtitle", "G1ytitle", false); 
     zgc.CreateMultiGraph("Graph2", 1, "G2xtitle", "G2ytitle", false); 
     zgc.CreateMultiGraph("Graph3", 1, "G3xtitle", "G3ytitle", false); 

     // save the Pans 
      foreach (GraphPane graph in masterPane.PaneList) 
       plist.Add(graph);    
    } 
    //--------------------------------------------------------------------------- 
    public void Englare(RichButton button) 
    { 
     var graph = Apprefs.Zedgraph2.graph; 

     if (button.Name == "Show1") 
     { 
      ShowOneGraph(0); 
     } 
     else if (button.Name == "Show2") 
     { 
      ShowOneGraph(1); 
     } 
     else if (button.Name == "ShowAll") 
     { 
      ShowAllGraphs(); 
     } 
    } 
    //--------------------------------------------------------------------------- 
    private void ShowOneGraph(int Graphindex) 
    { 
     if (masterPane == null) return; 
     var graph = Apprefs.Zedgraph.graph; 

     if (Graphindex >= 0 && Graphindex < plist.Count) 
     { 
      masterPane.PaneList.Clear(); 
      masterPane.PaneList.Add(plist[Graphindex]); 

      Layout(); 
     } 
    } 
    //--------------------------------------------------------------------------- 
    private void ShowAllGraphs() 
    { 
     if (masterPane == null) return; 
     var graph = Apprefs.Zedgraph.graph; 

      masterPane.PaneList.Clear(); 
      foreach (GraphPane gr in plist) 
       masterPane.PaneList.Add(gr); 

      Layout();   
    } 
    //--------------------------------------------------------------------------- 
    private void Layout() 
    { 
     var graph = Apprefs.Zedgraph2.graph; 
     using (Graphics g = graph.CreateGraphics()) 
     { 
      masterPane.SetLayout(g, PaneLayout.SingleColumn); 
      graph.AxisChange(); 
      graph.Refresh(); 
     } 
    } 
    //--------------------------------------------------------------------------- 

way2:englare通過點擊圖:
添加這個方法:

 //--------------------------------------------------------------------------- 
    GraphPane lastpan; 
    public void UCclicked(PointF mousePt) 
    { 
     GraphPane pan= masterPane.FindPane(mousePt); 
     if (pan != null) 
     { 
      if (pan == lastpan) 
      { 
       ShowAllGraphs(); 
       lastpan = null; 
      } 
      else 
      { 
       ShowOneGraph(plist.IndexOf(pan)); 
       lastpan = pan; 
      } 
     }  } 

也註冊到Click事件:

zgcGraph.MouseDoubleClick += new MouseEventHandler(zgcGraph_MouseDoubleClick); 

而且最後:

 void zgcGrzgcGraph_MouseDoubleClick(object source, System.Windows.Forms.MouseEventArgs e) 
    { 
     if (Apprefs.graphSystem != null) 
     { 
      System.Drawing.PointF mousePt = new System.Drawing.PointF(e.X, e.Y); 
      Apprefs.graphSystem.UCclicked(mousePt); 
     } 
    } 

多數民衆贊成它!

+1

©謝謝您的回答,我無法理解的是您使用的Apprefs命名空間(或者它是什麼)。請您澄清一下,非常感謝 –