如何使图表适合面板?

时间:2014-08-21 11:16:42

标签: c# winforms drawing

嘿,我正在尝试在.net中构建一个Windows应用程序,我必须在面板中绘制因子图像

 private void Canvas_Paint(object sender, PaintEventArgs e)
        {
            start_x = Canvas.Width / 2;
            start_Y = Canvas.Height / 2;
            for (int i = 0; i < 400; i++)
                draw_T();

        }

 public void draw_T()
        {
            mypen = new Pen(Color.Green, 2F);
            my_angle = my_angle + (45);
            my_length = 100 + (1);

            end_x = (int)(start_x + Math.Cos(my_angle * .0174539676) * my_length);

            end_Y = (int)(start_Y + Math.Sin(my_angle * .0174539676) * my_length);

            Point[] points =
            {
                new Point (start_x,start_Y),
                new Point (end_x,end_Y)
                            };
            Point[] points1 =
            {
                new Point ((end_x+start_x)/2,(end_Y+start_Y)/2),
                 new Point (end_x+50,end_Y-100)
                            };
            start_x = end_x;
            start_Y = end_Y;
            Graphics g = Canvas.CreateGraphics();
            g.DrawLines(mypen, points);
            g.DrawLines(mypen, points1);
        }

绘制T形线,然后我开始从最后的端点绘制另一个T形状。但问题是图表是在面板之外。如何在面板内修复绘图

0 个答案:

没有答案