Example #1
0
        private void ColorBox_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.Hand;
            IRadColorDialog dialogForm = RadColorEditor.CreateColorDialogInstance();

            if (this.ColorDialogCreated != null)
            {
                this.ColorDialogCreated((object)this, new ColorDialogEventArgs(dialogForm));
            }
            UserControl selectorInstance = RadColorEditor.CreateColorSelectorInstance() as UserControl;

            ((IColorSelector)dialogForm.RadColorSelector).SelectedColor = this.BackColor;
            ((IColorSelector)dialogForm.RadColorSelector).OldColor      = this.BackColor;
            ((IColorSelector)selectorInstance).OkButtonClicked         += (ColorChangedEventHandler)((sender1, args) =>
            {
                ((Form)dialogForm).DialogResult = DialogResult.OK;
                ((Form)dialogForm).Close();
            });
            ((IColorSelector)selectorInstance).CancelButtonClicked += (ColorChangedEventHandler)((sender1, args) =>
            {
                ((Form)dialogForm).DialogResult = DialogResult.Cancel;
                ((Form)dialogForm).Close();
            });
            selectorInstance.Dock = DockStyle.Fill;
            ((Control)dialogForm).Controls.Add((Control)selectorInstance);
            if (((Form)dialogForm).ShowDialog() == DialogResult.OK)
            {
                this.BackColor = ((IColorSelector)dialogForm.RadColorSelector).SelectedColor;
                if (this.ColorChanged != null)
                {
                    this.ColorChanged((object)this, new ColorChangedEventArgs(this.BackColor));
                }
            }
            this.Invalidate();
        }
Example #2
0
        public override object EditValue(
            ITypeDescriptorContext context,
            System.IServiceProvider provider,
            object value)
        {
            IRadColorDialog colorDialogInstance = RadColorEditor.CreateColorDialogInstance();
            UserControl     radColorSelector    = colorDialogInstance.RadColorSelector;
            bool            flag = false;

            if (value != null && (object)value.GetType() == (object)typeof(Color))
            {
                ((IColorSelector)radColorSelector).SelectedColor = (Color)value;
                ((IColorSelector)radColorSelector).OldColor      = (Color)value;
            }
            else if (value != null && (object)value.GetType() == (object)typeof(HslColor))
            {
                ((IColorSelector)radColorSelector).SelectedHslColor = (HslColor)value;
                ((IColorSelector)radColorSelector).OldColor         = ((HslColor)value).RgbValue;
                flag = true;
            }
            if (value == null)
            {
                return((object)null);
            }
            if (((Form)colorDialogInstance).ShowDialog() != DialogResult.OK)
            {
                return(value);
            }
            if (flag)
            {
                return((object)colorDialogInstance.SelectedHslColor);
            }
            return((object)colorDialogInstance.SelectedColor);
        }
Example #3
0
        private void InitializeComponent()
        {
            this.colorDialog1  = RadColorEditor.CreateColorDialogInstance();
            colorSelector      = RadColorEditor.CreateColorSelectorInstance() as UserControl;
            colorSelector.Dock = DockStyle.Fill;
            ((Form)colorDialog1).Controls.Add(colorSelector);

            this.tbColor        = new System.Windows.Forms.TextBox();
            this.btnSelectColor = new System.Windows.Forms.Button();
            this.label1         = new System.Windows.Forms.Label();
            this.SuspendLayout();
            //
            // tbColor
            //
            this.tbColor.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                         | System.Windows.Forms.AnchorStyles.Left)
                                                                        | System.Windows.Forms.AnchorStyles.Right)));
            this.tbColor.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.tbColor.Location    = new System.Drawing.Point(20, 2);
            this.tbColor.MinimumSize = new System.Drawing.Size(60, 13);
            this.tbColor.Name        = "tbColor";
            this.tbColor.Size        = new System.Drawing.Size(80, 13);
            this.tbColor.TabIndex    = 0;
            this.tbColor.Validating += new System.ComponentModel.CancelEventHandler(this.tbColor_Validating);
            //
            // btnSelectColor
            //
            this.btnSelectColor.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                                | System.Windows.Forms.AnchorStyles.Left)
                                                                               | System.Windows.Forms.AnchorStyles.Right)));
            this.btnSelectColor.Location = new System.Drawing.Point(101, -1);
            this.btnSelectColor.Name     = "btnSelectColor";
            this.btnSelectColor.Size     = new System.Drawing.Size(20, 18);
            this.btnSelectColor.TabIndex = 1;
            this.btnSelectColor.Text     = "...";
            this.btnSelectColor.UseVisualStyleBackColor = true;
            this.btnSelectColor.Click += new System.EventHandler(this.btnSelectColor_Click);
            //
            // label1
            //
            this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                       | System.Windows.Forms.AnchorStyles.Left)));
            this.label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.label1.Location    = new System.Drawing.Point(-1, -1);
            this.label1.Name        = "label1";
            this.label1.Size        = new System.Drawing.Size(20, 20);
            this.label1.TabIndex    = 2;
            //
            // ColorComboBox
            //
            this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.Controls.Add(this.label1);
            this.Controls.Add(this.btnSelectColor);
            this.Controls.Add(this.tbColor);
            this.MinimumSize = new System.Drawing.Size(100, 17);
            this.Name        = "ColorComboBox";
            this.Size        = new System.Drawing.Size(123, 18);
            this.ResumeLayout(false);
            this.PerformLayout();
        }
Example #4
0
 public override void Reset()
 {
     if (this.colorDialogForm != null)
     {
         (this.colorDialogForm as IDisposable)?.Dispose();
     }
     this.colorDialogForm = RadColorEditor.CreateColorDialogInstance();
 }
Example #5
0
        protected override void OnMouseDoubleClick(MouseEventArgs e)
        {
            base.OnMouseDoubleClick(e);

            Rectangle rect = ClientRectangle;

            rect.Height -= 16;
            rect.Width  -= 18;
            rect.X      += 8;

            GradientColorValue selected = null;

            for (int i = 0; i < values.Count; i++)
            {
                GradientColorValue value = values[i];

                Rectangle pointRect = new Rectangle((int)(rect.Width * value.ColorPosition + 4), rect.Height, 8, 14);
                if (pointRect.Contains(e.X, e.Y))
                {
                    selected = value;
                    break;
                }
                else if (pointRect.X > e.X)
                {
                    if (values.Count >= 4)
                    {
                        MessageBox.Show("Only four color gradient styles are supported");
                        return;
                    }

                    Values.Insert(i, new GradientColorValue(Color.White, ((float)e.X - this.Parent.Location.X - this.Location.X) / (rect.Width + 4)));
                    selected = Values[i];
                    break;
                }
            }

            if (selected != null)
            {
                IRadColorDialog dialogForm = RadColorEditor.CreateColorDialogInstance();

                UserControl colorSelector = RadColorEditor.CreateColorSelectorInstance() as UserControl;
                ((IColorSelector)dialogForm.RadColorSelector).SelectedColor = (Color)selected.ColorValue;
                ((IColorSelector)dialogForm.RadColorSelector).OldColor      = (Color)selected.ColorValue;

                colorSelector.Dock = DockStyle.Fill;

                if (((Form)dialogForm).ShowDialog() == DialogResult.OK)
                {
                    selected.ColorValue = ((IColorSelector)dialogForm.RadColorSelector).SelectedColor;
                }
                Refresh();

                if (ColorChanged != null)
                {
                    ColorChanged(this, new ColorChangedEventArgs(selected.ColorValue));
                }
            }
        }
Example #6
0
        protected override void OnMouseDoubleClick(MouseEventArgs e)
        {
            base.OnMouseDoubleClick(e);
            Rectangle clientRectangle = this.ClientRectangle;

            clientRectangle.Height -= 16;
            clientRectangle.Width  -= 18;
            clientRectangle.X      += 8;
            GradientColorValue gradientColorValue1 = (GradientColorValue)null;

            for (int index = 0; index < this.values.Count; ++index)
            {
                GradientColorValue gradientColorValue2 = this.values[index];
                Rectangle          rectangle           = new Rectangle((int)((double)clientRectangle.Width * (double)gradientColorValue2.ColorPosition + 4.0), clientRectangle.Height, 8, 14);
                if (rectangle.Contains(e.X, e.Y))
                {
                    gradientColorValue1 = gradientColorValue2;
                    break;
                }
                if (rectangle.X > e.X)
                {
                    if (this.values.Count >= 4)
                    {
                        int num = (int)MessageBox.Show("Only four color gradient styles are supported");
                        return;
                    }
                    this.Values.Insert(index, new GradientColorValue(Color.White, ((float)e.X - (float)this.Parent.Location.X - (float)this.Location.X) / (float)(clientRectangle.Width + 4)));
                    gradientColorValue1 = this.Values[index];
                    break;
                }
            }
            if (gradientColorValue1 == null)
            {
                return;
            }
            IRadColorDialog colorDialogInstance = RadColorEditor.CreateColorDialogInstance();
            UserControl     selectorInstance    = RadColorEditor.CreateColorSelectorInstance() as UserControl;

            ((IColorSelector)colorDialogInstance.RadColorSelector).SelectedColor = gradientColorValue1.ColorValue;
            ((IColorSelector)colorDialogInstance.RadColorSelector).OldColor      = gradientColorValue1.ColorValue;
            selectorInstance.Dock = DockStyle.Fill;
            if (((Form)colorDialogInstance).ShowDialog() == DialogResult.OK)
            {
                gradientColorValue1.ColorValue = ((IColorSelector)colorDialogInstance.RadColorSelector).SelectedColor;
            }
            this.Refresh();
            if (this.ColorChanged == null)
            {
                return;
            }
            this.ColorChanged((object)this, new ColorChangedEventArgs(gradientColorValue1.ColorValue));
        }
Example #7
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IRadColorDialog dialogForm = RadColorEditor.CreateColorDialogInstance();

            UserControl colorSelector = dialogForm.RadColorSelector;            // RadColorEditor.CreateColorSelectorInstance() as UserControl;

            bool isHslColor = false;

            if (value != null && value.GetType() == typeof(Color))
            {
                ((IColorSelector)colorSelector).SelectedColor = (Color)value;
                ((IColorSelector)colorSelector).OldColor      = (Color)value;
            }
            else if (value != null && value.GetType() == typeof(HslColor))
            {
                ((IColorSelector)colorSelector).SelectedHslColor = (HslColor)value;
                ((IColorSelector)colorSelector).OldColor         = ((HslColor)value).RgbValue;

                isHslColor = true;
            }

            if (value == null)
            {
                return(null);
            }

            if (((Form)dialogForm).ShowDialog() == DialogResult.OK)
            {
                if (isHslColor)
                {
                    return(dialogForm.SelectedHslColor);
                }
                else
                {
                    return(dialogForm.SelectedColor);
                }
            }

            return(value);
        }
Example #8
0
        void ColorBox_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.Hand;
            IRadColorDialog dialogForm = RadColorEditor.CreateColorDialogInstance();

            if (this.ColorDialogCreated != null)
            {
                ColorDialogEventArgs args = new ColorDialogEventArgs(dialogForm);

                this.ColorDialogCreated(this, args);
            }

            UserControl colorSelector = RadColorEditor.CreateColorSelectorInstance() as UserControl;

            ((IColorSelector)dialogForm.RadColorSelector).SelectedColor = this.BackColor;
            ((IColorSelector)dialogForm.RadColorSelector).OldColor      = this.BackColor;

            ((IColorSelector)colorSelector).OkButtonClicked += delegate(object sender1, ColorChangedEventArgs args)
            {
                ((Form)dialogForm).DialogResult = DialogResult.OK;
                ((Form)dialogForm).Close();
            };
            ((IColorSelector)colorSelector).CancelButtonClicked += delegate(object sender1, ColorChangedEventArgs args)
            {
                ((Form)dialogForm).DialogResult = DialogResult.Cancel;
                ((Form)dialogForm).Close();
            };
            colorSelector.Dock = DockStyle.Fill;
            ((Form)dialogForm).Controls.Add(colorSelector);
            if (((Form)dialogForm).ShowDialog() == DialogResult.OK)
            {
                this.BackColor = ((IColorSelector)dialogForm.RadColorSelector).SelectedColor;
                if (ColorChanged != null)
                {
                    ColorChanged(this, new ColorChangedEventArgs(this.BackColor));
                }
            }

            this.Invalidate();
        }
Example #9
0
 ///<summary>
 ///Resets the properties of a color dialog box to their default values. Replaces the underlaying ColorDialogForm
 /// with new instance
 ///</summary>
 ///<filterpriority>1</filterpriority>
 public override void Reset()
 {
     this.colorDialogForm = (IRadColorDialog)RadColorEditor.CreateColorDialogInstance();
 }