Exemplo n.º 1
0
        /// <summary>
        /// This method expands out to the right the dialog
        /// </summary>
        public void ExpandBottom()
        {
            DoubleAnimation temp;
            double          offsetToMove = _expandedHeight - Height;

            if (ElementRoot != null && _stateBottom == State.Normal || _stateBottom == State.Expanded)
            {
                if (_stateBottom == State.Expanded)
                {
                    offsetToMove = -(Height - OriginalHeight);
                }

                for (int i = 0; i < ElementToggleExpandBottom.Children.Count; i++)
                {
                    if (ElementToggleExpandBottom.Children[i] is DoubleAnimation)
                    {
                        temp = (DoubleAnimation)ElementToggleExpandBottom.Children[i];

                        switch (temp.GetValue(Storyboard.TargetNameProperty).ToString())
                        {
                        case ElementButtonsName:
                            temp.From = (double)ElementButtons.GetValue(Canvas.TopProperty);
                            temp.To   = temp.From + offsetToMove;
                            break;

                        case ElementBottomContentName:
                            if (_stateBottom == State.Expanded)
                            {
                                temp.From = 0;
                                temp.To   = offsetToMove;
                            }
                            else
                            {
                                temp.From = -offsetToMove;
                                temp.To   = 0;
                            }
                            break;

                        default:
                            temp.From = Height;
                            temp.To   = Height + offsetToMove;
                            break;
                        }
                        temp.Duration = _expandDuration;
                    }
                }

                _stateBottom = (_stateBottom == State.Normal ? State.Expanding : State.Collapsing);

                if (_stateBottom == State.Expanding)
                {
                    ElementWhole.Width   = _expandedWidth;
                    ElementWhole.Height  = (_expandedHeight > Height ? _expandedHeight : Height);
                    ElementClipping.Rect = new Rect(0, 0, ElementWhole.Width, ElementWhole.Height);
                }

                ElementToggleExpandBottom.Begin();
            }
        }
Exemplo n.º 2
0
        protected override void UpdateVisualState()
        {
            FrameworkElement right;

            base.UpdateVisualState();

            if (ElementRoot != null)
            {
                ElementRight.SetValue(Canvas.LeftProperty, OriginalWidth);
                ElementBottom.SetValue(Canvas.TopProperty, (double)ElementButtons.GetValue(Canvas.TopProperty));

                if (_expandedWidth >= OriginalWidth)
                {
                    ElementRight.Width = _expandedWidth - OriginalWidth;
                }
                else
                {
                    ElementRight.Width = 0;
                }

                ElementRight.Height = Height;

                if (ElementRight.Width < 0d)
                {
                    ElementRight.Width = 0d;
                }

                if (_expandedHeight >= OriginalHeight)
                {
                    ElementBottom.Height = _expandedHeight - OriginalHeight;
                }
                else
                {
                    ElementBottom.Height = 0;
                }

                ElementBottom.Width = Width;

                if (ElementBottom.Height < 0d)
                {
                    ElementBottom.Height = 0d;
                }

                if (ContentRight != null)
                {
                    right = (FrameworkElement)ContentRight;

                    if (_stateRight == State.Normal)
                    {
                        right.SetValue(Canvas.LeftProperty, -ElementRight.Width);
                    }
                    else
                    {
                        right.SetValue(Canvas.LeftProperty, 0d);
                    }

                    right.Width  = ElementRight.Width;
                    right.Height = Height;
                }

                if (ContentBottom != null)
                {
                    right = (FrameworkElement)ContentBottom;

                    if (_stateBottom == State.Normal)
                    {
                        right.SetValue(Canvas.TopProperty, -ElementBottom.Height);
                    }
                    else
                    {
                        right.SetValue(Canvas.TopProperty, 0d);
                    }

                    right.Width  = ElementBottom.Width;
                    right.Height = Height;
                }

                if (_stateRight == State.Expanded)
                {
                    ElementRightClipping.Rect = new Rect(0d, 0d, ElementRight.Width, ElementRight.Height);
                }
                if (_stateBottom == State.Expanded)
                {
                    ElementBottomClipping.Rect = new Rect(0d, 0d, ElementBottom.Width, ElementBottom.Height);
                }
            }
        }