Csharp/CSharp Tutorial/2D/SolidBrush — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 12:18, 26 мая 2010
Содержание
A purple dashed Brush
using System;
using System.Drawing;
using System.Collections;
using System.ruponentModel;
using System.Windows.Forms;
using System.Data;
public class BrushDashed : System.Windows.Forms.Form
{
private System.ruponentModel.Container components;
public BrushDashed()
{
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, 273);
this.Text = "Solid Brushes...";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
}
[STAThread]
static void Main()
{
Application.Run(new BrushDashed());
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
SolidBrush brush3= new SolidBrush(Color.Purple);
g.FillPolygon(brush3, new Point[]{new Point(30, 140),
new Point(265, 200),
new Point(100, 225),
new Point(190, 190),
new Point(50, 330),
new Point(20, 180)} );
}
}
Brushes: Firebrick
using System;
using System.Drawing;
using System.Collections;
using System.ruponentModel;
using System.Windows.Forms;
using System.Data;
public class BrushFirebrick : System.Windows.Forms.Form
{
private System.ruponentModel.Container components;
public BrushFirebrick()
{
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, 273);
this.Text = "Solid Brushes...";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
}
[STAThread]
static void Main()
{
Application.Run(new BrushFirebrick());
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
SolidBrush pen = (SolidBrush)Brushes.Firebrick;
g.FillEllipse(pen, 10, 10, 100, 100);
}
}
Draw string with Brush and Rectangle
using System;
using System.Drawing;
using System.Collections;
using System.ruponentModel;
using System.Windows.Forms;
using System.Data;
public class StringDrawBrushRectangle : System.Windows.Forms.Form
{
private System.ruponentModel.Container components;
public StringDrawBrushRectangle()
{
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, 273);
this.Text = "Solid Brushes...";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
}
[STAThread]
static void Main()
{
Application.Run(new StringDrawBrushRectangle());
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
Rectangle r = new Rectangle(150, 10, 130, 60);
g.DrawString("www.nfex.ru", new Font("Arial", 12), Brushes.White, r);
}
}
Fill a Rectangle with a blue Brush
using System;
using System.Drawing;
using System.Collections;
using System.ruponentModel;
using System.Windows.Forms;
using System.Data;
public class RectangleFillBrushBlue : System.Windows.Forms.Form
{
private System.ruponentModel.Container components;
public RectangleFillBrushBlue()
{
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, 273);
this.Text = "Solid Brushes...";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
}
[STAThread]
static void Main()
{
Application.Run(new RectangleFillBrushBlue());
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
Rectangle r = new Rectangle(150, 10, 130, 60);
g.FillRectangle(Brushes.Blue, r);
}
}
Make a blue SolidBrush
using System;
using System.Drawing;
using System.Collections;
using System.ruponentModel;
using System.Windows.Forms;
using System.Data;
public class BrushSolidBlue : System.Windows.Forms.Form
{
private System.ruponentModel.Container components;
public BrushSolidBlue()
{
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, 273);
this.Text = "Solid Brushes...";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
}
[STAThread]
static void Main()
{
Application.Run(new BrushSolidBlue());
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
SolidBrush blueBrush = new SolidBrush(Color.Blue);
g.FillEllipse(blueBrush, 10, 10, 100, 100);
}
}
SolidBrush with color
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.ruponentModel;
using System.Windows.Forms;
using System.Data;
public class SolidBrushWithColor : System.Windows.Forms.Form
{
public SolidBrushWithColor()
{
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(400, 400);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.SolidBrushWithColor_Paint);
}
static void Main()
{
Application.Run(new SolidBrushWithColor());
}
private void SolidBrushWithColor_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
Brush brSolid = new SolidBrush(Color.Blue);
g.FillPie(brSolid, 0, 0, 300, 300, 285, 75);
}
}
Use Brush directly
using System;
using System.Drawing;
using System.Collections;
using System.ruponentModel;
using System.Windows.Forms;
using System.Data;
public class BrushDirectly : System.Windows.Forms.Form
{
private System.ruponentModel.Container components;
public BrushDirectly()
{
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, 273);
this.Text = "Solid Brushes...";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
}
[STAThread]
static void Main()
{
Application.Run(new BrushDirectly());
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
g.FillPie(Brushes.Black, 150, 10, 120, 150, 90, 80);
}
}