dotnetspider.com


 


TutorialsForumResourcesReviewsJobsInterviewVideosCommunitiesProjectsTraining

Subscribe to Subscribers


Online MembersRavindran
Ajatshatru Upadhyay
abhishek
chirag jaguwala
R.Jaya kumar (JK)
More...




Forums » .NET » .NET »

How to Draw Circle in C# windows Form


Posted Date: 02 Oct 2008      Posted By:: Dnyaneshwar Bhamare     Member Level: Silver    Member Rank: 3307     Points: 1   Responses: 1



Hi
I have one windows form having a circle on center of the form.I wants to draw a 200 circles around my centered circle and connect that 200 circles to centered circle through the line,without touching the any outer circle.
So any one tell me how do i implement?





Responses

#302873    Author:       Member Level: Silver      Member Rank: 0     Date: 02/Oct/2008   Rating: 4 out of 54 out of 54 out of 54 out of 5     Points: 6

To draw circle use this code

//--start


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace circle
{
public partial class Form1 : Form
{
Graphics graphDrawingArea;
Bitmap bmpDrawingArea;
static int mainRadius = 10;
static int smallRadius = 5;
static bool isMax;
static bool smallRadiusMax;


public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
bmpDrawingArea = new Bitmap(Width, Height);
graphDrawingArea = Graphics.FromImage(bmpDrawingArea);
}
void DrawCentralCircle(int CenterX, int CenterY, int Radius)
{
int start = CenterX - Radius;
int end = CenterY - Radius;
int diam = Radius * 2;
bmpDrawingArea = new Bitmap(Width, Height);
graphDrawingArea = Graphics.FromImage(bmpDrawingArea);
graphDrawingArea.DrawEllipse(new Pen(Color.Blue),start, end, diam, diam);
}

void DrawCornerCircle(int CenterX, int CenterY, int Radius)
{
int start = CenterX - Radius;
int end = CenterY - Radius;
int diam = Radius * 2;
bmpDrawingArea = new Bitmap(Width, Height);
graphDrawingArea = Graphics.FromImage(bmpDrawingArea);
graphDrawingArea.DrawEllipse(new Pen(Color.Red),
start, end, diam, diam);
}

private void timer1_Tick(object sender, EventArgs e)
{
Graphics graph = Graphics.FromHwnd(this.Handle);

int centerX = ClientRectangle.Width / 2;
int centerY = ClientRectangle.Height / 2;

if (isMax == true)
mainRadius--;
else
mainRadius++;

if (mainRadius > (ClientRectangle.Height / 2))
isMax = true;
if (mainRadius < 10)
isMax = false;

if (smallRadiusMax == true)
smallRadius--;
else
smallRadius++;

if (smallRadius > 240)
smallRadiusMax = true;
if (smallRadius < 5)
smallRadiusMax = false;

// Central
DrawCentralCircle(centerX, centerY, mainRadius);
// Top-Left
DrawCornerCircle(centerX / 2, centerY / 2, smallRadius);
// Top-Right
DrawCornerCircle(centerX + (centerX / 2),
centerY / 2, smallRadius);
// Bottom-Left
DrawCornerCircle(centerX / 2, centerY + (centerY / 2),
smallRadius);
// BottomRight
DrawCornerCircle(centerX + (centerX / 2),
centerY + (centerY / 2), smallRadius);

graph.DrawImage(bmpDrawingArea, 0, 0);

}

}
}


//--end




Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Restoring Data Base
Previous : structure
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages

My Profile

Active Members
TodayLast 7 Daysmore...


Awards & Gifts


Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds



    About Us    Trademark Disclaimer    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.