# how to draw resizable circle with radius in it

Posted by Shanky11 under Windows Forms on 10/4/2013 | Points: 10 | Views : 1107 | Status : [Member] | Replies : 0
i am psting my code below
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Measurement
{
public partial class Demo : Form
{
int circleDiameter = 100;
int dia;
//double circleDiameter;
double distance;
public Demo()
{
InitializeComponent();
}
public double getdistance()
{
float dis;
string s = l.startPoint.ToString();
string s2 = l.endPoint.ToString();
dis = (l.endPoint.X - l.startPoint.X) * (l.endPoint.X - l.startPoint.X) + (l.endPoint.Y - l.startPoint.Y) * (l.endPoint.Y - l.startPoint.Y);
//distance = Math.Sqrt(dis).ToString();
distance = Math.Sqrt(dis);
string distan = distance.ToString();
return distance;
}

private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
dia = Convert.ToInt32(getdistance());
Point CenterPoint = new Point()
{
X = this.ClientRectangle.Width / 2,
Y = this.ClientRectangle.Height / 2
};
Point topLeft = new Point()
{
X = (this.ClientRectangle.Width - circleDiameter) / 2,
Y = (this.ClientRectangle.Height - circleDiameter) / 2
};
Point topRight = new Point()
{
X = (this.ClientRectangle.Width + circleDiameter) / 2,
Y = (this.ClientRectangle.Height - circleDiameter) / 2
};
Point bottomLeft = new Point()
{
X = (this.ClientRectangle.Width - circleDiameter) / 2,
Y = (this.ClientRectangle.Height + circleDiameter) / 2
};
Point bottomRight = new Point()
{
X = (this.ClientRectangle.Width + circleDiameter) / 2,
Y = (this.ClientRectangle.Height + circleDiameter) / 2
};
Point midpoint = new Point()

{
X = (this.ClientRectangle.Width + circleDiameter) / 2,
Y = (this.ClientRectangle.Height) / 2
};

// e.Graphics.DrawRectangle(Pens.Red, topLeft.X, topLeft.Y, circleDiameter, circleDiameter);
//e.Graphics.DrawLine(Pens.Red, CenterPoint, topLeft);
//e.Graphics.DrawLine(Pens.Red, CenterPoint, topRight);
//e.Graphics.DrawLine(Pens.Red, CenterPoint, bottomLeft);
//e.Graphics.DrawLine(Pens.Red, CenterPoint, bottomRight);
e.Graphics.DrawEllipse(Pens.Red, topLeft.X, topLeft.Y, circleDiameter, circleDiameter);//circle draw

}

}
}

#### Responses

(No response found.)

Latest Posts