Ejemplo n.º 1
0
        private void OnMouseClickEvent(object sender, MouseEventArgs e)
        {
            DirectionStyle oldStyle = directionStyle;

            switch (directionStyle)
            {
            case DirectionStyle.Up:
                directionStyle = DirectionStyle.Down;
                break;

            case DirectionStyle.Down:
                directionStyle = DirectionStyle.Up;
                break;

            case DirectionStyle.Left:
                directionStyle = DirectionStyle.Right;
                break;

            case DirectionStyle.Right:
                directionStyle = DirectionStyle.Left;
                break;
            }
            InitializeImage();
            // Update();
            if (handlerStyleChange != null)
            {
                ChangeStyleEventArgs args = new ChangeStyleEventArgs(oldStyle, directionStyle);
                handlerStyleChange(this, args);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Expands the control. No need to click on the direction control
        /// </summary>
        public void Expand()
        {
            if (this.state != ExtendedPanelState.Collapsed)
            {
                throw new InvalidOperationException("The control has to be in an expanded state for calling collapsing!");
            }

            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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Event raised for exapanding/collapsing the control
        /// </summary>
        /// <param name="sender">instance of the object raising the event</param>
        /// <param name="e">instance of an object containing the event data</param>
        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();
        }
        /// <summary>
        ///   Event raised for exapanding/collapsing the control
        /// </summary>
        /// <param name = "sender">instance of the object raising the event</param>
        /// <param name = "e">instance of an object containing the event data</param>
        private void CollapsingHandler(object sender, ChangeStyleEventArgs e)
        {
            //check to see  if Anchoring needs special treatment
              if (captionAlign == DirectionStyle.Right || captionAlign == DirectionStyle.Down)
              {
            backupAnchor = Anchor;
            Anchor |= AnchorStyles.Left;
            Anchor |= AnchorStyles.Top;
            Anchor &= ~AnchorStyles.Right;
            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 += OnNotifyAnimationEvent;
            collapseAnimation.NotifyAnimationFinished += OnNotifyAnimationFinished;
            if (backupHeight == 0)
            {
              backupHeight = Height;
            }
            if (backupWidth == 0)
            {
              backupWidth = Width;
            }
              }

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

            collapseAnimation.Maximum = Height;
            collapseAnimation.Minimum = captionCtrl.Height;
            if (animation == Animation.Yes)
            {
              collapseAnimation.Step = step;
            }
            else
            {
              collapseAnimation.Step = 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 = Height;
            backupWidth = Width;

            collapseAnimation.Maximum = Height;
            collapseAnimation.Minimum = captionCtrl.Height;
            if (animation == Animation.Yes)
            {
              collapseAnimation.Step = step;
            }
            else
            {
              collapseAnimation.Step = 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 = Height;
            backupWidth = Width;

            collapseAnimation.Maximum = Width;
            collapseAnimation.Minimum = captionCtrl.Width;
            if (animation == Animation.Yes)
            {
              collapseAnimation.Step = step;
            }
            else
            {
              collapseAnimation.Step = 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 = Height;
            backupWidth = Width;

            collapseAnimation.Maximum = Width;
            collapseAnimation.Minimum = captionCtrl.Width;
            if (animation == Animation.Yes)
            {
              collapseAnimation.Step = step;
            }
            else
            {
              collapseAnimation.Step = 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();
        }
        /// <summary>
        ///   Expands the control. No need to click on the direction control
        /// </summary>
        public void Expand()
        {
            if (state != ExtendedPanelState.Collapsed)
              {
            throw new InvalidOperationException("The control has to be in an expanded state for calling collapsing!");
              }

              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;
              }
              captionCtrl.SetDirectionStyle(newStyle);
              ChangeStyleEventArgs args = new ChangeStyleEventArgs(oldStyle, newStyle);
              CollapsingHandler(this, args);
        }