Enumerate LinearGradientMode : LinearGradientBrush « 2D Graphics « C# / C Sharp






Enumerate LinearGradientMode

Enumerate LinearGradientMode
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

public class MainForm : Form {
    public MainForm() {
        CenterToScreen();
    }

    protected void OnPaint(PaintEventArgs e) {
        Graphics g = e.Graphics;
        Rectangle r = new Rectangle(10, 10, 100, 100);
        LinearGradientBrush theBrush = null;
        int yOffSet = 10;
        Array obj = Enum.GetValues(typeof(LinearGradientMode));
        for (int x = 0; x < obj.Length; x++) {
            LinearGradientMode temp = (LinearGradientMode)obj.GetValue(x);
            theBrush = new LinearGradientBrush(r, Color.GreenYellow,
                                               Color.Blue, temp);
            g.DrawString(temp.ToString(), new Font("Times New Roman", 10),
                         new SolidBrush(Color.Black), 0, yOffSet);
            g.FillRectangle(theBrush, 150, yOffSet, 200, 50);
            yOffSet += 80;
        }
    }
}

 








Related examples in the same category

1.Two-Point Linear Gradient Brush
2.Rectangle Linear-Gradient Brush
3.LinearGradientMode.Horizontal, Vertical, BackwardDiagonal, ForwardDiagonal