📄 form1.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace BlendingSamp
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem ColorBlending;
private System.Windows.Forms.MenuItem AlphaBlending;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem EllipseMenu;
private System.Windows.Forms.MenuItem RectangleMenu;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem MixedBlendingMenu;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem SetBlendTriangularShapeMenu;
private System.Windows.Forms.MenuItem SetSigmaBellShapeMenu;
private System.Windows.Forms.MenuItem BlendPropMenu;
private System.Windows.Forms.MenuItem InterpolationColorsMenu;
private System.Windows.Forms.MenuItem GammaCorrectionMenu;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem PathGradientProsMenu;
private System.Windows.Forms.MenuItem PathGBBlend;
private System.Windows.Forms.MenuItem PathGBInterPol;
private System.Windows.Forms.MenuItem AlphaBPensBrushes;
private System.Windows.Forms.MenuItem AlphaBImages;
private System.Windows.Forms.MenuItem AlphaBCompGammaCorr;
private System.Windows.Forms.MenuItem AlphaBMatrix;
private System.Windows.Forms.MenuItem CompBlendTSigmaBell;
private System.Windows.Forms.MenuItem MixedBlending;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem CompBlendTSigmaBellMEnu;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.ColorBlending = new System.Windows.Forms.MenuItem();
this.AlphaBlending = new System.Windows.Forms.MenuItem();
this.MixedBlendingMenu = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.EllipseMenu = new System.Windows.Forms.MenuItem();
this.RectangleMenu = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.SetBlendTriangularShapeMenu = new System.Windows.Forms.MenuItem();
this.SetSigmaBellShapeMenu = new System.Windows.Forms.MenuItem();
this.BlendPropMenu = new System.Windows.Forms.MenuItem();
this.InterpolationColorsMenu = new System.Windows.Forms.MenuItem();
this.GammaCorrectionMenu = new System.Windows.Forms.MenuItem();
this.CompBlendTSigmaBell = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.PathGradientProsMenu = new System.Windows.Forms.MenuItem();
this.PathGBBlend = new System.Windows.Forms.MenuItem();
this.PathGBInterPol = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.AlphaBPensBrushes = new System.Windows.Forms.MenuItem();
this.AlphaBImages = new System.Windows.Forms.MenuItem();
this.AlphaBCompGammaCorr = new System.Windows.Forms.MenuItem();
this.AlphaBMatrix = new System.Windows.Forms.MenuItem();
this.MixedBlending = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.CompBlendTSigmaBellMEnu = new System.Windows.Forms.MenuItem();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem2,
this.menuItem4});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.ColorBlending,
this.AlphaBlending,
this.MixedBlendingMenu,
this.menuItem6});
this.menuItem1.Text = "Blending";
//
// ColorBlending
//
this.ColorBlending.Index = 0;
this.ColorBlending.Text = "Color Blending";
this.ColorBlending.Click += new System.EventHandler(this.ColorBlending_Click);
//
// AlphaBlending
//
this.AlphaBlending.Index = 1;
this.AlphaBlending.Text = "Alpha Blending";
this.AlphaBlending.Click += new System.EventHandler(this.AlphaBlending_Click);
//
// MixedBlendingMenu
//
this.MixedBlendingMenu.Index = 2;
this.MixedBlendingMenu.Text = "Mixed Blending";
this.MixedBlendingMenu.Click += new System.EventHandler(this.MixedBlendingMenu_Click);
//
// menuItem2
//
this.menuItem2.Index = 1;
this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.EllipseMenu,
this.RectangleMenu,
this.menuItem3,
this.menuItem5});
this.menuItem2.Text = "Color Blending";
//
// EllipseMenu
//
this.EllipseMenu.Index = 0;
this.EllipseMenu.Text = "Ellipse";
this.EllipseMenu.Click += new System.EventHandler(this.EllipseMenu_Click);
//
// RectangleMenu
//
this.RectangleMenu.Index = 1;
this.RectangleMenu.Text = "Rectangle";
this.RectangleMenu.Click += new System.EventHandler(this.RectangleMenu_Click);
//
// menuItem3
//
this.menuItem3.Index = 2;
this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.SetBlendTriangularShapeMenu,
this.SetSigmaBellShapeMenu,
this.BlendPropMenu,
this.InterpolationColorsMenu,
this.GammaCorrectionMenu,
this.CompBlendTSigmaBell,
this.CompBlendTSigmaBellMEnu});
this.menuItem3.Text = "LinearGradientBrush";
//
// SetBlendTriangularShapeMenu
//
this.SetBlendTriangularShapeMenu.Index = 0;
this.SetBlendTriangularShapeMenu.Text = "SetBlendTriangularShape";
this.SetBlendTriangularShapeMenu.Click += new System.EventHandler(this.SetBlendTriangularShapeMenu_Click);
//
// SetSigmaBellShapeMenu
//
this.SetSigmaBellShapeMenu.Index = 1;
this.SetSigmaBellShapeMenu.Text = "SetSigmaBellShape";
this.SetSigmaBellShapeMenu.Click += new System.EventHandler(this.SetSigmaBellShapeMenu_Click);
//
// BlendPropMenu
//
this.BlendPropMenu.Index = 2;
this.BlendPropMenu.Text = "Blend";
this.BlendPropMenu.Click += new System.EventHandler(this.BlendPropMenu_Click);
//
// InterpolationColorsMenu
//
this.InterpolationColorsMenu.Index = 3;
this.InterpolationColorsMenu.Text = "InterpolationColors";
this.InterpolationColorsMenu.Click += new System.EventHandler(this.InterpolationColorsMenu_Click);
//
// GammaCorrectionMenu
//
this.GammaCorrectionMenu.Index = 4;
this.GammaCorrectionMenu.Text = "GammaCorrection";
this.GammaCorrectionMenu.Click += new System.EventHandler(this.GammaCorrectionMenu_Click);
//
// CompBlendTSigmaBell
//
this.CompBlendTSigmaBell.Index = 5;
this.CompBlendTSigmaBell.Text = "Compare BlendTriangular and SigmaBell Shapes";
this.CompBlendTSigmaBell.Click += new System.EventHandler(this.CompBlendTSigmaBell_Click);
//
// menuItem5
//
this.menuItem5.Index = 3;
this.menuItem5.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.PathGradientProsMenu,
this.PathGBBlend,
this.PathGBInterPol});
this.menuItem5.Text = "PathGradientBrush";
//
// PathGradientProsMenu
//
this.PathGradientProsMenu.Index = 0;
this.PathGradientProsMenu.Text = "Properties";
this.PathGradientProsMenu.Click += new System.EventHandler(this.PathGradientProsMenu_Click);
//
// PathGBBlend
//
this.PathGBBlend.Index = 1;
this.PathGBBlend.Text = "Blend";
this.PathGBBlend.Click += new System.EventHandler(this.PathGBBlend_Click);
//
// PathGBInterPol
//
this.PathGBInterPol.Index = 2;
this.PathGBInterPol.Text = "InterpolationColors";
this.PathGBInterPol.Click += new System.EventHandler(this.PathGBInterPol_Click);
//
// menuItem4
//
this.menuItem4.Index = 2;
this.menuItem4.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.AlphaBPensBrushes,
this.AlphaBImages,
this.AlphaBCompGammaCorr,
this.AlphaBMatrix,
this.MixedBlending});
this.menuItem4.Text = "Alpha Blending";
//
// AlphaBPensBrushes
//
this.AlphaBPensBrushes.Index = 0;
this.AlphaBPensBrushes.Text = "Pens and Brushes";
this.AlphaBPensBrushes.Click += new System.EventHandler(this.AlphaBPensBrushes_Click);
//
// AlphaBImages
//
this.AlphaBImages.Index = 1;
this.AlphaBImages.Text = "Images and Alpha Blending";
this.AlphaBImages.Click += new System.EventHandler(this.AlphaBImages_Click);
//
// AlphaBCompGammaCorr
//
this.AlphaBCompGammaCorr.Index = 2;
this.AlphaBCompGammaCorr.Text = "CompositeMode and GammaCorrection";
this.AlphaBCompGammaCorr.Click += new System.EventHandler(this.AlphaBCompGammaCorr_Click);
//
// AlphaBMatrix
//
this.AlphaBMatrix.Index = 3;
this.AlphaBMatrix.Text = "Matrix In Alpha Blending";
this.AlphaBMatrix.Click += new System.EventHandler(this.AlphaBMatrix_Click);
//
// MixedBlending
//
this.MixedBlending.Index = 4;
this.MixedBlending.Text = "Mixed Blending";
this.MixedBlending.Click += new System.EventHandler(this.MixedBlending_Click);
//
// menuItem6
//
this.menuItem6.Index = 3;
this.menuItem6.Text = "CompBlendTSigmaBell";
//
// CompBlendTSigmaBellMEnu
//
this.CompBlendTSigmaBellMEnu.Index = 6;
this.CompBlendTSigmaBellMEnu.Text = "CompBlendTSigmaBell";
this.CompBlendTSigmaBellMEnu.Click += new System.EventHandler(this.CompBlendTSigmaBellMEnu_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(424, 317);
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Blending Sample";
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void ColorBlending_Click(object sender, System.EventArgs e)
{
Graphics g = this.CreateGraphics();
g.Clear(this.BackColor);
// Create three linear gradient brushes
LinearGradientBrush rgBrush = new LinearGradientBrush(
new RectangleF(20, 20, 100, 100),
Color.Red, Color.Green,
LinearGradientMode.Horizontal);
LinearGradientBrush yrBrush = new LinearGradientBrush(
new RectangleF(140, 20, 150, 300),
Color.Yellow, Color.Red,
LinearGradientMode.ForwardDiagonal);
LinearGradientBrush rbBrush = new LinearGradientBrush(
new RectangleF(10, 10, 50, 50),
Color.Red, Color.Blue,
LinearGradientMode.ForwardDiagonal);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -