Exemplo n.º 1
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            Rectangle clientRectangle = this.ClientRectangle;

            clientRectangle.Height -= 16;
            clientRectangle.Width  -= 18;
            clientRectangle.X      += 8;
            if (e.Y <= clientRectangle.Height + 1)
            {
                this.OnMouseDoubleClick(e);
            }
            this.marker = (GradientColorValue)null;
            for (int index = 1; index < this.values.Count - 1; ++index)
            {
                GradientColorValue gradientColorValue = this.values[index];
                if (new Rectangle((int)((double)clientRectangle.Width * (double)gradientColorValue.ColorPosition + 4.0), clientRectangle.Height + 2, 8, 12).Contains(e.X, e.Y))
                {
                    this.marker  = gradientColorValue;
                    this.Capture = true;
                    this.mouseOffsetFromTheCenter = e.X - (int)((double)clientRectangle.Width * (double)gradientColorValue.ColorPosition + 8.0);
                    this.mousePosition            = new Point(e.X, e.Y);
                    this.Refresh();
                    break;
                }
            }
        }
Exemplo n.º 2
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            Rectangle rect = ClientRectangle;

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

            if (e.Y <= rect.Height + 1)
            {
                OnMouseDoubleClick(e);
            }

            marker = null;
            for (int i = 1; i < values.Count - 1; i++)
            {
                GradientColorValue value = values[i];

                Rectangle pointRect = new Rectangle((int)(rect.Width * value.ColorPosition + 4), rect.Height + 2, 8, 12);
                if (pointRect.Contains(e.X, e.Y))
                {
                    marker                   = value;
                    this.Capture             = true;
                    mouseOffsetFromTheCenter = (e.X - (int)(rect.Width * value.ColorPosition + 8));
                    mousePosition            = new Point(e.X, e.Y);
                    Refresh();
                    return;
                }
            }
        }
Exemplo n.º 3
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));
                }
            }
        }
Exemplo n.º 4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Rectangle rect = ClientRectangle;

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

            if (values.Count > 0)
            {
                ColorBlend blend = new ColorBlend();

                blend.Colors    = new Color[values.Count];
                blend.Positions = new float[values.Count];
                for (int i = 0; i < values.Count; i++)
                {
                    blend.Colors[i]    = values[i].ColorValue;
                    blend.Positions[i] = values[i].ColorPosition;
                }

                if (blend.Colors.Length < 2)
                {
                    using (SolidBrush brush = new SolidBrush(blend.Colors[0]))
                        e.Graphics.FillRectangle(brush, rect);
                }
                else
                {
                    using (LinearGradientBrush brush = new LinearGradientBrush(rect, blend.Colors[0], blend.Colors[values.Count - 1], 0f))
                    {
                        brush.InterpolationColors = blend;
                        e.Graphics.FillRectangle(brush, rect);
                    }
                    for (int i = 0; i < values.Count; i++)
                    {
                        GradientColorValue value = values[i];

                        Rectangle pointRect = new Rectangle((int)(rect.Width * value.ColorPosition + 4), rect.Height + 2, 6, 12);
                        using (Brush brush = new SolidBrush(value.ColorValue))
                            e.Graphics.FillRectangle(brush, pointRect);
                        if (value == marker)
                        {
                            e.Graphics.DrawRectangle(new Pen(Brushes.OrangeRed, 1), pointRect);
                        }
                        else
                        {
                            e.Graphics.DrawRectangle(new Pen(Brushes.Black, 1), pointRect);
                        }
                    }
                }
            }
            else
            {
                e.Graphics.FillRectangle(Brushes.Blue, rect);
            }
        }
Exemplo n.º 5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Rectangle clientRectangle = this.ClientRectangle;

            clientRectangle.Height -= 16;
            clientRectangle.Width  -= 18;
            clientRectangle.X      += 8;
            if (this.values.Count > 0)
            {
                ColorBlend colorBlend = new ColorBlend();
                colorBlend.Colors    = new Color[this.values.Count];
                colorBlend.Positions = new float[this.values.Count];
                for (int index = 0; index < this.values.Count; ++index)
                {
                    colorBlend.Colors[index]    = this.values[index].ColorValue;
                    colorBlend.Positions[index] = this.values[index].ColorPosition;
                }
                if (colorBlend.Colors.Length < 2)
                {
                    using (SolidBrush solidBrush = new SolidBrush(colorBlend.Colors[0]))
                        e.Graphics.FillRectangle((Brush)solidBrush, clientRectangle);
                }
                else
                {
                    using (LinearGradientBrush linearGradientBrush = new LinearGradientBrush(clientRectangle, colorBlend.Colors[0], colorBlend.Colors[this.values.Count - 1], 0.0f))
                    {
                        linearGradientBrush.InterpolationColors = colorBlend;
                        e.Graphics.FillRectangle((Brush)linearGradientBrush, clientRectangle);
                    }
                    for (int index = 0; index < this.values.Count; ++index)
                    {
                        GradientColorValue gradientColorValue = this.values[index];
                        Rectangle          rect = new Rectangle((int)((double)clientRectangle.Width * (double)gradientColorValue.ColorPosition + 4.0), clientRectangle.Height + 2, 6, 12);
                        using (Brush brush = (Brush) new SolidBrush(gradientColorValue.ColorValue))
                            e.Graphics.FillRectangle(brush, rect);
                        if (gradientColorValue == this.marker)
                        {
                            e.Graphics.DrawRectangle(new Pen(Brushes.OrangeRed, 1f), rect);
                        }
                        else
                        {
                            e.Graphics.DrawRectangle(new Pen(Brushes.Black, 1f), rect);
                        }
                    }
                }
            }
            else
            {
                e.Graphics.FillRectangle(Brushes.Blue, clientRectangle);
            }
        }
Exemplo n.º 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));
        }
Exemplo n.º 7
0
 protected override void OnMouseUp(MouseEventArgs e)
 {
     base.OnMouseUp(e);
     if (!new Rectangle(this.ClientRectangle.X - 10, this.ClientRectangle.Y - 8, this.ClientRectangle.Width + 500, this.ClientRectangle.Height + 10).Contains(e.X, e.Y) && this.marker != null && (this.marker != this.values[0] && this.marker != this.values[this.values.Count - 1]) && Math.Abs(e.X - this.mousePosition.X) < 70)
     {
         this.values.Remove(this.marker);
         if (this.ColorChanged != null)
         {
             this.ColorChanged((object)this, new ColorChangedEventArgs(this.marker.ColorValue));
         }
     }
     this.marker = (GradientColorValue)null;
     this.Refresh();
 }
Exemplo n.º 8
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            Rectangle rect = new Rectangle(ClientRectangle.X - 10, ClientRectangle.Y - 8, ClientRectangle.Width + 500, ClientRectangle.Height + 10);

            if (!rect.Contains(e.X, e.Y) && marker != null && marker != values[0] && marker != values[values.Count - 1] && Math.Abs(e.X - mousePosition.X) < 70)
            {
                this.values.Remove(marker);
                if (ColorChanged != null)
                {
                    ColorChanged(this, new ColorChangedEventArgs(marker.ColorValue));
                }
            }
            marker = null;
            Refresh();
        }