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; } }
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(); }
private void BaseGradientUserControl_MouseUp(object sender, MouseEventArgs e) { _isDelete = false; _clrfloat = null; _bLeftDown = false; _ColorBlendEx.MouseUp(e.Location); Invalidate(); }
public ColorFloat MouseUp(Point MousePoint) { ColorFloat cf = null; for (int i = 0; i < DataList.Count; i++) { DataList[i].MouseUp(MousePoint); } return(cf); }
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); }
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); }
void SelectedColorChange(Color clr) { ColorFloat cf = _ColorBlendEx.GetSelected(); if (cf != null) { cf.Color = clr; if (ColorBlendChanged != null) { ColorBlendChanged(); } // Invalidate(); } }
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); } }
public void Remove(ColorFloat cf) { DataList.Remove(cf); SelectIndex = 0; }