/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { Debug.Assert(context != null); // Ask the renderer for the required size of the drop down button return context.Renderer.RenderGlyph.GetDropDownButtonPreferredSize(context, _palette, State, Orientation); }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // Validate incoming reference if (context == null) throw new ArgumentNullException("context"); // We take on all the available display area ClientRectangle = context.DisplayRectangle; // Layout children from top to bottom with equal height and the total width int yOffset = 0; int childHeight = (ClientHeight / Count) + 1; foreach (ViewBase child in this) { // If this is the last child in collection... if (child == this[Count - 1]) { //...then give it all the remainder space childHeight = ClientHeight - yOffset; } // Position the child context.DisplayRectangle = new Rectangle(ClientLocation.X, yOffset, ClientWidth, childHeight); child.Layout(context); // Move down to next position yOffset += (childHeight - 1); } // Put back the original display value now we have finished context.DisplayRectangle = ClientRectangle; }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { Debug.Assert(context != null); // Accumulate the stacked size Size preferredSize = Size.Empty; foreach (ViewBase child in this) { if (child.Visible) { // Get the preferred size of the child Size childSize = child.GetPreferredSize(context); // Depending on orientation, add up child sizes if (Horizontal) { preferredSize.Height = Math.Max(preferredSize.Height, childSize.Height); preferredSize.Width += childSize.Width; } else { preferredSize.Height += childSize.Height; preferredSize.Width = Math.Max(preferredSize.Width, childSize.Width); } } } return preferredSize; }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // We take on all the available display area ClientRectangle = context.DisplayRectangle; // Are we allowed to layout child controls? if (!context.ViewManager.DoNotLayoutControls) { // Are we allowed to actually layout the pages? if (_navigator.InternalCanLayout) { // Do not position the child panel if it is borrowed if (!_navigator.IsChildPanelBorrowed) { // Position the child panel for showing page information _navigator.ChildPanel.SetBounds(HIDDEN_OFFSET, HIDDEN_OFFSET, ClientWidth, ClientHeight); } } } }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { Debug.Assert(context != null); // We are a null leaf, so have no size return Size.Empty; }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // We take on all the available display area ClientRectangle = context.DisplayRectangle; // Are we allowed to layout child controls? if (!context.ViewManager.DoNotLayoutControls) { // Are we allowed to actually layout the pages? if (_navigator.InternalCanLayout) { // Update position of page if not already in correct position if ((_page.Location != Point.Empty) || (_page.Width != ClientWidth) || (_page.Height != ClientHeight)) { _page.SetBounds(0, 0, ClientWidth, ClientHeight); } // Update position of child panel if not already in correct position if ((_navigator.ChildPanel.Location != ClientLocation) || (_navigator.ChildPanel.Width != ClientWidth) || (_navigator.ChildPanel.Height != ClientHeight)) { // Position the child panel for showing page _navigator.ChildPanel.SetBounds(ClientLocation.X, ClientLocation.Y, ClientWidth, ClientHeight); } } } }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // We take on all the available display area ClientRectangle = context.DisplayRectangle; }
public override Size GetPreferredSize(ViewLayoutContext context) { Size preferredSize = Size.Empty; // We need an owning form to perform calculations if (_ownerForm != null) { // We only have size if custom chrome is being used with composition if (_ownerForm.ApplyCustomChrome && _ownerForm.ApplyComposition) { try { // Create structure that will be populated by call to WM_GETTITLEBARINFOEX PI.TITLEBARINFOEX tbi = new PI.TITLEBARINFOEX(); tbi.cbSize = (uint)Marshal.SizeOf(tbi); // Ask the window for the title bar information PI.SendMessage(_ownerForm.Handle, PI.WM_GETTITLEBARINFOEX, IntPtr.Zero, ref tbi); // Find width of the button rectangle int closeWidth = tbi.rcCloseButton.right - tbi.rcCloseButton.left; int helpWidth = tbi.rcHelpButton.right - tbi.rcHelpButton.left; int minWidth = tbi.rcMinButton.right - tbi.rcMinButton.left; int maxWidth = tbi.rcMaxButton.right - tbi.rcMaxButton.left; int clientWidth = _ownerForm.ClientSize.Width; int clientScreenRight = _ownerForm.RectangleToScreen(_ownerForm.ClientRectangle).Right; int leftMost = clientScreenRight; // Find the left most button edge (start with right side of client area) if ((closeWidth > 0) && (closeWidth < clientWidth)) leftMost = Math.Min(leftMost, tbi.rcCloseButton.left); if ((helpWidth > 0) && (helpWidth < clientWidth)) leftMost = Math.Min(leftMost, tbi.rcHelpButton.left); if ((minWidth > 0) && (minWidth < clientWidth)) leftMost = Math.Min(leftMost, tbi.rcMinButton.left); if ((maxWidth > 0) && (maxWidth < clientWidth)) leftMost = Math.Min(leftMost, tbi.rcMaxButton.left); // Our width is the distance between the left most button edge and the right // side of the client area (this space the buttons are taking up). Plus a small // extra gap between the first button and the caption elements to its left. _width = (clientScreenRight - leftMost) + SPACING_GAP; preferredSize.Width = _width; } catch(ObjectDisposedException) { // Asking for the WM_GETTITLEBARINFOEX can cause exception if the form level // Icon has already been disposed. This happens in rare circumstances. } } } return preferredSize; }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { // Make all stacking items that should be visible are visible ViewBuilder.UnshrinkAppropriatePages(); // Let base class continue with standard layout base.Layout(context); }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // Use all of the provided space // Always use the metric and ignore given space ClientRectangle = context.DisplayRectangle; }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { // Get the preferred size of the contained content Size preferredSize = base.GetPreferredSize(context); // Add on the padding we need around edges return new Size(preferredSize.Width + _preferredPadding.Horizontal, preferredSize.Height + _preferredPadding.Vertical); }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // Validate incoming reference if (context == null) throw new ArgumentNullException("context"); // We take on all the available display area Rectangle original = context.DisplayRectangle; ClientRectangle = original; // Layout each child int offset = 0; int space = (_orientation == Orientation.Vertical ? ClientHeight : ClientWidth); for(int i=0; i<Count; i++) { ViewBase child = this[i]; // Find length of this item int length = 0; // If this is the last item then it takes the remaining space if (i == (Count - 1)) length = space; else { // Give this item an equal portion of the remainder length = space / (Count - i); } // Ask child for it's own preferred size Size childPreferred = child.GetPreferredSize(context); // Size child to our relevant dimension if (_orientation == Orientation.Vertical) context.DisplayRectangle = new Rectangle(ClientRectangle.X, ClientRectangle.Y + offset, childPreferred.Width, length); else context.DisplayRectangle = new Rectangle(ClientRectangle.X + offset, ClientRectangle.Y, length, ClientRectangle.Height); // Ask the child to layout child.Layout(context); // Adjust running values offset += length; space -= length; } // Put back the original display value now we have finished context.DisplayRectangle = original; }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // We take on all the available display area ClientRectangle = context.DisplayRectangle; // Ensure all children are layed out in our total space base.Layout(context); }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { Debug.Assert(context != null); // Get the sizing metric int length = _paletteMetric.GetMetricInt(ElementState, _metricInt); // Use the same size for vertical and horizontal return new Size(length, length); }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // Get the sizing metric int length = _paletteMetric.GetMetricInt(ElementState, _metricInt); // Always use the metric and ignore given space ClientRectangle = new Rectangle(context.DisplayRectangle.Location, new Size(length, length)); }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // We take on all the available display area ClientRectangle = context.DisplayRectangle; // Put back the original display value now we have finished context.DisplayRectangle = ClientRectangle; }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // Validate incoming reference if (context == null) throw new ArgumentNullException("context"); // We take on all the available display area ClientRectangle = context.DisplayRectangle; }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { // Get size of the contained items Size preferredSize = base.GetPreferredSize(context); // Add on the border padding preferredSize = CommonHelper.ApplyPadding(Orientation.Horizontal, preferredSize, _borderPadding); preferredSize.Height = Math.Max(preferredSize.Height, QAT_HEIGHT_FULL); return preferredSize; }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { Debug.Assert(context != null); // Start with size needed to draw a week number Size retSize = new Size(_months.SizeDay.Width, _months.SizeDays.Height); // Add the width of the vertical border retSize.Width += _palette.GetBorderWidth(State); return retSize; }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { Debug.Assert(context != null); // Ask base class to find preferred size of all children Size preferredSize = base.GetPreferredSize(context); // Add on the display padding preferredSize.Width += _displayPadding.Horizontal; preferredSize.Height += _displayPadding.Vertical; return preferredSize; }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // We take on all the available display area ClientRectangle = context.DisplayRectangle; // Let base class layout the children base.Layout(context); // Put back the original size before returning context.DisplayRectangle = ClientRectangle; }
/// <summary> /// Initialize a new instance of the CorrectContextControl class. /// </summary> /// <param name="context">Context to update.</param> /// <param name="control">Actual parent control instance.</param> public CorrectContextControl(ViewLayoutContext context, Control control) { Debug.Assert(context != null); // Remmeber incoming context _context = context; // Remember staring setting _startControl = context.Control; // Update with correct control _context.Control = control; }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { Debug.Assert(context != null); // We have no preferred size by default Size preferredSize = Size.Empty; // Apply the border width in appropriate orientation if (Orientation == Orientation.Horizontal) preferredSize.Height = _palette.GetBorderWidth(State); else preferredSize.Width = _palette.GetBorderWidth(State); return preferredSize; }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // Validate incoming reference if (context == null) throw new ArgumentNullException("context"); // We take on all the available display area ClientRectangle = context.DisplayRectangle; // Reduce by the padding Rectangle innerRectangle = ClientRectangle; innerRectangle.X += PreferredPadding.Left; innerRectangle.Y += PreferredPadding.Top; innerRectangle.Width -= PreferredPadding.Horizontal; innerRectangle.Height -= PreferredPadding.Vertical; // Layout each child centered within this space foreach (ViewBase child in this) { // Only layout visible children if (child.Visible) { // Ask child for it's own preferred size Size childPreferred = child.GetPreferredSize(context); // Make sure the child is never bigger than the available space if (childPreferred.Width > ClientRectangle.Width) childPreferred.Width = ClientWidth; if (childPreferred.Height > ClientRectangle.Height) childPreferred.Height = ClientHeight; // Find vertical and horizontal offsets for centering int xOffset = (innerRectangle.Width - childPreferred.Width) / 2; int yOffset = (innerRectangle.Height - childPreferred.Height) / 2; // Create the rectangle that centers the child in our space context.DisplayRectangle = new Rectangle(innerRectangle.X + xOffset, innerRectangle.Y + yOffset, childPreferred.Width, childPreferred.Height); // Finally ask the child to layout child.Layout(context); } } // Put back the original display value now we have finished context.DisplayRectangle = ClientRectangle; }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { switch (_ribbon.RibbonShape) { default: case PaletteRibbonShape.Office2007: _viewSize = _viewSize_2007; _offsetY = _imageOffsetY_2007; break; case PaletteRibbonShape.Office2010: _viewSize = _viewSize_2010; _offsetY = _imageOffsetY_2010; break; } return _viewSize; }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { // Validate incoming reference if (context == null) throw new ArgumentNullException("context"); // We take on all the available display area ClientRectangle = context.DisplayRectangle; // Find the rectangle for the child elements by applying padding context.DisplayRectangle = CommonHelper.ApplyPadding(Orientation.Horizontal, ClientRectangle, _preferredPadding); // Let base perform actual layout process of child elements base.Layout(context); // Put back the original display value now we have finished context.DisplayRectangle = ClientRectangle; }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); Rectangle clientRect = context.DisplayRectangle; ClientRectangle = clientRect; // Remove QAT border for positioning children context.DisplayRectangle = CommonHelper.ApplyPadding(Orientation.Horizontal, ClientRectangle, _borderPadding); // Let children be layed out inside border area base.Layout(context); // Put back the original display value now we have finished context.DisplayRectangle = ClientRectangle; }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { Padding paddingText = Padding.Empty; // Grab the padding used for the text/extra content of a menu item if (_standardStyle) paddingText = _stateCommon.ItemTextStandard.GetContentPadding(PaletteState.Normal); else paddingText = _stateCommon.ItemTextAlternate.GetContentPadding(PaletteState.Normal); // Get padding needed for the left edge of the item highlight Padding paddingHighlight = context.Renderer.RenderStandardBorder.GetBorderDisplayPadding(_stateCommon.ItemHighlight.Border, PaletteState.Normal, VisualOrientation.Top); // Our separator size is the left padding values added together SeparatorSize = new Size(paddingHighlight.Left + paddingText.Left, 0); return base.GetPreferredSize(context); }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); Rectangle clientRect = context.DisplayRectangle; // For the minibar we have to position ourself at bottom of available area clientRect.Y = clientRect.Bottom - 1 - MINI_BUTTON_OFFSET; clientRect.Height = MINI_BUTTON_HEIGHT; // Use modified size to position base class and children context.DisplayRectangle = clientRect; // Let children be layed out inside border area base.Layout(context); // Put back the original display value now we have finished context.DisplayRectangle = ClientRectangle; }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { Size preferredSize = Size.Empty; // Height is the total height of all children, but width is just the widest found foreach (ViewBase child in this) { // Ask child for it's own preferred size Size childPreferred = child.GetPreferredSize(context); // Always add on the height of the child preferredSize.Height += childPreferred.Width; // Find the widest of the children preferredSize.Width = Math.Max(preferredSize.Width, childPreferred.Width); } return preferredSize; }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // Validate incoming reference if (context == null) { throw new ArgumentNullException("context"); } // Cache the right to left setting at layout time _rightToLeft = context.Control.RightToLeft; _rightToLeftLayout = CommonHelper.GetRightToLeftLayout(context.Control); // We take on all the available display area ClientRectangle = context.DisplayRectangle; // Available space for positioning starts with entire client area Rectangle positionRectangle = ClientRectangle; // Do we have a metric source for additional padding? if (_paletteMetrics != null) { // Get the padding to be applied Padding outerPadding = _paletteMetrics.GetMetricPadding(State, _metricPadding); // Reduce space for children by the padding area positionRectangle = ApplyPadding(positionRectangle, outerPadding); } // Do we need to fill any remainder space? if (FillSpace) { // Ensure the extent reflects the maximum size we want, the whole area if (_extent.Width < positionRectangle.Width) { _extent.Width = positionRectangle.Width; } if (_extent.Height < positionRectangle.Height) { _extent.Height = positionRectangle.Height; } } // Find the limits allowed for the offset given current extent and display rect _limit = new Point(Math.Min(positionRectangle.Width - _extent.Width, 0), Math.Min(positionRectangle.Height - _extent.Height, 0)); // Enforce the offset back to the limits if (_offset.X < _limit.X) { _offset.X = _limit.X; } if (_offset.Y < _limit.Y) { _offset.Y = _limit.Y; } // Calculate the offset given the current alignment and counter alignment Point childOffset; int childOffsetX; int childOffsetY; // Find the final child offset if (Horizontal) { childOffsetX = CalculateAlignedOffset(AlignmentRTL, positionRectangle.X, positionRectangle.Width, _offset.X, _extent.Width, _limit.X); childOffsetY = CalculateAlignedOffset(CounterAlignmentRTL, positionRectangle.Y, positionRectangle.Height, _offset.Y, _extent.Height, _limit.Y); } else { childOffsetX = CalculateAlignedOffset(CounterAlignmentRTL, positionRectangle.X, positionRectangle.Width, _offset.X, _extent.Width, _limit.X); childOffsetY = CalculateAlignedOffset(AlignmentRTL, positionRectangle.Y, positionRectangle.Height, _offset.Y, _extent.Height, _limit.Y); } childOffset = new Point(childOffsetX, childOffsetY); // Ask each child to layout in turn foreach (ViewBase child in this) { // Only layout visible children if (child.Visible) { // Give the child the available positioning size context.DisplayRectangle = positionRectangle; // Ask the child how much space they would like Size childSize = child.GetPreferredSize(context); // Do we need to fill any remainder space? if (FillSpace) { // Ensure the child reflect the size we want, the whole area if (childSize.Width < positionRectangle.Width) { childSize.Width = positionRectangle.Width; } if (childSize.Height < positionRectangle.Height) { childSize.Height = positionRectangle.Height; } } // Give the child all the space it requires context.DisplayRectangle = new Rectangle(childOffset, childSize); // Let the child layout using the provided space child.Layout(context); } } // Put back the original display value now we have finished context.DisplayRectangle = ClientRectangle; }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // We take on all the available display area ClientRectangle = context.DisplayRectangle; // Maximum space available for the next child Rectangle childRectangle = ClientRectangle; // Find the last visible child ViewBase lastVisible = null; foreach (ViewBase child in Reverse()) { if (child.Visible) { lastVisible = child; break; } } // Position each entry, with last entry filling remaining of space foreach (ViewBase child in this) { if (child.Visible) { // Provide the total space currently available context.DisplayRectangle = childRectangle; // Get the preferred size of the child Size childSize = child.GetPreferredSize(context); if (Horizontal) { // Ask child to fill the available height childSize.Height = childRectangle.Height; if ((child == lastVisible) && FillLastChild) { // This child takes all remainder width childSize.Width = childRectangle.Width; } else { // Reduce remainder space to exclude this child childRectangle.X += childSize.Width; childRectangle.Width -= childSize.Width; } } else { // Ask child to fill the available width childSize.Width = childRectangle.Width; if ((child == lastVisible) && FillLastChild) { // This child takes all remainder height childSize.Height = childRectangle.Height; } else { // Reduce remainder space to exclude this child childRectangle.Y += childSize.Height; childRectangle.Height -= childSize.Height; } } // Use the update child size as the actual space for layout context.DisplayRectangle = new Rectangle(context.DisplayRectangle.Location, childSize); // Layout child in the provided space child.Layout(context); } } // Put back the original display value now we have finished context.DisplayRectangle = ClientRectangle; }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { Debug.Assert(context != null); return(new Size(Length, Length)); }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { return(_child.GetPreferredSize(context)); }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { UpdateWeekNumberViews(); return(base.GetPreferredSize(context)); }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { Debug.Assert(context != null); return _preferredSize; }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { Debug.Assert(context != null); return(new Size(_months.SizeDays.Width * WEEKDAYS, _months.SizeDays.Height * WEEKS)); }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // We need to update the redirector for drawing each crumb PaletteRedirectBreadCrumb redirect = _kryptonBreadCrumb.GetRedirector() as PaletteRedirectBreadCrumb; // We take on all the available display area ClientRectangle = context.DisplayRectangle; // Create/delete child elements to match the current selected bread crumb path SyncBreadCrumbs(); // Positioning rectangle is our client rectangle reduced by control padding Rectangle layoutRect = new Rectangle(ClientLocation.X + _kryptonBreadCrumb.Padding.Left, ClientLocation.Y + _kryptonBreadCrumb.Padding.Top, ClientWidth - _kryptonBreadCrumb.Padding.Horizontal, ClientHeight - _kryptonBreadCrumb.Padding.Vertical); // Position from left to right all items except the overflow button int offset = layoutRect.X; for (int i = 1; i < Count; i++) { // Do not show the left border on the first crumb redirect.Left = (i == 1); // Find size of the child Size childSize = this[i].GetPreferredSize(context); context.DisplayRectangle = new Rectangle(offset, layoutRect.Y, childSize.Width, layoutRect.Height); // Position the child this[i].Layout(context); this[i].Visible = true; // Move across offset += childSize.Width; } // If we overflowed then we need to use the overflow button if (offset > ClientWidth) { // Overflow button must be visible this[0].Visible = true; // How much space do we need to save? int overflowed = offset - ClientWidth; // Position overflow button and only the last items to fit space offset = layoutRect.X; for (int i = 0; i < Count; i++) { // Decide if the crumb (not the overflow button) can be visible if (i > 0) { this[i].Visible = (overflowed <= 0); } if (this[i].Visible) { // Do not show the left border on the first crumb redirect.Left = (i == 0); // Recover the already calculated size Size childSize = this[i].GetPreferredSize(context); context.DisplayRectangle = new Rectangle(offset, layoutRect.Y, childSize.Width, layoutRect.Height); // Position the child this[i].Layout(context); // Move across offset += childSize.Width; } // Adjust overflow space depending on if we are positioning crumb or overflow if (i != 0) { overflowed -= this[i].ClientWidth; } else { overflowed += this[i].ClientWidth; } } } else { // No overflow then no need for the overflow button this[0].Visible = false; } // Must restore the display rectangle to the same size as when it entered context.DisplayRectangle = ClientRectangle; }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { // Always provide the requested fixed size return(_fixedSize); }
/// <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); } }
/// <summary> /// Ask the base docker element to perform a layout. /// </summary> protected void DockerLayout(ViewLayoutContext context) { // Get base class to perform actual layout base.Layout(context); }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { Debug.Assert(context != null); // Remember the original display rectangle provided Rectangle originalRect = context.DisplayRectangle; Rectangle displayRect = context.DisplayRectangle; // Border size that is not applied to preferred size Size borderSize = Size.Empty; // Accumulate the size that must be provided by docking edges and then filler Size preferredSize = Size.Empty; // Track the minimize size needed to satisfy the docking edges only Size minimumSize = Size.Empty; if (!IgnoreAllBorderAndPadding) { // Apply space the border takes up if (IgnoreBorderSpace) { borderSize = CommonHelper.ApplyPadding(Orientation, borderSize, context.Renderer.RenderStandardBorder.GetBorderDisplayPadding(_paletteBorder, State, Orientation)); } else { Padding padding = context.Renderer.RenderStandardBorder.GetBorderDisplayPadding(_paletteBorder, State, Orientation); preferredSize = CommonHelper.ApplyPadding(Orientation, preferredSize, padding); displayRect = CommonHelper.ApplyPadding(Orientation, displayRect, padding); } // Do we have a metric source for additional padding? if ((_paletteMetric != null) && (_metricPadding != PaletteMetricPadding.None)) { // Apply padding needed outside the border of the canvas Padding padding = _paletteMetric.GetMetricPadding(State, _metricPadding); preferredSize = CommonHelper.ApplyPadding(Orientation, preferredSize, padding); displayRect = CommonHelper.ApplyPadding(Orientation, displayRect, padding); } } PaletteDrawBorders leftEdges = PaletteDrawBorders.All; PaletteDrawBorders rightEdges = PaletteDrawBorders.All; PaletteDrawBorders topEdges = PaletteDrawBorders.All; PaletteDrawBorders bottomEdges = PaletteDrawBorders.All; PaletteDrawBorders fillEdges = PaletteDrawBorders.All; // Check for edge docking children foreach (ViewBase child in this.Reverse()) { // Only position visible children that are not 'fill' if ((child.Visible || PreferredSizeAll) && (GetDock(child) != ViewDockStyle.Fill)) { // Prevent children from showing adjacent borders that are not needed UpdateChildBorders(child, context, ref leftEdges, ref rightEdges, ref topEdges, ref bottomEdges, ref fillEdges); // Update with latest calculated display rectangle context.DisplayRectangle = displayRect; // Get the preferred size of the child Size childSize = child.GetPreferredSize(context); // Apply size requests from edge docking children switch (OrientateDock(GetDock(child))) { case ViewDockStyle.Top: preferredSize.Height += childSize.Height; displayRect.Y += childSize.Height; displayRect.Height -= childSize.Height; if (minimumSize.Width < childSize.Width) { minimumSize.Width = childSize.Width; } break; case ViewDockStyle.Bottom: preferredSize.Height += childSize.Height; displayRect.Height -= childSize.Height; if (minimumSize.Width < childSize.Width) { minimumSize.Width = childSize.Width; } break; case ViewDockStyle.Left: preferredSize.Width += childSize.Width; displayRect.X += childSize.Width; displayRect.Width -= childSize.Width; if (minimumSize.Height < childSize.Height) { minimumSize.Height = childSize.Height; } break; case ViewDockStyle.Right: preferredSize.Width += childSize.Width; displayRect.Width -= childSize.Width; if (minimumSize.Height < childSize.Height) { minimumSize.Height = childSize.Height; } break; } } } // Check for the fill child last foreach (ViewBase child in this.Reverse()) { // Only interested in a visible 'fill' child if ((child.Visible || PreferredSizeAll) && (GetDock(child) == ViewDockStyle.Fill)) { // Prevent children from showing adjacent borders that are not needed UpdateChildBorders(child, context, ref leftEdges, ref rightEdges, ref topEdges, ref bottomEdges, ref fillEdges); // Update with latest calculated display rectangle context.DisplayRectangle = displayRect; // Get the preferred size of the child Size childSize = child.GetPreferredSize(context); // Add on the preferred size of the filler preferredSize.Width += childSize.Width; preferredSize.Height += childSize.Height; } } // Put back the original display rect context.DisplayRectangle = originalRect; // Enforce the minimum values from the other docking edge sizes preferredSize.Width = Math.Max(preferredSize.Width, minimumSize.Width); preferredSize.Height = Math.Max(preferredSize.Height, minimumSize.Height); // Enforce the border sizing as the minimum preferredSize.Width = Math.Max(preferredSize.Width, borderSize.Width); preferredSize.Height = Math.Max(preferredSize.Height, borderSize.Height); return(preferredSize); }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // We take on all the available display area ClientRectangle = context.DisplayRectangle; if (!IgnoreAllBorderAndPadding) { // Do we have a metric source for additional padding? if ((_paletteMetric != null) && (_metricPadding != PaletteMetricPadding.None)) { // Get the padding to be applied before the canvas drawing Padding outerPadding = _paletteMetric.GetMetricPadding(State, _metricPadding); ClientRectangle = CommonHelper.ApplyPadding(Orientation, ClientRectangle, outerPadding); } } // Space available for children begins with our space Rectangle fillerRect = ClientRectangle; context.DisplayRectangle = fillerRect; // By default all the children need to draw all their borders PaletteDrawBorders leftEdges = PaletteDrawBorders.All; PaletteDrawBorders rightEdges = PaletteDrawBorders.All; PaletteDrawBorders topEdges = PaletteDrawBorders.All; PaletteDrawBorders bottomEdges = PaletteDrawBorders.All; PaletteDrawBorders fillEdges = PaletteDrawBorders.All; // Position all except the filler foreach (ViewBase child in this.Reverse()) { // Only position visible children if (child.Visible && (GetDock(child) != ViewDockStyle.Fill)) { // Prevent children from showing adjacent borders that are not needed UpdateChildBorders(child, context, ref leftEdges, ref rightEdges, ref topEdges, ref bottomEdges, ref fillEdges); // Get the preferred size of the child Size childSize = child.GetPreferredSize(context); // Position the child inside the available space switch (CalculateDock(OrientateDock(GetDock(child)), context.Control)) { case ViewDockStyle.Top: context.DisplayRectangle = new Rectangle(fillerRect.X, fillerRect.Y, fillerRect.Width, childSize.Height); fillerRect.Height -= childSize.Height; fillerRect.Y += childSize.Height; break; case ViewDockStyle.Bottom: context.DisplayRectangle = new Rectangle(fillerRect.X, fillerRect.Bottom - childSize.Height, fillerRect.Width, childSize.Height); fillerRect.Height -= childSize.Height; break; case ViewDockStyle.Left: context.DisplayRectangle = new Rectangle(fillerRect.X, fillerRect.Y, childSize.Width, fillerRect.Height); fillerRect.Width -= childSize.Width; fillerRect.X += childSize.Width; break; case ViewDockStyle.Right: context.DisplayRectangle = new Rectangle(fillerRect.Right - childSize.Width, fillerRect.Y, childSize.Width, fillerRect.Height); fillerRect.Width -= childSize.Width; break; } // Layout child in the provided space child.Layout(context); } } int borderWidth = 0; Rectangle borderRect = ClientRectangle; Padding padding = Padding.Empty; if (!IgnoreAllBorderAndPadding) { // Find the actual width of the border as we need to compare this to the calculating border // padding to work out how far from corners we can ignore the calculated border padding and // instead use the actual width only. borderWidth = _paletteBorder.GetBorderWidth(State); // Update padding to reflect the orientation we are using padding = context.Renderer.RenderStandardBorder.GetBorderDisplayPadding(_paletteBorder, State, Orientation); padding = CommonHelper.OrientatePadding(Orientation, padding); // If docking content extends beyond the border rounding effects then we can adjust // the padding back so that it lines against the edge and not the rounding edge padding = AdjustPaddingForDockers(padding, fillerRect, borderWidth); } // Apply the padding to the border rectangle borderRect = new Rectangle(borderRect.X + padding.Left, borderRect.Y + padding.Top, borderRect.Width - padding.Horizontal, borderRect.Height - padding.Vertical); // We need to ensure the filler is within the border rectangle if (fillerRect.X < borderRect.X) { fillerRect.Width -= borderRect.X - fillerRect.X; fillerRect.X = borderRect.X; } if (fillerRect.Y < borderRect.Y) { fillerRect.Height -= borderRect.Y - fillerRect.Y; fillerRect.Y = borderRect.Y; } if (fillerRect.Right > borderRect.Right) { fillerRect.Width -= fillerRect.Right - borderRect.Right; } if (fillerRect.Bottom > borderRect.Bottom) { fillerRect.Height -= fillerRect.Bottom - borderRect.Bottom; } // Position any filler last foreach (ViewBase child in this.Reverse()) { // Only position visible children if (child.Visible && (GetDock(child) == ViewDockStyle.Fill)) { // Prevent children from showing adjacent borders that are not needed UpdateChildBorders(child, context, ref leftEdges, ref rightEdges, ref topEdges, ref bottomEdges, ref fillEdges); // Give the filler the remaining space context.DisplayRectangle = fillerRect; // Layout child in the provided space child.Layout(context); } } // Put back the original display value now we have finished context.DisplayRectangle = ClientRectangle; // The fill rectangle is the space left over after all children are positioned _fillRectangle = fillerRect; }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // Get the current date values DateTime minDate = _calendar.MinDate.Date; DateTime maxDate = _calendar.MaxDate.Date; DateTime selectStart = _calendar.SelectionStart.Date; DateTime selectEnd = _calendar.SelectionEnd.Date; // We take on all the available display area ClientRectangle = context.DisplayRectangle; int layoutXCell = ClientLocation.X; int layoutXDay = ClientLocation.X + (_months.SizeDays.Width - _months.SizeDay.Width) / 2; Rectangle layoutRectCell = new Rectangle(layoutXCell, ClientLocation.Y, _months.SizeDays.Width, _months.SizeDays.Height); Rectangle layoutRectDay = new Rectangle(layoutXDay, ClientLocation.Y, _months.SizeDay.Width, _months.SizeDays.Height); // Layout each week as a row DateTime todayDate = _calendar.TodayDate; DateTime displayDate = _firstDay; for (int j = 0; j < WEEKS; j++) { // Layout each day as a column for (int i = 0; i < WEEKDAYS; i++) { // Memento index int index = j * WEEKDAYS + i; // Define text to be drawn _drawText = displayDate.Day.ToString(); if (_dayMementos[index] != null) { _dayMementos[index].Dispose(); _dayMementos[index] = null; } bool skip = false; PaletteState paletteState = PaletteState.Normal; IPaletteTriple paletteTriple = _calendar.OverrideNormal; // If the display date is not within the allowed range, do not draw it if ((displayDate < minDate) || (displayDate > maxDate)) { skip = true; } else { _calendar.SetFocusOverride(false); _calendar.SetBoldedOverride(BoldedDate(displayDate)); _calendar.SetTodayOverride(_months.ShowTodayCircle && (displayDate == todayDate)); // If the day is not actually in the month we are drawing if (displayDate.Month != _month.Month) { // If we need to show this day but disabled if (((j < 3) && _firstMonth) || ((j > 3) && _lastMonth)) { paletteState = PaletteState.Disabled; paletteTriple = _calendar.OverrideDisabled; } else { skip = true; } } else { // Is this day part of the selection? if ((displayDate >= selectStart) && (displayDate <= selectEnd)) { _calendar.SetFocusOverride(((_months.FocusDay != null) && (_months.FocusDay.Value == displayDate))); if (_months.TrackingDay.HasValue && (_months.TrackingDay.Value == displayDate)) { paletteState = PaletteState.CheckedTracking; paletteTriple = _calendar.OverrideCheckedTracking; } else { paletteState = PaletteState.CheckedNormal; paletteTriple = _calendar.OverrideCheckedNormal; } } else { if (_months.TrackingDay.HasValue && (_months.TrackingDay.Value == displayDate)) { paletteState = PaletteState.Tracking; paletteTriple = _calendar.OverrideTracking; } } } } if (!skip) { _dayMementos[index] = context.Renderer.RenderStandardContent.LayoutContent(context, layoutRectDay, paletteTriple.PaletteContent, this, VisualOrientation.Top, paletteState, false); // Track the maximum date displayed for this month (exclude disabled days that are shown for // information but cannot actually be selected themselves as part of a multi selection action) if (paletteState != PaletteState.Disabled) { _lastDay = displayDate; } } _dayRects[index] = layoutRectCell; // Move across to next column layoutRectCell.X += _months.SizeDays.Width; layoutRectDay.X += _months.SizeDays.Width; // Move to next day displayDate += TIMESPAN_1DAY; } // Move to start of the next row layoutRectCell.X = layoutXCell; layoutRectCell.Y += _months.SizeDays.Height; layoutRectDay.X = layoutXDay; layoutRectDay.Y += _months.SizeDays.Height; } // Put back the original display value now we have finished context.DisplayRectangle = ClientRectangle; }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // We take on all the available display area ClientRectangle = context.DisplayRectangle; // Space available for children begins with our space Rectangle fillerRect = ClientRectangle; // Apply the padding against the rect switch (Orientation) { case VisualOrientation.Top: fillerRect.X += Padding.Left; fillerRect.Y += Padding.Top; fillerRect.Width -= Padding.Horizontal; fillerRect.Height -= Padding.Vertical; break; case VisualOrientation.Bottom: fillerRect.X += Padding.Right; fillerRect.Y += Padding.Bottom; fillerRect.Width -= Padding.Horizontal; fillerRect.Height -= Padding.Vertical; break; case VisualOrientation.Left: fillerRect.X += Padding.Top; fillerRect.Y += Padding.Right; fillerRect.Width -= Padding.Vertical; fillerRect.Height -= Padding.Horizontal; break; case VisualOrientation.Right: fillerRect.X += Padding.Bottom; fillerRect.Y += Padding.Left; fillerRect.Width -= Padding.Vertical; fillerRect.Height -= Padding.Horizontal; break; } // By default all the children need to draw all their borders PaletteDrawBorders leftEdges = PaletteDrawBorders.All; PaletteDrawBorders rightEdges = PaletteDrawBorders.All; PaletteDrawBorders topEdges = PaletteDrawBorders.All; PaletteDrawBorders bottomEdges = PaletteDrawBorders.All; PaletteDrawBorders fillEdges = PaletteDrawBorders.All; // Position all except the filler foreach (ViewBase child in Reverse()) { // Only position visible children that are not 'fill' if (child.Visible && (GetDock(child) != ViewDockStyle.Fill)) { // Prevent children from showing adjacent borders that are not needed UpdateChildBorders(child, context, ref leftEdges, ref rightEdges, ref topEdges, ref bottomEdges, ref fillEdges); // Provide the available space left over context.DisplayRectangle = fillerRect; // Get the preferred size of the child Size childSize = child.GetPreferredSize(context); // Position the child inside the available space switch (CalculateDock(OrientateDock(GetDock(child)), context.Control)) { case ViewDockStyle.Top: context.DisplayRectangle = new Rectangle(fillerRect.X, fillerRect.Y, fillerRect.Width, childSize.Height); fillerRect.Height -= childSize.Height; fillerRect.Y += childSize.Height; break; case ViewDockStyle.Bottom: context.DisplayRectangle = new Rectangle(fillerRect.X, fillerRect.Bottom - childSize.Height, fillerRect.Width, childSize.Height); fillerRect.Height -= childSize.Height; break; case ViewDockStyle.Left: context.DisplayRectangle = new Rectangle(fillerRect.X, fillerRect.Y, childSize.Width, fillerRect.Height); fillerRect.Width -= childSize.Width; fillerRect.X += childSize.Width; break; case ViewDockStyle.Right: context.DisplayRectangle = new Rectangle(fillerRect.Right - childSize.Width, fillerRect.Y, childSize.Width, fillerRect.Height); fillerRect.Width -= childSize.Width; break; } // Layout child in the provided space child.Layout(context); } } // Allow the filler rectangle to be modified before being used fillerRect = UpdateFillerRect(fillerRect, context.Control); // Position any filler last foreach (ViewBase child in Reverse()) { // Only position visible children if (child.Visible && (GetDock(child) == ViewDockStyle.Fill)) { // Prevent children from showing adjacent borders that are not needed UpdateChildBorders(child, context, ref leftEdges, ref rightEdges, ref topEdges, ref bottomEdges, ref fillEdges); // Give the filler the remaining space context.DisplayRectangle = fillerRect; // Layout child in the provided space child.Layout(context); } } // Put back the original display value now we have finished context.DisplayRectangle = ClientRectangle; // Remember the filler size FillRectangle = fillerRect; }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { Debug.Assert(context != null); // Create new lookup that only contains entries for current child items ViewDockStyleLookup newChildDocking = new ViewDockStyleLookup(); // Remember the original display rectangle provided Rectangle originalRect = context.DisplayRectangle; Rectangle displayRect = context.DisplayRectangle; // Accumulate the size that must be provided by docking edges and then filler Size preferredSize = Size.Empty; // Track the minimize size needed to satisfy the docking edges only Size minimumSize = Size.Empty; PaletteDrawBorders leftEdges = PaletteDrawBorders.All; PaletteDrawBorders rightEdges = PaletteDrawBorders.All; PaletteDrawBorders topEdges = PaletteDrawBorders.All; PaletteDrawBorders bottomEdges = PaletteDrawBorders.All; PaletteDrawBorders fillEdges = PaletteDrawBorders.All; // Check for edge docking children foreach (ViewBase child in Reverse()) { // Add into the valid child lookup ViewDockStyle dockStyle = GetDock(child); newChildDocking.Add(child, dockStyle); // Only position visible children that are not 'fill' if ((child.Visible || PreferredSizeAll) && (GetDock(child) != ViewDockStyle.Fill)) { // Prevent children from showing adjacent borders that are not needed UpdateChildBorders(child, context, ref leftEdges, ref rightEdges, ref topEdges, ref bottomEdges, ref fillEdges); // Update with latest calculated display rectangle context.DisplayRectangle = displayRect; // Get the preferred size of the child Size childSize = child.GetPreferredSize(context); // Apply size requests from edge docking children switch (OrientateDock(dockStyle)) { case ViewDockStyle.Top: preferredSize.Height += childSize.Height; displayRect.Y += childSize.Height; displayRect.Height -= childSize.Height; if (minimumSize.Width < childSize.Width) { minimumSize.Width = childSize.Width; } break; case ViewDockStyle.Bottom: preferredSize.Height += childSize.Height; displayRect.Height -= childSize.Height; if (minimumSize.Width < childSize.Width) { minimumSize.Width = childSize.Width; } break; case ViewDockStyle.Left: preferredSize.Width += childSize.Width; displayRect.X += childSize.Width; displayRect.Width -= childSize.Width; if (minimumSize.Height < childSize.Height) { minimumSize.Height = childSize.Height; } break; case ViewDockStyle.Right: preferredSize.Width += childSize.Width; displayRect.Width -= childSize.Width; if (minimumSize.Height < childSize.Height) { minimumSize.Height = childSize.Height; } break; } } } // Check for the fill child last foreach (ViewBase child in Reverse()) { // Only interested in a visible 'fill' child if ((child.Visible || PreferredSizeAll) && (GetDock(child) == ViewDockStyle.Fill)) { // Prevent children from showing adjacent borders that are not needed UpdateChildBorders(child, context, ref leftEdges, ref rightEdges, ref topEdges, ref bottomEdges, ref fillEdges); // Update with latest calculated display rectangle context.DisplayRectangle = displayRect; // Get the preferred size of the child Size childSize = child.GetPreferredSize(context); preferredSize.Width += childSize.Width; preferredSize.Height += childSize.Height; // There can only be one filler! break; } } // Use updated lookup _childDocking = newChildDocking; // Put back the original display rect context.DisplayRectangle = originalRect; // Enforce the minimum values from the other docking edge sizes preferredSize.Width = Math.Max(preferredSize.Width, minimumSize.Width); preferredSize.Height = Math.Max(preferredSize.Height, minimumSize.Height); // Apply the padding request switch (Orientation) { case VisualOrientation.Top: case VisualOrientation.Bottom: preferredSize.Width += Padding.Horizontal; preferredSize.Height += Padding.Vertical; break; case VisualOrientation.Left: case VisualOrientation.Right: preferredSize.Width += Padding.Vertical; preferredSize.Height += Padding.Horizontal; break; } // Allow the preferred size to be modified before being used return(UpdatePreferredSize(preferredSize)); }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // Validate incoming reference if (context == null) { throw new ArgumentNullException(nameof(context)); } // We take on all the available display area Rectangle original = context.DisplayRectangle; ClientRectangle = original; // Do we have a border padding to apply? if ((_paletteMetric != null) && (MetricPadding != PaletteMetricPadding.None)) { // Get the required padding for the border Padding borderPadding = _paletteMetric.GetMetricPadding(ElementState, MetricPadding); // Applying the padding will depend on the orientation switch (Orientation) { case VisualOrientation.Top: ClientRectangle = new Rectangle(ClientLocation.X + borderPadding.Left, ClientLocation.Y + borderPadding.Top, ClientWidth - borderPadding.Horizontal, ClientHeight - borderPadding.Vertical); break; case VisualOrientation.Bottom: ClientRectangle = new Rectangle(ClientLocation.X + borderPadding.Right, ClientLocation.Y + borderPadding.Bottom, ClientWidth - borderPadding.Horizontal, ClientHeight - borderPadding.Vertical); break; case VisualOrientation.Left: ClientRectangle = new Rectangle(ClientLocation.X + borderPadding.Top, ClientLocation.Y + borderPadding.Right, ClientWidth - borderPadding.Vertical, ClientHeight - borderPadding.Horizontal); break; case VisualOrientation.Right: ClientRectangle = new Rectangle(ClientLocation.X + borderPadding.Bottom, ClientLocation.Y + borderPadding.Left, ClientWidth - borderPadding.Vertical, ClientHeight - borderPadding.Horizontal); break; } } // Do we have a manual padding to apply? if (_rectPadding != null) { // Applying the padding will depend on the orientation switch (Orientation) { case VisualOrientation.Top: ClientRectangle = new Rectangle(ClientLocation.X + _rectPadding.Left, ClientLocation.Y + _rectPadding.Top, ClientWidth - _rectPadding.Horizontal, ClientHeight - _rectPadding.Vertical); break; case VisualOrientation.Bottom: ClientRectangle = new Rectangle(ClientLocation.X + _rectPadding.Right, ClientLocation.Y + _rectPadding.Bottom, ClientWidth - _rectPadding.Horizontal, ClientHeight - _rectPadding.Vertical); break; case VisualOrientation.Left: ClientRectangle = new Rectangle(ClientLocation.X + _rectPadding.Top, ClientLocation.Y + _rectPadding.Right, ClientWidth - _rectPadding.Vertical, ClientHeight - _rectPadding.Horizontal); break; case VisualOrientation.Right: ClientRectangle = new Rectangle(ClientLocation.X + _rectPadding.Bottom, ClientLocation.Y + _rectPadding.Left, ClientWidth - _rectPadding.Vertical, ClientHeight - _rectPadding.Horizontal); break; } } // Layout each child centered within this space foreach (ViewBase child in this) { // Only layout visible children if (child.Visible) { // Ask child for it's own preferred size Size childPreferred = child.GetPreferredSize(context); // Make sure the child is never bigger than the available space if (childPreferred.Width > ClientWidth) { childPreferred.Width = ClientWidth; } if (childPreferred.Height > ClientHeight) { childPreferred.Height = ClientHeight; } // Find vertical and horizontal offsets for centering int xOffset = (ClientWidth - childPreferred.Width) / 2; int yOffset = (ClientHeight - childPreferred.Height) / 2; // Create the rectangle that centers the child in our space context.DisplayRectangle = new Rectangle(ClientRectangle.X + xOffset, ClientRectangle.Y + yOffset, childPreferred.Width, childPreferred.Height); // Finally ask the child to layout child.Layout(context); } } // Put back the original display value now we have finished context.DisplayRectangle = original; }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // Validate incoming reference if (context == null) { throw new ArgumentNullException("context"); } // We take on all the available display area ClientRectangle = context.DisplayRectangle; // How big would the track and position indicator like to be? Size trackSize = _drawTrack.GetPreferredSize(context); Size positionSize = _drawPosition.GetPreferredSize(context); // Grab range and current position from the bar int min = _drawTrackBar.Minimum; int max = _drawTrackBar.Maximum; int range = max - min; int offset = _drawTrackBar.Value - min; Rectangle trackRect = ClientRectangle; Rectangle positionRect = ClientRectangle; if (_drawTrackBar.Orientation == Orientation.Horizontal) { float valueLength = (ClientWidth - positionSize.Width); if (_drawTrackBar.RightToLeft == RightToLeft.Yes) { if (valueLength > 0) { positionRect.X = positionRect.Right - positionSize.Width - (int)Math.Round(valueLength / range * offset, 0, MidpointRounding.AwayFromZero); } } else { if (valueLength > 0) { positionRect.X += (int)Math.Round(valueLength / range * offset, 0, MidpointRounding.AwayFromZero); } } trackRect.Y += (ClientHeight - trackSize.Height) / 2; trackRect.Height = trackSize.Height; positionRect.Y += (ClientHeight - positionSize.Height) / 2; positionRect.Height = positionSize.Height; positionRect.Width = positionSize.Width; } else { float valueLength = (ClientHeight - positionSize.Height); if (valueLength > 0) { positionRect.Y = positionRect.Bottom - positionSize.Height - (int)Math.Round(valueLength / range * offset, 0, MidpointRounding.AwayFromZero); } trackRect.X += (ClientWidth - trackSize.Width) / 2; trackRect.Width = trackSize.Width; positionRect.X += (ClientWidth - positionSize.Width) / 2; positionRect.Width = positionSize.Width; positionRect.Height = positionSize.Height; } context.DisplayRectangle = trackRect; _drawTrack.Layout(context); context.DisplayRectangle = positionRect; _drawPosition.Layout(context); context.DisplayRectangle = ClientRectangle; }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { UpdateWeekNumberViews(); base.Layout(context); }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // Validate incoming reference if (context == null) { throw new ArgumentNullException("context"); } // We take on all the available display area Rectangle original = context.DisplayRectangle; ClientRectangle = original; // Layout each child int offset = 0; int space = (_orientation == Orientation.Vertical ? ClientHeight : ClientWidth); for (int i = 0; i < Count; i++) { ViewBase child = this[i]; // Find length of this item int length = 0; // If this is the last item then it takes the remaining space if (i == (Count - 1)) { length = space; } else { // Give this item an equal portion of the remainder length = space / (Count - i); } // Ask child for it's own preferred size Size childPreferred = child.GetPreferredSize(context); // Size child to our relevant dimension if (_orientation == Orientation.Vertical) { context.DisplayRectangle = new Rectangle(ClientRectangle.X, ClientRectangle.Y + offset, childPreferred.Width, length); } else { context.DisplayRectangle = new Rectangle(ClientRectangle.X + offset, ClientRectangle.Y, length, ClientRectangle.Height); } // Ask the child to layout child.Layout(context); // Adjust running values offset += length; space -= length; } // Put back the original display value now we have finished context.DisplayRectangle = original; }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { _child.Layout(context); }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { Debug.Assert(context != null); return(_drawTrackBar.TrackSize); }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { // We want to be as wide as drop down buttons on standard controls return(new Size(SystemInformation.VerticalScrollBarWidth - 2, 0)); }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> /// <exception cref="ArgumentNullException"></exception> public override Size GetPreferredSize(ViewLayoutContext context) { Debug.Assert(context != null); // Always update to the latest correct check state if (_imageCanvas != null) { if (ResolveChecked) { _imageCanvas.ElementState = PaletteState.CheckedNormal; _imageCanvas.Enabled = ResolveEnabled; } else { _imageCanvas.ElementState = PaletteState.Normal; _imageCanvas.Enabled = true; } } PaletteDouble splitPalette; // Make sure we are using the correct palette for state switch (State) { default: case PaletteState.Normal: SetPalettes(KryptonContextMenuItem.StateNormal.ItemHighlight.Back, KryptonContextMenuItem.StateNormal.ItemHighlight.Border, KryptonContextMenuItem.StateNormal.ItemHighlight); splitPalette = KryptonContextMenuItem.StateNormal.ItemSplit; break; case PaletteState.Disabled: SetPalettes(KryptonContextMenuItem.StateDisabled.ItemHighlight.Back, KryptonContextMenuItem.StateDisabled.ItemHighlight.Border, KryptonContextMenuItem.StateDisabled.ItemHighlight); splitPalette = KryptonContextMenuItem.StateDisabled.ItemSplit; break; case PaletteState.Tracking: SetPalettes(KryptonContextMenuItem.StateHighlight.ItemHighlight.Back, KryptonContextMenuItem.StateHighlight.ItemHighlight.Border, KryptonContextMenuItem.StateHighlight.ItemHighlight); splitPalette = KryptonContextMenuItem.StateHighlight.ItemSplit; break; } // Validate incoming reference if (context == null) { throw new ArgumentNullException(nameof(context)); } // If we have image display if (_fixedImage != null) { Image itemColumnImage = ResolveImage; Color itemImageTransparent = ResolveImageTransparentColor; // If no image found then... if (itemColumnImage == null) { // Ensure we have a fixed size if we are showing an image column if (_imageColumn) { itemColumnImage = _empty16x16; itemImageTransparent = Color.Magenta; } switch (ResolveCheckState) { case CheckState.Checked: itemColumnImage = _provider.ProviderImages.GetContextMenuCheckedImage(); itemImageTransparent = Color.Empty; break; case CheckState.Indeterminate: itemColumnImage = _provider.ProviderImages.GetContextMenuIndeterminateImage(); itemImageTransparent = Color.Empty; break; } } // Decide on the enabled state of the display ItemEnabled = _provider.ProviderEnabled && ResolveEnabled; PaletteContextMenuItemState menuItemState = (ItemEnabled ? KryptonContextMenuItem.StateNormal : KryptonContextMenuItem.StateDisabled); // Update palettes based on Checked state PaletteTripleJustImage justImage = (ResolveChecked ? KryptonContextMenuItem.StateChecked.ItemImage : menuItemState.ItemImage); _imageCanvas?.SetPalettes(justImage.Back, justImage.Border); // Update the Enabled state _imageContent.SetPalette(justImage.Content); _imageContent.Enabled = ItemEnabled; _textContent.Enabled = ItemEnabled; SplitSeparator.Enabled = ItemEnabled; _subMenuContent.Enabled = ItemEnabled; if (_shortcutContent != null) { _shortcutContent.Enabled = ItemEnabled; } // Update the Text/ExtraText _fixedTextExtraText.ShortText = ResolveText; _fixedTextExtraText.LongText = ResolveExtraText; // Update the Image _fixedImage.Image = itemColumnImage; _fixedImage.ImageTransparentColor = itemImageTransparent; } SplitSeparator?.SetPalettes(splitPalette.Back, splitPalette.Border); return(base.GetPreferredSize(context)); }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // Validate incoming reference if (context == null) { throw new ArgumentNullException(nameof(context)); } // We take on all the available display area ClientRectangle = context.DisplayRectangle; // Ensure that child elements have correct palette state CheckPaletteState(context); // Let base class perform usual processing base.Layout(context); // Extend the split border so it is not restricted by the content size Rectangle splitClientRect = _drawSplitBorder.ClientRectangle; if (_drawSplitBorder.Orientation == System.Windows.Forms.Orientation.Vertical) { splitClientRect = new Rectangle(splitClientRect.X, ClientRectangle.Y, splitClientRect.Width, ClientHeight); } else { splitClientRect = new Rectangle(ClientRectangle.X, splitClientRect.Y, ClientWidth, splitClientRect.Height); } _drawSplitBorder.ClientRectangle = splitClientRect; // Calculate the split and non-split area _nonSplitRectangle = ClientRectangle; if (_dropDown && _splitter) { // Splitter rectangle depends on drop down position switch (_dropDownPosition) { case VisualOrientation.Top: _splitRectangle = ClientRectangle; _splitRectangle.Height = _drawSplitBorder.ClientRectangle.Bottom; _nonSplitRectangle.Height = ClientHeight - _splitRectangle.Height; _nonSplitRectangle.Y = _splitRectangle.Bottom; break; case VisualOrientation.Bottom: _splitRectangle = ClientRectangle; _splitRectangle.Height = _splitRectangle.Bottom - _drawSplitBorder.ClientRectangle.Top; _splitRectangle.Y = ClientRectangle.Bottom - _splitRectangle.Height; _nonSplitRectangle.Height = ClientHeight - _splitRectangle.Height; break; case VisualOrientation.Left: _splitRectangle = ClientRectangle; _splitRectangle.Width = _drawSplitBorder.ClientRectangle.Right; _nonSplitRectangle.Width = ClientWidth - _splitRectangle.Width; _nonSplitRectangle.X = _splitRectangle.Right; break; case VisualOrientation.Right: _splitRectangle = ClientRectangle; _splitRectangle.Width = _splitRectangle.Right - _drawSplitBorder.ClientRectangle.Left; _splitRectangle.X = ClientRectangle.Right - _splitRectangle.Width; _nonSplitRectangle.Width = ClientWidth - _splitRectangle.Width; break; } } else { _splitRectangle = CommonHelper.NullRectangle; } // Update canvas with the rectangle to use for drawing the split area and the non-split area _drawCanvas.SplitRectangle = _splitRectangle; _drawCanvas.NonSplitRectangle = _nonSplitRectangle; }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); base.Layout(context); }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); ClientRectangle = context.DisplayRectangle; base.Layout(context); }
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.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; 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; 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; 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; break; } } }
/// <summary> /// This member overrides DataGridViewCell.Paint. /// </summary> /// <param name="graphics">The Graphics used to paint the DataGridViewCell.</param> /// <param name="clipBounds">A Rectangle that represents the area of the DataGridView that needs to be repainted.</param> /// <param name="cellBounds">A Rectangle that contains the bounds of the DataGridViewCell that is being painted.</param> /// <param name="rowIndex">The row index of the cell that is being painted.</param> /// <param name="cellState">A bitwise combination of DataGridViewElementStates values that specifies the state of the cell.</param> /// <param name="value">The data of the DataGridViewCell that is being painted.</param> /// <param name="formattedValue">The formatted data of the DataGridViewCell that is being painted.</param> /// <param name="errorText">An error message that is associated with the cell.</param> /// <param name="cellStyle">A DataGridViewCellStyle that contains formatting and style information about the cell.</param> /// <param name="advancedBorderStyle">A DataGridViewAdvancedBorderStyle that contains border styles for the cell that is being painted.</param> /// <param name="paintParts">A bitwise combination of the DataGridViewPaintParts values that specifies which parts of the cell need to be painted.</param> protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { if (DataGridView is KryptonDataGridView kDgv) { // Should we draw the content foreground? if ((paintParts & DataGridViewPaintParts.ContentForeground) == DataGridViewPaintParts.ContentForeground) { CheckState checkState = CheckState.Unchecked; if (formattedValue is CheckState state) { checkState = state; } else if (formattedValue is bool) { if ((bool)formattedValue) { checkState = CheckState.Checked; } else { checkState = CheckState.Unchecked; } } // Is this cell the currently active cell bool currentCell = (rowIndex == DataGridView.CurrentCellAddress.Y) && (ColumnIndex == DataGridView.CurrentCellAddress.X); // Is this cell the same as the one with the mouse inside it Point mouseEnteredCellAddress = MouseEnteredCellAddressInternal; bool mouseCell = (rowIndex == mouseEnteredCellAddress.Y) && (ColumnIndex == mouseEnteredCellAddress.X); // Snoop tracking and pressed status from the base class implementation bool tracking = mouseCell && MouseInContentBoundsInternal; bool pressed = currentCell && ((ButtonStateInternal & ButtonState.Pushed) == ButtonState.Pushed); using (RenderContext renderContext = new RenderContext(kDgv, graphics, cellBounds, kDgv.Renderer)) { Size checkBoxSize; // Find out the requested size of the check box drawing using (ViewLayoutContext viewContent = new ViewLayoutContext(kDgv, kDgv.Renderer)) { checkBoxSize = renderContext.Renderer.RenderGlyph.GetCheckBoxPreferredSize(viewContent, kDgv.Redirector, kDgv.Enabled, checkState, tracking, pressed); } // Remember the original cell bounds Rectangle startBounds = cellBounds; // Prevent check box overlapping the bottom/right border cellBounds.Width--; cellBounds.Height--; // Adjust the horizontal alignment switch (cellStyle.Alignment) { case DataGridViewContentAlignment.NotSet: case DataGridViewContentAlignment.TopCenter: case DataGridViewContentAlignment.MiddleCenter: case DataGridViewContentAlignment.BottomCenter: cellBounds.X += (cellBounds.Width - checkBoxSize.Width) / 2; break; case DataGridViewContentAlignment.TopRight: case DataGridViewContentAlignment.MiddleRight: case DataGridViewContentAlignment.BottomRight: cellBounds.X = cellBounds.Right - checkBoxSize.Width; break; } // Adjust the vertical alignment switch (cellStyle.Alignment) { case DataGridViewContentAlignment.NotSet: case DataGridViewContentAlignment.MiddleLeft: case DataGridViewContentAlignment.MiddleCenter: case DataGridViewContentAlignment.MiddleRight: cellBounds.Y += (cellBounds.Height - checkBoxSize.Height) / 2; break; case DataGridViewContentAlignment.BottomLeft: case DataGridViewContentAlignment.BottomCenter: case DataGridViewContentAlignment.BottomRight: cellBounds.Y = cellBounds.Bottom - checkBoxSize.Height; break; } // Make the cell the same size as the check box itself cellBounds.Width = checkBoxSize.Width; cellBounds.Height = checkBoxSize.Height; // Remember the current drawing bounds _contentBounds = new Rectangle(cellBounds.X - startBounds.X, cellBounds.Y - startBounds.Y, cellBounds.Width, cellBounds.Height); // Perform actual drawing of the check box renderContext.Renderer.RenderGlyph.DrawCheckBox(renderContext, cellBounds, kDgv.Redirector, kDgv.Enabled, checkState, tracking, pressed); } } } else { base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); } }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // Prevent recreate of the control if (!IsDisposed && !_removing) { // We take on all the available display area ClientRectangle = context.DisplayRectangle; // Are we allowed to layout child controls? if (!context.ViewManager.DoNotLayoutControls) { // Make sure the scrollbar has actually been created CreateScrollBar(context.Control); // If we need to hide/disable the control then do it before position changes if (!Visible) { _scrollBar.Hide(); } if (!Enabled) { _scrollBar.Enabled = false; } // Should the scrollbar is shorter than then the entire client area? if (ShortSize) { if (Vertical) { _scrollBar.SetBounds(ClientLocation.X, ClientLocation.Y, ClientWidth, ClientHeight - SystemInformation.HorizontalScrollBarHeight); } else { _scrollBar.SetBounds(ClientLocation.X, ClientLocation.Y, ClientWidth - SystemInformation.VerticalScrollBarWidth, ClientHeight); } } else { // Position the ScrollBar in the entire requested area _scrollBar.SetBounds(ClientLocation.X, ClientLocation.Y, ClientWidth, ClientHeight); } // If we need to show/enable control then do it after position changes if (Visible) { _scrollBar.Show(); } if (Enabled) { _scrollBar.Enabled = true; } } } }