예제 #1
0
        /// <summary>
        /// Add a view element to a docker.
        /// </summary>
        /// <param name="i">Index of view docker.</param>
        /// <param name="dockStyle">Dock style for placement.</param>
        /// <param name="view">Actual view to add.</param>
        /// <param name="usingSpacers">Are view spacers being used.</param>
        protected override void AddViewToDocker(int i,
                                                ViewDockStyle dockStyle,
                                                ViewBase view,
                                                bool usingSpacers)
        {
            // Get the indexed docker
            ViewLayoutDocker viewDocker = _viewDockers[i];

            // By default add to the end of the children
            var insertIndex = viewDocker.Count;

            // If using spacers, then insert before the first spacer
            if (usingSpacers)
            {
                for (var j = 0; j < insertIndex; j++)
                {
                    if (viewDocker[j] is ViewLayoutMetricSpacer)
                    {
                        insertIndex = j;
                        break;
                    }
                }
            }

            viewDocker.Insert(insertIndex, view);
            viewDocker.SetDock(view, dockStyle);
        }
예제 #2
0
        private void CreateNavCheckButtons()
        {
            // Maintain lookup between page and check button/button edge that represent it
            _pageLookup       = new PageToNavCheckButton();
            _buttonEdgeLookup = new PageToButtonEdge();

            VisualOrientation     checkButtonOrient = ResolveButtonOrientation();
            RelativePositionAlign alignment         = Navigator.Stack.StackAlignment;
            Orientation           stackOrient       = Navigator.Stack.StackOrientation;
            Orientation           buttonEdgeOrient  = (stackOrient == Orientation.Vertical ? Orientation.Horizontal : Orientation.Vertical);
            ViewDockStyle         dockNear          = (stackOrient == Orientation.Vertical ? ViewDockStyle.Top : ViewDockStyle.Left);
            ViewDockStyle         dockFar           = (stackOrient == Orientation.Vertical ? ViewDockStyle.Bottom : ViewDockStyle.Right);

            // Cache the border edge palette to use
            PaletteBorderEdge buttonEdgePalette = (Navigator.Enabled ? Navigator.StateNormal.BorderEdge :
                                                   Navigator.StateDisabled.BorderEdge);

            // Start stacking from the top/left if not explicitly set to be far aligned
            bool dockTopLeft = (alignment != RelativePositionAlign.Far);

            // Create a check button to represent each krypton page
            foreach (KryptonPage page in Navigator.Pages)
            {
                // Create the draw view element for the check button and provide page it represents
                ViewDrawNavCheckButtonStack checkButton = new ViewDrawNavCheckButtonStack(Navigator, page, checkButtonOrient);

                // Provide the drag rectangle when requested for this button
                checkButton.ButtonDragRectangle += OnCheckButtonDragRect;
                checkButton.ButtonDragOffset    += OnCheckButtonDragOffset;

                // Need to know when check button needs repainting
                checkButton.NeedPaint = NeedPaintDelegate;

                // Set the initial state
                checkButton.Visible     = page.LastVisibleSet;
                checkButton.Enabled     = page.Enabled;
                checkButton.Checked     = (Navigator.SelectedPage == page);
                checkButton.Orientation = checkButtonOrient;

                // Create the border edge for use next to the check button
                ViewDrawBorderEdge buttonEdge = new ViewDrawBorderEdge(buttonEdgePalette, buttonEdgeOrient)
                {
                    Visible = page.LastVisibleSet
                };

                // Add to lookup dictionary
                _pageLookup.Add(page, checkButton);
                _buttonEdgeLookup.Add(page, buttonEdge);

                // Add to the child collection with the correct docking style
                if (dockTopLeft)
                {
                    _viewLayout.Insert(1, checkButton);
                    _viewLayout.Insert(1, buttonEdge);
                    _viewLayout.SetDock(buttonEdge, dockNear);
                    _viewLayout.SetDock(checkButton, dockNear);
                }
                else
                {
                    _viewLayout.Add(buttonEdge, dockFar);
                    _viewLayout.Add(checkButton, dockFar);
                }

                // All entries after the selected page are docked at the bottom/right unless
                // we have been set to stack near or far, in which case we do not change.
                if (checkButton.Checked && (alignment == RelativePositionAlign.Center))
                {
                    dockTopLeft = false;
                }
            }

            // Need to monitor changes in the page collection to reflect in layout bar
            Navigator.Pages.Inserted += OnPageInserted;
            Navigator.Pages.Removed  += OnPageRemoved;
            Navigator.Pages.Cleared  += OnPagesCleared;
            _events = true;
        }