namespace PaintShape
{
partial class frmPaintShape
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// frmPaintShape
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(294, 271);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "frmPaintShape";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Paint Shape";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.frmPaintShape_Paint);
this.ResumeLayout(false);
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace PaintShape
{
public partial class frmPaintShape : Form
{
public frmPaintShape()
{
InitializeComponent();
}
private void frmPaintShape_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Pen pen = new Pen(Color.Red);
const float WIDTH= 30;
const float HEIGHT =50;
float centerX = (this.Width / 2) - WIDTH / 2;
float centerY = (this.Height / 2) - HEIGHT;
g.DrawRectangle(pen, centerX, centerY, WIDTH, HEIGHT);
}
}
}
Comments
Leave a comment