Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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;
        }