public void SetStartPositionRelativeLoc(Endogine.EPoint loc)
 {
     if (loc == null)
         loc = new Endogine.EPoint(Cursor.Position);
     //TODO: set a prop instead and automatically do this on Show(). But: can't override show, which event is it?
     this.Location = (loc + new Endogine.EPoint(-this.Width / 2, 15)).ToPoint();
     //TODO: if too far to left, right or bottom
 }
 public void SetStartPositionRelativeLoc(Endogine.EPoint loc)
 {
     if (loc == null)
     {
         loc = new Endogine.EPoint(Cursor.Position);
     }
     //TODO: set a prop instead and automatically do this on Show(). But: can't override show, which event is it?
     this.Location = (loc + new Endogine.EPoint(-this.Width / 2, 15)).ToPoint();
     //TODO: if too far to left, right or bottom
 }
        private void ColorGradientChip_MouseMove(object sender, MouseEventArgs e)
        {
            if (this._mouseDrag != null)
            {
                Endogine.EPoint pnt  = new Endogine.EPoint(this.PointToScreen(e.Location));
                Endogine.EPoint diff = pnt - this._mouseDrag;
                this._mouseDrag = pnt;

                //this.Location = (new Endogine.EPoint(this.Location) + diff).ToPoint();
                int left = this.Left + diff.X;
                if (left < 0)
                {
                    left = 0;
                }
                else if (left > this.Parent.Width - this.Width)
                {
                    left = this.Parent.Width - this.Width;
                }
                this.Left              = left;
                this._draggedDistance += diff.ToEPointF().Length;

                this._position = (float)this.Left / (this.Parent.Width - this.Width);

                if (Math.Abs(e.Y) > 20)
                {
                    if (this.Visible)
                    {
                        this.Visible = false;
                    }
                }
                else if (!this.Visible)
                {
                    this.Visible = true;
                }

                if (this.Dragged != null)
                {
                    this.Dragged(this, e);
                }
            }
        }
 private void ColorGradientChip_MouseUp(object sender, MouseEventArgs e)
 {
     if (this._mouseDrag != null)
     {
         this._mouseDrag = null;
         if (Math.Abs(e.Y) > 20)
         {
             //TODO: remove chip
             if (this.Removed != null)
             {
                 this.Removed(this, null);
             }
         }
         else if (this._draggedDistance < 2)
         {
             ColorPickerForm form = new ColorPickerForm();
             form.Show();
             form.SetStartPositionRelativeLoc(null);
             form.ColorObject   = this.ColorObject;
             form.ColorChanged += new EventHandler(form_ColorChanged);
         }
     }
 }
 private void ColorGradientChip_MouseDown(object sender, MouseEventArgs e)
 {
     this._mouseDrag       = new Endogine.EPoint(this.PointToScreen(e.Location));
     this._draggedDistance = 0;
 }
        private void ColorGradientChip_MouseMove(object sender, MouseEventArgs e)
        {
            if (this._mouseDrag != null)
            {
                Endogine.EPoint pnt = new Endogine.EPoint(this.PointToScreen(e.Location));
                Endogine.EPoint diff = pnt - this._mouseDrag;
                this._mouseDrag = pnt;

                //this.Location = (new Endogine.EPoint(this.Location) + diff).ToPoint();
                int left = this.Left + diff.X;
                if (left < 0) left = 0;
                else if (left > this.Parent.Width - this.Width) left = this.Parent.Width - this.Width;
                this.Left = left;
                this._draggedDistance += diff.ToEPointF().Length;

                this._position = (float)this.Left / (this.Parent.Width-this.Width);

                if (Math.Abs(e.Y) > 20)
                {
                    if (this.Visible)
                        this.Visible = false;
                }
                else if (!this.Visible)
                    this.Visible = true;

                if (this.Dragged != null)
                    this.Dragged(this, e);
            }
        }
 private void ColorGradientChip_MouseDown(object sender, MouseEventArgs e)
 {
     this._mouseDrag = new Endogine.EPoint(this.PointToScreen(e.Location));
     this._draggedDistance = 0;
 }
        private void ColorGradientChip_MouseUp(object sender, MouseEventArgs e)
        {
            if (this._mouseDrag != null)
            {
                this._mouseDrag = null;
                if (Math.Abs(e.Y) > 20)
                {
                    //TODO: remove chip
                    if (this.Removed != null)
                        this.Removed(this, null);

                }
                else if (this._draggedDistance < 2)
                {
                    ColorPickerForm form = new ColorPickerForm();
                    form.Show();
                    form.SetStartPositionRelativeLoc(null);
                    form.ColorObject = this.ColorObject;
                    form.ColorChanged += new EventHandler(form_ColorChanged);
                }
            }
        }