示例#1
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            var gr = e.Graphics;

            OnFramePainting(e);

            try
            {
                gr.DrawImage(bgBmp, 0, 0);
                if (frame != null)
                {
                    var ea = new TransfromNeededEventArg()
                    {
                        ClientRectangle = new Rectangle(0, 0, this.Width, this.Height)
                    };
                    ea.ClipRectangle = ea.ClientRectangle;
                    OnTransfromNeeded(ea);
                    gr.SetClip(ea.ClipRectangle);
                    gr.Transform = ea.Matrix;
                    gr.DrawImage(frame, 0, 0);
                }
            }
            catch { }

            //e.Graphics.DrawLine(Pens.Red, System.Drawing.Point.Empty, new System.Drawing.Point(Width, Height));

            OnFramePainted(e);
        }
示例#2
0
 /// <summary>
 /// Called when [transfrom needed].
 /// </summary>
 /// <param name="ea">The ea.</param>
 private void OnTransfromNeeded(TransfromNeededEventArg ea)
 {
     if (TransfromNeeded != null)
     {
         TransfromNeeded(this, ea);
     }
 }
        /// <summary>
        /// Called when [transfrom needed].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        protected virtual void OnTransfromNeeded(object sender, TransfromNeededEventArg e)
        {
            try
            {
                if (CustomClipRect != default(Rectangle))
                {
                    e.ClipRectangle = ControlRectToMyRect(CustomClipRect);
                }

                e.CurrentTime = CurrentTime;

                if (TransfromNeeded != null)
                {
                    TransfromNeeded(this, e);
                }
                else
                {
                    e.UseDefaultMatrix = true;
                }

                if (e.UseDefaultMatrix)
                {
                    TransfromHelper.DoScale(e, animation);
                    TransfromHelper.DoRotate(e, animation);
                    TransfromHelper.DoSlide(e, animation);
                }
            }
            catch
            {
            }
        }
示例#4
0
 /// <summary>
 /// Called when [transform needed].
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The e.</param>
 protected virtual void OnTransformNeeded(object sender, TransfromNeededEventArg e)
 {
     if (TransfromNeeded != null)
     {
         TransfromNeeded(this, e);
     }
     else
     {
         e.UseDefaultMatrix = true;
     }
 }
        /// <summary>
        /// Does the rotate.
        /// </summary>
        /// <param name="e">The e.</param>
        /// <param name="animation">The animation.</param>
        public static void DoRotate(TransfromNeededEventArg e, ZeroitAnimate_Animation animation)
        {
            var rect   = e.ClientRectangle;
            var center = new PointF(rect.Left + rect.Width / 2, rect.Top + rect.Height / 2);

            e.Matrix.Translate(center.X, center.Y);
            if (e.CurrentTime > animation.RotateLimit)
            {
                e.Matrix.Rotate(360 * (e.CurrentTime - animation.RotateLimit) * animation.RotateCoeff);
            }
            e.Matrix.Translate(-center.X, -center.Y);
        }
        /// <summary>
        /// Does the flip.
        /// </summary>
        /// <param name="e">The e.</param>
        /// <param name="animation">The animation.</param>
        public static void DoFlip(TransfromNeededEventArg e, ZeroitAnimate_Animation animation)
        {
            var cy = e.ClientRectangle.Height / 5;

            var sy = 1 - 2 * e.CurrentTime;

            if (sy < 0.01f && sy > -0.01f)
            {
                sy = 0.01f;
            }

            e.Matrix.Translate(0, cy);
            e.Matrix.Scale(1, sy);
            e.Matrix.Translate(0, -cy);
        }
示例#7
0
        /// <summary>
        /// Handles the <see cref="E:Paint" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            var gr = e.Graphics;

            OnFramePainting(e);

            try
            {
                gr.DrawImage(bgBmp, -Location.X, -Location.Y);

                /*
                 * if (frame == null)
                 * {
                 *  control.Focus();
                 *  if (control.Focused)
                 *  {
                 *      frame = new Bitmap(control.Width, control.Height);
                 *      //control.DrawToBitmap(frame, new Rectangle(padding.Left, padding.Top, control.Width, control.Height));
                 *      control.DrawToBitmap(frame, new Rectangle(0, 0, control.Width, control.Height));
                 *  }
                 * }*/

                if (frame != null)
                {
                    //var ea = new TransfromNeededEventArg(){ ClientRectangle = new Rectangle(0, 0, this.Width, this.Height) };
                    var ea = new TransfromNeededEventArg();
                    ea.ClientRectangle = ea.ClipRectangle = new Rectangle(control.Bounds.Left - padding.Left, control.Bounds.Top - padding.Top, control.Bounds.Width + padding.Horizontal, control.Bounds.Height + padding.Vertical);
                    OnTransfromNeeded(ea);
                    gr.SetClip(ea.ClipRectangle);
                    gr.Transform = ea.Matrix;
                    //var p = new System.Drawing.Point();
                    var p = control.Location;
                    //gr.Transform.Translate(p.X, p.Y);
                    gr.DrawImage(frame, p.X - padding.Left, p.Y - padding.Top);
                }

                OnFramePainted(e);
            }
            catch { }

            //e.Graphics.DrawLine(Pens.Red, System.Drawing.Point.Empty, new System.Drawing.Point(Width, Height));
        }
        /// <summary>
        /// Does the scale.
        /// </summary>
        /// <param name="e">The e.</param>
        /// <param name="animation">The animation.</param>
        public static void DoScale(TransfromNeededEventArg e, ZeroitAnimate_Animation animation)
        {
            var rect   = e.ClientRectangle;
            var center = new PointF(rect.Left + rect.Width / 2, rect.Top + rect.Height / 2);

            e.Matrix.Translate(center.X, center.Y);
            var kx = 1f - animation.ScaleCoeff.X * e.CurrentTime;
            var ky = 1f - animation.ScaleCoeff.X * e.CurrentTime;

            if (Math.Abs(kx) <= 0.001f)
            {
                kx = 0.001f;
            }
            if (Math.Abs(ky) <= 0.001f)
            {
                ky = 0.001f;
            }
            e.Matrix.Scale(kx, ky);
            e.Matrix.Translate(-center.X, -center.Y);
        }
        /// <summary>
        /// Does the slide.
        /// </summary>
        /// <param name="e">The e.</param>
        /// <param name="animation">The animation.</param>
        public static void DoSlide(TransfromNeededEventArg e, ZeroitAnimate_Animation animation)
        {
            var k = e.CurrentTime;

            e.Matrix.Translate(-e.ClientRectangle.Width * k * animation.SlideCoeff.X, -e.ClientRectangle.Height * k * animation.SlideCoeff.Y);
        }