ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

CodeGo.net>如何选择和放大Zedgraph中的Masterpane

2019-11-22 19:05:41  阅读:202  来源: 互联网

标签:zedgraph visual-studio-2010 c visual-studio


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

在我的代码中,我创建了一个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

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有