/// <summary> /// Disposes this instance. /// </summary> public void Dispose() { if (ctrlBmp != null) { BgBmp.Dispose(); } if (ctrlBmp != null) { ctrlBmp.Dispose(); } if (Frame != null) { Frame.Dispose(); } AnimatedControl = null; Hide(); }
public void Dispose() { BgBmp?.Dispose(); CoverBmp?.Dispose(); RingBrush?.Dispose(); TextBrush?.Dispose(); CoverBrush?.Dispose(); // Background if (BoundControl != null) { BoundControl.ViewChanged -= SV_ViewChanged; } DataContext.PropertyChanged -= Context_PropertyChanged; // RippleEx BindItem.PropertyChanged -= BindItem_PropertyChanged; }
/// <summary> /// Initializes a new instance of the <see cref="Controller"/> class. /// </summary> /// <param name="control">The control.</param> /// <param name="mode">The mode.</param> /// <param name="animation">The animation.</param> /// <param name="timeStep">The time step.</param> /// <param name="controlClipRect">The control clip rect.</param> public Controller(Control control, AnimateMode mode, ZeroitAnimate_Animation animation, float timeStep, Rectangle controlClipRect) { if (control is System.Windows.Forms.Form) { DoubleBitmap = new DoubleBitmapForm(); } else { DoubleBitmap = new DoubleBitmapControl(); } (DoubleBitmap as IFakeControl).FramePainting += OnFramePainting; (DoubleBitmap as IFakeControl).FramePainted += OnFramePainting; (DoubleBitmap as IFakeControl).TransfromNeeded += OnTransfromNeeded; DoubleBitmap.MouseDown += OnMouseDown; this.animation = animation; this.AnimatedControl = control; this.mode = mode; this.CustomClipRect = 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; } try { switch (mode) { case AnimateMode.Hide: { BgBmp = GetBackground(control); (DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); ctrlBmp = GetForeground(control); DoubleBitmap.Visible = true; control.Visible = false; } break; case AnimateMode.Show: { BgBmp = GetBackground(control); (DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); DoubleBitmap.Visible = true; DoubleBitmap.Refresh(); control.Visible = true; ctrlBmp = GetForeground(control); } break; case AnimateMode.BeginUpdate: case AnimateMode.Update: { (DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); BgBmp = GetBackground(control, true); DoubleBitmap.Visible = true; } break; } } catch { Dispose(); } #if debug BgBmp.Save("c:\\bgBmp.png"); if (ctrlBmp != null) { ctrlBmp.Save("c:\\ctrlBmp.png"); } #endif CurrentTime = timeStep > 0 ? animation.MinTime : animation.MaxTime; }
public Controller(Control control, AnimateMode mode, Animation animation, float timeStep, Rectangle controlClipRect) { DoubleBitmap = new DoubleBitmapControl(); (DoubleBitmap as IFakeControl).FramePainting += OnFramePainting; (DoubleBitmap as IFakeControl).FramePainted += OnFramePainting; (DoubleBitmap as IFakeControl).TransfromNeeded += OnTransfromNeeded; DoubleBitmap.MouseDown += OnMouseDown; this.animation = animation; this.AnimatedControl = control; this.mode = mode; if (controlClipRect == default(Rectangle)) { this.clipRect = new Rectangle(Point.Empty, GetBounds().Size); } else { this.clipRect = 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.Hide: { BgBmp = GetBackground(control); (DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); ctrlBmp = GetForeground(control); DoubleBitmap.Visible = true; control.Visible = false; } break; case AnimateMode.Show: { BgBmp = GetBackground(control); (DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); DoubleBitmap.Visible = true; DoubleBitmap.Refresh(); control.Visible = true; ctrlBmp = GetForeground(control); } break; case AnimateMode.BeginUpdate: case AnimateMode.Update: { (DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); BgBmp = GetBackground(control, true); DoubleBitmap.Visible = true; } break; } #if debug BgBmp.Save("c:\\bgBmp.png"); if (ctrlBmp != null) { ctrlBmp.Save("c:\\ctrlBmp.png"); } #endif CurrentTime = timeStep > 0 ? animation.MinTime : animation.MaxTime; }