none
WInform画图 RRS feed

答案

  • Hi,

    这是使用GDI+直接在窗体上画出来的,不是图片,没有办法通过鼠标来直接缩放和移动。

    如果你想实现通过鼠标来缩放和移动,我建议你使用chart控件。

    或者使用截图,把这块区域截下来,然后使用picturebox进行缩放处理。

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • 已编辑 Bob Ding 2017年4月7日 10:40
    • 已标记为答案 lctk 2017年4月12日 0:20
    2017年4月7日 10:39

全部回复

  • 多线程(或并行),异步模式(BackgroundWorker),数据提前加载到内存(缓存)


    专注于.NET ERP/CRM开发框架,C/S架构,SQL Server + ORM(LLBL Gen Pro) + Infragistics WinForms

    2017年4月7日 0:11
  • 图形怎么画

    please verify my account

    2017年4月7日 2:21
  • 参考

    http://docs.roguewave.com/imsl/net/5.0.1/chartpg/intro.html

    https://www.codeproject.com/articles/32836/a-simple-c-library-for-graph-plotting


    专注于.NET ERP/CRM开发框架,C/S架构,SQL Server + ORM(LLBL Gen Pro) + Infragistics WinForms

    2017年4月7日 4:23
  • Hi,

    参考:

    public partial class 振荡 : Form
        {
            public 振荡()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                Graphics g = this.CreateGraphics();
                g.DrawLines(new Pen(Color.Red), createData(100, 500,5));
                g.DrawLines(new Pen(Color.Red), createData(200, 500, 5));
                g.DrawLines(new Pen(Color.Red), createData(300, 500, 5));
                Application.DoEvents();
            }
            /// <summary>
            /// 模拟数据
            /// </summary>
            /// <param name="baseValue">基线</param>
            /// <param name="count">点的数量</param>
            /// <param name="Oscillationfrequency">振荡频率</param>
            /// <returns></returns>
            private Point[] createData(int baseValue, int count,int Oscillationfrequency)
            {
                Point[] dataPoints = new Point[count];
                Random ran = new Random();
         
                for (int i = 0; i < count; i++)
                {
                    dataPoints[i] = new Point(i, baseValue + ran.Next(-Oscillationfrequency, Oscillationfrequency));
                }
                return dataPoints;
            }      
    }

    希望有帮助。

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2017年4月7日 8:45
  • 多谢,请问这个图形如何放大,缩小,变化位置

    please verify my account

    2017年4月7日 10:30
  • Hi,

    这是使用GDI+直接在窗体上画出来的,不是图片,没有办法通过鼠标来直接缩放和移动。

    如果你想实现通过鼠标来缩放和移动,我建议你使用chart控件。

    或者使用截图,把这块区域截下来,然后使用picturebox进行缩放处理。

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • 已编辑 Bob Ding 2017年4月7日 10:40
    • 已标记为答案 lctk 2017年4月12日 0:20
    2017年4月7日 10:39
  • 请问能通过按钮放大和缩小吗?还有最下面x轴能显示个数字吗?

    please verify my account

    2017年4月7日 10:43
  • HI,

    >>  请问能通过按钮放大和缩小吗? 

    直接画在Bitmap上,然后再对bitmap进行缩放。

     private void drawData(int width, int height)
            {
                Bitmap BM = new Bitmap(width,height);
                Graphics g = Graphics.FromImage(BM);
                g.DrawImage(BM, BM.Width, BM.Height);
                g.DrawLines(new Pen(Color.Red), createData(100, 500, 5));
                g.DrawLines(new Pen(Color.Red), createData(200, 500, 5));
                g.DrawLines(new Pen(Color.Red), createData(300, 500, 5));
                pictureBox2.Image = BM;
                Application.DoEvents();
                g.Dispose();
            }

    >>还有最下面x轴能显示个数字吗?

    使用DrawString()画。

      Graphics.DrawString(“... ”,new Font("宋体", 8), new SolidBrush(Color.Black), x, y);

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2017年4月7日 12:42
  • Hi,

    参考:

    public partial class 振荡 : Form
        {
            public 振荡()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                Graphics g = this.CreateGraphics();
                g.DrawLines(new Pen(Color.Red), createData(100, 500,5));
                g.DrawLines(new Pen(Color.Red), createData(200, 500, 5));
                g.DrawLines(new Pen(Color.Red), createData(300, 500, 5));
                Application.DoEvents();
            }
            /// <summary>
            /// 模拟数据
            /// </summary>
            /// <param name="baseValue">基线</param>
            /// <param name="count">点的数量</param>
            /// <param name="Oscillationfrequency">振荡频率</param>
            /// <returns></returns>
            private Point[] createData(int baseValue, int count,int Oscillationfrequency)
            {
                Point[] dataPoints = new Point[count];
                Random ran = new Random();
         
                for (int i = 0; i < count; i++)
                {
                    dataPoints[i] = new Point(i, baseValue + ran.Next(-Oscillationfrequency, Oscillationfrequency));
                }
                return dataPoints;
            }      
    }

    希望有帮助。

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    请问

     g.DrawLines   这个怎么知道一屏幕能画多少那?即

    Point[] dataPoints = new Point[count];

    x值一屏幕最大是多少那?


    please verify my account

    2017年4月8日 7:17