Exemplo n.º 1
0
        /// <summary>
        /// Removes a panel from the host.
        /// </summary>
        /// <param name="panel">The panel to remove.</param>
        public void RemovePanel ( DragDockPanel panel ) {
            Dictionary<int, DragDockPanel> orderedPanels = new Dictionary<int, DragDockPanel> ();
            List<int> indexes = new List<int> ();

            // Loop through children to order them according to their
            // current row and column...
            foreach ( UIElement child in this.Children ) {
                DragDockPanel childPanel = ( DragDockPanel ) child;

                Type t = childPanel.Content.GetType ();


                orderedPanels.Add (
                    ( Grid.GetRow ( childPanel ) * this.columns ) + Grid.GetColumn ( childPanel ),
                    childPanel );

                indexes.Add ( ( Grid.GetRow ( childPanel ) * this.columns ) + Grid.GetColumn ( childPanel ) );
            }

            orderedPanels.Remove ( ( Grid.GetRow ( panel ) * this.columns ) + Grid.GetColumn ( panel ) );
            indexes.Remove ( ( Grid.GetRow ( panel ) * this.columns ) + Grid.GetColumn ( panel ) );
            this.Children.Remove ( panel );

            Dictionary<int, DragDockPanel> reorderedPanels = new Dictionary<int, DragDockPanel> ();

            for ( int i = 0; i < indexes.Count; i++ ) {
                reorderedPanels.Add ( i, orderedPanels[indexes[i]] );
            }

            this.SetRowsAndColumns ( reorderedPanels );

            if ( this.maximizedPanel == panel || reorderedPanels.Count == 1 ) {
                if ( reorderedPanels.Count > 0 )
                    reorderedPanels[0].PanelMaximized = false;
                this.maximizedPanel = null;

                foreach ( UIElement child in this.Children ) {
                    DragDockPanel childPanel = ( DragDockPanel ) child;
                    childPanel.DraggingEnabled = true;
                    childPanel.Visibility = Visibility.Visible;
                }
            }

            this.AnimatePanelSizes ();
            this.AnimatePanelLayout ();

            panel.ClosePanel ();
        }