CodeGo.net>如何选择和放大Zedgraph中的Masterpane
作者:互联网
我一直在网上搜索此问题,并浏览了文档,但是未能成功找到解决方案.
在我的代码中,我创建了一个MasterPane并使用了13个GraphPanes,问题是,如果有很多图形,则细节变得难以区分,因此我想选择(单击)图形并将其放大.是否有特定功能要实现如果没有,应该遵循哪些步骤.
先感谢您
解决方法:
甚至迟到了,我希望它将对其他人有所帮助.
这个想法是使用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();
}
}
//---------------------------------------------------------------------------
方式2:点击Graph即可使自己感到高兴:
添加此方法:
//---------------------------------------------------------------------------
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;
}
} }
同时注册点击事件:
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);
}
}
而已!
标签:zedgraph,visual-studio-2010,c,visual-studio 来源: https://codeday.me/bug/20191122/2062047.html