using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Test
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
#region Windows Form Designer generated code
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// panel1
//
this.panel1.Location = new System.Drawing.Point(56, 112);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(80, 40);
this.panel1.TabIndex = 1;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// panel2
//
this.panel2.Location = new System.Drawing.Point(160, 112);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(80, 40);
this.panel2.TabIndex = 2;
this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.panel1,
this.panel2});
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Color color1 = Color.Blue;
Color color2 = Color.White;
Color current = Color.Empty;
int red;
int green;
int blue;
for (int i = 0; i < panel1.Height; i++)
{
red = color1.R + (i * (color2.R - color1.R) / 40);
green = color1.G + (i * (color2.G - color1.G) / 40);
blue = color1.B + (i * (color2.B - color1.B) / 40);
current = Color.FromArgb(red, green, blue);
e.Graphics.DrawLine(new Pen(new SolidBrush(current), 1), 0, i, panel1.Width, i);
}
}
private void panel2_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
//Brush brush = new LinearGradientBrush(new Rectangle(0, 0, panel2.Width, panel2.Height), Color.Blue, Color.White, LinearGradientMode.Vertical);
//e.Graphics.FillRectangle(brush, 0, 0, panel2.Width, panel2.Height);
}
}
}