/// <summary> /// Prints the selection. /// </summary> public virtual void Print() { ILayoutNodeState State = StateView.State; ILayoutListInner ParentInner = State.PropertyToInner(PropertyName) as ILayoutListInner; Debug.Assert(ParentInner != null); LayoutControllerView ControllerView = StateView.ControllerView; Debug.Assert(ControllerView.PrintContext != null); ControllerView.UpdateLayout(); Debug.Assert(StartIndex <= EndIndex); ILayoutNodeStateView FirstStateView = (ILayoutNodeStateView)ControllerView.StateViewTable[ParentInner.StateList[StartIndex]]; Point Origin = FirstStateView.CellOrigin.Opposite; for (int i = StartIndex; i < EndIndex; i++) { ILayoutNodeStateView StateView = (ILayoutNodeStateView)ControllerView.StateViewTable[ParentInner.StateList[i]]; Debug.Assert(RegionHelper.IsValid(StateView.ActualCellSize)); StateView.PrintCells(Origin); } }
/// <summary> /// Initializes a new instance of the <see cref="LayoutSourceStateView"/> class. /// </summary> /// <param name="controllerView">The controller view to which this object belongs.</param> /// <param name="state">The source state.</param> public LayoutSourceStateView(LayoutControllerView controllerView, ILayoutSourceState state) : base(controllerView, state) { CellOrigin = RegionHelper.InvalidOrigin; CellSize = RegionHelper.InvalidSize; ActualCellSize = RegionHelper.InvalidSize; }
/// <summary> /// Initializes a new instance of the <see cref="LayoutEmptyNodeStateView"/> class. /// </summary> /// <param name="controllerView">The controller view to which this object belongs.</param> /// <param name="state">The child node state.</param> protected LayoutEmptyNodeStateView(LayoutControllerView controllerView, ILayoutNodeState state) : base(controllerView, state) { CellOrigin = RegionHelper.InvalidOrigin; CellSize = RegionHelper.InvalidSize; ActualCellSize = RegionHelper.InvalidSize; }
/// <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); }
/// <summary> /// Prints the selection. /// </summary> public virtual void Print() { LayoutControllerView ControllerView = StateView.ControllerView; Debug.Assert(ControllerView.PrintContext != null); ControllerView.UpdateLayout(); Debug.Assert(RegionHelper.IsValid(StateView.ActualCellSize)); Point Origin = StateView.CellOrigin.Opposite; StateView.PrintCells(Origin); }
/// <summary> /// Draws a cell created with this frame. /// </summary> /// <param name="drawContext">The context used to draw the cell.</param> /// <param name="cellView">The cell to draw.</param> /// <param name="origin">The location where to start drawing.</param> /// <param name="size">The drawing size, padding included.</param> /// <param name="padding">The padding to use when drawing.</param> public virtual void Draw(ILayoutDrawContext drawContext, ILayoutCellView cellView, Point origin, Size size, Padding padding) { 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; } if (Text != null) { if ((DisplayMode == CommentDisplayModes.OnFocus && IsFocused) || DisplayMode == CommentDisplayModes.All) { Point OriginWithPadding = origin.Moved(padding.Left, padding.Top); drawContext.DrawTextBackground(Text, OriginWithPadding, TextStyles.Comment); LayoutControllerView ControllerView = cellView.StateView.ControllerView; if (ControllerView.Selection is ILayoutCommentSelection AsCommentSelection && AsCommentSelection.StateView == cellView.StateView) { int Start = AsCommentSelection.Start; int End = AsCommentSelection.End; Debug.Assert(Start <= End); drawContext.DrawSelectionText(Text, OriginWithPadding, TextStyles.Comment, Start, End); } drawContext.DrawText(Text, OriginWithPadding, TextStyles.Comment, isFocused: false); // The caret is drawn separately. } else if (DisplayMode == CommentDisplayModes.OnFocus && cellView.StateView.ControllerView.ShowUnfocusedComments) { drawContext.DrawCommentIcon(new Rect(cellView.CellOrigin, Size.Empty)); } } }
/// <summary> /// Prints the selection. /// </summary> public virtual void Print() { LayoutControllerView ControllerView = StateView.ControllerView; Debug.Assert(ControllerView.PrintContext != null); ControllerView.UpdateLayout(); Debug.Assert(RegionHelper.IsValid(StateView.ActualCellSize)); ILayoutTemplateSet TemplateSet = ControllerView.TemplateSet; IList <FocusFrameSelectorList> SelectorStack = StateView.GetSelectorStack(); ILayoutDiscreteFrame Frame = (ILayoutDiscreteFrame)TemplateSet.PropertyToFrame(StateView.State, PropertyName, SelectorStack); Debug.Assert(Frame != null); int Value = NodeTreeHelper.GetEnumValue(StateView.State.Node, PropertyName); Frame.Print(ControllerView.PrintContext, Value, Point.Origin); }
/// <summary> /// Draws a cell created with this frame. /// </summary> /// <param name="drawContext">The context used to draw the cell.</param> /// <param name="cellView">The cell to draw.</param> /// <param name="origin">The location where to start drawing.</param> /// <param name="size">The drawing size, padding included.</param> /// <param name="padding">The padding to use when drawing.</param> public virtual void Draw(ILayoutDrawContext drawContext, ILayoutCellView cellView, Point origin, Size size, Padding padding) { Node Node = cellView.StateView.State.Node; string Text = BaseNodeHelper.NodeTreeHelper.GetString(Node, PropertyName); Point OriginWithPadding = origin.Moved(padding.Left, padding.Top); drawContext.DrawTextBackground(Text, OriginWithPadding, TextStyle); LayoutControllerView ControllerView = cellView.StateView.ControllerView; if (ControllerView.Selection is ILayoutStringContentSelection AsStringContentSelection && AsStringContentSelection.StateView == cellView.StateView) { int Start = AsStringContentSelection.Start; int End = AsStringContentSelection.End; Debug.Assert(Start <= End); drawContext.DrawSelectionText(Text, OriginWithPadding, TextStyle, Start, End); } drawContext.DrawText(Text, OriginWithPadding, TextStyle, isFocused: false); // The caret is drawn separately. }
/// <summary> /// Prints the selection. /// </summary> public virtual void Print() { LayoutControllerView ControllerView = StateView.ControllerView; Debug.Assert(ControllerView.PrintContext != null); ControllerView.UpdateLayout(); Debug.Assert(RegionHelper.IsValid(StateView.ActualCellSize)); ILayoutTemplateSet TemplateSet = ControllerView.TemplateSet; IList <FocusFrameSelectorList> SelectorStack = StateView.GetSelectorStack(); ILayoutTextValueFrame Frame = (ILayoutTextValueFrame)TemplateSet.PropertyToFrame(StateView.State, PropertyName, SelectorStack); Debug.Assert(Frame != null); string Text = NodeTreeHelper.GetString(StateView.State.Node, PropertyName); Debug.Assert(Text != null); Debug.Assert(Start <= End); Debug.Assert(End <= Text.Length); Frame.Print(ControllerView.PrintContext, Text.Substring(Start, End - Start), Point.Origin); }
/// <summary> /// Initializes a new instance of the <see cref="LayoutCellViewTreeContext"/> class. /// </summary> /// <param name="controllerView">The view in which cells are created.</param> /// <param name="stateView">The state view for which to create cells.</param> /// <param name="forcedCommentStateView">The state view for which the comment must be visible, even if empty.</param> public LayoutCellViewTreeContext(LayoutControllerView controllerView, ILayoutNodeStateView stateView, ILayoutNodeStateView forcedCommentStateView) : base(controllerView, stateView, forcedCommentStateView) { }
/// <summary> /// Initializes a new instance of the <see cref="LayoutBlockStateView"/> class. /// </summary> /// <param name="controllerView">The controller view to which this object belongs.</param> /// <param name="blockState">The block state.</param> /// <param name="template">The frame template.</param> protected LayoutBlockStateView(LayoutControllerView controllerView, ILayoutBlockState blockState, ILayoutTemplate template) : base(controllerView, blockState, template) { }