I mostly use Console or Forms applications in VS for my projects.
Did anyone among you ever use an Empty Project when starting a new one?
Well, it is as clean as you can get with Visual Studio! The world is at your feet!
I use it mainly to test some drawing methods from the Graphics class.
To get a feeling of it, let’s start a new empty project.
I called mine “Draw” and I right clicked it to get the properties window and set the Output type: to Windows Application, to avoid that a console window opens also.
Because it is an empty project, you are responsible for the References you want to use.
Here I used
System
System.Drawing
System.Windows.Forms
Now in the Program.cs file fill in these 40 lines or so, remember this in fact a complete project! Enjoy!
How to use an “Empty projectâ€
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Draw
{
public class DrawingForm : Form
{
public DrawingForm() // contructor
{
//InitializeComponent
this.Text = "My drawings"; // title of window form
this.Size = new Size(600, 600); // size of window form
this.Paint += new PaintEventHandler(MyPainting); // install handler
}
private void MyPainting(object sender, PaintEventArgs e)
{
Graphics G = e.Graphics;
// Test some GDI+ drawing here: methods to draw from point to point
Pen redPen = new Pen(Color.Red,2);
Pen bluePen = new Pen(Color.Blue,4);
Pen blackPen = new Pen(Color.Black,6);
Point[] pnts = { new Point(50, 150), new Point(200, 350),
new Point(400, 200), new Point(350, 150),
new Point(450, 100), new Point(550, 400),
new Point(400, 300)};
G.DrawLines(redPen, pnts); // draw from point to point
G.DrawCurve(bluePen, pnts); // draw splines
G.DrawBeziers(blackPen, pnts); //needs 7 points
}
}
public class Program //main program
{
public static int Main()
{
Application.Run(new DrawingForm()); // run a form
return 0; // let the OS know everything is OK
}
}
}
kvprajapati 1,826 Posting Genius Team Colleague
ddanbe 2,724 Professional Procrastinator Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.