Esempio n. 1
0
        private void BaseGradientUserControl_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                bool bSel = _ColorBlendEx.MouseDown(e.Location);
                if (bSel)
                {
                    SolidUserCtrl.color = _ColorBlendEx.GetSelected().Color;
                }
                if (SolidUserCtrl == null)
                {
                    return;
                }
                if (!bSel && ClientRect.Contains(e.Location)) //添加一个新的颜色
                {
                    ColorFloat cf = new ColorFloat(SolidUserCtrl.color, (e.X - ClientRect.X) / (float)ClientRect.Width);
                    cf.Selected = true;
                    _ColorBlendEx.Add(cf, ClientRect);
                    _ColorBlendEx.Redraw();
                }

                Invalidate();
                _bLeftDown = true;
            }
        }
Esempio n. 2
0
 bool _isDelete       = false; //是否删除过
 private void BaseGradientUserControl_MouseMove(object sender, MouseEventArgs e)
 {
     if (!_bLeftDown)
     {
         return;
     }
     _ColorBlendEx.MouseMove(e.Location);
     if (e.Location.Y >= (ClientRect.Bottom + 17) && _ColorBlendEx.Count > 2)
     {
         ColorFloat cf = _ColorBlendEx.GetSelected();
         if (cf != null && _isDelete == false)
         {
             _clrfloat = cf;
             _ColorBlendEx.Remove(cf);
             _isDelete = true;
         }
     }
     else if (_clrfloat != null && ClientRectangle.Contains(e.Location)) //添加一个新的颜色
     {
         ColorFloat cf = new ColorFloat(_clrfloat.Color, (e.X - ClientRect.X) / (float)ClientRect.Width);
         cf.Selected = true;
         _clrfloat   = null;
         _isDelete   = false;
         _ColorBlendEx.Add(cf, ClientRect);
         _ColorBlendEx.GetSelected()._bMove = true;
         _ColorBlendEx.Redraw();
     }
     if (ColorBlendChanged != null)
     {
         ColorBlendChanged();
     }
     Invalidate();
 }
Esempio n. 3
0
 private void BaseGradientUserControl_MouseUp(object sender, MouseEventArgs e)
 {
     _isDelete  = false;
     _clrfloat  = null;
     _bLeftDown = false;
     _ColorBlendEx.MouseUp(e.Location);
     Invalidate();
 }
Esempio n. 4
0
        public ColorFloat MouseUp(Point MousePoint)
        {
            ColorFloat cf = null;

            for (int i = 0; i < DataList.Count; i++)
            {
                DataList[i].MouseUp(MousePoint);
            }
            return(cf);
        }
Esempio n. 5
0
 public void Add(ColorFloat cf, Rectangle linearRect)
 {
     cf.LinearRectangle = linearRect;
     if (cf.Selected)
     {
         for (int i = 0; i < DataList.Count; i++)
         {
             DataList[i].Selected = false;
         }
     }
     DataList.Add(cf);
 }
Esempio n. 6
0
        public void Add(Color clr, float pos, Rectangle linearRect)
        {
            ColorFloat cf = new ColorFloat(clr, pos);

            cf.LinearRectangle = linearRect;

            /*cf.Selected = true;
             * for (int i = 0; i < DataList.Count; i++)
             * {
             *  DataList[i].Selected = false;
             * }*/
            DataList.Add(cf);
        }
Esempio n. 7
0
        void SelectedColorChange(Color clr)
        {
            ColorFloat cf = _ColorBlendEx.GetSelected();

            if (cf != null)
            {
                cf.Color = clr;
                if (ColorBlendChanged != null)
                {
                    ColorBlendChanged();
                }
                //   Invalidate();
            }
        }
Esempio n. 8
0
        public void Reset(ColorBlend ColorBlend, Rectangle rect)
        {
            DataList.Clear();
            int i;

            for (i = 0; i < ColorBlend.Colors.Length; i++)
            {
                if (ColorBlend.Colors.Length > 3)
                {
                    if (i == 0 && ColorBlend.Positions[i] == 0)
                    {
                        continue;
                    }
                    if (i == ColorBlend.Colors.Length - 1 && ColorBlend.Positions[i] == 1)
                    {
                        continue;
                    }
                }
                ColorFloat cf = new ColorFloat(ColorBlend.Colors[i], ColorBlend.Positions[i]);
                Add(cf, rect);
            }
        }
Esempio n. 9
0
 public void Remove(ColorFloat cf)
 {
     DataList.Remove(cf);
     SelectIndex = 0;
 }