Exemple #1
0
        protected virtual void OnTransfromNeeded(object sender, TransfromNeededEventArg e)
        {
            try
            {
                e.ClipRectangle = clipRect;
                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
            {
            }
        }
Exemple #2
0
        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)
                    };
                    OnTransfromNeeded(ea);
                    gr.SetClip(ea.ClipRectangle);
                    gr.Transform = ea.Matrix;
                    gr.DrawImage(frame, 0, 0);
                }
            }
            catch { }

            OnFramePainted(e);
        }
Exemple #3
0
 private void OnTransfromNeeded(TransfromNeededEventArg ea)
 {
     if (TransfromNeeded != null)
     {
         TransfromNeeded(this, ea);
     }
 }
Exemple #4
0
 protected virtual void OnTransformNeeded(object sender, TransfromNeededEventArg e)
 {
     if (TransfromNeeded != null)
     {
         TransfromNeeded(this, e);
     }
     else
     {
         e.UseDefaultMatrix = true;
     }
 }
Exemple #5
0
        public static void DoRotate(TransfromNeededEventArg e, 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);
        }
        public static void DoRotate(TransfromNeededEventArg e, Animation animation)
        {
            Rectangle clientRectangle = e.ClientRectangle;
            PointF    tf = new PointF((float)(clientRectangle.Width / 2), (float)(clientRectangle.Height / 2));

            e.Matrix.Translate(tf.X, tf.Y);
            if (e.CurrentTime > animation.RotateLimit)
            {
                e.Matrix.Rotate((360f * (e.CurrentTime - animation.RotateLimit)) * animation.RotateCoeff);
            }
            e.Matrix.Translate(-tf.X, -tf.Y);
        }
 public static void DoScale(TransfromNeededEventArg e, Animation animation)
 {
     var rect = e.ClientRectangle;
     var center = new PointF(rect.Width / 2, 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);
 }
Exemple #8
0
        /// <summary>
        /// Handles TransfromNeeded event
        /// </summary>
        private void animator_TransfromNeeded(object sender, TransfromNeededEventArg e)
        {
            if (rbCustom.Checked)
            {
                var cy = e.ClientRectangle.Height / 2;

                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);
            }else
                e.UseDefaultMatrix = true;
        }
        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 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, Point.Empty, new Point(Width, Height));
        }
        public static void DoScale(TransfromNeededEventArg e, Animation animation)
        {
            Rectangle clientRectangle = e.ClientRectangle;
            PointF    tf = new PointF((float)(clientRectangle.Width / 2), (float)(clientRectangle.Height / 2));

            e.Matrix.Translate(tf.X, tf.Y);
            float num  = 1f - (animation.ScaleCoeff.X * e.CurrentTime);
            float num2 = 1f - (animation.ScaleCoeff.X * e.CurrentTime);

            if (Math.Abs(num) <= 0.001f)
            {
                num = 0.001f;
            }
            if (Math.Abs(num2) <= 0.001f)
            {
                num2 = 0.001f;
            }
            e.Matrix.Scale(num, num2);
            e.Matrix.Translate(-tf.X, -tf.Y);
        }
Exemple #11
0
        public static void DoScale(TransfromNeededEventArg e, 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);
        }
        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) };
                    OnTransfromNeeded(ea);
                    gr.SetClip(ea.ClipRectangle);
                    gr.Transform = ea.Matrix;
                    gr.DrawImage(frame, 0, 0);
                }
            }
            catch { }

            OnFramePainted(e);
        }
Exemple #13
0
        protected virtual void OnTransfromNeeded(TransfromNeededEventArg e)
        {
            try
            {
                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
            {
            }
        }
Exemple #14
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics graphics = e.Graphics;

            this.OnFramePainting(e);
            try
            {
                graphics.DrawImage(this.bgBmp, 0, 0);
                if (this.frame != null)
                {
                    TransfromNeededEventArg ea = new TransfromNeededEventArg {
                        ClientRectangle = new Rectangle(0, 0, base.Width, base.Height)
                    };
                    this.OnTransfromNeeded(ea);
                    graphics.SetClip(ea.ClipRectangle);
                    graphics.Transform = ea.Matrix;
                    graphics.DrawImage(this.frame, 0, 0);
                }
            }
            catch
            {
            }
            this.OnFramePainted(e);
        }
        public static void DoRotate(TransfromNeededEventArg e, Animation animation)
        {
            var rect = e.ClientRectangle;
            var center = new PointF(rect.Width / 2, 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);
        }
 public static void DoSlide(TransfromNeededEventArg e, Animation animation)
 {
     var k = e.CurrentTime;
     e.Matrix.Translate(-e.ClientRectangle.Width * k * animation.SlideCoeff.X, -e.ClientRectangle.Height * k * animation.SlideCoeff.Y);
 }
Exemple #17
0
        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
            {
            }
        }
Exemple #18
0
 protected virtual void OnTransformNeeded(object sender, TransfromNeededEventArg e)
 {
     if (TransfromNeeded != null)
         TransfromNeeded(this, e);
     else
         e.UseDefaultMatrix = true;
 }
Exemple #19
0
        public static void DoSlide(TransfromNeededEventArg e, Animation animation)
        {
            var k = e.CurrentTime;

            e.Matrix.Translate(-e.ClientRectangle.Width * k * animation.SlideCoeff.X, -e.ClientRectangle.Height * k * animation.SlideCoeff.Y);
        }
 private void OnTransfromNeeded(TransfromNeededEventArg ea)
 {
     if (TransfromNeeded != null)
         TransfromNeeded(this, ea);
 }
        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 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, Point.Empty, new Point(Width, Height));
        }