Example #1
0
 //general
 private void onChanged(object sender, EventArgs e)
 {
     this.Refresh();
     //update ui
     ModifiedEventArgs args = e as ModifiedEventArgs;
     if (args != null && (args.Action == Action.Cleared ||
         (args.Action == Action.Removed && args.Point == _selection)))
         Selection = null;
     else
         RaiseGradientChanged();
 }
Example #2
0
        /// <summary>
        /// move, drag out/in a fader
        /// </summary>
        private bool UpdateSelection(MouseEventArgs e)
        {
            if (_blend == null)
                return false;
            if (_selection != null)
            {
                if (_focussel)
                {
                    //move focus point
                    _blend.SetFocusPosition(_selection, PointToPos(new Point(
                            e.X - _offset.X,
                            e.Y - _offset.Y)));
                }
                else if (!this.ClientRectangle.Contains(e.Location))
                {
                    // don't remove the point if dragged outside the area anymore,
                    // it's bloody annoying and easy to do.
                    ////remove point if dragged out
                    //_tmp = _selection;
                    //if (_selection is ColorPoint)
                    //    _blend.Colors.Remove(_selection as ColorPoint);
                    //else
                    //    _blend.Alphas.Remove(_selection as AlphaPoint);

                    //_selection = null;
                    //RaiseSelectionChanged();
                }
                else
                {
                    //move selected point
                    _selection.Position = PointToPos(new Point(
                            e.X - _offset.X,
                            e.Y - _offset.Y));
                }
            }
            else if (_tmp != null && this.ClientRectangle.Contains(e.Location))
            {
                _tmp.Position = PointToPos(new Point(
                            e.X - _offset.X,
                            e.Y - _offset.Y));
                //re-add point
                if (_tmp is ColorPoint)
                    _blend.Colors.Add((ColorPoint)_tmp);
                else
                    _blend.Alphas.Add((AlphaPoint)_tmp);
                Selection = _tmp;
                _tmp = null;
            }
            else
                return false;
            return true;
        }
Example #3
0
 //select or add faders
 protected override void OnMouseDown(MouseEventArgs e)
 {
     if (_blend != null && e.Button == MouseButtons.Left && !ReadOnly)
     {
         bool foc;
         Selection = GetFaderUnderMouse(e.Location, ref _offset, out foc);
         FocusSelection = foc;
         if (_selection == null)
         {
             //create new color or alpha point
             Rectangle area = Rectangle.Inflate(this.ClientRectangle, -BORDER, -BORDER);
             double pos = PointToPos(e.Location);
             _offset = Point.Empty;
             //
             if (_orientation == Orientation.Horizontal ?
                 e.Y > area.Bottom : e.X > area.Right)
             {
                 ColorPoint pnt = new ColorPoint(_blend.GetColorAt((float)pos), pos);
                 _selection = pnt;
                 _blend.Colors.Add(pnt);
             }
             else if (_orientation == Orientation.Horizontal ?
                 e.Y < area.Y : e.X < area.X)
             {
                 // MS: 25/09/11: disable drawing alpha points, we don't want to use them (yet).
                 //AlphaPoint pnt = new AlphaPoint(_blend.GetColorAt((float)pos).A, pos);
                 //_selection = pnt;
                 //_blend.Alphas.Add(pnt);
             }
         }
     }
     base.OnMouseDown(e);
 }