コード例 #1
0
ファイル: ColorWheel.cs プロジェクト: 15831944/WW
        protected override void OnPaint(PaintEventArgs e)
        {
            if (this.int_0 <= 0)
            {
                return;
            }
            int    num1 = this.int_0 * this.int_0;
            double num2 = 1.0 / (double)this.int_0;
            int    num3 = this.Width / 2;
            int    num4 = this.Height / 2;
            int    num5 = this.int_0 * 2 + 1;

            using (Bitmap bitmap = new Bitmap(num5, num5))
            {
                for (int index1 = -this.int_0; index1 <= this.int_0; ++index1)
                {
                    int num6 = index1 * index1;
                    for (int index2 = -this.int_0; index2 <= this.int_0; ++index2)
                    {
                        int num7 = num6 + index2 * index2;
                        if (num7 <= num1)
                        {
                            double d = System.Math.Sqrt((double)num7) * num2;
                            System.Drawing.Color color = ColorWheel.smethod_0((double)index1, (double)index2, d);
                            bitmap.SetPixel(index1 + this.int_0, index2 + this.int_0, color);
                        }
                    }
                }
                e.Graphics.DrawImageUnscaled((Image)bitmap, num3 + -this.int_0, num4 - this.int_0);
            }
            if (!this.nullable_0.HasValue)
            {
                return;
            }
            Vector2D vector2D = (double)this.int_0 * this.GetNormalizedColorLocation(this.nullable_0.Value);
            Point2D  point2D  = new Point2D((double)(int)System.Math.Round(vector2D.X), (double)(int)System.Math.Round(vector2D.Y));
            int      x        = (int)System.Math.Round((double)num3 + point2D.X);
            int      y        = (int)System.Math.Round((double)num4 + point2D.Y);

            e.Graphics.FillPolygon(Brushes.Black, new Point[3]
            {
                new Point(x - 3, y - 2 - 10),
                new Point(x, y - 2),
                new Point(x + 3, y - 2 - 10)
            });
            e.Graphics.FillPolygon(Brushes.Black, new Point[3]
            {
                new Point(x - 3, y + 2 + 10),
                new Point(x, y + 2),
                new Point(x + 3, y + 2 + 10)
            });
            e.Graphics.FillPolygon(Brushes.Black, new Point[3]
            {
                new Point(x - 2 - 10, y - 3),
                new Point(x - 2, y),
                new Point(x - 2 - 10, y + 3)
            });
            e.Graphics.FillPolygon(Brushes.Black, new Point[3]
            {
                new Point(x + 2 + 10, y - 3),
                new Point(x + 2, y),
                new Point(x + 2 + 10, y + 3)
            });
        }
コード例 #2
0
 private void InitializeComponent()
 {
     this.label1                    = new Label();
     this.label2                    = new Label();
     this.label3                    = new Label();
     this.hexValueTextBox           = new TextBox();
     this.colorPanel                = new Panel();
     this.colorListPicker           = new ColorListPicker();
     this.lightnessComponentEditor  = new ColorComponentEditor();
     this.saturationComponentEditor = new ColorComponentEditor();
     this.hueComponentEditor        = new ColorComponentEditor();
     this.blueComponentEditor       = new ColorComponentEditor();
     this.greenComponentEditor      = new ColorComponentEditor();
     this.redComponentEditor        = new ColorComponentEditor();
     this.colorWheel                = new ColorWheel();
     this.SuspendLayout();
     this.label1.AutoSize                                       = true;
     this.label1.Font                                           = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Bold, GraphicsUnit.Point, (byte)0);
     this.label1.Location                                       = new Point(229, 9);
     this.label1.Name                                           = "label1";
     this.label1.Size                                           = new Size(33, 13);
     this.label1.TabIndex                                       = 7;
     this.label1.Text                                           = "RGB";
     this.label2.AutoSize                                       = true;
     this.label2.Font                                           = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Bold, GraphicsUnit.Point, (byte)0);
     this.label2.Location                                       = new Point(229, 176);
     this.label2.Name                                           = "label2";
     this.label2.Size                                           = new Size(31, 13);
     this.label2.TabIndex                                       = 8;
     this.label2.Text                                           = "HSL";
     this.label3.AutoSize                                       = true;
     this.label3.Location                                       = new Point(229, 133);
     this.label3.Name                                           = "label3";
     this.label3.Size                                           = new Size(26, 13);
     this.label3.TabIndex                                       = 9;
     this.label3.Text                                           = "Hex";
     this.hexValueTextBox.Location                              = new Point(559, 133);
     this.hexValueTextBox.MaxLength                             = 8;
     this.hexValueTextBox.Name                                  = "hexValueTextBox";
     this.hexValueTextBox.Size                                  = new Size(59, 20);
     this.hexValueTextBox.TabIndex                              = 10;
     this.hexValueTextBox.Validated                            += new EventHandler(this.hexValueTextBox_Validated);
     this.colorPanel.BorderStyle                                = BorderStyle.FixedSingle;
     this.colorPanel.Location                                   = new Point(88, 200);
     this.colorPanel.Name                                       = "colorPanel";
     this.colorPanel.Size                                       = new Size(50, 50);
     this.colorPanel.TabIndex                                   = 11;
     this.colorListPicker.ColorBoxDistance                      = new Size(22, 22);
     this.colorListPicker.ColorBoxMargin                        = new Size(2, 2);
     this.colorListPicker.ColorBoxSize                          = new Size(18, 18);
     this.colorListPicker.Location                              = new Point(8, 258);
     this.colorListPicker.Name                                  = "colorListPicker";
     this.colorListPicker.SelectedColorIndex                    = -1;
     this.colorListPicker.Size                                  = new Size(214, 26);
     this.colorListPicker.TabIndex                              = 12;
     this.colorListPicker.Text                                  = "colorListPicker";
     this.colorListPicker.SelectedColorIndexChanged            += new EventHandler(this.colorListPicker_SelectedColorIndexChanged);
     this.lightnessComponentEditor.ColorComponentMaxValue       = 100;
     this.lightnessComponentEditor.ColorComponentToColorMapper  = (Func <int, Color>)null;
     this.lightnessComponentEditor.ColorComponentValue          = 0;
     this.lightnessComponentEditor.Label                        = "Lightness";
     this.lightnessComponentEditor.Location                     = new Point(225, 258);
     this.lightnessComponentEditor.Name                         = "lightnessComponentEditor";
     this.lightnessComponentEditor.Size                         = new Size(400, 30);
     this.lightnessComponentEditor.TabIndex                     = 6;
     this.lightnessComponentEditor.ColorComponentValueChanged  += new EventHandler(this.lightnessComponentEditor_ColorComponentValueChanged);
     this.saturationComponentEditor.ColorComponentMaxValue      = 100;
     this.saturationComponentEditor.ColorComponentToColorMapper = (Func <int, Color>)null;
     this.saturationComponentEditor.ColorComponentValue         = 0;
     this.saturationComponentEditor.Label                       = "Saturation";
     this.saturationComponentEditor.Location                    = new Point(225, 225);
     this.saturationComponentEditor.Name                        = "saturationComponentEditor";
     this.saturationComponentEditor.Size                        = new Size(400, 30);
     this.saturationComponentEditor.TabIndex                    = 5;
     this.saturationComponentEditor.ColorComponentValueChanged += new EventHandler(this.saturationComponentEditor_ColorComponentValueChanged);
     this.hueComponentEditor.ColorComponentMaxValue             = 359;
     this.hueComponentEditor.ColorComponentToColorMapper        = (Func <int, Color>)null;
     this.hueComponentEditor.ColorComponentValue                = 0;
     this.hueComponentEditor.Label                              = "Hue";
     this.hueComponentEditor.Location                           = new Point(225, 192);
     this.hueComponentEditor.Name                               = "hueComponentEditor";
     this.hueComponentEditor.Size                               = new Size(400, 30);
     this.hueComponentEditor.TabIndex                           = 4;
     this.hueComponentEditor.ColorComponentValueChanged        += new EventHandler(this.hueComponentEditor_ColorComponentValueChanged);
     this.blueComponentEditor.ColorComponentMaxValue            = (int)byte.MaxValue;
     this.blueComponentEditor.ColorComponentToColorMapper       = (Func <int, Color>)null;
     this.blueComponentEditor.ColorComponentValue               = 0;
     this.blueComponentEditor.Label                             = "Blue";
     this.blueComponentEditor.Location                          = new Point(225, 91);
     this.blueComponentEditor.Name                              = "blueComponentEditor";
     this.blueComponentEditor.Size                              = new Size(400, 30);
     this.blueComponentEditor.TabIndex                          = 3;
     this.blueComponentEditor.ColorComponentValueChanged       += new EventHandler(this.blueComponentEditor_ColorComponentValueChanged);
     this.greenComponentEditor.ColorComponentMaxValue           = (int)byte.MaxValue;
     this.greenComponentEditor.ColorComponentToColorMapper      = (Func <int, Color>)null;
     this.greenComponentEditor.ColorComponentValue              = 0;
     this.greenComponentEditor.Label                            = "Green";
     this.greenComponentEditor.Location                         = new Point(225, 58);
     this.greenComponentEditor.Name                             = "greenComponentEditor";
     this.greenComponentEditor.Size                             = new Size(400, 30);
     this.greenComponentEditor.TabIndex                         = 2;
     this.greenComponentEditor.ColorComponentValueChanged      += new EventHandler(this.greenComponentEditor_ColorComponentValueChanged);
     this.redComponentEditor.ColorComponentMaxValue             = (int)byte.MaxValue;
     this.redComponentEditor.ColorComponentToColorMapper        = (Func <int, Color>)null;
     this.redComponentEditor.ColorComponentValue                = 0;
     this.redComponentEditor.Label                              = "Red";
     this.redComponentEditor.Location                           = new Point(225, 25);
     this.redComponentEditor.Name                               = "redComponentEditor";
     this.redComponentEditor.Size                               = new Size(400, 30);
     this.redComponentEditor.TabIndex                           = 1;
     this.redComponentEditor.ColorComponentValueChanged        += new EventHandler(this.redComponentEditor_ColorComponentValueChanged);
     this.colorWheel.Color                                      = new Color?();
     this.colorWheel.Location                                   = new Point(0, 0);
     this.colorWheel.Name                                       = "colorWheel";
     this.colorWheel.Padding                                    = new Padding(15);
     this.colorWheel.Size                                       = new Size(219, 194);
     this.colorWheel.TabIndex                                   = 0;
     this.colorWheel.Text                                       = "colorWheel1";
     this.colorWheel.ColorChanged                              += new EventHandler(this.colorWheel_ColorChanged);
     this.AutoScaleDimensions                                   = new SizeF(6f, 13f);
     this.AutoScaleMode                                         = AutoScaleMode.Font;
     this.Controls.Add((Control)this.colorListPicker);
     this.Controls.Add((Control)this.colorPanel);
     this.Controls.Add((Control)this.hexValueTextBox);
     this.Controls.Add((Control)this.label3);
     this.Controls.Add((Control)this.label2);
     this.Controls.Add((Control)this.label1);
     this.Controls.Add((Control)this.lightnessComponentEditor);
     this.Controls.Add((Control)this.saturationComponentEditor);
     this.Controls.Add((Control)this.hueComponentEditor);
     this.Controls.Add((Control)this.blueComponentEditor);
     this.Controls.Add((Control)this.greenComponentEditor);
     this.Controls.Add((Control)this.redComponentEditor);
     this.Controls.Add((Control)this.colorWheel);
     this.Name = nameof(ColorRgbEditor);
     this.Size = new Size(625, 295);
     this.ResumeLayout(false);
     this.PerformLayout();
 }
コード例 #3
0
ファイル: ColorWheel.cs プロジェクト: 15831944/WW
        public System.Drawing.Color GetColor(Vector2D normalizedColorLocation)
        {
            Vector2D vector2D = normalizedColorLocation;

            return(ColorWheel.smethod_0(vector2D.X, vector2D.Y, vector2D.GetLength()));
        }