public static void DoBlind(NonLinearTransfromNeededEventArg e, Animation animation) { if (animation.BlindCoeff != PointF.Empty) { byte[] pixels = e.Pixels; int width = e.ClientRectangle.Width; int height = e.ClientRectangle.Height; int stride = e.Stride; float x = animation.BlindCoeff.X; float y = animation.BlindCoeff.Y; int num8 = (int)(((width * x) + (height * y)) * (1f - e.CurrentTime)); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { int num5 = (j * stride) + (i * 4); float num9 = ((i * x) + (j * y)) - num8; if (num9 >= 0f) { pixels[num5 + 3] = 0; } } } } }
public void Add(Animation a) { this.SlideCoeff = new PointF(this.SlideCoeff.X + a.SlideCoeff.X, this.SlideCoeff.Y + a.SlideCoeff.Y); this.RotateCoeff += a.RotateCoeff; this.RotateLimit += a.RotateLimit; this.ScaleCoeff = new PointF(this.ScaleCoeff.X + a.ScaleCoeff.X, this.ScaleCoeff.Y + a.ScaleCoeff.Y); this.TransparencyCoeff += a.TransparencyCoeff; this.LeafCoeff += a.LeafCoeff; this.MosaicShift = new PointF(this.MosaicShift.X + a.MosaicShift.X, this.MosaicShift.Y + a.MosaicShift.Y); this.MosaicCoeff = new PointF(this.MosaicCoeff.X + a.MosaicCoeff.X, this.MosaicCoeff.Y + a.MosaicCoeff.Y); this.MosaicSize += a.MosaicSize; this.BlindCoeff = new PointF(this.BlindCoeff.X + a.BlindCoeff.X, this.BlindCoeff.Y + a.BlindCoeff.Y); this.TimeCoeff += a.TimeCoeff; this.Padding += a.Padding; }
public static void DoTransparent(NonLinearTransfromNeededEventArg e, Animation animation) { if (animation.TransparencyCoeff != 0f) { float num2 = 1f - (animation.TransparencyCoeff * e.CurrentTime); if (num2 < 0f) { num2 = 0f; } if (num2 > 1f) { num2 = 1f; } byte[] pixels = e.Pixels; for (int i = 0; i < pixels.Length; i += 4) { pixels[i + 3] = (byte)(pixels[i + 3] * num2); } } }
public static void DoSlide(TransfromNeededEventArg e, Animation animation) { float currentTime = e.CurrentTime; e.Matrix.Translate((-e.ClientRectangle.Width * currentTime) * animation.SlideCoeff.X, (-e.ClientRectangle.Height * currentTime) * animation.SlideCoeff.Y); }
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); }
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 DoMosaic(NonLinearTransfromNeededEventArg e, Animation animation, ref Point[] buffer, ref byte[] pixelsBuffer) { if ((animation.MosaicCoeff != PointF.Empty) && (animation.MosaicSize != 0)) { byte[] pixels = e.Pixels; int width = e.ClientRectangle.Width; int height = e.ClientRectangle.Height; int stride = e.Stride; float currentTime = e.CurrentTime; int length = pixels.Length; float num7 = 1f - e.CurrentTime; if (num7 < 0f) { num7 = 0f; } if (num7 > 1f) { num7 = 1f; } float x = animation.MosaicCoeff.X; float y = animation.MosaicCoeff.Y; if (buffer == null) { buffer = new Point[pixels.Length]; for (int k = 0; k < pixels.Length; k++) { buffer[k] = new Point((int)(x * (rnd.NextDouble() - 0.5)), (int)(y * (rnd.NextDouble() - 0.5))); } } if (pixelsBuffer == null) { pixelsBuffer = (byte[])pixels.Clone(); } for (int i = 0; i < length; i += 4) { pixels[i] = 0xff; pixels[i + 1] = 0xff; pixels[i + 2] = 0xff; pixels[i + 3] = 0; } int mosaicSize = animation.MosaicSize; float num16 = animation.MosaicShift.X; float num17 = animation.MosaicShift.Y; for (int j = 0; j < height; j++) { for (int m = 0; m < width; m++) { int num12 = j / mosaicSize; int num13 = m / mosaicSize; int index = (j * stride) + (m * 4); int num14 = (num12 * stride) + (num13 * 4); int num = m + ((int)(currentTime * (buffer[num14].X + (num13 * num16)))); int num3 = j + ((int)(currentTime * (buffer[num14].Y + (num12 * num17)))); if (((num >= 0) && (num < width)) && ((num3 >= 0) && (num3 < height))) { int num5 = (num3 * stride) + (num * 4); pixels[num5] = pixelsBuffer[index]; pixels[num5 + 1] = pixelsBuffer[index + 1]; pixels[num5 + 2] = pixelsBuffer[index + 2]; pixels[num5 + 3] = (byte)(pixelsBuffer[index + 3] * num7); } } } } }
public static void DoLeaf(NonLinearTransfromNeededEventArg e, Animation animation) { if (animation.LeafCoeff != 0f) { byte[] pixels = e.Pixels; int width = e.ClientRectangle.Width; int height = e.ClientRectangle.Height; int stride = e.Stride; int num7 = (int)((width + height) * (1f - (e.CurrentTime * e.CurrentTime))); int length = pixels.Length; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { int index = (j * stride) + (i * 4); if ((i + j) >= num7) { int num9 = num7 - j; int num8 = num7 - i; int num2 = (num7 - i) - j; if (num2 < -20) { num2 = -20; } int num = (num8 * stride) + (num9 * 4); if ((((num9 >= 0) && (num8 >= 0)) && ((num >= 0) && (num < length))) && (pixels[index + 3] > 0)) { pixels[num] = (byte)Math.Min(0xff, (num2 + 250) + (pixels[index] / 10)); pixels[num + 1] = (byte)Math.Min(0xff, (num2 + 250) + (pixels[index + 1] / 10)); pixels[num + 2] = (byte)Math.Min(0xff, (num2 + 250) + (pixels[index + 2] / 10)); pixels[num + 3] = 230; } pixels[index + 3] = 0; } } } } }
public Controller(Control control, AnimateMode mode, Animation animation, float timeStep, Rectangle controlClipRect) { this.DoubleBitmap = new DoubleBitmapControl(); (this.DoubleBitmap as IFakeControl).FramePainting += new EventHandler<PaintEventArgs>(this.OnFramePainting); (this.DoubleBitmap as IFakeControl).FramePainted += new EventHandler<PaintEventArgs>(this.OnFramePainting); (this.DoubleBitmap as IFakeControl).TransfromNeeded += new EventHandler<TransfromNeededEventArg>(this.OnTransfromNeeded); this.DoubleBitmap.MouseDown += new MouseEventHandler(this.OnMouseDown); this.animation = animation; this.AnimatedControl = control; this.mode = mode; if (controlClipRect == new Rectangle()) { this.clipRect = new Rectangle(Point.Empty, this.GetBounds().Size); } else { this.clipRect = this.ControlRectToMyRect(controlClipRect); } if ((mode == AnimateMode.Show) || (mode == AnimateMode.BeginUpdate)) { timeStep = -timeStep; } this.TimeStep = timeStep * ((animation.TimeCoeff == 0f) ? 1f : animation.TimeCoeff); if (this.TimeStep == 0f) { timeStep = 0.01f; } switch (mode) { case AnimateMode.Show: this.BgBmp = this.GetBackground(control, false, false); (this.DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); this.DoubleBitmap.Visible = true; this.DoubleBitmap.Refresh(); control.Visible = true; this.ctrlBmp = this.GetForeground(control); break; case AnimateMode.Hide: this.BgBmp = this.GetBackground(control, false, false); (this.DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); this.ctrlBmp = this.GetForeground(control); this.DoubleBitmap.Visible = true; control.Visible = false; break; case AnimateMode.Update: case AnimateMode.BeginUpdate: (this.DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); this.BgBmp = this.GetBackground(control, true, false); this.DoubleBitmap.Visible = true; break; } this.CurrentTime = (timeStep > 0f) ? animation.MinTime : animation.MaxTime; }
public void AddToQueue(Control control, AnimateMode mode, bool parallel = true, Animation animation = null, Rectangle clipRectangle = new Rectangle()) { if (animation == null) { animation = this.DefaultAnimation; } if (control is IFakeControl) { control.Visible = false; } else { QueueItem item = new QueueItem { animation = animation, control = control, IsActive = parallel, mode = mode, clipRectangle = clipRectangle }; switch (mode) { case AnimateMode.Show: { if (!control.Visible) { break; } QueueItem item2 = new QueueItem { control = control, mode = mode }; this.OnCompleted(item2); return; } case AnimateMode.Hide: { if (control.Visible) { break; } QueueItem item3 = new QueueItem { control = control, mode = mode }; this.OnCompleted(item3); return; } } lock (this.queue) { this.queue.Add(item); } lock (this.requests) { this.requests.Add(item); } } }
public void ShowSync(Control control, bool parallel = false, Animation animation = null) { this.Show(control, parallel, animation); this.WaitAnimation(control); }
public void Show(Control control, bool parallel = false, Animation animation = null) { this.AddToQueue(control, AnimateMode.Show, parallel, animation, new Rectangle()); }
private Controller CreateDoubleBitmap(Control control, AnimateMode mode, Animation animation, Rectangle clipRect) { Controller controller = new Controller(control, mode, animation, this.TimeStep, clipRect); controller.TransfromNeeded += new EventHandler<TransfromNeededEventArg>(this.OnTransformNeeded); controller.NonLinearTransfromNeeded += new EventHandler<NonLinearTransfromNeededEventArg>(this.OnNonLinearTransfromNeeded); controller.MouseDown += new EventHandler<MouseEventArgs>(this.OnMouseDown); controller.DoubleBitmap.Cursor = this.Cursor; controller.FramePainted += new EventHandler<PaintEventArgs>(this.OnFramePainted); return controller; }
public void BeginUpdateSync(Control control, bool parallel = false, Animation animation = null, Rectangle clipRectangle = new Rectangle()) { this.AddToQueue(control, AnimateMode.BeginUpdate, parallel, animation, clipRectangle); bool flag = false; while (true) { flag = false; lock (this.queue) { foreach (QueueItem item in this.queue) { if (((item.control == control) && (item.mode == AnimateMode.BeginUpdate)) && (item.controller == null)) { flag = true; } } } if (flag) { Application.DoEvents(); } if (!flag) { return; } } }