用户控件添加贝塞尔 曲线不显示问题

来源:互联网 发布:万能看图王pdf 软件 编辑:程序博客网 时间:2024/06/10 02:07
在应用过程中 在添加    
         Region myRegion = new Region(ppath);

        this.Region = myRegion;      时有时控件不显示 主要是可能单条曲线需要闭包

我们可以扩充闭包区间即可解决。


g = this.CreateGraphics();
            
            Pen pen = new Pen(Color.Blue, 4);
           

           g.DrawBezier(pen, startx, starty, con1x, con1y, con2x, con2y, endx, endy);
//
           // g.DrawBezier(pen, 200, 200, 0, 0, 0, 0, 0, 0);

            g.Dispose();


          // // GraphicsPath graphPath = new GraphicsPath();
          //  graphPath.AddBezier(startx, starty, con1x, con1y, con2x, con2y, endx, endy);

            // Create pen.
           // Pen blackPen = new Pen(Color.Blue , 3);

            // Draw graphics path to screen.
           // e.Graphics.DrawPath(blackPen, graphPath);


            Point[] myPoint=
             {
                 new Point(0, 0),
                 new Point(0 ,2),
                 new Point(endx, endy ),
                 new Point(endx-2, endy-2)
                 
             };


          GraphicsPath ppath= new GraphicsPath();

            
              ppath.StartFigure();

ppath.AddBezier(startx-2, starty-2, con1x-2, con1y-3, con2x-2, con2y-3, endx-2, endy-3);

             // ppath.AddBezier(startx, starty , con1x, con1y , con2x, con2y , endx, endy );

ppath.AddLine(endx-2, endy-3 , endx+2, endy + 3);
           //   ppath.AddLine(endx, endy , endx, endy + 3);
ppath.AddBezier(endx+2, endy+3, con2x+2 , con2y+3, con1x+2, con1y+3, startx+2, starty+3);
ppath.CloseFigure();


//ppath.AddPolygon(myPoint);


             // ppath.AddPath (0, 0,endx, endy);
           
            //ppath.AddBezier(0, 0, 0, 0, 0, 0, 100, 100);
          //  ppath.CloseFigure();
  Region myRegion = new Region(ppath);

               this.Region = myRegion;   

0 0
原创粉丝点击