Beispiel #1
0
        private void animationTimer_Tick(object sender, System.EventArgs e)
        {
            //	---------------------------------------------------------------
            //	Gradually reduce the interval between timer events so that the
            //	animation begins slowly and eventually accelerates to completion
            //	---------------------------------------------------------------
            if (animationTimer.Interval > 10) {
                animationTimer.Interval -= 10 ;
            } else {
                animationHeightAdjustment += 2 ;
            }

            // Increase transparency as we collapse
            if ((animationOpacity + 5) <  byte.MaxValue) {
                animationOpacity += 5 ;
            }

            int currOpacity = animationOpacity ;

            switch (PanelDrawState) {
                case XPPanelDrawState.Expanding:
                    // still room to expand?
                    if ((Height + animationHeightAdjustment) < ExpandedHeight) {
                        Height += animationHeightAdjustment;
                        // notify panel state change listeners so they can react
                        OnPanelStateChange() ;
                    } else {
                        // we are done so we dont want any transparency
                        currOpacity = byte.MaxValue ;
                        PanelState = XPPanelState.Expanded ;
                        PanelDrawState = XPPanelDrawState.Normal ;
                    }
                    break;

                case XPPanelDrawState.Collapsing:
                    // still something to collapse
                    if ((Height - animationHeightAdjustment) > xpPanelRect.Top) {
                        Height -= animationHeightAdjustment ;
                        // continue decreasing opacity
                        currOpacity = byte.MaxValue - animationOpacity ;
                        // notify panel state change listeners so they can react
                        OnPanelStateChange() ;
                    } else {
                        // we are done so we dont want any transparency
                        currOpacity = byte.MaxValue ;
                        PanelState = XPPanelState.Collapsed ;
                        PanelDrawState = XPPanelDrawState.Normal ;
                    }
                    break;

                default:
                    return ;
            }

            // set the opacity for all the controls on the XPPanel
            SetControlsOpacity(currOpacity);
            // make panel colors more/less transparent
            panelGradient.Start = SetColorAlpha(currOpacity,panelGradient.Start);
            panelGradient.End = SetColorAlpha(currOpacity,panelGradient.End);
            PanelBrush = null ;
            panelOutlineColor = SetColorAlpha(currOpacity,panelOutlineColor );
            // hide/show controls based on the height of the XPPanel (as it shrinks/grows)
            SetControlsVisible();

            // are we done?
            if (!IsActive) {
                animationTimer.Enabled = false;
            }

            Invalidate();
        }
Beispiel #2
0
        /// <summary>
        /// Routine to toggle the state of <c>XPPanel</c> from Expanded to Collapsed
        /// (or visa-versa)
        /// </summary>
        /// <remarks>
        /// This routine provides a way to trigger the visual animation of
        /// expanding/collapsing a <c>XPPanel</c>
        /// </remarks>
        public virtual void TogglePanelState()
        {
            // If we are animating, start it now...
            if (animationRate != 0) {
                if (IsExpanded) {
                    PanelDrawState = XPPanelDrawState.Collapsing ;
                } else {
                    PanelDrawState = XPPanelDrawState.Expanding ;
                }

                StartAnimation() ;
            } else {
                // No animation. Just expand/collapse immediately
                // (note: set the DrawState to internal so that expandedHeight does not
                // get mucked up)
                if (IsExpanded) {
                    PanelDrawState = XPPanelDrawState.Internal ;
                    PanelState = XPPanelState.Collapsed ;
                } else {
                    PanelDrawState = XPPanelDrawState.Internal ;
                    PanelState = XPPanelState.Expanded ;
                }

                // we are back to normal
                PanelDrawState = XPPanelDrawState.Normal ;
            }
        }