Example #1
0
        /// <summary>
        /// Animates the panel sizes
        /// </summary>
        private void AnimatePanelSizes()
        {
            if (double.IsInfinity(this.ActualWidth) || double.IsNaN(this.ActualWidth) || this.ActualWidth == 0)
            {
                return;
            }

            // If there is not a maxmized panel...
            if (this.maximizedPanel == null)
            {
                // Animate the panel sizes to row / column sizes
                foreach (UIElement child in this.panels)
                {
                    DragDockPanel panel = (DragDockPanel)child;

                    double width  = (this.ActualWidth / (double)this.columns) - panel.Margin.Left - panel.Margin.Right;
                    double height = (this.ActualHeight / (double)this.rows) - panel.Margin.Top - panel.Margin.Bottom;

                    if (width < 0)
                    {
                        width = 0;
                    }

                    if (height < 0)
                    {
                        height = 0;
                    }

                    panel.AnimateSize(
                        width,
                        height);
                }
            }
            else
            {
                // Loop through the children
                foreach (UIElement child in this.panels)
                {
                    DragDockPanel panel =
                        (DragDockPanel)child;

                    // Set the size of the non
                    // maximized children
                    if (panel != this.maximizedPanel)
                    {
                        #region determine new width & height depending on docking axis
                        double newWidth  = this.minimizedColumnWidth - panel.Margin.Left - panel.Margin.Right;
                        double newHeight = (this.ActualHeight / (double)(this.panels.Count - 1)) - panel.Margin.Top - panel.Margin.Bottom;
                        if (this.minimizedPosition.Equals(MinimizedPositions.Bottom) || this.minimizedPosition.Equals(MinimizedPositions.Top))
                        {
                            newWidth  = (this.ActualWidth / (double)(this.panels.Count - 1)) - panel.Margin.Left - panel.Margin.Right;
                            newHeight = this.minimizedRowHeight - panel.Margin.Top - panel.Margin.Bottom;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.None))
                        {
                            newWidth = newHeight = 0;
                        }
                        #endregion

                        if (newHeight < 0)
                        {
                            newHeight = 0;
                        }

                        if (newWidth < 0)
                        {
                            newWidth = 0;
                        }

                        panel.AnimateSize(
                            newWidth,
                            newHeight);
                    }
                    else
                    {
                        #region determine new width & height depending on docking axis
                        double newWidth  = this.ActualWidth - this.minimizedColumnWidth - panel.Margin.Left - panel.Margin.Right;
                        double newHeight = this.ActualHeight - panel.Margin.Top - panel.Margin.Bottom;
                        if (this.minimizedPosition.Equals(MinimizedPositions.Bottom) || this.minimizedPosition.Equals(MinimizedPositions.Top))
                        {
                            newWidth  = this.ActualWidth - panel.Margin.Left - panel.Margin.Right;
                            newHeight = this.ActualHeight - this.minimizedRowHeight - panel.Margin.Top - panel.Margin.Bottom;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.None))
                        {
                            newWidth  = this.ActualWidth - panel.Margin.Right - panel.Margin.Left;
                            newHeight = this.ActualHeight - panel.Margin.Bottom - panel.Margin.Top;
                        }
                        #endregion

                        if (newHeight < 0)
                        {
                            newHeight = 0;
                        }

                        if (newWidth < 0)
                        {
                            newWidth = 0;
                        }

                        panel.AnimateSize(
                            newWidth,
                            newHeight);
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Animates the panel sizes
        /// </summary>
        private void AnimatePanelSizes()
        {
            double determinedWidth = (double)this.columns * (this.minimizedColumnWidth + 30);
            double aw = this.ActualWidth;
            double ah = this.ActualHeight;


            #region determine width of the app
            determinedWidth = 0;
            foreach (UIElement child in this.panels)
            {
                DragDockPanel panel = (DragDockPanel)child;
                panel.UpdateLayout();
                determinedWidth += panel.ActualWidth < this.minimizedColumnWidth ? this.minimizedColumnWidth : panel.ActualWidth;
            }
            aw = determinedWidth;
            #endregion

            if (CancelPanelResizingAnimation)
            {
                aw = determinedWidth;
            }
            else
            {
                aw = this.ActualWidth;
            }

            if (double.IsInfinity(aw) || double.IsNaN(aw) || aw == 0)
            {
                return;
            }

            // If there is not a maxmized panel...
            if (this.maximizedPanel == null)
            {
                // Animate the panel sizes to row / column sizes
                foreach (UIElement child in this.panels)
                {
                    DragDockPanel panel = (DragDockPanel)child;

                    double width  = (aw / (double)this.columns) - panel.Margin.Left - panel.Margin.Right;
                    double height = (ah / (double)this.rows) - panel.Margin.Top - panel.Margin.Bottom;

                    if (width < 0)
                    {
                        width = 0;
                    }

                    if (height < 0)
                    {
                        height = 0;
                    }

                    panel.AnimateSize(
                        width,
                        height);
                }
            }
            else
            {
                // Loop through the children
                foreach (UIElement child in this.panels)
                {
                    DragDockPanel panel =
                        (DragDockPanel)child;

                    // Set the size of the non
                    // maximized children
                    if (panel != this.maximizedPanel)
                    {
                        #region determine new width & height depending on docking axis
                        double newWidth  = this.minimizedColumnWidth - panel.Margin.Left - panel.Margin.Right;
                        double newHeight = (this.ActualHeight / (double)(this.panels.Count - 1)) - panel.Margin.Top - panel.Margin.Bottom;
                        if (this.minimizedPosition.Equals(MinimizedPositions.Bottom) || this.minimizedPosition.Equals(MinimizedPositions.Top))
                        {
                            newWidth  = (this.ActualWidth / (double)(this.panels.Count - 1)) - panel.Margin.Left - panel.Margin.Right;
                            newHeight = this.minimizedRowHeight - panel.Margin.Top - panel.Margin.Bottom;
                        }
                        #endregion

                        if (newHeight < 0)
                        {
                            newHeight = 0;
                        }

                        if (newWidth < 0)
                        {
                            newWidth = 0;
                        }

                        panel.AnimateSize(
                            newWidth,
                            newHeight);
                    }
                    else
                    {
                        #region determine new width & height depending on docking axis
                        double newWidth  = this.ActualWidth - this.minimizedColumnWidth - panel.Margin.Left - panel.Margin.Right;
                        double newHeight = this.ActualHeight - panel.Margin.Top - panel.Margin.Bottom;
                        if (this.minimizedPosition.Equals(MinimizedPositions.Bottom) || this.minimizedPosition.Equals(MinimizedPositions.Top))
                        {
                            newWidth  = this.ActualWidth - panel.Margin.Left - panel.Margin.Right;
                            newHeight = this.ActualHeight - this.minimizedRowHeight - panel.Margin.Top - panel.Margin.Bottom;
                        }
                        #endregion

                        if (newHeight < 0)
                        {
                            newHeight = 0;
                        }

                        if (newWidth < 0)
                        {
                            newWidth = 0;
                        }

                        panel.AnimateSize(
                            newWidth,
                            newHeight);
                    }
                }
            }
        }