/// <summary> /// Measures the cell. /// </summary> /// <param name="collectionWithSeparator">A collection that can draw separators around the cell.</param> /// <param name="referenceContainer">The cell view in <paramref name="collectionWithSeparator"/> that contains this cell.</param> /// <param name="separatorLength">The length of the separator in <paramref name="collectionWithSeparator"/>.</param> public virtual void Measure(ILayoutCellViewCollection collectionWithSeparator, ILayoutCellView referenceContainer, Measure separatorLength) { CollectionWithSeparator = collectionWithSeparator; ReferenceContainer = referenceContainer; SeparatorLength = separatorLength; Debug.Assert(StateView != null); Debug.Assert(StateView.ControllerView != null); ILayoutMeasureContext MeasureContext = StateView.ControllerView.MeasureContext; Debug.Assert(MeasureContext != null); Size MeasuredSize; if (Frame is ILayoutMeasurableFrame AsMeasurableFrame) { AsMeasurableFrame.Measure(MeasureContext, this, collectionWithSeparator, referenceContainer, separatorLength, out Size Size, out Padding Padding); MeasuredSize = Size; CellPadding = Padding; } else { Debug.Assert(ChildStateView != null); ChildStateView.MeasureCells(collectionWithSeparator, referenceContainer, separatorLength); MeasuredSize = ChildStateView.CellSize; } CellSize = MeasuredSize; ActualCellSize = RegionHelper.InvalidSize; Debug.Assert(RegionHelper.IsValid(CellSize)); }
/// <summary> /// Measures a cell created with this frame. /// </summary> /// <param name="measureContext">The context used to measure the cell.</param> /// <param name="cellView">The cell to measure.</param> /// <param name="collectionWithSeparator">A collection that can draw separators around the cell.</param> /// <param name="referenceContainer">The cell view in <paramref name="collectionWithSeparator"/> that contains this cell.</param> /// <param name="separatorLength">The length of the separator in <paramref name="collectionWithSeparator"/>.</param> /// <param name="size">The cell size upon return, padding included.</param> /// <param name="padding">The cell padding.</param> public virtual void Measure(ILayoutMeasureContext measureContext, ILayoutCellView cellView, ILayoutCellViewCollection collectionWithSeparator, ILayoutCellView referenceContainer, Measure separatorLength, out Size size, out Padding padding) { padding = Padding.Empty; ILayoutCommentCellView CommentCellView = cellView as ILayoutCommentCellView; Debug.Assert(CommentCellView != null); string Text = CommentHelper.Get(CommentCellView.Documentation); CommentDisplayModes DisplayMode = cellView.StateView.ControllerView.CommentDisplayMode; Debug.Assert(DisplayMode == CommentDisplayModes.OnFocus || DisplayMode == CommentDisplayModes.All); bool IsFocused = cellView.StateView.ControllerView.Focus.CellView == cellView; if (IsFocused && Text == null) { Text = string.Empty; } bool IsDisplayed = Text != null && ((DisplayMode == CommentDisplayModes.OnFocus && IsFocused) || DisplayMode == CommentDisplayModes.All); if (IsDisplayed) { size = measureContext.MeasureText(Text, TextStyles.Comment, Controller.Measure.Floating); } else { size = Size.Empty; } Debug.Assert(RegionHelper.IsValid(size)); }
/// <summary> /// Measures a cell created with this frame. /// </summary> /// <param name="measureContext">The context used to measure the cell.</param> /// <param name="cellView">The cell to measure.</param> /// <param name="collectionWithSeparator">A collection that can draw separators around the cell.</param> /// <param name="referenceContainer">The cell view in <paramref name="collectionWithSeparator"/> that contains this cell.</param> /// <param name="separatorLength">The length of the separator in <paramref name="collectionWithSeparator"/>.</param> /// <param name="size">The cell size upon return, padding included.</param> /// <param name="padding">The cell padding.</param> public virtual void Measure(ILayoutMeasureContext measureContext, ILayoutCellView cellView, ILayoutCellViewCollection collectionWithSeparator, ILayoutCellView referenceContainer, Measure separatorLength, out Size size, out Padding padding) { size = measureContext.MeasureSymbolSize(Symbols.InsertSign); measureContext.UpdatePadding(LeftMargin, RightMargin, ref size, out padding); Debug.Assert(RegionHelper.IsValid(size)); }
/// <summary> /// Measures a cell created with this frame. /// </summary> /// <param name="measureContext">The context used to measure the cell.</param> /// <param name="cellView">The cell to measure.</param> /// <param name="collectionWithSeparator">A collection that can draw separators around the cell.</param> /// <param name="referenceContainer">The cell view in <paramref name="collectionWithSeparator"/> that contains this cell.</param> /// <param name="separatorLength">The length of the separator in <paramref name="collectionWithSeparator"/>.</param> /// <param name="size">The cell size upon return, padding included.</param> /// <param name="padding">The cell padding.</param> public virtual void Measure(ILayoutMeasureContext measureContext, ILayoutCellView cellView, ILayoutCellViewCollection collectionWithSeparator, ILayoutCellView referenceContainer, Measure separatorLength, out Size size, out Padding padding) { INode Node = cellView.StateView.State.Node; string Text = BaseNodeHelper.NodeTreeHelper.GetString(Node, PropertyName); size = measureContext.MeasureNumber(Text); measureContext.UpdatePadding(LeftMargin, RightMargin, ref size, out padding); Debug.Assert(RegionHelper.IsValid(size)); }
/// <summary> /// Initializes a new instance of the <see cref="LayoutControllerView"/> class. /// </summary> /// <param name="controller">The controller on which the view is attached.</param> /// <param name="templateSet">The template set used to describe the view.</param> /// <param name="context">The context used to measure, arrange, and draw or print the view.</param> private protected LayoutControllerView(LayoutController controller, ILayoutTemplateSet templateSet, ILayoutMeasureContext context) : base(controller, templateSet) { MeasureContext = context; DrawContext = context as ILayoutDrawContext; PrintContext = context as ILayoutPrintContext; InternalViewSize = RegionHelper.InvalidSize; IsInvalidated = true; ShowUnfocusedComments = true; }
/// <summary> /// Measures a cell created with this frame. /// </summary> /// <param name="measureContext">The context used to measure the cell.</param> /// <param name="cellView">The cell to measure.</param> /// <param name="collectionWithSeparator">A collection that can draw separators around the cell.</param> /// <param name="referenceContainer">The cell view in <paramref name="collectionWithSeparator"/> that contains this cell.</param> /// <param name="separatorLength">The length of the separator in <paramref name="collectionWithSeparator"/>.</param> /// <param name="size">The cell size upon return, padding included.</param> /// <param name="padding">The cell padding.</param> public virtual void Measure(ILayoutMeasureContext measureContext, ILayoutCellView cellView, ILayoutCellViewCollection collectionWithSeparator, ILayoutCellView referenceContainer, Measure separatorLength, out Size size, out Padding padding) { ILayoutDiscreteContentFocusableCellView DiscreteContentFocusableCellView = cellView as ILayoutDiscreteContentFocusableCellView; Debug.Assert(DiscreteContentFocusableCellView != null); ILayoutKeywordFrame KeywordFrame = DiscreteContentFocusableCellView.KeywordFrame; Debug.Assert(KeywordFrame != null); KeywordFrame.Measure(measureContext, DiscreteContentFocusableCellView, collectionWithSeparator, referenceContainer, separatorLength, out size, out padding); Debug.Assert(padding.IsEmpty); measureContext.UpdatePadding(LeftMargin, RightMargin, ref size, out padding); Debug.Assert(RegionHelper.IsValid(size)); }
/// <summary> /// Measures a cell created with this frame. /// </summary> /// <param name="measureContext">The context used to measure the cell.</param> /// <param name="cellView">The cell to measure.</param> /// <param name="collectionWithSeparator">A collection that can draw separators around the cell.</param> /// <param name="referenceContainer">The cell view in <paramref name="collectionWithSeparator"/> that contains this cell.</param> /// <param name="separatorLength">The length of the separator in <paramref name="collectionWithSeparator"/>.</param> /// <param name="size">The cell size upon return, padding included.</param> /// <param name="padding">The cell padding.</param> public virtual void Measure(ILayoutMeasureContext measureContext, ILayoutCellView cellView, ILayoutCellViewCollection collectionWithSeparator, ILayoutCellView referenceContainer, Measure separatorLength, out Size size, out Padding padding) { ILayoutContainerCellView ContainerCellView = cellView as ILayoutContainerCellView; Debug.Assert(ContainerCellView != null); ILayoutNodeStateView ChildStateView = ContainerCellView.ChildStateView; Debug.Assert(ChildStateView != null); ChildStateView.MeasureCells(collectionWithSeparator, referenceContainer, separatorLength); Debug.Assert(RegionHelper.IsValid(ChildStateView.CellSize)); size = ChildStateView.CellSize; measureContext.UpdatePadding(LeftMargin, RightMargin, ref size, out padding); Debug.Assert(RegionHelper.IsValid(size)); }
/// <summary> /// Arranges the cell. /// </summary> /// <param name="origin">The cell location.</param> public virtual void Arrange(Point origin) { CellOrigin = origin; Debug.Assert(StateView != null); Debug.Assert(StateView.ControllerView != null); ILayoutMeasureContext MeasureContext = StateView.ControllerView.MeasureContext; Debug.Assert(MeasureContext != null); Point OriginWithPadding = origin.Moved(CellPadding.Left, Controller.Measure.Zero); Debug.Assert(ChildStateView != null); ChildStateView.ArrangeCells(OriginWithPadding); Debug.Assert(RegionHelper.IsValid(CellOrigin)); }
/// <summary> /// Arranges the cell. /// </summary> /// <param name="origin">The cell location.</param> public virtual void Arrange(Point origin) { CellOrigin = origin; Debug.Assert(StateView != null); Debug.Assert(StateView.ControllerView != null); ILayoutMeasureContext MeasureContext = StateView.ControllerView.MeasureContext; Debug.Assert(MeasureContext != null); Measure LeftPadding = (Frame is ILayoutVerticalTabulatedFrame AsTabulatedFrame && AsTabulatedFrame.HasTabulationMargin) ? MeasureContext.TabulationWidth : Controller.Measure.Zero; Measure OriginX = origin.X + LeftPadding + (HasBlockGeometry ? MeasureContext.BlockGeometryWidth : Controller.Measure.Zero); Measure OriginY = origin.Y; for (int i = 0; i < CellViewList.Count; i++) { ILayoutCellView CellView = (ILayoutCellView)CellViewList[i]; // The separator length has been calculated in Measure(). if (i > 0) { OriginY += CellView.SeparatorLength; } Point LineOrigin = new Point(OriginX, OriginY); CellView.Arrange(LineOrigin); Size NestedCellSize = CellView.CellSize; Debug.Assert(!NestedCellSize.Height.IsFloating); OriginY += NestedCellSize.Height; } Point FinalOrigin = new Point(OriginX, OriginY); Point ExpectedOrigin = CellOrigin.Moved(LeftPadding + (HasBlockGeometry ? MeasureContext.BlockGeometryWidth : Controller.Measure.Zero), CellSize.Height); bool IsEqual = Point.IsEqual(FinalOrigin, ExpectedOrigin); Debug.Assert(IsEqual); }
/// <summary> /// Updates the actual size of the cell. /// </summary> public virtual void UpdateActualSize() { Debug.Assert(StateView != null); Debug.Assert(StateView.ControllerView != null); ILayoutMeasureContext MeasureContext = StateView.ControllerView.MeasureContext; Debug.Assert(MeasureContext != null); ILayoutDrawableFrame AsDrawableFrame = Frame as ILayoutDrawableFrame; Debug.Assert(AsDrawableFrame != null); ActualCellSize = CellSize; if (ParentCellView != null) { ActualCellSize = ParentCellView.GetMeasuredSize(CellSize); } Debug.Assert(RegionHelper.IsFixed(ActualCellSize)); Debug.Assert(Size.IsEqual(CellRect.Size, ActualCellSize)); }
/// <summary> /// Arranges the cell. /// </summary> /// <param name="origin">The cell location.</param> public virtual void Arrange(Point origin) { CellOrigin = origin; Debug.Assert(StateView != null); Debug.Assert(StateView.ControllerView != null); ILayoutMeasureContext MeasureContext = StateView.ControllerView.MeasureContext; Debug.Assert(MeasureContext != null); Measure OriginX = origin.X; Measure OriginY = origin.Y + (HasBlockGeometry ? MeasureContext.BlockGeometryHeight : Controller.Measure.Zero); for (int i = 0; i < CellViewList.Count; i++) { ILayoutCellView CellView = CellViewList[i]; // The separator length has been calculated in Measure(). if (i > 0) { OriginX += CellView.SeparatorLength; } Point ColumnOrigin = new Point(OriginX, OriginY); CellView.Arrange(ColumnOrigin); Size NestedCellSize = CellView.CellSize; Debug.Assert(!NestedCellSize.Width.IsFloating); OriginX += NestedCellSize.Width; } Point FinalOrigin = new Point(OriginX, OriginY); Point ExpectedOrigin = CellOrigin.Moved(CellSize.Width, HasBlockGeometry ? MeasureContext.BlockGeometryHeight : Controller.Measure.Zero); bool IsEqual = Point.IsEqual(FinalOrigin, ExpectedOrigin); Debug.Assert(IsEqual); }
/// <summary> /// Measures the cell. /// </summary> /// <param name="collectionWithSeparator">A collection that can draw separators around the cell.</param> /// <param name="referenceContainer">The cell view in <paramref name="collectionWithSeparator"/> that contains this cell.</param> /// <param name="separatorLength">The length of the separator in <paramref name="collectionWithSeparator"/>.</param> public virtual void Measure(ILayoutCellViewCollection collectionWithSeparator, ILayoutCellView referenceContainer, Measure separatorLength) { CollectionWithSeparator = collectionWithSeparator; ReferenceContainer = referenceContainer; SeparatorLength = separatorLength; Debug.Assert(StateView != null); Debug.Assert(StateView.ControllerView != null); ILayoutMeasureContext MeasureContext = StateView.ControllerView.MeasureContext; Debug.Assert(MeasureContext != null); ILayoutDiscreteFrame AsDiscreteFrame = KeywordFrame.ParentFrame as ILayoutDiscreteFrame; Debug.Assert(AsDiscreteFrame != null); AsDiscreteFrame.Measure(MeasureContext, this, collectionWithSeparator, referenceContainer, separatorLength, out Size Size, out Padding Padding); CellSize = Size; ActualCellSize = RegionHelper.InvalidSize; CellPadding = Padding; Debug.Assert(RegionHelper.IsValid(CellSize)); }
/// <summary> /// Measures the cell. /// </summary> /// <param name="collectionWithSeparator">A collection that can draw separators around the cell.</param> /// <param name="referenceContainer">The cell view in <paramref name="collectionWithSeparator"/> that contains this cell.</param> /// <param name="separatorLength">The length of the separator in <paramref name="collectionWithSeparator"/>.</param> public virtual void Measure(ILayoutCellViewCollection collectionWithSeparator, ILayoutCellView referenceContainer, Measure separatorLength) { CollectionWithSeparator = collectionWithSeparator; ReferenceContainer = referenceContainer; SeparatorLength = separatorLength; Debug.Assert(StateView != null); Debug.Assert(StateView.ControllerView != null); ILayoutMeasureContext MeasureContext = StateView.ControllerView.MeasureContext; Debug.Assert(MeasureContext != null); ILayoutFrameWithHorizontalSeparator AsFrameWithHorizontalSeparator = Frame as ILayoutFrameWithHorizontalSeparator; Debug.Assert(AsFrameWithHorizontalSeparator != null); bool OverrideReferenceContainer = false; // Ensures arguments of Arrange() are valid. This only happens for the root cell view, where there is no separator. if (collectionWithSeparator == null && referenceContainer == null) { collectionWithSeparator = this; OverrideReferenceContainer = true; separatorLength = Controller.Measure.Zero; } Measure Width = Controller.Measure.Zero; Measure Height = Controller.Measure.Floating; for (int i = 0; i < CellViewList.Count; i++) { ILayoutCellView CellView = CellViewList[i]; if (i > 0) { // Starting with the second cell, we use the separator of our frame. if (i == 1) { collectionWithSeparator = this; OverrideReferenceContainer = true; separatorLength = MeasureContext.GetHorizontalSeparatorWidth(AsFrameWithHorizontalSeparator.Separator); } Width += separatorLength; } if (OverrideReferenceContainer) { referenceContainer = CellView; } Debug.Assert(collectionWithSeparator != this || CellViewList.IndexOf(referenceContainer) == i); CellView.Measure(collectionWithSeparator, referenceContainer, separatorLength); Size NestedCellSize = CellView.CellSize; Debug.Assert(RegionHelper.IsValid(NestedCellSize)); bool IsFixed = RegionHelper.IsFixed(NestedCellSize); bool IsStretched = RegionHelper.IsStretchedVertically(NestedCellSize); Debug.Assert(IsFixed || IsStretched); Debug.Assert(!NestedCellSize.Width.IsFloating); Width += NestedCellSize.Width; if (IsFixed) { Debug.Assert(!NestedCellSize.Height.IsFloating); if (Height.IsFloating || Height.Draw < NestedCellSize.Height.Draw) { Height = NestedCellSize.Height; } } } Size AccumulatedSize = Size.Empty; if (!Width.IsZero) { AccumulatedSize = new Size(Width, Height + (HasBlockGeometry ? MeasureContext.BlockGeometryHeight : Controller.Measure.Zero)); } CellSize = AccumulatedSize; ActualCellSize = RegionHelper.InvalidSize; Debug.Assert(RegionHelper.IsValid(CellSize)); }
public void Measure(ILayoutMeasureContext measureContext, ILayoutCellView cellView, ILayoutCellViewCollection collectionWithSeparator, ILayoutCellView referenceContainer, Measure separatorLength, out Size size, out Padding padding) { size = new(); padding = new(); }
/// <summary> /// Creates and initializes a new instance of a <see cref="LayoutControllerView"/> object. /// </summary> /// <param name="controller">The controller on which the view is attached.</param> /// <param name="templateSet">The template set used to describe the view.</param> /// <param name="context">The context used to measure, arrange, and draw or print the view.</param> public static LayoutControllerView Create(LayoutController controller, ILayoutTemplateSet templateSet, ILayoutMeasureContext context) { LayoutControllerView View = new LayoutControllerView(controller, templateSet, context); View.Init(); return(View); }