/// <summary>
 /// Builds the next frame.
 /// </summary>
 internal void BuildNextFrame()
 {
     if (mode == AnimateMode.BeginUpdate)
     {
         return;
     }
     DoubleBitmap.Invalidate();
 }
        /// <summary>
        /// Gets the screen background.
        /// </summary>
        /// <param name="ctrl">The control.</param>
        /// <param name="includeForeground">if set to <c>true</c> [include foreground].</param>
        /// <param name="clip">if set to <c>true</c> [clip].</param>
        /// <returns>Bitmap.</returns>
        private Bitmap GetScreenBackground(Control ctrl, bool includeForeground, bool clip)
        {
            var      size = Screen.PrimaryScreen.Bounds.Size;
            Graphics temp = DoubleBitmap.CreateGraphics();//???
            var      bmp  = new Bitmap(size.Width, size.Height, temp);
            Graphics gr   = Graphics.FromImage(bmp);

            gr.CopyFromScreen(0, 0, 0, 0, size);
            return(bmp);
        }
 /// <summary>
 /// Hides this instance.
 /// </summary>
 public void Hide()
 {
     if (DoubleBitmap != null)
     {
         try
         {
             DoubleBitmap.BeginInvoke(new MethodInvoker(() =>
             {
                 if (DoubleBitmap.Visible)
                 {
                     DoubleBitmap.Hide();
                 }
                 DoubleBitmap.Parent = null;
                 //DoubleBitmap.Dispose();
             }));
         }
         catch { }
     }
 }
        /// <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;
        }
Exemple #5
0
 internal void BuildNextFrame()
 {
     DoubleBitmap.Invalidate();
 }