Beispiel #1
0
 private void SetupFlyinAnim()
 {
     flyinAnim = new Animator()
     {
         OnCompleted = () =>
         {
             currentIndex       = newIndex;
             drawPrev           = imgs.Count > 0 && currentIndex > 0;
             drawNext           = currentIndex < imgs.Count - 1;
             opacityBrush.Color = Color.FromArgb(0, Color.Black);
             RecalcImageRect();
         }
     };
     flyinAnim.Add(new Step
     {
         Interval   = 20, // ms
         TotalStep  = step,
         AnimAction = (stepI) =>
         {
             // current
             currentImgRect     = currentImgRect.AdjustXF(direction * vCurrentHor);
             opacityBrush.Color = Color.FromArgb(255 - stepI * opacityStep, Color.Black);
             // next
             newImgRect = newImgRect.AdjustSizeFromCenter(vNewHor, vNewVer);
             Invalidate();
         }
     });
 }
Beispiel #2
0
        private void FlyIn()
        {
            if (currentIndex > -1)
            {
                currentImgRect = ImageDisplayModeHelper.GetImageRect(
                    this.ClientRectangle,
                    new Rectangle(Point.Empty, imgs[currentIndex].Size),
                    DisplayMode.ScaleLossLessCenter);
                direction   = -1;
                s           = (int)(0.5 * (this.Width + currentImgRect.Width));
                vCurrentHor = s / step + ((s % step == 0) ? 0 : 1);
            }

            //
            newImgRect = ImageDisplayModeHelper.GetImageRect(
                this.ClientRectangle,
                new Rectangle(Point.Empty, imgs[newIndex].Size),
                DisplayMode.ScaleLossLessCenter);

            int offsetSizeHor = 40;
            int offsetSizeVer = (int)(offsetSizeHor * 1f * newImgRect.Height / newImgRect.Width);

            vNewHor    = 1f * offsetSizeHor / step;
            vNewVer    = 1f * offsetSizeVer / step;
            newImgRect = newImgRect.AdjustSizeFromCenter(-offsetSizeHor, -offsetSizeVer);
            flyinAnim.Start();
        }