C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Graphics »

One movement with ControlPaint


Posted Date: 22 Aug 2009    Resource Type: Code Snippets    Category: Graphics
Author: Shunmuganathan MMember Level: Diamond    
Rating: 1 out of 5Points: 10



Description :


We can draw our own size of controls.
For Example we cannot increase the size of the checkbox.
But by using the bellow code we can create the big size of checkbox.

Used Namespaces

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;



Code Part

public class ControlPaintForm : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
public ControlPaintForm()
{
InitializeComponent();
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

private void InitializeComponent()
{
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "ControlPaint";
this.Text = "ControlPaint";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.ControlPaint_Paint);

}
private void ControlPaint_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
ControlPaint.DrawCheckBox(e.Graphics, new Rectangle(11, 11, 55, 55), ButtonState.Checked);
ControlPaint.DrawCheckBox(e.Graphics, new Rectangle(70, 10, 30, 30), ButtonState.Normal);
ControlPaint.DrawCheckBox(e.Graphics, new Rectangle(110, 11, 25, 25), ButtonState.Checked);

ControlPaint.DrawButton(e.Graphics, new Rectangle(10, 80, 18, 18), ButtonState.Checked);
ControlPaint.DrawButton(e.Graphics, new Rectangle(50, 80, 18, 18), ButtonState.Flat);
ControlPaint.DrawButton(e.Graphics, new Rectangle(90, 80, 18, 18), ButtonState.Normal);
ControlPaint.DrawFocusRectangle(e.Graphics, new Rectangle(130, 80, 18, 18));

ControlPaint.DrawGrid(e.Graphics, new Rectangle(10, 120, 250, 50), new Size(5, 5), Color.Blue);
ControlPaint.DrawScrollButton(e.Graphics, new Rectangle(10, 180, 21, 21), ScrollButton.Left, ButtonState.Normal);
ControlPaint.DrawScrollButton(e.Graphics, new Rectangle(50, 180, 21, 21), ScrollButton.Max, ButtonState.Pushed);
ControlPaint.DrawScrollButton(e.Graphics, new Rectangle(90, 180, 21, 21), ScrollButton.Up, ButtonState.Normal);

ControlPaint.DrawMenuGlyph(e.Graphics, new Rectangle(10, 220, 21, 21), MenuGlyph.Arrow);
ControlPaint.DrawMenuGlyph(e.Graphics, new Rectangle(50, 220, 21, 21), MenuGlyph.Checkmark);
ControlPaint.DrawMenuGlyph(e.Graphics, new Rectangle(90, 220, 21, 21), MenuGlyph.Max);
}

[STAThread]
static void Main()
{
Application.Run(new ControlPaintForm());
}

}



Code Explanation
1. The above code is like a mapaint
2. Override "Dispose" for clean up any resources being used.
3. ControlPaint is used to create our own size controls.


By
Nathan



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
One movement with ControlPaint  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Mathematics SET in Graphics view
Previous Resource: Code for Converting an Image to Icon
Return to Discussion Resource Index
Post New Resource
Category: Graphics


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use