1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216:
| using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Text; using System.Windows.Forms;
namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); this.Select(); }
int DrawPosition; Color Color01, Color02; private void HuePanel_Paint(object sender, PaintEventArgs e) { for (int i = 0; i < 6; i++) { switch (i) { case 0: Color01 = Color.Red; Color02 = Color.Yellow; break; case 1: Color01 = Color.Yellow; Color02 = Color.Green; break; case 2: Color01 = Color.Green; Color02 = Color.Cyan; break; case 3: Color01 = Color.Cyan; Color02 = Color.Blue; break; case 4: Color01 = Color.Blue; Color02 = Color.Magenta; break; case 5: Color01 = Color.Magenta; Color02 = Color.Red; break; }
Rectangle Rectangle = new Rectangle(DrawPosition, 0, this.HuePanel.Width / 6, this.HuePanel.Height); LinearGradientBrush LinearGradientBrush = new LinearGradientBrush(Rectangle, Color01, Color02, LinearGradientMode.Horizontal); LinearGradientBrush.WrapMode = WrapMode.TileFlipX; e.Graphics.FillRectangle(LinearGradientBrush, Rectangle); DrawPosition += this.HuePanel.Width / 6; } }
private void SaturationPanel_Paint(object sender, PaintEventArgs e) { Rectangle Rectangle = new Rectangle(0, 0, this.SaturationPanel.Width, this.SaturationPanel.Height); LinearGradientBrush LinearGradientBrush = new LinearGradientBrush(Rectangle, Color.White, Color.Red, LinearGradientMode.Horizontal); LinearGradientBrush.WrapMode = WrapMode.TileFlipX; e.Graphics.FillRectangle(LinearGradientBrush, Rectangle); }
private void BrightnessPanel_Paint(object sender, PaintEventArgs e) { Rectangle Rectangle = new Rectangle(0, 0, this.BrightnessPanel.Width, this.BrightnessPanel.Height); LinearGradientBrush LinearGradientBrush = new LinearGradientBrush(Rectangle, Color.Black, Color.Red, LinearGradientMode.Horizontal); LinearGradientBrush.WrapMode = WrapMode.TileFlipX; e.Graphics.FillRectangle(LinearGradientBrush, Rectangle); }
int HueArrow = 0; int SaturationArrow = 100; int BrightnessArrow = 0; private void Form1_Paint(object sender, PaintEventArgs e) { Point[] HueTriangle = { new Point(this.HuePanel.Location.X + this.HuePanel.Width / 2 - 6 + HueArrow, this.HuePanel.Location.Y + this.HuePanel.Height + 10), new Point(this.HuePanel.Location.X + this.HuePanel.Width / 2 + 6 + HueArrow, this.HuePanel.Location.Y + this.HuePanel.Height + 10), new Point(this.HuePanel.Location.X + this.HuePanel.Width / 2 + HueArrow, this.HuePanel.Location.Y + this.HuePanel.Height) }; e.Graphics.FillPolygon(new SolidBrush(Color.Gray), HueTriangle);
Point[] SaturationTriangle = { new Point(this.SaturationPanel.Location.X - 6 + SaturationArrow, this.SaturationPanel.Location.Y + this.SaturationPanel.Height + 10), new Point(this.SaturationPanel.Location.X + 6 + SaturationArrow, this.SaturationPanel.Location.Y + this.SaturationPanel.Height + 10), new Point(this.SaturationPanel.Location.X + SaturationArrow, this.SaturationPanel.Location.Y + this.SaturationPanel.Height) }; e.Graphics.FillPolygon(new SolidBrush(Color.Gray), SaturationTriangle);
Point[] BrightnessTriangle = { new Point(this.BrightnessPanel.Location.X + this.BrightnessPanel.Width / 2 - 6 + BrightnessArrow, this.BrightnessPanel.Location.Y + this.BrightnessPanel.Height + 10), new Point(this.BrightnessPanel.Location.X + this.BrightnessPanel.Width / 2 + 6 + BrightnessArrow, this.BrightnessPanel.Location.Y + this.BrightnessPanel.Height + 10), new Point(this.BrightnessPanel.Location.X + this.BrightnessPanel.Width / 2 + BrightnessArrow, this.BrightnessPanel.Location.Y + this.BrightnessPanel.Height) }; e.Graphics.FillPolygon(new SolidBrush(Color.Gray), BrightnessTriangle); }
private void Form1_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (e.Y >= this.HuePanel.Location.Y + this.HuePanel.Height && e.Y <= this.HuePanel.Location.Y + this.HuePanel.Height + 10) { if (e.X >= this.HuePanel.Location.X && e.X <= this.HuePanel.Location.X + this.HuePanel.Width) { HueArrow = e.X - this.HuePanel.Location.X - this.HuePanel.Width / 2; } else if (e.X <= this.HuePanel.Location.X) { HueArrow = -100; } else if (e.X >= this.HuePanel.Location.X + this.HuePanel.Width) { HueArrow = 100; }
this.HueTextBox.Text = Convert.ToString(HueArrow * 18 / 10); }
if (e.Y >= this.SaturationPanel.Location.Y + this.SaturationPanel.Height && e.Y <= this.SaturationPanel.Location.Y + this.SaturationPanel.Height + 10) { if (e.X >= this.SaturationPanel.Location.X && e.X <= this.SaturationPanel.Location.X + this.SaturationPanel.Width) { SaturationArrow = e.X - this.SaturationPanel.Location.X; } else if (e.X <= this.SaturationPanel.Location.X) { SaturationArrow = 0; } else if (e.X >= this.SaturationPanel.Location.X + this.SaturationPanel.Width) { SaturationArrow = 200; }
this.SaturationTextBox.Text = Convert.ToString(SaturationArrow - 100); }
if (e.Y >= this.BrightnessPanel.Location.Y + this.BrightnessPanel.Height && e.Y <= this.BrightnessPanel.Location.Y + this.BrightnessPanel.Height + 10) { if (e.X >= this.BrightnessPanel.Location.X && e.X <= this.BrightnessPanel.Location.X + this.BrightnessPanel.Width) { BrightnessArrow = e.X - this.BrightnessPanel.Location.X - this.BrightnessPanel.Width / 2; } else if (e.X <= this.SaturationPanel.Location.X) { BrightnessArrow = -100; } else if (e.X >= this.BrightnessPanel.Location.X + this.BrightnessPanel.Width) { BrightnessArrow = 100; }
this.BrightnessTextBox.Text = Convert.ToString(BrightnessArrow); }
this.Invalidate(); } }
private void HueTextBox_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (Convert.ToInt32(this.HueTextBox.Text) < -180) { this.HueTextBox.Text = "-180"; } else if (Convert.ToInt32(this.HueTextBox.Text) > 180) { this.HueTextBox.Text = "180"; }
HueArrow = Convert.ToInt32(this.HueTextBox.Text) / 18 * 10; this.Invalidate(); } }
private void SaturationTextBox_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (Convert.ToInt32(this.SaturationTextBox.Text) < -100) { this.SaturationTextBox.Text = "-100"; } else if (Convert.ToInt32(this.SaturationTextBox.Text) > 100) { this.SaturationTextBox.Text = "100"; }
SaturationArrow = Convert.ToInt32(this.SaturationTextBox.Text) + 100; this.Invalidate(); } }
private void BrightnessTextBox_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (Convert.ToInt32(this.BrightnessTextBox.Text) < -100) { this.BrightnessTextBox.Text = "-100"; } else if (Convert.ToInt32(this.BrightnessTextBox.Text) > 100) { this.BrightnessTextBox.Text = "100"; }
BrightnessArrow = Convert.ToInt32(this.BrightnessTextBox.Text); this.Invalidate(); } } } } |