using System.Drawing; using System.Windows.Forms; namespace MyProgram { public class CircleDrawer { public static void Main() { // Create a new form Form form = new Form(); // Set the form size form.ClientSize = new Size(400, 400); // Set the form background color form.BackColor = Color.White; // Create a graphics object Graphics graphics = form.CreateGraphics(); // Set the circle color and size Pen pen = new Pen(Color.Red, 2); int x = 100, y = 100, radius = 50; // Draw the circle graphics.DrawEllipse(pen, x, y, radius, radius); // Display the form Application.Run(form); } } }
using System.Drawing; using System.Windows.Forms; namespace MyProgram { public class ImageDisplay { public static void Main() { // Create a new form Form form = new Form(); // Set the form size form.ClientSize = new Size(400, 400); // Set the form background color form.BackColor = Color.White; // Load the image Image image = Image.FromFile("myImage.png"); // Create a graphics object Graphics graphics = form.CreateGraphics(); // Draw the image on the form graphics.DrawImage(image, 100, 100); // Display the form Application.Run(form); } } }This program loads an image called "myImage.png" and displays it on a white form at the position (100, 100). The package library used for these examples is System.Drawing, which is a part of the .NET Framework Class Library.