求助高手,用C#画圆与矩形的方法~

解决方案 »

  1.   

    Graphics
      

  2.   

    晕 MSDN就有
    myGraphics.DrawRectangle(myPen, 100, 50, 80, 40);
    http://blog.csdn.net/stone0419/archive/2007/10/04/1811412.aspx
      

  3.   

    private void button1_Click(object sender, EventArgs e)
      {  Graphics _Graphics = Graphics.FromHwnd(pictureBox1.Handle);  _Graphics.DrawEllipse(new Pen(Brushes.Yellow, 2), GetEllopse(new Point(50, 50), 10));
      _Graphics.Dispose();  }
      /// <summary>
      /// 根据圆心和半径获取图形坐标
      /// </summary>
      /// <param name="p_CenterPoint">圆心</param>
      /// <param name="p_Radius">半径</param>
      /// <returns>坐标</returns>
      public Rectangle GetEllopse(Point p_CenterPoint, int p_Radius)
      {
      int _X = p_CenterPoint.X - p_Radius;
      int _Y = p_CenterPoint.Y - p_Radius;
      return new Rectangle(_X, _Y, p_Radius * 2, p_Radius * 2);
      }
      

  4.   

    Graphics g = e.Graphics; //创建画板
    Pen p = new Pen(Color.Blue, 2);
    g.DrawRectangle(p, 10, 10, 100, 100);//在画板上画矩形,起始坐标为(10,10),宽为,高为
    g.DrawEllipse(p, 10, 10, 100, 100);//在画板上画椭圆,起始坐标为(10,10)
      

  5.   

    完全不是一个概念,你的地图不会是google或者其他网页上的吧?不然一个图你怎么会有经纬度信息?
      

  6.   

    把这个话与你八楼的话对比看一下,有些矛盾吧,逻辑 或者 表达
    画圆->在圆上画经纬度?
    有了经纬度(这个么可以自己定义的咯?)->画圆?
      

  7.   

    google上画?google上有自己的API呀
      

  8.   


    Graphics g = e.Graphics; //创建画板
    Pen p = new Pen(Color.Blue, 2);
    g.DrawRectangle(p, 10, 10, 100, 100);//在画板上画矩形,起始坐标为(10,10),宽为,高为
    g.DrawEllipse(p, 10, 10, 100, 100);//在画板上画椭圆,起始坐标为(10,10)
      

  9.   

    #region GoogleMap
            /// <summary>
            /// GoogleMap
            /// </summary>
            ///点,线坐标
            public void GoogleMap(string allPoint, string allLine)
            {
                //webBrowser1.Navigate("http://localhost:2865/Default.aspx");            wbMap.ObjectForScripting = this;            string szWebBrowserText = @"
            <html>
            <head>
            <title></title>        <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true_or_false&amp;key=ABQIAAAAuLMCs813ETPzKnClYiBwuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxRogqzInHtHXDyDOAQDeSX3MxNWbg'
            type='text/javascript'></script>
            
            <script type='text/javascript'>        function initialize()
            { 
              if (GBrowserIsCompatible())
                { 
                  var map = new GMap2(document.getElementById('map')); 
                  map.setCenter(new GLatLng(26.157042, 111.269531), 6); 
                  map.setUIToDefault();              function createMarker(point, prompt)
                  { 
                      var baseIcon = new GIcon(G_DEFAULT_ICON); 
                      baseIcon.shadow = 'http://www.google.com/mapfiles/shadow50.png'; 
                      baseIcon.iconSize = new GSize(20, 34); 
                      baseIcon.shadowSize = new GSize(37, 34); 
                      baseIcon.iconAnchor = new GPoint(9, 34); 
                      baseIcon.infoWindowAnchor = new GPoint(9, 2);                   var redIcon = new GIcon(baseIcon);              
                      redIcon.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png';                  
                      erOptions = { icon:redIcon };
                      var er = new GMarker(point, erOptions);
                      GEvent.addListener(er, 'mouseover', function() {
                      er.openInfoWindowHtml(prompt);
                         });                  GEvent.addListener(er, 'click', function(){
                      var xlatlng = er.getLatLng();
                      window.external.ClickPoint(xlatlng.lat().toString(),xlatlng.lng().toString());
                         });                  return er;
                  }              function createMarker02(point, prompt)
                  { 
                      var baseIcon = new GIcon(G_DEFAULT_ICON); 
                      baseIcon.shadow = 'http://maps.google.com/mapfiles/arrowshadow.png'; 
                      baseIcon.iconSize = new GSize(20, 34); 
                      baseIcon.shadowSize = new GSize(37, 34); 
                      baseIcon.iconAnchor = new GPoint(9, 34); 
                      baseIcon.infoWindowAnchor = new GPoint(9, 2);                   var redIcon = new GIcon(baseIcon);              
                      redIcon.image = 'http://maps.google.com/mapfiles/arrow.png';
                      erOptions = { icon:redIcon };
                      var er = new GMarker(point, erOptions);
                      GEvent.addListener(er, 'mouseover', function() {
                      er.openInfoWindowHtml(prompt);
                         });                  GEvent.addListener(er, 'click', function(){
                      window.external.ClickMidPoint(prompt.toString());
                         });                  return er;
                  }              " + allPoint + @"              " + allLine + @"
                }  
            }         </script>
            
            </head>
            <body onload='initialize();' oncontextmenu='event.returnValue=false'>        <div id='map' style='width: 950px; height: 525px;'>
            </div>        </body>
            </html>";            wbMap.DocumentText = szWebBrowserText;
            }
            #endregion这个是C#利用google地图的一小段代码,
      

  10.   

    不是GOOGLE的,是用的我们自己的地图引擎。
      

  11.   

    在form paint 事件里
    Graphics g = e.Grahpics
    具体方法上面给出了。
    或者在load事件里
    Grahpics g = this.CreateGraphics();
    或者在某个控件里
    Grahpics g = button1.CreateGraphics();
    在图片里
    Bitmap mybit = new Bitmap(""e:/1.jpg);
    graphics g = pictureBox1.CreateGraphics();
      

  12.   


    是桌面应用程序了,不是GOOGLE的API,只是用的他们的图片而已,就是要在图片上画圆啊
      

  13.   

    private void pictureBox1_Paint(object sender, PaintEventArgs e)
      {
      Rectangle r=new Rectangle(10,10,10,10); //圆
      e.Graphics.DrawEllipse(new Pen(Color.Red),r); //Graphics.DrawEllipse画椭圆
      }
      

  14.   

    画圆就是上面的代码
    e.Graphics.DrawEllipse(new Pen(Color.Red),r); 关键就是得到这个e,看你的图片放在什么地方了,放在picturebox的话,就是paint里话,还要用个变量保存你这些点的信息