示例#1
0
        public override bool DoMouseUp(Point p, MouseButtons button)
        {
            // No righties
            if (button != MouseButtons.Left)
            {
                return(true);
            }

            // If we've been tracking thumb, stoppit.
            if (pressedPart == WorkingPart.Thumb)
            {
                StopCapturingMouse();
            }

            pressedPart = WorkingPart.None;
            lock (animLOScroll)
            {
                // No forced positioning
                animPosInDrag = int.MinValue;
                // Cancel any repeat purchase order
                animRepeatCounter  = int.MinValue;
                animRepeatPurchase = float.MinValue;
            }
            doAnimateTo(true, false, false, false, pressedPart);
            return(true);
        }
示例#2
0
 public override void DoMouseLeave()
 {
     // When we leave, that unpresses whatever's currently pressed, except held thumb
     if (pressedPart != WorkingPart.Thumb)
     {
         // If we're holding on to thumb, pretend we don't leave
         pressedPart = WorkingPart.None;
         // Cancel any repeat purchase order (pressed up/down buttons)
         lock (animLOScroll)
         {
             animRepeatCounter  = int.MinValue;
             animRepeatPurchase = float.MinValue;
         }
     }
     // Update our make-up.
     doAnimateTo(false, false, false, false, pressedPart);
 }
示例#3
0
        /// <summary>
        /// Updates animations to target new states for our components.
        /// </summary>
        private void doAnimateTo(bool mouseIn, bool overTop, bool overThumb, bool overBottom,
                                 WorkingPart wp)
        {
            // Figure out each component's desired color based on arguments
            // First, just hover stuff
            Color topBtnBg       = overTop ? ZenParams.ScrollColBtnHover : ZenParams.ScrollColBg;
            Color topBtnArrow    = overTop ? ZenParams.ScrollColArrowHover : ZenParams.ScrollColArrowBase;
            Color bottomBtnBg    = overBottom ? ZenParams.ScrollColBtnHover : ZenParams.ScrollColBg;
            Color bottomBtnArrow = overBottom ? ZenParams.ScrollColArrowHover : ZenParams.ScrollColArrowBase;
            Color thumb          = mouseIn ? ZenParams.ScrollColThumbSemiHover : ZenParams.ScrollColThumbBase;

            if (overThumb)
            {
                thumb = ZenParams.ScrollColThumbHover;
            }
            // Then, pressed stuff
            if (wp == WorkingPart.TopBtn)
            {
                topBtnBg    = ZenParams.ScrollColBtnPress;
                topBtnArrow = ZenParams.ScrollColArrowPress;
            }
            else if (wp == WorkingPart.BottomBtn)
            {
                bottomBtnBg    = ZenParams.ScrollColBtnPress;
                bottomBtnArrow = ZenParams.ScrollColArrowPress;
            }
            else if (wp == WorkingPart.Thumb)
            {
                thumb = ZenParams.ScrollColThumbActive;
            }
            // Go from here to there, if we have to
            lock (animLO)
            {
                // If something is "working", i.e., pressed, we need timer for repeat action fires
                bool needTimer = wp != WorkingPart.None;
                // Must change top button colors, or not
                if (animVals.TopBtnBg == topBtnBg)
                {
                    animState.StateTopBtn = -1;
                }
                else
                {
                    animState.StateTopBtn      = (overTop || wp == WorkingPart.TopBtn) ? 2 : 0;
                    animState.From.TopBtnBg    = animVals.TopBtnBg;
                    animState.From.TopBtnArrow = animVals.TopBtnArrow;
                    animState.To.TopBtnBg      = topBtnBg;
                    animState.To.TopBtnArrow   = topBtnArrow;
                    needTimer |= true;
                }
                // Must change bottom button colors, or not
                if (animVals.BottomBtnBg == bottomBtnBg)
                {
                    animState.StateBottomBtn = -1;
                }
                else
                {
                    animState.StateBottomBtn      = (overBottom || wp == WorkingPart.BottomBtn) ? 2 : 0;
                    animState.From.BottomBtnBg    = animVals.BottomBtnBg;
                    animState.From.BottomBtnArrow = animVals.BottomBtnArrow;
                    animState.To.BottomBtnBg      = bottomBtnBg;
                    animState.To.BottomBtnArrow   = bottomBtnArrow;
                    needTimer |= true;
                }
                // Must change thumb color, or not
                if (animVals.Thumb == thumb)
                {
                    animState.StateThumb = -1;
                }
                else
                {
                    animState.StateThumb = (overThumb || wp == WorkingPart.Thumb) ? 2 : 0;
                    animState.From.Thumb = animVals.Thumb;
                    animState.To.Thumb   = thumb;
                    needTimer           |= true;
                }
                // Donee. Make sure we got timer, or not.
                if (needTimer)
                {
                    SubscribeToTimer();
                }
                else
                {
                    UnsubscribeFromTimer();
                }
            }
        }
示例#4
0
        public override bool DoMouseDown(Point p, MouseButtons button)
        {
            // No righties
            if (button != MouseButtons.Left)
            {
                return(true);
            }

            // Figure out what's been pressed
            Rectangle thumbRect     = getThumbRect(position);
            bool      overTopBtn    = new Rectangle(0, 0, Width, Width).Contains(p);
            bool      overThumb     = thumbRect.Contains(p);
            bool      overBottomBtn = new Rectangle(0, Height - Width, Width, Width).Contains(p);

            if (overTopBtn)
            {
                pressedPart = WorkingPart.TopBtn;
            }
            else if (overThumb)
            {
                pressedPart = WorkingPart.Thumb;
            }
            else if (overBottomBtn)
            {
                pressedPart = WorkingPart.BottomBtn;
            }
            else if (p.Y < thumbRect.Top)
            {
                pressedPart = WorkingPart.TopJump;
            }
            else if (p.Y > thumbRect.Bottom)
            {
                pressedPart = WorkingPart.BottomJump;
            }
            else
            {
                pressedPart = WorkingPart.None;
            }

            // UI goodies, ease colors in and out
            doAnimateTo(true, overTopBtn, overThumb, overBottomBtn, pressedPart);

            // Thumb now gets dragged around
            if (pressedPart == WorkingPart.Thumb)
            {
                // Dragging the thumb means any scrolling in progress stops right now
                // But: record mandatory scroll position
                doStopAnyScroll(position);
                // Remember where we started dragging
                thumbHoldStartMouseY   = p.Y;
                thumbHoldStartThumbTop = thumbRect.Top;
                thumbHoldStartPos      = position;
                // Start capturing mouse. We want to keep tracking even if pointer leaves to left or right while
                // button is pressed.
                CaptureMouse();
            }
            // Jumpy-holdy parts (buttons and full page scroll)
            else
            {
                int fuelToBuy;
                int repeatBuy;
                if (pressedPart == WorkingPart.TopBtn)
                {
                    fuelToBuy = -smallSchange; repeatBuy = fuelToBuy / 2;
                }
                else if (pressedPart == WorkingPart.BottomBtn)
                {
                    fuelToBuy = smallSchange; repeatBuy = fuelToBuy / 2;
                }
                else if (pressedPart == WorkingPart.TopJump)
                {
                    fuelToBuy = -pageSize / 4; repeatBuy = fuelToBuy / 6;
                }
                else
                {
                    fuelToBuy = pageSize / 4; repeatBuy = fuelToBuy / 6;
                }
                // Buy the fuel
                doBuyScrollFuel(fuelToBuy);
                // Commission repeated purchases: "repeat fire" effect if button is kept pressed
                lock (animLOScroll)
                {
                    animRepeatCounter  = 0;
                    animRepeatPurchase = ((float)repeatBuy);
                    if (pressedPart == WorkingPart.TopJump || pressedPart == WorkingPart.BottomJump)
                    {
                        animRepeatBarrierY = p.Y;
                    }
                    else
                    {
                        if (pressedPart == WorkingPart.TopBtn)
                        {
                            animRepeatBarrierY = Width + 1;
                        }
                        else
                        {
                            animRepeatBarrierY = Height - Width - 1;
                        }
                    }
                }
            }

            // We're done here.
            return(true);
        }
示例#5
0
 /// <summary>
 /// Updates animations to target new states for our components.
 /// </summary>
 private void doAnimateTo(bool mouseIn, bool overTop, bool overThumb, bool overBottom,
     WorkingPart wp)
 {
     // Figure out each component's desired color based on arguments
     // First, just hover stuff
     Color topBtnBg = overTop ? ZenParams.ScrollColBtnHover : ZenParams.ScrollColBg;
     Color topBtnArrow = overTop ? ZenParams.ScrollColArrowHover : ZenParams.ScrollColArrowBase;
     Color bottomBtnBg = overBottom ? ZenParams.ScrollColBtnHover : ZenParams.ScrollColBg;
     Color bottomBtnArrow = overBottom ? ZenParams.ScrollColArrowHover : ZenParams.ScrollColArrowBase;
     Color thumb = mouseIn ? ZenParams.ScrollColThumbSemiHover : ZenParams.ScrollColThumbBase;
     if (overThumb) thumb = ZenParams.ScrollColThumbHover;
     // Then, pressed stuff
     if (wp == WorkingPart.TopBtn)
     {
         topBtnBg = ZenParams.ScrollColBtnPress;
         topBtnArrow = ZenParams.ScrollColArrowPress;
     }
     else if (wp == WorkingPart.BottomBtn)
     {
         bottomBtnBg = ZenParams.ScrollColBtnPress;
         bottomBtnArrow = ZenParams.ScrollColArrowPress;
     }
     else if (wp == WorkingPart.Thumb) thumb = ZenParams.ScrollColThumbActive;
     // Go from here to there, if we have to
     lock (animLO)
     {
         // If something is "working", i.e., pressed, we need timer for repeat action fires
         bool needTimer = wp != WorkingPart.None;
         // Must change top button colors, or not
         if (animVals.TopBtnBg == topBtnBg) animState.StateTopBtn = -1;
         else
         {
             animState.StateTopBtn = (overTop || wp == WorkingPart.TopBtn) ? 2 : 0;
             animState.From.TopBtnBg = animVals.TopBtnBg;
             animState.From.TopBtnArrow = animVals.TopBtnArrow;
             animState.To.TopBtnBg = topBtnBg;
             animState.To.TopBtnArrow = topBtnArrow;
             needTimer |= true;
         }
         // Must change bottom button colors, or not
         if (animVals.BottomBtnBg == bottomBtnBg) animState.StateBottomBtn = -1;
         else
         {
             animState.StateBottomBtn = (overBottom || wp == WorkingPart.BottomBtn) ? 2 : 0;
             animState.From.BottomBtnBg = animVals.BottomBtnBg;
             animState.From.BottomBtnArrow = animVals.BottomBtnArrow;
             animState.To.BottomBtnBg = bottomBtnBg;
             animState.To.BottomBtnArrow = bottomBtnArrow;
             needTimer |= true;
         }
         // Must change thumb color, or not
         if (animVals.Thumb == thumb) animState.StateThumb = -1;
         else
         {
             animState.StateThumb = (overThumb || wp == WorkingPart.Thumb) ? 2 : 0;
             animState.From.Thumb = animVals.Thumb;
             animState.To.Thumb = thumb;
             needTimer |= true;
         }
         // Donee. Make sure we got timer, or not.
         if (needTimer) SubscribeToTimer();
         else UnsubscribeFromTimer();
     }
 }
示例#6
0
        public override bool DoMouseUp(Point p, MouseButtons button)
        {
            // No righties
            if (button != MouseButtons.Left) return true;

            // If we've been tracking thumb, stoppit.
            if (pressedPart == WorkingPart.Thumb) StopCapturingMouse();

            pressedPart = WorkingPart.None;
            lock (animLOScroll)
            {
                // No forced positioning
                animPosInDrag = int.MinValue;
                // Cancel any repeat purchase order
                animRepeatCounter = int.MinValue;
                animRepeatPurchase = float.MinValue;
            }
            doAnimateTo(true, false, false, false, pressedPart);
            return true;
        }
示例#7
0
 public override void DoMouseLeave()
 {
     // When we leave, that unpresses whatever's currently pressed, except held thumb
     if (pressedPart != WorkingPart.Thumb)
     {
         // If we're holding on to thumb, pretend we don't leave
         pressedPart = WorkingPart.None;
         // Cancel any repeat purchase order (pressed up/down buttons)
         lock (animLOScroll)
         {
             animRepeatCounter = int.MinValue;
             animRepeatPurchase = float.MinValue;
         }
     }
     // Update our make-up.
     doAnimateTo(false, false, false, false, pressedPart);
 }
示例#8
0
        public override bool DoMouseDown(Point p, MouseButtons button)
        {
            // No righties
            if (button != MouseButtons.Left) return true;

            // Figure out what's been pressed
            Rectangle thumbRect = getThumbRect(position);
            bool overTopBtn = new Rectangle(0, 0, Width, Width).Contains(p);
            bool overThumb = thumbRect.Contains(p);
            bool overBottomBtn = new Rectangle(0, Height - Width, Width, Width).Contains(p);
            if (overTopBtn) pressedPart = WorkingPart.TopBtn;
            else if (overThumb) pressedPart = WorkingPart.Thumb;
            else if (overBottomBtn) pressedPart = WorkingPart.BottomBtn;
            else if (p.Y < thumbRect.Top) pressedPart = WorkingPart.TopJump;
            else if (p.Y > thumbRect.Bottom) pressedPart = WorkingPart.BottomJump;
            else pressedPart = WorkingPart.None;

            // UI goodies, ease colors in and out
            doAnimateTo(true, overTopBtn, overThumb, overBottomBtn, pressedPart);

            // Thumb now gets dragged around
            if (pressedPart == WorkingPart.Thumb)
            {
                // Dragging the thumb means any scrolling in progress stops right now
                // But: record mandatory scroll position
                doStopAnyScroll(position);
                // Remember where we started dragging
                thumbHoldStartMouseY = p.Y;
                thumbHoldStartThumbTop = thumbRect.Top;
                thumbHoldStartPos = position;
                // Start capturing mouse. We want to keep tracking even if pointer leaves to left or right while
                // button is pressed.
                CaptureMouse();
            }
            // Jumpy-holdy parts (buttons and full page scroll)
            else
            {
                int fuelToBuy;
                int repeatBuy;
                if (pressedPart == WorkingPart.TopBtn) { fuelToBuy = -smallSchange; repeatBuy = fuelToBuy / 2; }
                else if (pressedPart == WorkingPart.BottomBtn) { fuelToBuy = smallSchange; repeatBuy = fuelToBuy / 2; }
                else if (pressedPart == WorkingPart.TopJump) { fuelToBuy = -pageSize / 4; repeatBuy = fuelToBuy / 6; }
                else { fuelToBuy = pageSize / 4; repeatBuy = fuelToBuy / 6; }
                // Buy the fuel
                doBuyScrollFuel(fuelToBuy);
                // Commission repeated purchases: "repeat fire" effect if button is kept pressed
                lock (animLOScroll)
                {
                    animRepeatCounter = 0;
                    animRepeatPurchase = ((float)repeatBuy);
                    if (pressedPart == WorkingPart.TopJump || pressedPart == WorkingPart.BottomJump)
                        animRepeatBarrierY = p.Y;
                    else
                    {
                        if (pressedPart == WorkingPart.TopBtn) animRepeatBarrierY = Width + 1;
                        else animRepeatBarrierY = Height - Width - 1;
                    }
                }
            }

            // We're done here.
            return true;
        }