colorchoosecontrol.cs
来自「Fireball.CodeEditor is an source code ed」· CS 代码 · 共 1,133 行 · 第 1/3 页
CS
1,133 行
// Copyright (C) 2005/2006 Riccardo Marzi <riccardo@dotnetfireball.org>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using Fireball.Drawing;
namespace Fireball.Windows.Forms
{
public class ColorChooseControl:UserControl
{
private ColorPicker lsView;
private ColorSlider hueView;
private Label label1;
private Label label2;
private Label label3;
private NumericUpDown numR;
private NumericUpDown numG;
private NumericUpDown numB;
private Panel panelColor1;
private Panel panelColor2;
private Panel panelColors;
private Panel panel1;
private Panel panel2;
private ColorChooseControl.ColorSlider saturationView;
private Panel panel3;
private ColorChooseControl.ColorSlider luminanceView;
private Panel panel4;
private Label label4;
private Label label5;
private Label label6;
private NumericUpDown numHue;
private NumericUpDown numSat;
private NumericUpDown numLum;
private ColorHLS _currentColor;
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.numR = new System.Windows.Forms.NumericUpDown();
this.numG = new System.Windows.Forms.NumericUpDown();
this.numB = new System.Windows.Forms.NumericUpDown();
this.panelColor1 = new System.Windows.Forms.Panel();
this.panelColor2 = new System.Windows.Forms.Panel();
this.panelColors = new System.Windows.Forms.Panel();
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.panel3 = new System.Windows.Forms.Panel();
this.panel4 = new System.Windows.Forms.Panel();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.numHue = new System.Windows.Forms.NumericUpDown();
this.numSat = new System.Windows.Forms.NumericUpDown();
this.numLum = new System.Windows.Forms.NumericUpDown();
this.luminanceView = new Fireball.Windows.Forms.ColorChooseControl.ColorSlider();
this.saturationView = new Fireball.Windows.Forms.ColorChooseControl.ColorSlider();
this.lsView = new Fireball.Windows.Forms.ColorChooseControl.ColorPicker();
this.hueView = new Fireball.Windows.Forms.ColorChooseControl.ColorSlider();
((System.ComponentModel.ISupportInitialize)(this.numR)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numG)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numB)).BeginInit();
this.panelColors.SuspendLayout();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.panel3.SuspendLayout();
this.panel4.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numHue)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numSat)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numLum)).BeginInit();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(386, 100);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(18, 13);
this.label1.TabIndex = 5;
this.label1.Text = "R:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(386, 126);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(18, 13);
this.label2.TabIndex = 5;
this.label2.Text = "G:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(386, 152);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(17, 13);
this.label3.TabIndex = 5;
this.label3.Text = "B:";
//
// numR
//
this.numR.Location = new System.Drawing.Point(408, 98);
this.numR.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.numR.Name = "numR";
this.numR.Size = new System.Drawing.Size(48, 20);
this.numR.TabIndex = 6;
this.numR.Value = new decimal(new int[] {
255,
0,
0,
0});
this.numR.ValueChanged += new System.EventHandler(this.numR_ValueChanged);
//
// numG
//
this.numG.Location = new System.Drawing.Point(408, 124);
this.numG.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.numG.Name = "numG";
this.numG.Size = new System.Drawing.Size(48, 20);
this.numG.TabIndex = 6;
this.numG.ValueChanged += new System.EventHandler(this.numG_ValueChanged);
//
// numB
//
this.numB.Location = new System.Drawing.Point(408, 150);
this.numB.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.numB.Name = "numB";
this.numB.Size = new System.Drawing.Size(48, 20);
this.numB.TabIndex = 6;
this.numB.ValueChanged += new System.EventHandler(this.numB_ValueChanged);
//
// panelColor1
//
this.panelColor1.BackColor = System.Drawing.Color.Red;
this.panelColor1.Location = new System.Drawing.Point(1, 1);
this.panelColor1.Name = "panelColor1";
this.panelColor1.Size = new System.Drawing.Size(68, 34);
this.panelColor1.TabIndex = 7;
//
// panelColor2
//
this.panelColor2.BackColor = System.Drawing.Color.Red;
this.panelColor2.Location = new System.Drawing.Point(1, 35);
this.panelColor2.Name = "panelColor2";
this.panelColor2.Size = new System.Drawing.Size(68, 34);
this.panelColor2.TabIndex = 7;
//
// panelColors
//
this.panelColors.BackColor = System.Drawing.SystemColors.ControlDark;
this.panelColors.Controls.Add(this.panelColor1);
this.panelColors.Controls.Add(this.panelColor2);
this.panelColors.Location = new System.Drawing.Point(387, 5);
this.panelColors.Name = "panelColors";
this.panelColors.Size = new System.Drawing.Size(70, 70);
this.panelColors.TabIndex = 8;
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.ControlDark;
this.panel1.Controls.Add(this.hueView);
this.panel1.Location = new System.Drawing.Point(347, 5);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(22, 258);
this.panel1.TabIndex = 9;
//
// panel2
//
this.panel2.BackColor = System.Drawing.SystemColors.ControlDark;
this.panel2.Controls.Add(this.lsView);
this.panel2.Location = new System.Drawing.Point(3, 5);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(258, 258);
this.panel2.TabIndex = 10;
//
// panel3
//
this.panel3.BackColor = System.Drawing.SystemColors.ControlDark;
this.panel3.Controls.Add(this.saturationView);
this.panel3.Location = new System.Drawing.Point(274, 5);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(22, 258);
this.panel3.TabIndex = 11;
//
// panel4
//
this.panel4.BackColor = System.Drawing.SystemColors.ControlDark;
this.panel4.Controls.Add(this.luminanceView);
this.panel4.Location = new System.Drawing.Point(310, 5);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(22, 258);
this.panel4.TabIndex = 12;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(386, 192);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(18, 13);
this.label4.TabIndex = 5;
this.label4.Text = "H:";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(386, 218);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(17, 13);
this.label5.TabIndex = 5;
this.label5.Text = "S:";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(386, 244);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(16, 13);
this.label6.TabIndex = 5;
this.label6.Text = "L:";
//
// numHue
//
this.numHue.Location = new System.Drawing.Point(408, 190);
this.numHue.Maximum = new decimal(new int[] {
359,
0,
0,
0});
this.numHue.Name = "numHue";
this.numHue.Size = new System.Drawing.Size(48, 20);
this.numHue.TabIndex = 6;
this.numHue.Value = new decimal(new int[] {
359,
0,
0,
0});
this.numHue.ValueChanged += new System.EventHandler(this.numHue_ValueChanged);
//
// numSat
//
this.numSat.DecimalPlaces = 1;
this.numSat.Location = new System.Drawing.Point(408, 216);
this.numSat.Name = "numSat";
this.numSat.Size = new System.Drawing.Size(48, 20);
this.numSat.TabIndex = 6;
this.numSat.Value = new decimal(new int[] {
100,
0,
0,
0});
this.numSat.ValueChanged += new System.EventHandler(this.numSat_ValueChanged);
//
// numLum
//
this.numLum.DecimalPlaces = 1;
this.numLum.Location = new System.Drawing.Point(408, 242);
this.numLum.Name = "numLum";
this.numLum.Size = new System.Drawing.Size(48, 20);
this.numLum.TabIndex = 6;
this.numLum.Value = new decimal(new int[] {
100,
0,
0,
0});
this.numLum.ValueChanged += new System.EventHandler(this.numLum_ValueChanged);
//
// luminanceView
//
this.luminanceView.ColorMode = Fireball.Windows.Forms.ColorChooseControl.ColorSliderMode.Hue;
this.luminanceView.Location = new System.Drawing.Point(1, 1);
this.luminanceView.Name = "luminanceView";
this.luminanceView.Size = new System.Drawing.Size(20, 256);
this.luminanceView.TabIndex = 1;
this.luminanceView.Value = 0F;
//
// saturationView
//
this.saturationView.ColorMode = Fireball.Windows.Forms.ColorChooseControl.ColorSliderMode.Hue;
this.saturationView.Location = new System.Drawing.Point(1, 1);
this.saturationView.Name = "saturationView";
this.saturationView.Size = new System.Drawing.Size(20, 256);
this.saturationView.TabIndex = 1;
this.saturationView.Value = 0F;
//
// lsView
//
this.lsView.Hue = 360F;
this.lsView.Location = new System.Drawing.Point(1, 1);
this.lsView.Luminance = 16.13725F;
this.lsView.Name = "lsView";
this.lsView.Saturation = 1.019608F;
this.lsView.Size = new System.Drawing.Size(256, 256);
this.lsView.TabIndex = 0;
//
// hueView
//
this.hueView.ColorMode = Fireball.Windows.Forms.ColorChooseControl.ColorSliderMode.Hue;
this.hueView.Location = new System.Drawing.Point(1, 1);
this.hueView.Name = "hueView";
this.hueView.Size = new System.Drawing.Size(20, 256);
this.hueView.TabIndex = 1;
this.hueView.Value = 0F;
//
// ColorChooseControl
//
this.Controls.Add(this.panel4);
this.Controls.Add(this.panel3);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Controls.Add(this.panelColors);
this.Controls.Add(this.numLum);
this.Controls.Add(this.numSat);
this.Controls.Add(this.numB);
this.Controls.Add(this.numHue);
this.Controls.Add(this.numG);
this.Controls.Add(this.label6);
this.Controls.Add(this.numR);
this.Controls.Add(this.label5);
this.Controls.Add(this.label3);
this.Controls.Add(this.label4);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "ColorChooseControl";
this.Size = new System.Drawing.Size(491, 300);
((System.ComponentModel.ISupportInitialize)(this.numR)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numG)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numB)).EndInit();
this.panelColors.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.panel3.ResumeLayout(false);
this.panel4.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numHue)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numSat)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numLum)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
public ColorChooseControl()
{
InitializeComponent();
_currentColor = new ColorHLS(255,255, 0, 0);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?