Beispiel #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics g = e.Graphics;

            g.Clear(BackgroundColor);
            DrawGrid(g);
            DrawTracks(g);
            DrawLabels(g);

            ScrollbarH.Refresh();
            ScrollbarV.Refresh();
        }
Beispiel #2
0
 private void RecalculateScrollbarBounds()
 {
     if (_tracks.Count == 0)
     {
         ScrollbarH.Maximum = 0;
         ScrollbarV.Maximum = 0;
         //ScrollbarH.Max = ScrollbarV.Max = 0;
     }
     else
     {
         ScrollbarV.Maximum = (int)((_tracks.Count * (TrackHigh + TrackSpace)) * _renderingScale.Y);
         ScrollbarH.Maximum = 100;
         // TODO (int)(_tracks.Max(t => t.TrackElements.Any() ? t.TrackElements.Max(te => te.End) : 0) * _renderingScale.X);
     }
     ScrollbarV.Refresh();
     ScrollbarH.Refresh();
 }
Beispiel #3
0
        /// <summary>
        /// Perform a layout of the elements.
        /// </summary>
        /// <param name="context">Layout context.</param>
        public override void Layout(ViewLayoutContext context)
        {
            bool relayout;
            bool canScrollV;
            bool canScrollH;

            // Update the enabled state of the scrollbars and contained control
            ViewControl.Enabled = this.Enabled;
            ScrollbarV.Enabled  = this.Enabled;
            ScrollbarH.Enabled  = this.Enabled;
            BorderEdgeV.Enabled = this.Enabled;
            BorderEdgeH.Enabled = this.Enabled;

            // Cache the starting viewport offsets
            Point originalOffset = Viewport.Offset;

            // Hide both scrollbars, in case having them both hidden
            // always enough content to be seen that none or only one
            // of them is required.
            BorderEdgeV.Visible = ScrollbarV.Visible = false;
            BorderEdgeH.Visible = ScrollbarH.Visible = false;

            // Get the the visible state before processing
            string beforeOverflowState = _viewBuilder.GetOverflowButtonStates();

            // Make all stacking items visible so all that can be shown will be
            ViewBuilder.UnshrinkAppropriatePages();

            // Do not actually change the layout of any child controls
            context.ViewManager.DoNotLayoutControls = true;

            do
            {
                // Do we need to layout again?
                relayout = false;

                // Always reinstate the cached offset, so that if one of the cycles
                // limits the offset to a different value then subsequent cycles
                // will not remember that artificial limitation
                Viewport.Offset = originalOffset;

                // Make sure the viewport has extents calculated
                Viewport.GetPreferredSize(context);

                // Let base class perform a layout calculation
                DockerLayout(context);

                // Find the latest scrolling requirement
                canScrollV = Viewport.CanScrollV;
                canScrollH = Viewport.CanScrollH;

                // If we need to use vertical scrolling...
                if (canScrollV)
                {
                    // Ask the view builder to try and hide stacking items to free up some vertical
                    // space. We provide the amount of space required to remove the vertical scroll
                    // bar from view, so only the minimum number of stacking items are removed.
                    relayout = ViewBuilder.ShrinkVertical(Viewport.ScrollExtent.Height - Viewport.ClientSize.Height);
                }

                // Is there a change in vertical scrolling?
                if (canScrollV != ScrollbarV.Visible)
                {
                    // Update the view elements
                    ScrollbarV.Visible  = canScrollV;
                    BorderEdgeV.Visible = canScrollV;
                    relayout            = true;
                }

                // Is there a change in horizontally scrolling?
                if (canScrollH != ScrollbarH.Visible)
                {
                    // Update the view elements
                    ScrollbarH.Visible  = canScrollH;
                    BorderEdgeH.Visible = canScrollH;
                    relayout            = true;
                }

                // We short size the horizontal scrollbar if both bars are showing
                bool needShortSize = (ScrollbarV.Visible && ScrollbarH.Visible);

                if (ScrollbarH.ShortSize != needShortSize)
                {
                    // Update the scrollbar view and need layout to reflect resizing
                    ScrollbarH.ShortSize = needShortSize;
                    relayout             = true;
                }
            } while (relayout);

            // Now all layouts have occured we can actually move child controls
            context.ViewManager.DoNotLayoutControls = false;

            // Perform actual layout of child controls
            foreach (ViewBase child in this)
            {
                context.DisplayRectangle = child.ClientRectangle;
                child.Layout(context);
            }

            // Do we need to update the vertical scrolling values?
            if (canScrollV)
            {
                ScrollbarV.SetScrollValues(0, Viewport.ScrollExtent.Height - 1,
                                           1, Viewport.ClientSize.Height,
                                           Viewport.ScrollOffset.Y);
            }

            // Do we need to update the horizontal scrolling values?
            if (canScrollH)
            {
                ScrollbarH.SetScrollValues(0, Viewport.ScrollExtent.Width - 1,
                                           1, Viewport.ClientSize.Width,
                                           Viewport.ScrollOffset.X);
            }

            // If visible state of an overflow button has changed, need to relayout
            if (!beforeOverflowState.Equals(_viewBuilder.GetOverflowButtonStates()))
            {
                NeedPaint(true);
            }
        }
        /// <summary>
        /// Perform a layout of the elements.
        /// </summary>
        /// <param name="context">Layout context.</param>
        public override void Layout(ViewLayoutContext context)
        {
            bool relayout;
            bool canScrollV;
            bool canScrollH;

            // Update the enabled state of the scrollbars and contained control
            ViewControl.Enabled = this.Enabled;
            ScrollbarV.Enabled  = this.Enabled;
            ScrollbarH.Enabled  = this.Enabled;
            BorderEdgeV.Enabled = this.Enabled;
            BorderEdgeH.Enabled = this.Enabled;

            // Cache the starting viewport offsets
            Point originalOffset = Viewport.Offset;

            // Hide both scrollbars, in case having them both hidden
            // always enough content to be seen that none or only one
            // of them is required.
            BorderEdgeV.Visible = ScrollbarV.Visible = false;
            BorderEdgeH.Visible = ScrollbarH.Visible = false;

            // Do not actually change the layout of any child controls
            context.ViewManager.DoNotLayoutControls = true;

            do
            {
                // Do we need to layout again?
                relayout = false;

                // Always reinstate the cached offset, so that if one of the cycles
                // around limits the offset to a different value then subsequent cycles
                // will not remember that artificial limitation
                Viewport.Offset = originalOffset;

                // Make sure the viewport has extents calculated
                Viewport.GetPreferredSize(context);

                // Let base class perform a layout calculation
                base.Layout(context);

                // Find the latest scrolling requirement
                canScrollV = Viewport.CanScrollV;
                canScrollH = Viewport.CanScrollH;

                // Is there a change in vertical scrolling?
                if (canScrollV != ScrollbarV.Visible)
                {
                    // Update the view elements
                    ScrollbarV.Visible  = canScrollV;
                    BorderEdgeV.Visible = canScrollV;
                    relayout            = true;
                }

                // Is there a change in horizontally scrolling?
                if (canScrollH != ScrollbarH.Visible)
                {
                    // Update the view elements
                    ScrollbarH.Visible  = canScrollH;
                    BorderEdgeH.Visible = canScrollH;
                    relayout            = true;
                }

                // We short size the horizontal scrollbar if both bars are showing
                bool needShortSize = (ScrollbarV.Visible && ScrollbarH.Visible);

                if (ScrollbarH.ShortSize != needShortSize)
                {
                    // Update the scrollbar view and need layout to reflect resizing
                    ScrollbarH.ShortSize = needShortSize;
                    relayout             = true;
                }
            } while (relayout);

            // Now all layouts have occured we can actually move child controls
            context.ViewManager.DoNotLayoutControls = false;

            // Perform actual layout of child controls
            foreach (ViewBase child in this)
            {
                context.DisplayRectangle = child.ClientRectangle;
                child.Layout(context);
            }

            // Do we need to update the vertical scrolling values?
            if (canScrollV)
            {
                ScrollbarV.SetScrollValues(0, Viewport.ScrollExtent.Height - 1,
                                           1, Viewport.ClientSize.Height,
                                           Viewport.ScrollOffset.Y);
            }

            // Do we need to update the horizontal scrolling values?
            if (canScrollH)
            {
                ScrollbarH.SetScrollValues(0, Viewport.ScrollExtent.Width - 1,
                                           1, Viewport.ClientSize.Width,
                                           Viewport.ScrollOffset.X);
            }
        }