Question

Windows Graphics Assignment item options Your graphics assignment is to write a program for windows forms...

Windows Graphics Assignment item options Your graphics assignment is to write a program for windows forms in C#. That will draw a red circle in the middle of the screen.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the program for your description in C# Programming Language using Visual Studio 2017.

Steps to create a Windows Form Application in Visual Studio.

1. Open Visual Studio. File > New Project > Select "Visual C#" > Select "Windows Form Application(.Net Framework)> Name the app and choose the destination folder > Click "OK".

2. Now you will see a project window like below and right click on it or click "F4" to go to properties and choose "Paint".

3.Double click on paint . It will open Form1.cs file with some function code auto generated.

4. Now write the code for drawing circle.

CODE :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;
namespace CircleApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Creating a pen object to draw border of circle in black color.
Pen black = new Pen(Color.Black);
//Creating a solid brush object of color red to fill the circle.
SolidBrush red = new SolidBrush(Color.Red);
  
private void Form1_Paint(object sender, PaintEventArgs e)
{
//Creating object for graphics class using event arguments object.
Graphics graphics = e.Graphics;

//Identifying the center of the window.
//Let us take the diameter of the circle as 150
int circleDiameter = 150;
//Creating a center point of X and Y axis as follow
Point center = new Point()
{
X = (this.ClientRectangle.Width - circleDiameter) / 2,
Y = (this.ClientRectangle.Height - circleDiameter) / 2
};

//Creating an object of rectangle class.
//The first two parameters represent x and y axis positions
//The last two parameters represent height and width of rectangle.
Rectangle circle = new Rectangle(center.X, center.Y, circleDiameter, circleDiameter);

//Drawing the circle using DrawEclipse method.
graphics.DrawEllipse(black,circle);

//Filling the circle with red color.
graphics.FillEllipse(red, circle);


}
}
}

SCREENSHOTS

Please see the screenshots of the code for indentations.

OUTPUT :

Any doubts regarding this can be explained with pleasure :)

Add a comment
Know the answer?
Add Answer to:
Windows Graphics Assignment item options Your graphics assignment is to write a program for windows forms...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT