Example #1
0
 private void InitializeComponent()
 {
     goodColorControl21 = new GoodColorControl2();
     SuspendLayout();
     //
     // goodColorControl21
     //
     goodColorControl21.Color     = Color.Empty;
     goodColorControl21.Dock      = DockStyle.Fill;
     goodColorControl21.EditAlpha = true;
     goodColorControl21.Location  = new Drawing.Point(0, 0);
     goodColorControl21.Name      = "goodColorControl21";
     //this.goodColorControl21.ShowOldColor = false;
     goodColorControl21.Size     = new Drawing.Size(335, 253);
     goodColorControl21.TabIndex = 7;
     //
     // GoodColorDialog
     //
     ClientSize = new Drawing.Size(335, 253);
     Controls.Add(goodColorControl21);
     FormBorderStyle = FormBorderStyle.FixedToolWindow;
     MaximizeBox     = false;
     MinimizeBox     = false;
     Name            = "GoodColorDialog";
     ShowInTaskbar   = false;
     Text            = "Color Selector";
     ResumeLayout(false);
 }
Example #2
0
 private void InitializeComponent()
 {
     this.goodColorControl21 = new System.Windows.Forms.GoodColorControl2();
     this.SuspendLayout();
     //
     // goodColorControl21
     //
     this.goodColorControl21.Color     = System.Drawing.Color.Empty;
     this.goodColorControl21.Dock      = System.Windows.Forms.DockStyle.Fill;
     this.goodColorControl21.EditAlpha = true;
     this.goodColorControl21.Location  = new System.Drawing.Point(0, 0);
     this.goodColorControl21.Name      = "goodColorControl21";
     //this.goodColorControl21.ShowOldColor = false;
     this.goodColorControl21.Size     = new System.Drawing.Size(335, 253);
     this.goodColorControl21.TabIndex = 7;
     //
     // GoodColorDialog
     //
     this.ClientSize = new System.Drawing.Size(335, 253);
     this.Controls.Add(this.goodColorControl21);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
     this.MaximizeBox     = false;
     this.MinimizeBox     = false;
     this.Name            = "GoodColorDialog";
     this.ShowInTaskbar   = false;
     this.Text            = "Color Selector";
     this.ResumeLayout(false);
 }
        public override object EditValue(
            ITypeDescriptorContext context,
            IServiceProvider provider,
            object value)
        {
            if (provider != null)
            {
                _service =
                    provider.GetService(
                        typeof(IWindowsFormsEditorService))
                    as IWindowsFormsEditorService;
            }

            if (_service != null)
            {
                GoodColorControl2 selectionControl = new GoodColorControl2();
                selectionControl.Closed += selectionControl_Closed;

                Type t = value.GetType();

                if (t == typeof(ARGBPixel))
                {
                    selectionControl.Color = (Color)(ARGBPixel)value;
                }
                else if (t == typeof(RGBAPixel))
                {
                    selectionControl.Color = (Color)(RGBAPixel)value;
                }
                else if (t == typeof(GXColorS10))
                {
                    selectionControl.Color = (Color)(GXColorS10)value;
                }

                _service.DropDownControl(selectionControl);

                if (selectionControl.DialogResult == DialogResult.OK)
                {
                    if (t == typeof(ARGBPixel))
                    {
                        value = (ARGBPixel)selectionControl.Color;
                    }
                    else if (t == typeof(RGBAPixel))
                    {
                        value = (RGBAPixel)(ARGBPixel)selectionControl.Color;
                    }
                    else if (t == typeof(GXColorS10))
                    {
                        value = (GXColorS10)(ARGBPixel)selectionControl.Color;
                    }
                }
                _service = null;
            }

            return(value);
        }