public AlignedAxes GetAlignedAxes(AlignmentDirection alignmentDirection, int position, int span) { var axes = alignedAxesList.Where(t => t.AlignmentDirection == alignmentDirection && t.Position == position && t.Span == span).DefaultIfEmpty(null).First(); if (axes == null) { var newAxes = new AlignedAxes() { Axes = new List<Axis2D>(), AlignmentDirection = alignmentDirection, Position = position, Span = span }; alignedAxesList.Add(newAxes); return newAxes; } else return axes; }
public AlignedAxes GetAlignedAxes(AlignmentDirection alignmentDirection, int position, int span) { var axes = alignedAxesList.Where(t => t.AlignmentDirection == alignmentDirection && t.Position == position && t.Span == span).DefaultIfEmpty(null).First(); if (axes == null) { var newAxes = new AlignedAxes() { Axes = new List <Axis2D>(), AlignmentDirection = alignmentDirection, Position = position, Span = span }; alignedAxesList.Add(newAxes); return(newAxes); } else { return(axes); } }
/// <summary> /// Initializes a new instance of <see cref="Alignment"/>. /// </summary> /// <param name="direction">The text alignment direction.</param> /// <param name="width">The width of the text, in characters.</param> public Alignment(AlignmentDirection direction, int width) { _direction = direction; _width = width; }
/// <summary> /// Initializes a new instance of <see cref="Alignment"/>. /// </summary> /// <param name="direction">The text alignment direction.</param> /// <param name="width">The width of the text, in characters.</param> public Alignment(AlignmentDirection direction, int width) { Direction = direction; Width = width; }
public static float ResolveOriginBaseY(LayoutResult result, float viewportY, AlignmentTarget target, AlignmentDirection direction, InputSystem inputSystem) { switch (target) { case AlignmentTarget.Unset: case AlignmentTarget.LayoutBox: return(result.allocatedPosition.y); case AlignmentTarget.Parent: return(0); case AlignmentTarget.ParentContentArea: LayoutResult parentResult = result.layoutParent; if (parentResult == null) { return(0); } if (direction == AlignmentDirection.Start) { return(parentResult.padding.top + parentResult.border.top); } else { return(parentResult.padding.bottom + parentResult.border.bottom); } case AlignmentTarget.Template: throw new NotImplementedException(); case AlignmentTarget.TemplateContentArea: throw new NotImplementedException(); case AlignmentTarget.View: { if (result.element.parent == null) { return(0); } LayoutResult ptr = result.element.parent.layoutResult; float output = viewportY; while (ptr != null) { output -= ptr.alignedPosition.y; if (ptr.element.parent == null) { return(output); } ptr = ptr.element.parent.layoutResult; } return(output); } case AlignmentTarget.Screen: { if (result.element.parent == null) { return(0); } LayoutResult ptr = result.element.parent.layoutResult; float output = 0; while (ptr != null) { output -= ptr.alignedPosition.y; if (ptr.element.parent == null) { return(output); } ptr = ptr.element.parent.layoutResult; } return(output); } case AlignmentTarget.Mouse: float dist = GetYDistanceToScreen(result); return(inputSystem.MousePosition.y + dist); default: throw new ArgumentOutOfRangeException(nameof(target), target, null); } }
public static float ResolveOriginBaseX(LayoutResult result, float viewportX, AlignmentTarget target, AlignmentDirection direction, InputSystem inputSystem) { switch (target) { case AlignmentTarget.Unset: case AlignmentTarget.LayoutBox: return(result.allocatedPosition.x); case AlignmentTarget.Parent: return(0); case AlignmentTarget.ParentContentArea: LayoutResult parentResult = result.layoutParent; if (parentResult == null) { return(0); } if (direction == AlignmentDirection.Start) { return(parentResult.padding.left + parentResult.border.left); } else { return(parentResult.padding.right + parentResult.border.right); } case AlignmentTarget.Template: // todo handle transclusion return(0); case AlignmentTarget.TemplateContentArea: // todo handle transclusion return(0); case AlignmentTarget.View: { if (result.element.parent == null) { return(0); } LayoutResult ptr = result.element.parent.layoutResult; float output = viewportX; while (ptr != null) { output -= ptr.alignedPosition.x; if (ptr.element.parent == null) { return(output); } ptr = ptr.element.parent.layoutResult; } return(output); } case AlignmentTarget.Screen: { if (result.element.parent == null) { return(0); } LayoutResult ptr = result.element.parent.layoutResult; float output = 0; while (ptr != null) { output -= ptr.alignedPosition.x; if (ptr.element.parent == null) { return(output); } ptr = ptr.element.parent.layoutResult; } return(output); } case AlignmentTarget.Mouse: { float dist = GetXDistanceToScreen(result); return(inputSystem.MousePosition.x + dist); } default: throw new ArgumentOutOfRangeException(nameof(target), target, null); } }