Use Label as status bar
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form
{
private System.Windows.Forms.Label lblCount;
List<Rectangle> squares = new List<Rectangle>();
public Form1() {
InitializeComponent();
}
private void NonOptimizedSquares_Paint(object sender, PaintEventArgs e)
{
Pen pen = new Pen(Color.Red, 10);
foreach (Rectangle square in squares) {
e.Graphics.DrawRectangle(pen, square);
}
pen.Dispose();
lblCount.Text = " " + squares.Count.ToString() + " squares";
}
private void NonOptimizedSquares_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Rectangle square = new Rectangle(e.X, e.Y, 20, 20);
squares.Add(square);
square.Inflate(1, 1);
Invalidate(square);
}
}
private void InitializeComponent()
{
this.lblCount = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// lblCount
//
this.lblCount.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lblCount.Dock = System.Windows.Forms.DockStyle.Bottom;
this.lblCount.Location = new System.Drawing.Point(0, 251);
this.lblCount.Name = "lblCount";
this.lblCount.Padding = new System.Windows.Forms.Padding(2);
this.lblCount.Size = new System.Drawing.Size(299, 21);
this.lblCount.TabIndex = 0;
//
// NonOptimizedSquares
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(299, 272);
this.Controls.Add(this.lblCount);
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "NonOptimizedSquares";
this.Text = "NonOptimizedSquares";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.NonOptimizedSquares_Paint);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.NonOptimizedSquares_MouseDown);
this.ResumeLayout(false);
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
}
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
-
|
|