如何在Zedgraph中选择和放大Masterpane [英] How to select and enlarge a Masterpane in Zedgraph

查看:123
本文介绍了如何在Zedgraph中选择和放大Masterpane的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在网上搜索此问题,并浏览了文档,但是未能成功找到解决方案.

I have been searching this issue in the web and have gone trough the documentation,however was not successful in finding a solution.

在我的代码中,我创建了一个MasterPane并使用了13个GraphPanes,问题是,如果有很多图形,则细节变得难以区分,因此我想选择(单击)图形并放大它.功能来实现此目标.否则,应遵循哪些步骤.

In my code I have created a MasterPane and utilize 13 GraphPanes,The problem is that if there are many graphs, the details become indistinguishable,hence I want to select(by clicking) a graph and enlarge it.Is there a specific function to realize this goal.If not,which steps are to be followed.

提前谢谢

推荐答案


甚至迟到了,我希望它会对其他人有所帮助.
这个想法是使用MasterPan PaneList集合.
我在窗口中添加了一些按钮,并通过另一种方法从中进行控制
是要在MasterPan类中使用FindPane方法,然后单击以执行此操作.
我会展示两种方式.
代码如下:


Even late,i hope it'll will help others.
The idea is to use the MasterPan PaneList collection.
I added a few buttons to the Window and do the control from them, another way
is to use FindPane method in the MasterPan class and do this by clicking.
I'll show both ways.
The code follows:

   // 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:单击图上"以炫耀:
添加此方法:

way2: englare by click On Graph:
Add this method:

        //---------------------------------------------------------------------------
    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中选择和放大Masterpane的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆