Пример #1
0
        /// <summary>
        /// Initialize a new instance of the ViewLayoutViewport class.
        /// </summary>
        /// <param name="paletteMetrics">Palette source for metrics.</param>
        /// <param name="metricPadding">Metric used to get view padding.</param>
        /// <param name="metricOvers">Metric used to get overposition.</param>
        /// <param name="orientation">Orientation for the viewport children.</param>
        /// <param name="alignment">Alignment of the children within the viewport.</param>
        /// <param name="animateChange">Animate changes in the viewport.</param>
        public ViewLayoutViewport(IPaletteMetric paletteMetrics,
                                  PaletteMetricPadding metricPadding,
                                  PaletteMetricInt metricOvers,
                                  VisualOrientation orientation,
                                  RelativePositionAlign alignment,
                                  bool animateChange)
        {
            // Remember the source information
            _paletteMetrics = paletteMetrics;
            _metricPadding = metricPadding;
            _metricOvers = metricOvers;
            _orientation = orientation;
            _alignment = alignment;
            _animateChange = animateChange;

            // Default other state
            _offset = Point.Empty;
            _extent = Size.Empty;
            _rightToLeft = RightToLeft.No;
            _rightToLeftLayout = false;
            _fillSpace = false;
            _counterAlignment = RelativePositionAlign.Far;

            // Create a timer for animation effect
            _animationTimer = new Timer();
            _animationTimer.Interval = _animationInterval;
            _animationTimer.Tick += new EventHandler(OnAnimationTick);
        }
Пример #2
0
 /// <summary>
 /// Initialize a new instance of the ViewLayoutBarForTabs class.
 /// </summary>
 /// <param name="itemSizing">Method used to calculate item size.</param>
 /// <param name="itemAlignment">Method used to align items within lines.</param>
 /// <param name="barMultiline">Multline showing of items.</param>
 /// <param name="itemMinimumSize">Maximum allowed item size.</param>
 /// <param name="itemMaximumSize">Minimum allowed item size.</param>
 /// <param name="barMinimumHeight">Minimum height of the bar.</param>
 /// <param name="tabBorderStyle">Tab border style.</param>
 /// <param name="reorderSelectedLine">Should line with selection be reordered.</param>
 public ViewLayoutBarForTabs(BarItemSizing itemSizing,
                             RelativePositionAlign itemAlignment,
                             BarMultiline barMultiline,
                             Size itemMinimumSize,
                             Size itemMaximumSize,
                             int barMinimumHeight,
                             TabBorderStyle tabBorderStyle,
                             bool reorderSelectedLine)
     : base(itemSizing, itemAlignment, barMultiline, itemMinimumSize,
            itemMaximumSize, barMinimumHeight, tabBorderStyle, reorderSelectedLine)
 {
 }
Пример #3
0
 /// <summary>
 /// Initialize a new instance of the ViewLayoutBar class.
 /// </summary>
 /// <param name="itemSizing">Method used to calculate item size.</param>
 /// <param name="itemAlignment">Method used to align items within lines.</param>
 /// <param name="barMultiline">Multline showing of items.</param>
 /// <param name="itemMinimumSize">Maximum allowed item size.</param>
 /// <param name="itemMaximumSize">Minimum allowed item size.</param>
 /// <param name="barMinimumHeight">Minimum height of the bar.</param>
 /// <param name="tabBorderStyle">Tab border style.</param>
 /// <param name="reorderSelectedLine">Should line with selection be reordered.</param>
 public ViewLayoutBar(BarItemSizing itemSizing,
                      RelativePositionAlign itemAlignment,
                      BarMultiline barMultiline,
                      Size itemMinimumSize,
                      Size itemMaximumSize,
                      int barMinimumHeight,
                      TabBorderStyle tabBorderStyle,
                      bool reorderSelectedLine)
     : this(null, PaletteMetricInt.None, itemSizing, 
            itemAlignment, barMultiline, itemMinimumSize, 
            itemMaximumSize, barMinimumHeight, tabBorderStyle,
            reorderSelectedLine)
 {
 }
Пример #4
0
        private void RecreateView()
        {
            // Remove all the existing layout content except the old root at postiion 0
            ViewBase firstChild = _viewLayout[0];

            _viewLayout.Clear();
            _viewLayout.Add(firstChild);

            // Start stacking from the top/left if not explicitly set to be far aligned
            RelativePositionAlign alignment   = Navigator.Stack.StackAlignment;
            Orientation           stackOrient = Navigator.Stack.StackOrientation;
            ViewDockStyle         dockNear    = (stackOrient == Orientation.Vertical ? ViewDockStyle.Top : ViewDockStyle.Left);
            ViewDockStyle         dockFar     = (stackOrient == Orientation.Vertical ? ViewDockStyle.Bottom : ViewDockStyle.Right);

            bool dockTopLeft = (alignment != RelativePositionAlign.Far);

            foreach (KryptonPage page in Navigator.Pages)
            {
                // Grab the page associated view elements
                ViewDrawNavCheckButtonStack checkButton = (ViewDrawNavCheckButtonStack)_pageLookup[page];
                ViewDrawBorderEdge          buttonEdge  = (ViewDrawBorderEdge)_buttonEdgeLookup[page];

                // 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;
                }
            }
        }
Пример #5
0
 /// <summary>
 /// Initialize a new instance of the ViewLayoutOutlookFull class.
 /// </summary>
 /// <param name="viewBuilder">View builder reference.</param>
 /// <param name="rootControl">Top level visual control.</param>
 /// <param name="viewportFiller">View element to place inside viewport.</param>
 /// <param name="paletteBorderEdge">Palette for use with the border edge.</param>
 /// <param name="paletteMetrics">Palette source for metrics.</param>
 /// <param name="metricPadding">Metric used to get view padding.</param>
 /// <param name="metricOvers">Metric used to get overposition.</param>
 /// <param name="orientation">Orientation for the viewport children.</param>
 /// <param name="alignment">Alignment of the children within the viewport.</param>
 /// <param name="animateChange">Animate changes in the viewport.</param>
 /// <param name="vertical">Is the viewport vertical.</param>
 /// <param name="needPaintDelegate">Delegate for notifying paint requests.</param>
 public ViewLayoutOutlookFull(ViewBuilderOutlookBase viewBuilder,
                              VisualControl rootControl,
                              ViewBase viewportFiller,
                              PaletteBorderEdge paletteBorderEdge,
                              IPaletteMetric paletteMetrics,
                              PaletteMetricPadding metricPadding,
                              PaletteMetricInt metricOvers,
                              VisualOrientation orientation,
                              RelativePositionAlign alignment,
                              bool animateChange,
                              bool vertical,
                              NeedPaintHandler needPaintDelegate)
     : base(rootControl, viewportFiller, paletteBorderEdge, paletteMetrics,
            metricPadding, metricOvers, orientation, alignment, animateChange,
            vertical, needPaintDelegate)
 {
     Debug.Assert(viewBuilder != null);
     _viewBuilder = viewBuilder;
 }
Пример #6
0
 /// <summary>
 /// Initialize a new instance of the ViewLayoutOutlookFull class.
 /// </summary>
 /// <param name="viewBuilder">View builder reference.</param>
 /// <param name="rootControl">Top level visual control.</param>
 /// <param name="viewportFiller">View element to place inside viewport.</param>
 /// <param name="paletteBorderEdge">Palette for use with the border edge.</param>
 /// <param name="paletteMetrics">Palette source for metrics.</param>
 /// <param name="metricPadding">Metric used to get view padding.</param>
 /// <param name="metricOvers">Metric used to get overposition.</param>
 /// <param name="orientation">Orientation for the viewport children.</param>
 /// <param name="alignment">Alignment of the children within the viewport.</param>
 /// <param name="animateChange">Animate changes in the viewport.</param>
 /// <param name="vertical">Is the viewport vertical.</param>
 /// <param name="needPaintDelegate">Delegate for notifying paint requests.</param>
 public ViewLayoutOutlookFull(ViewBuilderOutlookBase viewBuilder,
                              VisualControl rootControl,
                              ViewBase viewportFiller,
                              PaletteBorderEdge paletteBorderEdge,
                              IPaletteMetric paletteMetrics,
                              PaletteMetricPadding metricPadding,
                              PaletteMetricInt metricOvers,
                              VisualOrientation orientation,
                              RelativePositionAlign alignment,
                              bool animateChange,
                              bool vertical,
                              NeedPaintHandler needPaintDelegate)
     : base(rootControl, viewportFiller, paletteBorderEdge, paletteMetrics, 
            metricPadding, metricOvers, orientation, alignment, animateChange, 
            vertical, needPaintDelegate)
 {
     Debug.Assert(viewBuilder != null);
     _viewBuilder = viewBuilder;
 }
        private int FindStartingXPosition(ViewLayoutContext context,
                                          LineDetails lineDetails,
                                          bool reversePosition)
        {
            RelativePositionAlign align = ItemAlignment;

            // Do we need to apply right to left by aligning in opposite direction?
            if (IsOneLine && !BarVertical && (context.Control.RightToLeft == RightToLeft.Yes))
            {
                if (align == RelativePositionAlign.Near)
                {
                    align = RelativePositionAlign.Far;
                }
                else if (align == RelativePositionAlign.Far)
                {
                    align = RelativePositionAlign.Near;
                }
            }

            switch (align)
            {
            case RelativePositionAlign.Near:
                return(reversePosition ? ClientRectangle.Right : ClientLocation.X);

            case RelativePositionAlign.Center:
                return(reversePosition
                        ? ClientRectangle.Right - ((ClientRectangle.Width - lineDetails.InlineLength) / 2)
                        : ClientLocation.X + ((ClientRectangle.Width - lineDetails.InlineLength) / 2));

            case RelativePositionAlign.Far:
                return(reversePosition
                        ? ClientRectangle.Right - (ClientRectangle.Width - lineDetails.InlineLength)
                        : ClientLocation.X + (ClientRectangle.Width - lineDetails.InlineLength));

            default:
                // Should never happen!
                Debug.Assert(false);
                return(ClientLocation.X);
            }
        }
Пример #8
0
        /// <summary>
        /// Initialize a new instance of the NavigatorStack class.
        /// </summary>
        /// <param name="navigator">Reference to owning navigator instance.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public NavigatorStack(KryptonNavigator navigator,
                              NeedPaintHandler needPaint)
        {
            Debug.Assert(navigator != null);

            // Remember back reference
            _navigator = navigator;

            // Store the provided paint notification delegate
            NeedPaint = needPaint;

            // Default values
            _checkButtonStyle = ButtonStyle.NavigatorStack;
            _borderEdgeStyle = PaletteBorderStyle.ControlClient;
            _stackAnimation = true;
            _stackOrientation = Orientation.Vertical;
            _stackAlignment = RelativePositionAlign.Center;
            _itemOrientation = ButtonOrientation.Auto;
            _stackMapImage = MapKryptonPageImage.Small;
            _stackMapText = MapKryptonPageText.TextTitle;
            _stackMapExtraText = MapKryptonPageText.None;
        }
Пример #9
0
        /// <summary>
        /// Initialize a new instance of the NavigatorStack class.
        /// </summary>
        /// <param name="navigator">Reference to owning navigator instance.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public NavigatorStack(KryptonNavigator navigator,
                              NeedPaintHandler needPaint)
        {
            Debug.Assert(navigator != null);

            // Remember back reference
            _navigator = navigator;

            // Store the provided paint notification delegate
            NeedPaint = needPaint;

            // Default values
            _checkButtonStyle  = ButtonStyle.NavigatorStack;
            _borderEdgeStyle   = PaletteBorderStyle.ControlClient;
            _stackAnimation    = true;
            _stackOrientation  = Orientation.Vertical;
            _stackAlignment    = RelativePositionAlign.Center;
            _itemOrientation   = ButtonOrientation.Auto;
            _stackMapImage     = MapKryptonPageImage.Small;
            _stackMapText      = MapKryptonPageText.TextTitle;
            _stackMapExtraText = MapKryptonPageText.None;
        }
Пример #10
0
 /// <summary>
 /// Resets the StackAlignment property to its default value.
 /// </summary>
 public void ResetStackAlignment()
 {
     StackAlignment = RelativePositionAlign.Center;
 }
        /// <summary>
        /// Initialize a new instance of the ViewLayoutScrollViewport class.
        /// </summary>
        /// <param name="rootControl">Top level visual control.</param>
        /// <param name="viewportFiller">View element to place inside viewport.</param>
        /// <param name="paletteBorderEdge">Palette for use with the border edge.</param>
        /// <param name="paletteMetrics">Palette source for metrics.</param>
        /// <param name="metricPadding">Metric used to get view padding.</param>
        /// <param name="metricOvers">Metric used to get overposition.</param>
        /// <param name="orientation">Orientation for the viewport children.</param>
        /// <param name="alignment">Alignment of the children within the viewport.</param>
        /// <param name="animateChange">Animate changes in the viewport.</param>
        /// <param name="vertical">Is the viewport vertical.</param>
        /// <param name="needPaintDelegate">Delegate for notifying paint requests.</param>
        public ViewLayoutScrollViewport(VisualControl rootControl,
                                        ViewBase viewportFiller,
                                        PaletteBorderEdge paletteBorderEdge,
                                        IPaletteMetric paletteMetrics,
                                        PaletteMetricPadding metricPadding,
                                        PaletteMetricInt metricOvers,
                                        VisualOrientation orientation,
                                        RelativePositionAlign alignment,
                                        bool animateChange,
                                        bool vertical,
                                        NeedPaintHandler needPaintDelegate)
        {
            Debug.Assert(rootControl != null);
            Debug.Assert(viewportFiller != null);
            Debug.Assert(needPaintDelegate != null);

            // We need a way to notify changes in layout
            _needPaintDelegate = needPaintDelegate;

            // By default we are showing the contained viewport in vertical scrolling
            _viewportVertical = vertical;

            // Our initial visual orientation should match the parameter
            Orientation = orientation;

            // Create the child viewport
            _viewport = new ViewLayoutViewport(paletteMetrics, metricPadding,
                                               metricOvers, ViewportOrientation(_viewportVertical),
                                               alignment, animateChange)
            {
                // Default to same alignment for both directions
                CounterAlignment = alignment,

                // We always want the viewport to fill any remainder space
                FillSpace = true
            };

            // Put the provided element inside the viewport
            _viewport.Add(viewportFiller);

            // Hook into animation step events
            _viewport.AnimateStep += new EventHandler(OnAnimateStep);

            // To prevent the contents of the viewport from being able to draw outside
            // the viewport (such as having child controls) we use a ViewLayoutControl
            // that uses a child control to restrict the drawing region.
            _viewControl = new ViewLayoutControl(rootControl, _viewport)
            {
                InDesignMode = rootControl.InDesignMode
            };

            // Create the scrollbar and matching border edge
            _scrollbarV  = new ViewDrawScrollBar(true);
            _scrollbarH  = new ViewDrawScrollBar(false);
            _borderEdgeV = new ViewDrawBorderEdge(paletteBorderEdge, System.Windows.Forms.Orientation.Vertical);
            _borderEdgeH = new ViewDrawBorderEdge(paletteBorderEdge, System.Windows.Forms.Orientation.Horizontal);

            // Hook into scroll position changes
            _scrollbarV.ScrollChanged += new EventHandler(OnScrollVChanged);
            _scrollbarH.ScrollChanged += new EventHandler(OnScrollHChanged);

            // Add with appropriate docking style
            Add(_viewControl, ViewDockStyle.Fill);
            Add(_borderEdgeV, ViewDockStyle.Right);
            Add(_borderEdgeH, ViewDockStyle.Bottom);
            Add(_scrollbarV, ViewDockStyle.Right);
            Add(_scrollbarH, ViewDockStyle.Bottom);
        }
Пример #12
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;
        }
Пример #13
0
 /// <summary>
 /// Resets the ItemAlignment property to its default value.
 /// </summary>
 public void ResetItemAlignment()
 {
     ItemAlignment = RelativePositionAlign.Near;
 }
Пример #14
0
        private Point OffsetForChildRect(Rectangle rect)
        {
            // Begin by using the current offset
            Point offset = _offset;

            // Find how far to over position the viewport
            int overs = 0;

            // We might not be provided with metrics, so only use if reference provided
            if (_paletteMetrics != null)
            {
                overs = _paletteMetrics.GetMetricInt(State, _metricOvers) + _scrollOvers;
            }

            // Move the required rectangle more than exactly into view in order to make it
            // easier for users to see extra pages before and after it for easy selection
            if ((Orientation == VisualOrientation.Top) ||
                (Orientation == VisualOrientation.Bottom))
            {
                rect.X     -= overs;
                rect.Width += overs * 2;
            }
            else
            {
                rect.Y      -= overs;
                rect.Height += overs * 2;
            }

            //If all the children are completely visible then nothing to do
            if ((_limit.X != 0) || (_limit.Y != 0))
            {
                // Is part of the required rectangle not currently visible
                if (!ClientRectangle.Contains(rect))
                {
                    // Correct the alignmnet to take right to left into account
                    RelativePositionAlign alignment = AlignmentRTL;

                    // Center alignment needs changing to near or far for scrolling
                    if (alignment == RelativePositionAlign.Center)
                    {
                        alignment = RelativePositionAlign.Near;
                    }

                    // How to scroll into view depends on the alignmnent of items
                    switch (alignment)
                    {
                    case RelativePositionAlign.Near:
                        if (rect.Right > ClientRectangle.Right)
                        {
                            offset.X += (ClientRectangle.Right - rect.Right);
                        }
                        if (rect.Left < ClientRectangle.Left)
                        {
                            offset.X += (ClientRectangle.Left - rect.Left);
                        }
                        if (rect.Bottom > ClientRectangle.Bottom)
                        {
                            offset.Y += (ClientRectangle.Bottom - rect.Bottom);
                        }
                        if (rect.Top < ClientRectangle.Top)
                        {
                            offset.Y += (ClientRectangle.Top - rect.Top);
                        }
                        break;

                    case RelativePositionAlign.Far:
                        if (rect.Right > ClientRectangle.Right)
                        {
                            offset.X -= (ClientRectangle.Right - rect.Right);
                        }
                        if (rect.Left < ClientRectangle.Left)
                        {
                            offset.X -= (ClientRectangle.Left - rect.Left);
                        }
                        if (rect.Bottom > ClientRectangle.Bottom)
                        {
                            offset.Y -= (ClientRectangle.Bottom - rect.Bottom);
                        }
                        if (rect.Top < ClientRectangle.Top)
                        {
                            offset.Y -= (ClientRectangle.Top - rect.Top);
                        }
                        break;
                    }
                }
            }

            // Enforce the offset back to the limits
            offset.X = Math.Min(Math.Max(offset.X, _limit.X), 0);
            offset.Y = Math.Min(Math.Max(offset.Y, _limit.Y), 0);

            return(offset);
        }
        /// <summary>
        /// Initialize a new instance of the ViewLayoutScrollViewport class.
        /// </summary>
        /// <param name="rootControl">Top level visual control.</param>
        /// <param name="viewportFiller">View element to place inside viewport.</param>
        /// <param name="paletteBorderEdge">Palette for use with the border edge.</param>
        /// <param name="paletteMetrics">Palette source for metrics.</param>
        /// <param name="metricPadding">Metric used to get view padding.</param>
        /// <param name="metricOvers">Metric used to get overposition.</param>
        /// <param name="orientation">Orientation for the viewport children.</param>
        /// <param name="alignment">Alignment of the children within the viewport.</param>
        /// <param name="animateChange">Animate changes in the viewport.</param>
        /// <param name="vertical">Is the viewport vertical.</param>
        /// <param name="needPaintDelegate">Delegate for notifying paint requests.</param>
        public ViewLayoutScrollViewport(VisualControl rootControl,
                                        ViewBase viewportFiller,
                                        PaletteBorderEdge paletteBorderEdge,
                                        IPaletteMetric paletteMetrics,
                                        PaletteMetricPadding metricPadding,
                                        PaletteMetricInt metricOvers,
                                        VisualOrientation orientation,
                                        RelativePositionAlign alignment,
                                        bool animateChange,
                                        bool vertical,
                                        NeedPaintHandler needPaintDelegate)
        {
            Debug.Assert(rootControl != null);
            Debug.Assert(viewportFiller != null);
            Debug.Assert(needPaintDelegate != null);

            // We need a way to notify changes in layout
            _needPaintDelegate = needPaintDelegate;

            // By default we are showing the contained viewport in vertical scrolling
            _viewportVertical = vertical;

            // Our initial visual orientation should match the parameter
            Orientation = orientation;

            // Create the child viewport
            _viewport = new ViewLayoutViewport(paletteMetrics, metricPadding,
                                               metricOvers, ViewportOrientation(_viewportVertical),
                                               alignment, animateChange);

            // Default to same alignment for both directions
            _viewport.CounterAlignment = alignment;

            // We always want the viewport to fill any remainder space
            _viewport.FillSpace = true;

            // Put the provided element inside the viewport
            _viewport.Add(viewportFiller);

            // Hook into animation step events
            _viewport.AnimateStep += new EventHandler(OnAnimateStep);

            // To prevent the contents of the viewport from being able to draw outside
            // the viewport (such as having child controls) we use a ViewLayoutControl
            // that uses a child control to restrict the drawing region.
            _viewControl = new ViewLayoutControl(rootControl, _viewport);
            _viewControl.InDesignMode = rootControl.InDesignMode;

            // Create the scrollbar and matching border edge
            _scrollbarV = new ViewDrawScrollBar(true);
            _scrollbarH = new ViewDrawScrollBar(false);
            _borderEdgeV = new ViewDrawBorderEdge(paletteBorderEdge, System.Windows.Forms.Orientation.Vertical);
            _borderEdgeH = new ViewDrawBorderEdge(paletteBorderEdge, System.Windows.Forms.Orientation.Horizontal);

            // Hook into scroll position changes
            _scrollbarV.ScrollChanged += new EventHandler(OnScrollVChanged);
            _scrollbarH.ScrollChanged += new EventHandler(OnScrollHChanged);

            // Add with appropriate docking style
            Add(_viewControl, ViewDockStyle.Fill);
            Add(_borderEdgeV, ViewDockStyle.Right);
            Add(_borderEdgeH, ViewDockStyle.Bottom);
            Add(_scrollbarV, ViewDockStyle.Right);
            Add(_scrollbarH, ViewDockStyle.Bottom);
        }
Пример #16
0
 private int CalculateAlignedOffset(RelativePositionAlign alignment,
                                    int posRect,
                                    int posRectLength,
                                    int offset,
                                    int extent,
                                    int limit)
 {
     switch (alignment)
     {
         case RelativePositionAlign.Near:
             // Position at the near side of the viewport
             return posRect + offset;
         case RelativePositionAlign.Center:
             // If there is no need for any scrolling then center, otherwise place near
             if (limit == 0)
                 return posRect + (posRectLength - extent) / 2;
             else
                 return posRect + offset;
         case RelativePositionAlign.Far:
             // Position against the far side
             return posRect + posRectLength - extent - offset;
         default:
             // Should never happen!
             Debug.Assert(false);
             return 0;
     }
 }
Пример #17
0
        /// <summary>
        /// Initialize a new instance of the ViewLayoutBar class.
        /// </summary>
        /// <param name="paletteMetric">Palette source for metric values.</param>
        /// <param name="metricGap">Metric for gap between each child item.</param>
        /// <param name="itemSizing">Method used to calculate item size.</param>
        /// <param name="itemAlignment">Method used to align items within lines.</param>
        /// <param name="barMultiline">Multline showing of items.</param>
        /// <param name="itemMinimumSize">Maximum allowed item size.</param>
        /// <param name="itemMaximumSize">Minimum allowed item size.</param>
        /// <param name="barMinimumHeight">Minimum height of the bar.</param>
        /// <param name="tabBorderStyle">Tab border style.</param>
        /// <param name="reorderSelectedLine">Should line with selection be reordered.</param>
        public ViewLayoutBar(IPaletteMetric paletteMetric,
                             PaletteMetricInt metricGap,
                             BarItemSizing itemSizing,
                             RelativePositionAlign itemAlignment,
                             BarMultiline barMultiline,
                             Size itemMinimumSize,
                             Size itemMaximumSize,
                             int barMinimumHeight,
                             TabBorderStyle tabBorderStyle,
                             bool reorderSelectedLine)
        {
            // Remember the source information
            _paletteMetric = paletteMetric;
            _metricGap = metricGap;
            _itemSizing = itemSizing;
            _itemAlignment = itemAlignment;
            _itemMinimumSize = itemMinimumSize;
            _itemMaximumSize = itemMaximumSize;
            _barMinimumHeight = barMinimumHeight;
            _tabBorderStyle = tabBorderStyle;
            _barMultiline = barMultiline;
            _reorderSelectedLine = reorderSelectedLine;

            // Default other state
            _orientation = VisualOrientation.Top;
            _itemOrientation = VisualOrientation.Top;
        }
Пример #18
0
 /// <summary>
 /// Initialize a new instance of the ViewLayoutBar class.
 /// </summary>
 /// <param name="paletteMetric">Palette source for metric values.</param>
 /// <param name="metricGap">Metric for gap between each child item.</param>
 /// <param name="itemSizing">Method used to calculate item size.</param>
 /// <param name="itemAlignment">Method used to align items within lines.</param>
 /// <param name="barMultiline">Multline showing of items.</param>
 /// <param name="itemMinimumSize">Maximum allowed item size.</param>
 /// <param name="itemMaximumSize">Minimum allowed item size.</param>
 /// <param name="barMinimumHeight">Minimum height of the bar.</param>
 /// <param name="reorderSelectedLine">Should line with selection be reordered.</param>
 public ViewLayoutBar(IPaletteMetric paletteMetric,
                      PaletteMetricInt metricGap,
                      BarItemSizing itemSizing,
                      RelativePositionAlign itemAlignment,
                      BarMultiline barMultiline,
                      Size itemMinimumSize,
                      Size itemMaximumSize,
                      int barMinimumHeight,
                      bool reorderSelectedLine)
     : this(paletteMetric, metricGap, itemSizing, 
            itemAlignment, barMultiline, itemMinimumSize, 
            itemMaximumSize, barMinimumHeight, 
            TabBorderStyle.RoundedOutsizeMedium,
            reorderSelectedLine)
 {
 }
Пример #19
0
        /// <summary>
        /// Initialize a new instance of the NavigatorBar class.
        /// </summary>
        /// <param name="navigator">Reference to owning navigator instance.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public NavigatorBar(KryptonNavigator navigator,
                            NeedPaintHandler needPaint)
        {
            Debug.Assert(navigator != null);

            // Remember back reference
            _navigator = navigator;

            // Store the provided paint notification delegate
            NeedPaint = needPaint;

            // Default values
            _barAnimation = true;
            _barFirstItemInset = 0;
            _barLastItemInset = 0;
            _barOrientation = VisualOrientation.Top;
            _barMinimumHeight = _defaultBarMinimumHeight;
            _barMultiline = BarMultiline.Singleline;
            _checkButtonStyle = ButtonStyle.Standalone;
            _tabStyle = TabStyle.HighProfile;
            _tabBorderStyle = TabBorderStyle.RoundedOutsizeMedium;
            _itemAlignment = RelativePositionAlign.Near;
            _itemMinimumSize = _defaultItemMinimumSize;
            _itemMaximumSize = _defaultItemMaximumSize;
            _itemOrientation = ButtonOrientation.Auto;
            _itemSizing = BarItemSizing.SameHeight;
            _barMapImage = MapKryptonPageImage.Small;
            _barMapText = MapKryptonPageText.TextTitle;
            _barMapExtraText = MapKryptonPageText.None;
        }