View element that applies padding to the drawing of a border and background.
Наследование: ViewComposite
Пример #1
0
        /// <summary>
        /// Construct the view appropriate for this builder.
        /// </summary>
        /// <param name="navigator">Reference to navigator instance.</param>
        /// <param name="manager">Reference to current manager.</param>
        /// <param name="redirector">Palette redirector.</param>
        public override void Construct(KryptonNavigator navigator, 
									   ViewManager manager,
									   PaletteRedirect redirector)
        {
            // Let base class perform common operations
            base.Construct(navigator, manager, redirector);

            // Get the current root element
            _oldRoot = ViewManager.Root;

            // Create a canvas for the border and background using current enabled state
            _drawCanvas = new ViewDrawCanvas(Navigator.StateNormal.HeaderGroup.Back,
                                             Navigator.StateNormal.HeaderGroup.Border,
                                             VisualOrientation.Top);

            // Put the exising root into the canvas
            _drawCanvas.Add(_oldRoot);

            // Set the correct palettes based on enabled state and selected page
            UpdateStatePalettes();

            // Canvas becomes the new root
            ViewManager.Root = _drawCanvas;

            // Need to monitor changes in the enabled state
            Navigator.EnabledChanged += new EventHandler(OnEnabledChanged);
        }
Пример #2
0
        private void Construct(KryptonContextMenuCollection items,
                               bool keyboardActivated)
        {
            // Ask the top level collection to generate the child view elements
            items.GenerateView(_provider, this, _viewColumns, true, true);

            // Create the control panel canvas
            ViewDrawCanvas mainBackground = new ViewDrawCanvas(_provider.ProviderStateCommon.ControlInner.Back, _provider.ProviderStateCommon.ControlInner.Border, VisualOrientation.Top);

            mainBackground.Add(_viewColumns);

            ViewLayoutDocker layoutDocker = new ViewLayoutDocker();
            Padding          outerPadding = _provider.ProviderRedirector.GetMetricPadding(PaletteState.Normal, PaletteMetricPadding.ContextMenuItemOuter);

            layoutDocker.Add(new ViewLayoutSeparator(outerPadding.Top), ViewDockStyle.Top);
            layoutDocker.Add(new ViewLayoutSeparator(outerPadding.Bottom), ViewDockStyle.Bottom);
            layoutDocker.Add(new ViewLayoutSeparator(outerPadding.Left), ViewDockStyle.Left);
            layoutDocker.Add(new ViewLayoutSeparator(outerPadding.Right), ViewDockStyle.Right);
            layoutDocker.Add(mainBackground, ViewDockStyle.Fill);

            // Create the docking element that gives us a border and background
            _drawDocker = new ViewDrawDocker(_provider.ProviderStateCommon.ControlOuter.Back, _provider.ProviderStateCommon.ControlOuter.Border, null);
            _drawDocker.Add(layoutDocker, ViewDockStyle.Fill);
            _drawDocker.KeyController = new ContextMenuController((ViewContextMenuManager)ViewManager);
            ViewManager.Root          = _drawDocker;

            // With keyboard activate we select the first valid item
            if (keyboardActivated)
            {
                ((ViewContextMenuManager)ViewManager).KeyDown();
            }
        }
Пример #3
0
        /// <summary>
        /// Create the view hierarchy for this view mode.
        /// </summary>
        protected override void CreateCheckItemView()
        {
            // Create a canvas for containing the selected page and put old root inside it
            _drawGroup = new ViewDrawCanvas(Navigator.StateNormal.HeaderGroup.Back,
                                            Navigator.StateNormal.HeaderGroup.Border,
                                            VisualOrientation.Top);

            _drawGroup.Add(_oldRoot);

            // Create the view element that lays out the check/tab buttons
            ViewLayoutBarForTabs layoutBar = new ViewLayoutBarForTabs(Navigator.Bar.ItemSizing,
                                                                      Navigator.Bar.ItemAlignment,
                                                                      Navigator.Bar.BarMultiline,
                                                                      Navigator.Bar.ItemMinimumSize,
                                                                      Navigator.Bar.ItemMaximumSize,
                                                                      Navigator.Bar.BarMinimumHeight,
                                                                      Navigator.Bar.TabBorderStyle,
                                                                      true);
            _layoutBar = layoutBar;

            // Create the scroll spacer that restricts display
            _layoutBarViewport = new ViewLayoutViewport(Navigator.StateCommon.Bar,
                                                        PaletteMetricPadding.BarPaddingTabs,
                                                        PaletteMetricInt.CheckButtonGap,
                                                        Navigator.Bar.BarOrientation,
                                                        Navigator.Bar.ItemAlignment,
                                                        Navigator.Bar.BarAnimation);
            _layoutBarViewport.Add(_layoutBar);

            // Create the button bar area docker
            _layoutBarDocker = new ViewLayoutDocker();
            _layoutBarDocker.Add(_layoutBarViewport, ViewDockStyle.Fill);

            // Add a separators for insetting items
            _layoutBarSeparatorFirst = new ViewLayoutSeparator(0);
            _layoutBarSeparatorLast = new ViewLayoutSeparator(0);
            _layoutBarDocker.Add(_layoutBarSeparatorFirst, ViewDockStyle.Left);
            _layoutBarDocker.Add(_layoutBarSeparatorLast, ViewDockStyle.Right);

            // Create the layout that insets the contents to allow for rounding of the group border
            _layoutOverlap = new ViewLayoutInsetOverlap(_drawGroup);
            _layoutOverlap.Add(_layoutBarDocker);

            // Create the docker used to layout contents of main panel and fill with group
            _layoutPanelDocker = new ViewLayoutDockerOverlap(_drawGroup, _layoutOverlap, layoutBar);
            _layoutPanelDocker.Add(_layoutOverlap, ViewDockStyle.Top);
            _layoutPanelDocker.Add(_drawGroup, ViewDockStyle.Fill);

            // Create the top level panel and put a layout docker inside it
            _drawPanel = new ViewDrawPanel(Navigator.StateNormal.Back);
            _drawPanel.Add(_layoutPanelDocker);
            _newRoot = _drawPanel;

            // Set the correct tab style
            UpdateTabStyle();

            // Must call the base class to perform common actions
            base.CreateCheckItemView();
        }
        /// <summary>
        /// Initialize a new instance of the ViewLayoutInsetOverlap class.
        /// </summary>
        public ViewLayoutInsetOverlap(ViewDrawCanvas drawCanvas)
        {
            Debug.Assert(drawCanvas != null);

            // Remember source of the rounding values
            _drawCanvas = drawCanvas;

            // Default other state
            _orientation = VisualOrientation.Top;
        }
Пример #5
0
        /// <summary>
        /// Initialize a new instance of the VisualPopupPage class.
        /// </summary>
        /// <param name="navigator">Reference to owning navigator control.</param>
        /// <param name="page">Reference to page for display.</param>
        /// <param name="renderer">Drawing renderer.</param>
        public VisualPopupPage(KryptonNavigator navigator,
                               KryptonPage page,
                               IRenderer renderer)
            : base(renderer, true)
        {
            Debug.Assert(navigator != null);
            Debug.Assert(page != null);

            // Remember references needed later
            _navigator = navigator;
            _page = page;

            // Always create the layout that positions the actual page
            ViewLayoutPopupPage layoutPage = new ViewLayoutPopupPage(navigator, page);

            // Create the internal panel used for containing content
            ViewDrawCanvas drawGroup = new ViewDrawCanvas(navigator.StateNormal.HeaderGroup.Back,
                                                          navigator.StateNormal.HeaderGroup.Border,
                                                          VisualOrientation.Top);

            // Add the layout inside the draw group
            drawGroup.Add(layoutPage);

            // Do we need to add a border area around the page group
            if (_navigator.PopupPages.Border > 0)
            {
                // Grab the actual border values
                int border = _navigator.PopupPages.Border;

                // Put the page group inside a layout that has separators
                // to pad out the sizing to the border size we need
                ViewLayoutDocker layoutDocker = new ViewLayoutDocker();
                layoutDocker.Add(drawGroup, ViewDockStyle.Fill);
                layoutDocker.Add(new ViewLayoutSeparator(border), ViewDockStyle.Top);
                layoutDocker.Add(new ViewLayoutSeparator(border), ViewDockStyle.Bottom);
                layoutDocker.Add(new ViewLayoutSeparator(border), ViewDockStyle.Left);
                layoutDocker.Add(new ViewLayoutSeparator(border), ViewDockStyle.Right);

                // Create a new top level group that contains the layout
                drawGroup = new ViewDrawCanvas(navigator.StateNormal.Back,
                                               navigator.StateNormal.HeaderGroup.Border,
                                               VisualOrientation.Top);

                drawGroup.Add(layoutDocker);
            }

            ViewManager = new ViewManager(this, drawGroup);

            // Borrow the child panel that contains all the pages from
            // the navigator and add it inside as a child of ourself
            navigator.BorrowChildPanel();
            Controls.Add(navigator.ChildPanel);
        }
        /// <summary>
        /// Initialize a new instance of the ViewLayoutDockerOverlap class.
        /// </summary>
        /// <param name="drawCanvas">Canvas used to recover border width/rounding for overlapping.</param>
        /// <param name="layoutOverlap">Overlapping element.</param>
        /// <param name="layoutTabs">Tab item container element.</param>
        public ViewLayoutDockerOverlap(ViewDrawCanvas drawCanvas,
                                       ViewLayoutInsetOverlap layoutOverlap,
                                       ViewLayoutBarForTabs layoutTabs)
        {
            Debug.Assert(drawCanvas != null);
            Debug.Assert(layoutOverlap != null);
            Debug.Assert(layoutTabs != null);

            // Remember provided references
            _drawCanvas = drawCanvas;
            _layoutOverlap = layoutOverlap;
            _layoutTabs = layoutTabs;
        }
Пример #7
0
        private void UpdateChildBorders(ViewBase child,
                                        ViewLayoutContext context,
                                        ref PaletteDrawBorders leftEdges,
                                        ref PaletteDrawBorders rightEdges,
                                        ref PaletteDrawBorders topEdges,
                                        ref PaletteDrawBorders bottomEdges,
                                        ref PaletteDrawBorders fillEdges)
        {
            // Do we need to calculate if the child should remove any borders?
            if (RemoveChildBorders)
            {
                // Check if the view is a canvas
                ViewDrawCanvas childCanvas = child as ViewDrawCanvas;

                // Docking edge determines calculation
                switch (CalculateDock(GetDock(child), context.Control))
                {
                case ViewDockStyle.Fill:
                    if (childCanvas != null)
                    {
                        childCanvas.MaxBorderEdges = CommonHelper.ReverseOrientateDrawBorders(fillEdges, childCanvas.Orientation);
                    }
                    else
                    {
                        if (child is ViewLayoutDocker layoutDocker)
                        {
                            foreach (ViewBase layoutChild in layoutDocker)
                            {
                                childCanvas = layoutChild as ViewDrawCanvas;
                                if (childCanvas != null)
                                {
                                    childCanvas.MaxBorderEdges = CommonHelper.ReverseOrientateDrawBorders(fillEdges, childCanvas.Orientation);
                                }
                            }
                        }
                    }
                    break;

                case ViewDockStyle.Top:
                    if (childCanvas != null)
                    {
                        childCanvas.MaxBorderEdges = CommonHelper.ReverseOrientateDrawBorders(topEdges, childCanvas.Orientation);
                    }

                    // Remove top edges from subsequent children
                    leftEdges  &= PaletteDrawBorders.BottomLeftRight;
                    rightEdges &= PaletteDrawBorders.BottomLeftRight;
                    topEdges   &= PaletteDrawBorders.BottomLeftRight;
                    fillEdges  &= PaletteDrawBorders.BottomLeftRight;
                    break;

                case ViewDockStyle.Bottom:
                    if (childCanvas != null)
                    {
                        childCanvas.MaxBorderEdges = CommonHelper.ReverseOrientateDrawBorders(bottomEdges, childCanvas.Orientation);
                    }

                    // Remove bottom edges from subsequent children
                    leftEdges   &= PaletteDrawBorders.TopLeftRight;
                    rightEdges  &= PaletteDrawBorders.TopLeftRight;
                    bottomEdges &= PaletteDrawBorders.TopLeftRight;
                    fillEdges   &= PaletteDrawBorders.TopLeftRight;
                    break;

                case ViewDockStyle.Left:
                    if (childCanvas != null)
                    {
                        childCanvas.MaxBorderEdges = CommonHelper.ReverseOrientateDrawBorders(leftEdges, childCanvas.Orientation);
                    }

                    // Remove left edges from subsequent children
                    topEdges    &= PaletteDrawBorders.TopBottomRight;
                    bottomEdges &= PaletteDrawBorders.TopBottomRight;
                    leftEdges   &= PaletteDrawBorders.TopBottomRight;
                    fillEdges   &= PaletteDrawBorders.TopBottomRight;
                    break;

                case ViewDockStyle.Right:
                    if (childCanvas != null)
                    {
                        childCanvas.MaxBorderEdges = CommonHelper.ReverseOrientateDrawBorders(rightEdges, childCanvas.Orientation);
                    }

                    // Remove right edges from subsequent children
                    topEdges    &= PaletteDrawBorders.TopBottomLeft;
                    bottomEdges &= PaletteDrawBorders.TopBottomLeft;
                    rightEdges  &= PaletteDrawBorders.TopBottomLeft;
                    fillEdges   &= PaletteDrawBorders.TopBottomLeft;
                    break;
                }
            }
        }
        /// <summary>
        /// Create the view hierarchy for this view mode.
        /// </summary>
        protected override void CreateCheckItemView()
        {
            // Create the view element that lays out the check buttons
            _layoutBar = new ViewLayoutBar(Navigator.StateCommon.Bar,
                                           PaletteMetricInt.CheckButtonGap,
                                           Navigator.Bar.ItemSizing,
                                           Navigator.Bar.ItemAlignment,
                                           Navigator.Bar.BarMultiline,
                                           Navigator.Bar.ItemMinimumSize,
                                           Navigator.Bar.ItemMaximumSize,
                                           Navigator.Bar.BarMinimumHeight,
                                           false);

            // Create the scroll spacer that restricts display
            _layoutBarViewport = new ViewLayoutViewport(Navigator.StateCommon.Bar,
                                                        PaletteMetricPadding.BarPaddingInside,
                                                        PaletteMetricInt.CheckButtonGap,
                                                        Navigator.Bar.BarOrientation,
                                                        Navigator.Bar.ItemAlignment,
                                                        Navigator.Bar.BarAnimation);
            _layoutBarViewport.Add(_layoutBar);

            // Create the button bar area docker
            _layoutBarDocker = new ViewLayoutDocker();
            _layoutBarDocker.Add(_layoutBarViewport, ViewDockStyle.Fill);

            // Add a separators for insetting items
            _layoutBarSeparatorFirst = new ViewLayoutSeparator(0);
            _layoutBarSeparatorLast = new ViewLayoutSeparator(0);
            _layoutBarDocker.Add(_layoutBarSeparatorFirst, ViewDockStyle.Left);
            _layoutBarDocker.Add(_layoutBarSeparatorLast, ViewDockStyle.Right);

            // Create the docker used to layout contents of main panel and fill with group
            _layoutPanelDocker = new ViewLayoutDocker();
            _layoutPanelDocker.Add(_oldRoot, ViewDockStyle.Fill);
            _layoutPanelDocker.Add(_layoutBarDocker, ViewDockStyle.Top);

            // Create a canvas for containing the selected page and put old root inside it
            _drawGroup = new ViewDrawCanvas(Navigator.StateNormal.HeaderGroup.Back, Navigator.StateNormal.HeaderGroup.Border, VisualOrientation.Top);
            _drawGroup.Add(_layoutPanelDocker);
            _newRoot = _drawGroup;

            // Must call the base class to perform common actions
            base.CreateCheckItemView();
        }
Пример #9
0
        private void Construct(KryptonContextMenuCollection items,
                               bool keyboardActivated)
        {
            // Ask the top level collection to generate the child view elements
            items.GenerateView(_provider, this, _viewColumns, true, true);

            // Create the control panel canvas
            ViewDrawCanvas mainBackground = new ViewDrawCanvas(_provider.ProviderStateCommon.ControlInner.Back, _provider.ProviderStateCommon.ControlInner.Border, VisualOrientation.Top);
            mainBackground.Add(_viewColumns);

            ViewLayoutDocker layoutDocker = new ViewLayoutDocker();
            Padding outerPadding = _provider.ProviderRedirector.GetMetricPadding(PaletteState.Normal, PaletteMetricPadding.ContextMenuItemOuter);
            layoutDocker.Add(new ViewLayoutSeparator(outerPadding.Top), ViewDockStyle.Top);
            layoutDocker.Add(new ViewLayoutSeparator(outerPadding.Bottom), ViewDockStyle.Bottom);
            layoutDocker.Add(new ViewLayoutSeparator(outerPadding.Left), ViewDockStyle.Left);
            layoutDocker.Add(new ViewLayoutSeparator(outerPadding.Right), ViewDockStyle.Right);
            layoutDocker.Add(mainBackground, ViewDockStyle.Fill);

            // Create the docking element that gives us a border and background
            _drawDocker = new ViewDrawDocker(_provider.ProviderStateCommon.ControlOuter.Back, _provider.ProviderStateCommon.ControlOuter.Border, null);
            _drawDocker.Add(layoutDocker, ViewDockStyle.Fill);
            _drawDocker.KeyController = new ContextMenuController((ViewContextMenuManager)ViewManager);
            ViewManager.Root = _drawDocker;

            // With keyboard activate we select the first valid item
            if (keyboardActivated)
                ((ViewContextMenuManager)ViewManager).KeyDown();
        }
Пример #10
0
 private ViewDrawCanvas CreateInsideCanvas()
 {
     ViewDrawCanvas mainBackground = new ViewDrawCanvas(_provider.ProviderStateCommon.ControlInner.Back, _provider.ProviderStateCommon.ControlInner.Border, VisualOrientation.Top);
     mainBackground.Add(_viewColumns);
     mainBackground.KeyController = new ContextMenuController((ViewContextMenuManager)ViewManager);
     return mainBackground;
 }
 private void SetHeaderPosition(ViewDrawCanvas canvas,
                                ViewDrawContent content,
                                VisualOrientation position)
 {
     switch (position)
     {
         case VisualOrientation.Top:
             _topGroup.SetDock(canvas, ViewDockStyle.Top);
             canvas.Orientation = VisualOrientation.Top;
             content.Orientation = VisualOrientation.Top;
             break;
         case VisualOrientation.Bottom:
             _topGroup.SetDock(canvas, ViewDockStyle.Bottom);
             canvas.Orientation = VisualOrientation.Top;
             content.Orientation = VisualOrientation.Top;
             break;
         case VisualOrientation.Left:
             _topGroup.SetDock(canvas, ViewDockStyle.Left);
             canvas.Orientation = VisualOrientation.Left;
             content.Orientation = VisualOrientation.Left;
             break;
         case VisualOrientation.Right:
             _topGroup.SetDock(canvas, ViewDockStyle.Right);
             canvas.Orientation = VisualOrientation.Right;
             content.Orientation = VisualOrientation.Right;
             break;
     }
 }
        /// <summary>
        /// Create the view hierarchy for this view mode.
        /// </summary>
        protected override void CreateCheckItemView()
        {
            // Create the two headers and header content
            _viewContentPrimary = new ViewDrawContent(Navigator.StateNormal.HeaderGroup.HeaderPrimary.Content,
                                                      Navigator.Header.HeaderValuesPrimary,
                                                      VisualOrientation.Top);

            _viewHeadingPrimary = new ViewDrawDocker(Navigator.StateNormal.HeaderGroup.HeaderPrimary.Back,
                                                     Navigator.StateNormal.HeaderGroup.HeaderPrimary.Border,
                                                     Navigator.StateNormal.HeaderGroup.HeaderPrimary,
                                                     PaletteMetricBool.None,
                                                     PaletteMetricPadding.HeaderGroupPaddingPrimary,
                                                     VisualOrientation.Top);

            _viewContentSecondary = new ViewDrawContent(Navigator.StateNormal.HeaderGroup.HeaderSecondary.Content,
                                                        Navigator.Header.HeaderValuesSecondary,
                                                        VisualOrientation.Top);

            _viewHeadingSecondary = new ViewDrawDocker(Navigator.StateNormal.HeaderGroup.HeaderSecondary.Back,
                                                       Navigator.StateNormal.HeaderGroup.HeaderSecondary.Border,
                                                       Navigator.StateNormal.HeaderGroup.HeaderSecondary,
                                                       PaletteMetricBool.None,
                                                       PaletteMetricPadding.HeaderGroupPaddingSecondary,
                                                       VisualOrientation.Top);

            // Place the the content as fillers in the headers
            _viewHeadingPrimary.Add(_viewContentPrimary, ViewDockStyle.Fill);
            _viewHeadingSecondary.Add(_viewContentSecondary, ViewDockStyle.Fill);

            // Create a canvas for containing the selected page and put old root inside it
            _drawGroup = new ViewDrawCanvas(Navigator.StateNormal.HeaderGroup.Back,
                                            Navigator.StateNormal.HeaderGroup.Border,
                                            VisualOrientation.Top);

            _drawGroup.ApplyIncludeBorderEdge = true;
            _drawGroup.Add(_oldRoot);

            // Create the view element that lays out the check/tab buttons
            ViewLayoutBarForTabs layoutBar = new ViewLayoutBarForTabs(Navigator.Bar.ItemSizing,
                                                                      Navigator.Bar.ItemAlignment,
                                                                      Navigator.Bar.BarMultiline,
                                                                      Navigator.Bar.ItemMinimumSize,
                                                                      Navigator.Bar.ItemMaximumSize,
                                                                      Navigator.Bar.BarMinimumHeight,
                                                                      Navigator.Bar.TabBorderStyle,
                                                                      true);
            _layoutBar = layoutBar;

            // Create the scroll spacer that restricts display
            _layoutBarViewport = new ViewLayoutViewport(Navigator.StateCommon.Bar,
                                                        PaletteMetricPadding.BarPaddingTabs,
                                                        PaletteMetricInt.CheckButtonGap,
                                                        Navigator.Bar.BarOrientation,
                                                        Navigator.Bar.ItemAlignment,
                                                        Navigator.Bar.BarAnimation);
            _layoutBarViewport.Add(_layoutBar);

            // Create the button bar area docker
            _layoutBarDocker = new ViewLayoutDocker();
            _layoutBarDocker.Add(_layoutBarViewport, ViewDockStyle.Fill);

            // Add a separators for insetting items
            _layoutBarSeparatorFirst = new ViewLayoutSeparator(0);
            _layoutBarSeparatorLast = new ViewLayoutSeparator(0);
            _layoutBarDocker.Add(_layoutBarSeparatorFirst, ViewDockStyle.Left);
            _layoutBarDocker.Add(_layoutBarSeparatorLast, ViewDockStyle.Right);

            // Create the layout that insets the contents to allow for rounding of the group border
            _layoutOverlap = new ViewLayoutInsetOverlap(_drawGroup);
            _layoutOverlap.Add(_layoutBarDocker);

            // Create the docker used to layout contents of main panel and fill with group
            _layoutPanelDocker = new ViewLayoutDockerOverlap(_drawGroup, _layoutOverlap, layoutBar);
            _layoutPanelDocker.Add(_layoutOverlap, ViewDockStyle.Top);
            _layoutPanelDocker.Add(_drawGroup, ViewDockStyle.Fill);

            // Place the headers and page holding area into the group
            _topGroup = new ViewLayoutDocker();
            _topGroup.Add(_viewHeadingSecondary, ViewDockStyle.Bottom);
            _topGroup.Add(_viewHeadingPrimary, ViewDockStyle.Top);
            _topGroup.Add(_layoutPanelDocker, ViewDockStyle.Fill);

            // Prevent adjacent headers from having two borders
            _topGroup.RemoveChildBorders = true;

            // Create the top level panel and put a layout docker inside it
            _drawPanel = new ViewDrawPanel(Navigator.StateNormal.Back);
            _drawPanel.Add(_topGroup);
            _newRoot = _drawPanel;

            // Set initial visible state of headers
            _viewHeadingPrimary.Visible = Navigator.Header.HeaderVisiblePrimary;
            _viewHeadingSecondary.Visible = Navigator.Header.HeaderVisibleSecondary;

            // Set the correct tab style
            UpdateTabStyle();

            // Must call the base class to perform common actions
            base.CreateCheckItemView();
        }