Quantcast
Viewing all articles
Browse latest Browse all 12583

Draw 2 Circle and connects circles at the circumference of the circle

Hello experts Please Help
I have a Problem I am Drawing 2 Circle Using C# Graphics . 

Image may be NSFW.
Clik here to view.

I want to add a Line Between them How do i do that My code Is Below

protected override void OnPaint(PaintEventArgs e)
{
using (Graphics dc = this.CreateGraphics())//data Context
{
Rectangle ellipseArea1 = new Rectangle(0, 0, 200, 200);
Rectangle ellipseArea2 = new Rectangle(0, 300, 200, 200);

StringFormat stringFormat = new StringFormat();
stringFormat.Alignment = StringAlignment.Center;
stringFormat.LineAlignment = StringAlignment.Center;

Pen greenPen = new Pen(Color.Green, BorderWidth);
Pen bluePen = new Pen(Color.Blue, BorderWidth);

float[] dashValues = { 2 ,2, 2, 2 };
Pen darkBluePen = new Pen(Color.DarkBlue, BorderWidth);
//darkBluePen.DashPattern = dashValues;


Brush redBrush = new SolidBrush(Color.Red);
Brush yellowBrush = new SolidBrush(Color.Yellow);

Brush textBrush1 = new SolidBrush(Color.Black);
Brush textBrush2 = new SolidBrush(Color.Brown);

dc.DrawEllipse(greenPen, ellipseArea1);
dc.FillEllipse(redBrush, ellipseArea1);// Filling Circle with Red Brush
dc.DrawString("Circle1", new Font("Arial", 12), textBrush1, ellipseArea1, stringFormat);


dc.DrawEllipse(bluePen, ellipseArea2);
dc.FillEllipse(yellowBrush, ellipseArea2);// Filling Circle with Yellow Brush
dc.DrawString("Circle2", new Font("Arial", 12), textBrush2, ellipseArea2, stringFormat);


base.OnPaint(e);

greenPen.Dispose();
bluePen.Dispose();

redBrush.Dispose();
yellowBrush.Dispose();
textBrush1.Dispose();
textBrush2.Dispose();

}
}

 


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>