示例#1
0
        /* Slide the main button left or right with the user's mouse movement when
         * the mouse is held down.  Once it crosses the left or right slide limit
         * thresholds, fire the appropriate slide event, and fire the mouse up event
         * to reset the main button to a sane location. */

        private void BtnEdit_MouseMove(object sender, MouseEventArgs e)
        {
            var withinLimitLeft  = btnMain.Location.X >= btnLeft.Location.X - btnLeft.Width;
            var withinLimitRight = btnMain.Location.X <= btnLeft.Location.X + btnLeft.Width;


            if (Slide && withinLimitLeft && withinLimitRight)
            {
                btnMain.Location = new Point(btnMain.Location.X + (e.X - Mouse), btnMain.Location.Y);

                var beyondLimitLeft  = btnMain.Location.X <= btnLeft.Location.X - btnLeft.Width;
                var beyondLimitRight = btnMain.Location.X >= btnLeft.Location.X + btnLeft.Width;

                if (beyondLimitLeft)
                {
                    btnMain.Location = new Point(btnLeft.Location.X - btnLeft.Width, btnMain.Location.Y);
                    SlideLeft?.Invoke(this, null);
                    BtnEdit_MouseUp(this, null);
                }

                if (beyondLimitRight)
                {
                    btnMain.Location = new Point(btnLeft.Location.X + btnLeft.Width, btnMain.Location.Y);
                    SlideRight?.Invoke(this, null);
                    BtnEdit_MouseUp(this, null);
                }
            }
        }
示例#2
0
 public virtual void OnSlideRight(GestureEventArgs e)
 {
     SlideRight?.Invoke(this, e);
 }