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;
using System.Drawing.Drawing2D;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void onPaint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Brush yel = new SolidBrush(Color.Yellow);
Brush grn = new SolidBrush(Color.Green);
Brush blu = new SolidBrush(Color.SkyBlue);
Rectangle sun = new Rectangle(Width-100,15 , 80, 80);
Rectangle grass = new Rectangle(0, 300, Width, Height);
Rectangle sky = new Rectangle(0, 0, Width, Height);
g.FillRectangle(blu, sky);
g.FillRectangle(grn, grass);
g.FillEllipse(yel, sun);
I have a paint component in my windows form C# program, How can i recall this method? See attached code.?
A simple way would be to break paint out into its own function (with a graphics object as a parameter) then call it with either e.Graphics (from onPaint) or with Form1.CreateGraphics() (from whatever function).
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment