コード例 #1
0
        /// <summary>
        /// Arrange horizontal composition (creating grid with rows)
        /// </summary>
        private void _ArrangeHorizontal(Grid grid, ref double minWidth)
        {
            Debug.Assert(CompositionType.Terminal != _type);

            minWidth = DockablePane.MIN_PANE_SIZE;
            for (int index = 0; index < _children.Count; ++index)
            {
                Composition currentComposition = _children[index];

                // create row for child
                RowDefinition row = new RowDefinition();
                row.Height = new GridLength(currentComposition.SpaceFactor, GridUnitType.Star);
                grid.RowDefinitions.Add(row);

                double    minHeight   = DockablePane.MIN_PANE_SIZE;
                UIElement gridElement = null;
                if (CompositionType.Terminal == currentComposition.Type)
                {
                    gridElement = currentComposition.AttachedPane;
                }
                else
                {   // if child is compostition - create grid for children
                    Grid lineGrid = new Grid();
                    currentComposition._ArrangeVertical(lineGrid, ref minHeight);
                    gridElement = lineGrid;

                    double splittersSpace = SPLITTER_SIZE * (currentComposition.Children.Count - 1);
                    lineGrid.MinWidth = grid.MinWidth = DockablePane.MIN_PANE_SIZE * currentComposition.Children.Count + splittersSpace;
                    minWidth          = Math.Max(minWidth, grid.MinWidth);
                }
                row.MinHeight = minHeight;

                // inited row number in new element
                grid.Children.Add(gridElement);
                Grid.SetRow(gridElement, index);

                // set margin for splitter
                Thickness margin = new Thickness(0);
                if ((index < _children.Count - 1) && (1 < _children.Count))
                {
                    margin = new Thickness(0, 0, 0, SPLITTER_SIZE);
                }
                gridElement.SetValue(FrameworkElement.MarginProperty, margin);

                if (0 < index)
                {   // add splitter
                    GridSplitter splitter = new GridSplitter();
                    splitter.Height = SPLITTER_SIZE;
                    splitter.HorizontalAlignment = HorizontalAlignment.Stretch;
                    splitter.VerticalAlignment   = VerticalAlignment.Bottom;
                    splitter.Style = (Style)Application.Current.FindResource("DockingSplitterStyle");
                    Grid.SetRow(splitter, index - 1);
                    grid.Children.Add(splitter);
                }
            }
        }