/// <summary>
        /// 展开
        /// </summary>
        public void Expand()
        {
            if (this.state != ExtendedPanelState.Collapsed)
            {
                throw new InvalidOperationException("控制必须在扩大后的状态,并要求被收起!");
            }

            DirectionStyle oldStyle = DirectionStyle.Down;
            DirectionStyle newStyle = DirectionStyle.Up;

            switch (captionAlign)
            {
            case DirectionStyle.Up:             //set above
                break;

            case DirectionStyle.Left:
                oldStyle = DirectionStyle.Right;
                newStyle = DirectionStyle.Left;
                break;

            case DirectionStyle.Right:
                oldStyle = DirectionStyle.Left;
                newStyle = DirectionStyle.Right;
                break;

            case DirectionStyle.Down:
                oldStyle = DirectionStyle.Up;
                newStyle = DirectionStyle.Down;
                break;
            }
            this.captionCtrl.SetDirectionStyle(newStyle);
            ChangeStyleEventArgs args = new ChangeStyleEventArgs(oldStyle, newStyle);

            CollapsingHandler(this, args);
        }
        private void CollapsingHandler(object sender, ChangeStyleEventArgs e)
        {
            //check to see  if Anchoring needs special treatment
            if (this.captionAlign == DirectionStyle.Right || this.captionAlign == DirectionStyle.Down)
            {
                backupAnchor = this.Anchor;
                this.Anchor |= AnchorStyles.Left;
                this.Anchor |= AnchorStyles.Top;
                this.Anchor &= ~AnchorStyles.Right;
                this.Anchor &= ~AnchorStyles.Bottom;
            }
            //create the thread for collasping/expanding the control
            if (null == collapseAnimation)
            {
                collapseAnimation = new CollapseAnimation();
                //set the events to be raised by the animation worker thread
                collapseAnimation.NotifyAnimation         += new NotifyAnimationEvent(OnNotifyAnimationEvent);
                collapseAnimation.NotifyAnimationFinished += new NotifyAnimationFinishedEvent(OnNotifyAnimationFinished);
                if (backupHeight == 0)
                {
                    backupHeight = this.Height;
                }
                if (backupWidth == 0)
                {
                    backupWidth = this.Width;
                }
            }

            switch (this.captionAlign)
            {
            case DirectionStyle.Up:
                if (e.Old == DirectionStyle.Up)
                {
                    backupHeight = this.Height;
                    backupWidth  = this.Width;

                    collapseAnimation.Maximum = this.Height;
                    collapseAnimation.Minimum = captionCtrl.Height;
                    if (animation == Animation.Yes)
                    {
                        collapseAnimation.Step = step;
                    }
                    else
                    {
                        collapseAnimation.Step = this.Height - captionCtrl.Height;
                    }
                }
                else
                {
                    collapseAnimation.Maximum = backupHeight;
                    collapseAnimation.Minimum = captionCtrl.Height;
                    if (animation == Animation.Yes)
                    {
                        collapseAnimation.Step = -step;
                    }
                    else
                    {
                        collapseAnimation.Step = -(backupHeight - captionCtrl.Height);
                    }
                }
                break;

            case DirectionStyle.Down:
                if (e.Old == DirectionStyle.Down)
                {
                    //have to extract caption ctrl because of the flickering involved
                    ChangeCaptionParent();

                    //save the size as will need them for expanding the control back
                    backupHeight = this.Height;
                    backupWidth  = this.Width;

                    collapseAnimation.Maximum = this.Height;
                    collapseAnimation.Minimum = captionCtrl.Height;
                    if (animation == Animation.Yes)
                    {
                        collapseAnimation.Step = step;
                    }
                    else
                    {
                        collapseAnimation.Step = this.Height - captionCtrl.Height;
                    }
                }
                else
                {
                    //have to extract caption ctrl because of the flickering involved
                    ChangeCaptionParent();

                    collapseAnimation.Maximum = backupHeight;
                    collapseAnimation.Minimum = captionCtrl.Height;
                    if (animation == Animation.Yes)
                    {
                        collapseAnimation.Step = -step;
                    }
                    else
                    {
                        collapseAnimation.Step = -(backupHeight - captionCtrl.Height);
                    }
                }
                break;


            case DirectionStyle.Left:
                if (e.Old == DirectionStyle.Left)
                {
                    //save the size as will need them for expanding the control back
                    backupHeight = this.Height;
                    backupWidth  = this.Width;

                    collapseAnimation.Maximum = this.Width;
                    collapseAnimation.Minimum = captionCtrl.Width;
                    if (animation == Animation.Yes)
                    {
                        collapseAnimation.Step = step;
                    }
                    else
                    {
                        collapseAnimation.Step = this.Width - captionCtrl.Width;
                    }
                }
                else
                {
                    collapseAnimation.Maximum = backupWidth;
                    collapseAnimation.Minimum = captionCtrl.Width;
                    if (animation == Animation.Yes)
                    {
                        collapseAnimation.Step = -step;
                    }
                    else
                    {
                        collapseAnimation.Step = -(backupWidth - captionCtrl.Width);
                    }
                }
                break;

            case DirectionStyle.Right:
                if (e.Old == DirectionStyle.Right)
                {
                    //have to extract caption ctrl because of the flickering involved
                    ChangeCaptionParent();

                    backupHeight = this.Height;
                    backupWidth  = this.Width;

                    collapseAnimation.Maximum = this.Width;
                    collapseAnimation.Minimum = captionCtrl.Width;
                    if (animation == Animation.Yes)
                    {
                        collapseAnimation.Step = step;
                    }
                    else
                    {
                        collapseAnimation.Step = this.Width - captionCtrl.Width;
                    }
                }
                else
                {
                    //have to extract caption ctrl because of the flickering involved
                    ChangeCaptionParent();

                    collapseAnimation.Maximum = backupWidth;
                    collapseAnimation.Minimum = captionCtrl.Width;
                    if (animation == Animation.Yes)
                    {
                        collapseAnimation.Step = -step;
                    }
                    else
                    {
                        collapseAnimation.Step = -(backupWidth - captionCtrl.Width);
                    }
                }
                break;
            }

            SetState();
            ShowControls();
            //start collapsing/expanding and set the new state
            if (state == ExtendedPanelState.Collapsed)
            {
                state = ExtendedPanelState.Expanding;
            }
            else
            {
                if (state == ExtendedPanelState.Expanded)
                {
                    state = ExtendedPanelState.Collapsing;
                }
            }
            collapseAnimation.Start();
        }