Example #1
0
 public ParagraphStyle(
     LineAlignment lineAlignment,
     ParagraphSpacing spacing)
 {
     this.LineAlignment = lineAlignment;
     this.Spacing       = spacing;
 }
Example #2
0
        public static string AlignLine(int maxWidth, int width, string line, LineAlignment alignment, bool canBreak, int[] columnWidths = null)
        {
            maxWidth = maxWidth / (width + 1);

            var tag = GetTag(line);

            line = line.Replace(tag, "");

            switch (alignment)
            {
            case LineAlignment.Left:
                return(tag + line.PadRight(maxWidth, ' '));

            case LineAlignment.Right:
                return(tag + line.PadLeft(maxWidth, ' '));

            case LineAlignment.Center:
                return(tag + line.PadLeft(((maxWidth + line.Length) / 2), ' ').PadRight(maxWidth, ' '));

            case LineAlignment.Justify:
                return(tag + JustifyText(maxWidth, line, canBreak, columnWidths));

            default:
                return(tag + line);
            }
        }
Example #3
0
        public void WriteLine(string line, int height, int width, LineAlignment alignment)
        {
            int h = height + (width * 16);

            WriteData(AsciiControlChars.GroupSeparator + "!" + (char)h);
            WriteData(line + (char)0xA);
        }
Example #4
0
 public LineRendererValues(LineRenderer lr)
 {
     loop              = lr.loop;
     widthCurve        = lr.widthCurve;
     colorGradient     = lr.colorGradient;
     numCornerVertices = lr.numCornerVertices;
     numCapVertices    = lr.numCapVertices;
     alignment         = lr.alignment;
     textureMode       = lr.textureMode;
 }
 /// <summary>
 /// Converts an object into its XML representation.
 /// </summary>
 /// <param name="writer">The <see cref="T:System.Xml.XmlWriter" /> stream to which the object is serialized.</param>
 public void WriteXml(XmlWriter writer)
 {
     writer.WriteElementString("LineAlignment", LineAlignment.ToString());
     writer.WriteElementString("Alignment", Alignment.ToString());
     writer.WriteElementString("Trimming", Trimming.ToString());
     writer.WriteElementString("Xshift", Xshift.ToString());
     writer.WriteElementString("Yshift", Yshift.ToString());
     writer.WriteElementString("Font",
                               TypeDescriptor.GetConverter(Font).ConvertTo(Font, typeof(string)).ToString());
 }
Example #6
0
 public override bool Equals(object obj)
 {
     return((obj is StringFormat f) &&
            FormatFlags.Equals(f.FormatFlags) &&
            HotkeyPrefix.Equals(f.HotkeyPrefix) &&
            measurableCharacterRanges == f.measurableCharacterRanges &&
            Alignment.Equals(f.Alignment) &&
            LineAlignment.Equals(f.LineAlignment) &&
            Trimming.Equals(f.Trimming));
 }
Example #7
0
        public Size Arrange(
            Size finalSize,
            VirtualizingLayoutContext context,
            LineAlignment lineAlignment,
            string layoutId)
        {
            ArrangeVirtualizingLayout(finalSize, lineAlignment, layoutId);

            return(new Size(
                       Math.Max(finalSize.Width, _lastExtent.Width),
                       Math.Max(finalSize.Height, _lastExtent.Height)));
        }
        public override JObject SaveToJsonObject(StiJsonSaveMode mode)
        {
            var jObject = base.SaveToJsonObject(mode);

            jObject.Add(new JProperty("IsGeneric", IsGeneric));
            jObject.Add(new JProperty("Alignment", Alignment.ToString()));
            jObject.Add(new JProperty("FormatFlags", FormatFlags.ToString()));
            jObject.Add(new JProperty("HotkeyPrefix", HotkeyPrefix.ToString()));
            jObject.Add(new JProperty("LineAlignment", LineAlignment.ToString()));
            jObject.Add(new JProperty("Trimming", Trimming.ToString()));

            return(jObject);
        }
Example #9
0
        static bool Get(char c, out LineAlignment a)
        {
            switch (c)
            {
            case '1': a = LineAlignment.Top; return(true);

            case '2': a = LineAlignment.Center; return(true);

            case '3': a = LineAlignment.Bottom; return(true);
            }

            a = LineAlignment.Default;
            return(false);
        }
Example #10
0
        public Size Arrange(
            Size finalSize,
            VirtualizingLayoutContext context,
            bool isWrapping,
            LineAlignment lineAlignment,
            string layoutId)
        {
            Logger.TryGet(LogEventLevel.Verbose, "Repeater")?.Log(this, "{LayoutId}: ArrangeLayout", layoutId);
            ArrangeVirtualizingLayout(finalSize, lineAlignment, isWrapping, layoutId);

            return(new Size(
                       Math.Max(finalSize.Width, _lastExtent.Width),
                       Math.Max(finalSize.Height, _lastExtent.Height)));
        }
Example #11
0
        public static LineSegment CreateLineSegment(
            this Stack <LineElement> fromElements,
            HorizontalSpace space,
            LineAlignment lineAlignment,
            double defaultLineHeight,
            PageVariables variables)
        {
            var overflow = lineAlignment == LineAlignment.Justify ? 2 : 0;
            var elements = fromElements
                           .GetElementsToFitMaxWidth(space.Width + overflow, variables)
                           .ToArray();

            return(new LineSegment(elements, lineAlignment, space, defaultLineHeight));
        }
Example #12
0
        public static LineAlignment GetLinesAlignment(
            this Word.Justification justification,
            LineAlignment ifNull)
        {
            if (justification == null)
            {
                return(ifNull);
            }

            return(justification.Val.Value switch
            {
                Word.JustificationValues.Right => LineAlignment.Right,
                Word.JustificationValues.Center => LineAlignment.Center,
                Word.JustificationValues.Both => LineAlignment.Justify,
                _ => LineAlignment.Left,
            });
Example #13
0
        public virtual void SetConfig(TextParser.Config c)
        {
            d_bBlink      = c.isBlink;
            lineAlignment = c.lineAlignment;

            d_color   = c.fontColor;
            d_bOffset = c.isOffset;
            if (c.isOffset)
            {
                d_rectOffset = c.offsetRect;
            }
            else
            {
                d_rectOffset.Set(0, 0, 0, 0);
            }
        }
Example #14
0
        /// <summary>
        /// Utility method to serialize elements of LineAlignment enum.
        /// </summary>
        /// <param name="lineAlignment">Enum value to serialize.</param>
        /// <returns>Serialized enum value.</returns>
        private static string GetLineAlignmentValue(LineAlignment lineAlignment)
        {
            switch (lineAlignment)
            {
            case LineAlignment.Start:
                return(Constants.StartValue);

            case LineAlignment.Center:
                return(Constants.CenterValue);

            case LineAlignment.End:
                return(Constants.EndValue);

            default:
                throw new ArgumentOutOfRangeException(string.Format("Unknown cue line align value '{0}'.", lineAlignment.ToString()));
            }
        }
Example #15
0
        /// <summary>
        /// Print string to line of console, using default foreground/background colors
        /// </summary>
        /// <param name="str">String to print</param>
        /// <param name="x">x (Width) position of first character</param>
        /// <param name="y">y (Height) position of first character</param>
        /// <param name="flag">Background flag</param>
        /// <param name="align">Alignment of string</param>
        public void PrintLine(string str, int x, int y, Background flag, LineAlignment align)
        {
            switch (align)
            {
            case LineAlignment.Left:
                TCOD_console_print_left(m_consolePtr, x, y, flag.m_value, new StringBuilder(str));
                break;

            case LineAlignment.Center:
                TCOD_console_print_center(m_consolePtr, x, y, flag.m_value, new StringBuilder(str));
                break;

            case LineAlignment.Right:
                TCOD_console_print_right(m_consolePtr, x, y, flag.m_value, new StringBuilder(str));
                break;
            }
        }
Example #16
0
        private void ArrangeVirtualizingLayout(
            Size finalSize,
            LineAlignment lineAlignment,
            bool isWrapping,
            string layoutId)
        {
            // Walk through the realized elements one line at a time and
            // align them, Then call element.Arrange with the arranged bounds.
            int realizedElementCount = _elementManager.GetRealizedElementCount();

            if (realizedElementCount > 0)
            {
                var countInLine           = 1;
                var previousElementBounds = _elementManager.GetLayoutBoundsForRealizedIndex(0);
                var currentLineOffset     = _orientation.MajorStart(previousElementBounds);
                var spaceAtLineStart      = _orientation.MinorStart(previousElementBounds);
                var spaceAtLineEnd        = 0.0;
                var currentLineSize       = _orientation.MajorSize(previousElementBounds);
                for (int i = 1; i < realizedElementCount; i++)
                {
                    var currentBounds = _elementManager.GetLayoutBoundsForRealizedIndex(i);
                    if (_orientation.MajorStart(currentBounds) != currentLineOffset)
                    {
                        spaceAtLineEnd = _orientation.Minor(finalSize) - _orientation.MinorStart(previousElementBounds) - _orientation.MinorSize(previousElementBounds);
                        PerformLineAlignment(i - countInLine, countInLine, spaceAtLineStart, spaceAtLineEnd, currentLineSize, lineAlignment, isWrapping, finalSize, layoutId);
                        spaceAtLineStart  = _orientation.MinorStart(currentBounds);
                        countInLine       = 0;
                        currentLineOffset = _orientation.MajorStart(currentBounds);
                        currentLineSize   = 0;
                    }

                    countInLine++; // for current element
                    currentLineSize       = Math.Max(currentLineSize, _orientation.MajorSize(currentBounds));
                    previousElementBounds = currentBounds;
                }

                // Last line - potentially have a property to customize
                // aligning the last line or not.
                if (countInLine > 0)
                {
                    var spaceAtEnd = _orientation.Minor(finalSize) - _orientation.MinorStart(previousElementBounds) - _orientation.MinorSize(previousElementBounds);
                    PerformLineAlignment(realizedElementCount - countInLine, countInLine, spaceAtLineStart, spaceAtEnd, currentLineSize, lineAlignment, isWrapping, finalSize, layoutId);
                }
            }
        }
Example #17
0
        public void WriteLine(string line, int height, int width, LineAlignment alignment)
        {
            int h = height + (width * 16);

            WriteData(AsciiControlChars.GroupSeparator + "!" + (char)h);

            if (alignment != LineAlignment.Justify)
            {
                WriteData(AsciiControlChars.Escape + "a" + (char)((int)alignment));
            }
            else
            {
                WriteData(AsciiControlChars.Escape + "a" + (char)0);
                line = AlignLine(_maxChars, width, line, alignment);
            }

            WriteData(line + (char)0xA);
        }
Example #18
0
        private static string AlignLine(int maxWidth, int width, string line, LineAlignment alignment)
        {
            maxWidth = maxWidth / (width + 1);

            switch (alignment)
            {
            case LineAlignment.Right:
                return(line.PadLeft(maxWidth, ' '));

            case LineAlignment.Center:
                return(line.PadLeft(((maxWidth + line.Length) / 2), ' '));

            case LineAlignment.Justify:
                return(JustifyText(maxWidth, line));

            default:
                return(line);
            }
        }
Example #19
0
        private static (LineSegment[], double) CreateLineSegments(
            this Stack <LineElement> fromElements,
            LineAlignment lineAlignment,
            double relativeYOffset,
            IEnumerable <Rectangle> fixedDrawings,
            double availableWidth,
            double defaultLineHeight,
            PageVariables variables)
        {
            var reserveSpaceHelper = new LineReservedSpaceHelper(fixedDrawings, relativeYOffset, availableWidth);

            var expectedLineHeight = 0.0;
            var finished           = false;

            do
            {
                var segmentSpaces = reserveSpaceHelper
                                    .GetLineSegments()
                                    .ToArray();

                var lineSegments = segmentSpaces
                                   .Select((space, i) => fromElements.CreateLineSegment(space, lineAlignment, defaultLineHeight, variables))
                                   .ToArray();

                var maxHeight = lineSegments.Max(l => l.Size.Height);
                expectedLineHeight = Math.Max(maxHeight, expectedLineHeight);
                var hasChanged = reserveSpaceHelper.UpdateLineHeight(expectedLineHeight);

                if (!hasChanged)
                {
                    return(lineSegments, expectedLineHeight);
                }
                else
                {
                    foreach (var ls in lineSegments.Reverse())
                    {
                        ls.ReturnElementsToStack(fromElements);
                    }
                }
            } while (!finished);

            return(new LineSegment[0], expectedLineHeight);
        }
Example #20
0
        public LineSegment(
            IEnumerable <LineElement> elements,
            LineAlignment lineAlignment,
            HorizontalSpace space,
            double defaultLineHeight)
        {
            _elements        = elements.ToArray();
            _trimmedElements = _elements
                               .SkipWhile(e => e is SpaceElement) // skip leading spaces
                               .Reverse()
                               .SkipWhile(e => e is SpaceElement) // skip trailing spaces
                               .Reverse()
                               .ToArray();

            _lineAlignment = lineAlignment;
            _space         = space;

            var _lineHeight = _trimmedElements.MaxOrDefault(e => e.Size.Height, defaultLineHeight);

            this.Size = new Size(_space.Width, _lineHeight);
        }
Example #21
0
        public static string AlignLine(int maxWidth, int width, string line, LineAlignment alignment, bool canBreak, int[] columnWidths = null)
        {
            maxWidth = maxWidth / (width + 1);

            var tag = GetTag(line);
            line = line.Replace(tag, "");

            switch (alignment)
            {
                case LineAlignment.Left:
                    return tag + line.PadRight(maxWidth, ' ');
                case LineAlignment.Right:
                    return tag + line.PadLeft(maxWidth, ' ');
                case LineAlignment.Center:
                    return tag + line.PadLeft(((maxWidth + line.Length) / 2), ' ').PadRight(maxWidth, ' ');
                case LineAlignment.Justify:
                    return tag + JustifyText(maxWidth, line, canBreak, columnWidths);
                default:
                    return tag + line;
            }
        }
Example #22
0
            public void Set(Config c)
            {
                anchor      = c.anchor;
                font        = c.font;
                fontStyle   = c.fontStyle;
                fontSize    = c.fontSize;
                fontColor   = c.fontColor;
                isUnderline = c.isUnderline;
                isStrickout = c.isStrickout;
                isBlink     = c.isBlink;
                dyncSpeed   = c.dyncSpeed;

                isOffset   = c.isOffset;
                offsetRect = c.offsetRect;

                effectType      = c.effectType;
                effectColor     = c.effectColor;
                effectDistance  = c.effectDistance;
                isDyncUnderline = c.isDyncUnderline;
                isDyncStrickout = c.isDyncStrickout;
                lineAlignment   = c.lineAlignment;
            }
Example #23
0
            public void Clear()
            {
                anchor          = Anchor.Null;
                font            = null;
                fontStyle       = FontStyle.Normal;
                fontSize        = 0;
                fontColor       = Color.white;
                isUnderline     = false;
                isStrickout     = false;
                isBlink         = false;
                isDyncUnderline = false;
                isDyncStrickout = false;
                dyncSpeed       = 0;
                isOffset        = false;
                offsetRect.Set(0, 0, 0, 0);

                effectType     = EffectType.Null;
                effectColor    = Color.black;
                effectDistance = Vector2.zero;

                lineAlignment = LineAlignment.Default;
            }
        protected override void ReadFromImpl(object obj)
        {
            base.ReadFromImpl(obj);
            LineRenderer uo = (LineRenderer)obj;

            startWidth        = uo.startWidth;
            endWidth          = uo.endWidth;
            widthMultiplier   = uo.widthMultiplier;
            numCornerVertices = uo.numCornerVertices;
            numCapVertices    = uo.numCapVertices;
            useWorldSpace     = uo.useWorldSpace;
            loop                 = uo.loop;
            startColor           = uo.startColor;
            endColor             = uo.endColor;
            positionCount        = uo.positionCount;
            generateLightingData = uo.generateLightingData;
            textureMode          = uo.textureMode;
            alignment            = uo.alignment;
            widthCurve           = uo.widthCurve;
            colorGradient        = uo.colorGradient;
            shadowBias           = uo.shadowBias;
        }
Example #25
0
        public static Line CreateLine(
            this Stack <LineElement> fromElements,
            LineAlignment lineAlignment,
            double relativeYOffset,
            IEnumerable <FixedDrawing> fixedDrawings,
            double availableWidth,
            double defaultLineHeight,
            PageVariables variables,
            LineSpacing lineSpacing)
        {
            var(lineSegments, lineHeight) = fromElements
                                            .CreateLineSegments(lineAlignment, relativeYOffset, fixedDrawings.Select(d => d.BoundingBox), availableWidth, defaultLineHeight, variables);

            var baseLineOffset = lineSegments.Max(ls => ls.GetBaseLineOffset());

            foreach (var ls in lineSegments)
            {
                ls.JustifyElements(baseLineOffset, lineHeight);
            }

            return(new Line(lineSegments, lineSpacing));
        }
Example #26
0
 /// <summary>
 /// Print aligned string inside the defined rectangle, truncating if bottom is reached
 /// </summary>
 /// <param name="str">String to print</param>
 /// <param name="x">x (Width) position of first character</param>
 /// <param name="y">y (Height) position of first character</param>
 /// <param name="w">Width of rectangle to print in</param>
 /// <param name="h">Height of rectangle to print in. If 0, string is only truncated if reaches bottom of console.</param>
 /// <param name="align">Alignment of string</param>
 /// <returns>Number of lines printed</returns>
 public int PrintLineRect(string str, int x, int y, int w, int h, LineAlignment align)
 {
     return PrintLineRect(str, x, y, w, h, new Background(BackgroundFlag.Set), align);
 }
Example #27
0
 public TextElementLine(LineAlignment alignment)
 {
     Alignment = alignment;
 }
Example #28
0
        public void StartLine(LineAlignment alignment)
        {
            var line = new TextElementLine(alignment);

            ContainerStack.Push(line);
        }
Example #29
0
 public void NewLine(LineAlignment alignment)
 {
     EndLine();
     StartLine(alignment);
 }
Example #30
0
        /// <summary>
        /// Print a string in a rectangle
        /// </summary>
        void PrintLineRect(string msg, int x, int y, int width, int height, LineAlignment alignment, Color color)
        {
            //Get screen handle
            RootConsole rootConsole = RootConsole.GetInstance();

            rootConsole.ForegroundColor = color;
            rootConsole.PrintLineRect(msg, x, y, width, height, alignment);
            rootConsole.ForegroundColor = ColorPresets.White;
        }
Example #31
0
        /// <summary>
        /// Print a string in a rectangle
        /// </summary>
        void PrintLineRect(string msg, int x, int y, int width, int height, LineAlignment alignment)
        {
            //Get screen handle
            RootConsole rootConsole = RootConsole.GetInstance();

            rootConsole.PrintLineRect(msg, x, y, width, height, alignment);
        }
Example #32
0
 /// <summary>
 /// Returns height that a call to PrintLineRect would use/return without actually printing
 /// </summary>
 /// <param name="str">String to print</param>
 /// <param name="x">x (Width) position of first character</param>
 /// <param name="y">y (Height) position of first character</param>
 /// <param name="w">Width of rectangle to print in</param>
 /// <param name="h">Height of rectangle to print in. If 0, string is only truncated if reaches bottom of console.</param>
 /// <param name="align">Alignment of string</param>
 /// <returns>Number of lines printed</returns>
 public int GetHeightPrintLineRectWouldUse(string str, int x, int y, int w, int h, LineAlignment align)
 {
     switch (align)
     {
         case LineAlignment.Left:
             return TCOD_console_height_left_rect(m_consolePtr, x, y, w, h, new StringBuilder(str));
         case LineAlignment.Center:
             return TCOD_console_height_right_rect(m_consolePtr, x, y, w, h, new StringBuilder(str));
         case LineAlignment.Right:
             return TCOD_console_height_center_rect(m_consolePtr, x, y, w, h, new StringBuilder(str));
         default:
             throw new Exception("Must Pass Alignment to PrintLineRect");
     }
 }
Example #33
0
        protected override JSONObject ToJSON(WXHierarchyContext context)
        {
            JSONObject json = new JSONObject(JSONObject.Type.OBJECT);
            JSONObject data = new JSONObject(JSONObject.Type.OBJECT);

            json.AddField("type", "LineRenderer");
            json.AddField("data", data);

            JSONObject materialArray = new JSONObject(JSONObject.Type.ARRAY);

            Material[] materials = renderer.sharedMaterials;
            foreach (Material material in materials)
            {
                WXMaterial materialConverter = new WXMaterial(material, renderer);
                string     materialPath      = materialConverter.Export(context.preset);
                materialArray.Add(materialPath);
                context.AddResource(materialPath);
            }
            data.AddField("materials", materialArray);

            ShadowCastingMode mode        = renderer.shadowCastingMode;
            StaticEditorFlags shadowFlags = GameObjectUtility.GetStaticEditorFlags(renderer.gameObject);

            if (mode == ShadowCastingMode.Off || (shadowFlags & StaticEditorFlags.LightmapStatic) != 0)
            {
                data.AddField("castShadow", false);
            }
            else
            {
                data.AddField("castShadow", true);
            }

            bool receiveShadow = renderer.receiveShadows;

            data.AddField("receiveShadow", receiveShadow);
            int alignmentNum = 0;

#if UNITY_2017_1_OR_NEWER
            LineAlignment alignment = renderer.alignment;
            switch (alignment)
            {
            case LineAlignment.View:
                alignmentNum = 0;
                break;

    #if UNITY_2018_2_OR_NEWER
            case LineAlignment.TransformZ:
                alignmentNum = 1;
                break;
    #else
            case LineAlignment.Local:
                alignmentNum = 1;
                break;
    #endif
            }
            data.AddField("alignment", alignmentNum);
#endif
            Color startColor = renderer.startColor;
            data.AddField("startColor", parseColor(startColor));

            Color endColor = renderer.endColor;
            data.AddField("endColor", parseColor(endColor));

            float startWidth = renderer.startWidth;
            data.AddField("startWidth", startWidth);

            float endWidth = renderer.endWidth;
            data.AddField("endWidth", endWidth);

            LineTextureMode textureMode    = renderer.textureMode;
            int             textureModeNum = 0;
            switch (textureMode)
            {
            case LineTextureMode.Stretch:
                textureModeNum = 0;
                break;

            case LineTextureMode.Tile:
                textureModeNum = 1;
                break;
            }
            data.AddField("textureMode", textureModeNum);

            int positionCount = 0;
#if UNITY_2017_1_OR_NEWER
            positionCount = renderer.positionCount;
#else
            positionCount = renderer.numPositions;
#endif
            Vector3[] positionsVec = new Vector3[positionCount];
            renderer.GetPositions(positionsVec);
            JSONObject jSONObject = new JSONObject(JSONObject.Type.ARRAY);
            for (int i = 0; i < positionCount; i++)
            {
                JSONObject vec = new JSONObject(JSONObject.Type.ARRAY);
                vec.Add(positionsVec[i].x * -1f);
                vec.Add(positionsVec[i].y);
                vec.Add(positionsVec[i].z);
                jSONObject.Add(vec);
            }
            data.AddField("positions", jSONObject);

            data.AddField("numCapVertices", renderer.numCapVertices);
            data.AddField("numCornerVertices", renderer.numCornerVertices);
#if UNITY_2017_1_OR_NEWER
            data.AddField("loop", renderer.loop);
#endif
            data.AddField("useWorldSpace", renderer.useWorldSpace);

            data.AddField("gColor", GetGradientColor(renderer.colorGradient));

            data.AddField("widthCurve", GetCurveData(renderer.widthCurve));
            data.AddField("widthMultiplier", renderer.widthMultiplier);

            return(json);
        }
Example #34
0
        public void WriteLine(string line, int height, int width, LineAlignment alignment)
        {
            int h = height + (width * 16);
            WriteData(AsciiControlChars.GroupSeparator + "!" + (char)h);

            if (alignment != LineAlignment.Justify)
                WriteData(AsciiControlChars.Escape + "a" + (char)((int)alignment));
            else
            {
                WriteData(AsciiControlChars.Escape + "a" + (char)0);
                line = AlignLine(_maxChars, width, line, alignment);
            }

            WriteData(line + (char)0xA);
        }
Example #35
0
        private static string AlignLine(int maxWidth, int width, string line, LineAlignment alignment)
        {
            maxWidth = maxWidth / (width + 1);

            switch (alignment)
            {
                case LineAlignment.Right:
                    return line.PadLeft(maxWidth, ' ');
                case LineAlignment.Center:
                    return line.PadLeft(((maxWidth + line.Length) / 2), ' ');
                case LineAlignment.Justify:
                    return JustifyText(maxWidth, line);
                default:
                    return line;
            }
        }
Example #36
0
 /// <summary>
 /// Print string to line of console, using default foreground/background colors
 /// </summary>
 /// <param name="str">String to print</param>
 /// <param name="x">x (Width) position of first character</param>
 /// <param name="y">y (Height) position of first character</param>
 /// <param name="align">Alignment of string</param>
 public void PrintLine(string str, int x, int y, LineAlignment align)
 {
     PrintLine(str, x, y, Background.Set, align);
 }
Example #37
0
        /// <summary>
        /// Print a string at a location
        /// </summary>
        void PrintLine(string msg, int x, int y, LineAlignment alignment)
        {
            //Get screen handle
            RootConsole rootConsole = RootConsole.GetInstance();

            rootConsole.PrintLine(msg, x, y, alignment);
        }
Example #38
0
 public void WriteLine(string line, int height, int width, LineAlignment alignment)
 {
     int h = height + (width * 16);
     WriteData(AsciiControlChars.GroupSeparator + "!" + (char)h);
     WriteData(line + (char)0xA);
 }
Example #39
0
 /// <summary>
 /// Print string to line of console, using default foreground/background colors
 /// </summary>
 /// <param name="str">String to print</param>
 /// <param name="x">x (Width) position of first character</param>
 /// <param name="y">y (Height) position of first character</param>
 /// <param name="flag">Background flag</param>
 /// <param name="align">Alignment of string</param>
 public void PrintLine(string str, int x, int y, Background flag, LineAlignment align)
 {
     switch (align)
     {
         case LineAlignment.Left:
             TCOD_console_print_left(m_consolePtr, x, y, flag.m_value, new StringBuilder(str));
             break;
         case LineAlignment.Center:
             TCOD_console_print_center(m_consolePtr, x, y, flag.m_value, new StringBuilder(str));
             break;
         case LineAlignment.Right:
             TCOD_console_print_right(m_consolePtr, x, y, flag.m_value, new StringBuilder(str));
             break;
     }
 }
Example #40
0
 /// <summary>
 /// Print string to line of console, using default foreground/background colors
 /// </summary>
 /// <param name="str">String to print</param>
 /// <param name="x">x (Width) position of first character</param>
 /// <param name="y">y (Height) position of first character</param>
 /// <param name="align">Alignment of string</param>
 public void PrintLine(string str, int x, int y, LineAlignment align)
 {
     PrintLine(str, x, y, new Background(BackgroundFlag.Set), align);
 }
Example #41
0
        // Align elements within a line. Note that this does not modify LayoutBounds. So if we get
        // repeated measures, the LayoutBounds remain the same in each layout.
        private void PerformLineAlignment(
            int lineStartIndex,
            int countInLine,
            double spaceAtLineStart,
            double spaceAtLineEnd,
            double lineSize,
            LineAlignment lineAlignment,
            bool isWrapping,
            Size finalSize,
            string layoutId)
        {
            for (int rangeIndex = lineStartIndex; rangeIndex < lineStartIndex + countInLine; ++rangeIndex)
            {
                var bounds = _elementManager.GetLayoutBoundsForRealizedIndex(rangeIndex);
                _orientation.SetMajorSize(ref bounds, lineSize);

                if (!_scrollOrientationSameAsFlow)
                {
                    // Note: Space at start could potentially be negative
                    if (spaceAtLineStart != 0 || spaceAtLineEnd != 0)
                    {
                        var totalSpace = spaceAtLineStart + spaceAtLineEnd;
                        var minorStart = _orientation.MinorStart(bounds);
                        switch (lineAlignment)
                        {
                        case LineAlignment.Start:
                        {
                            _orientation.SetMinorStart(ref bounds, minorStart - spaceAtLineStart);
                            break;
                        }

                        case LineAlignment.End:
                        {
                            _orientation.SetMinorStart(ref bounds, minorStart + spaceAtLineEnd);
                            break;
                        }

                        case LineAlignment.Center:
                        {
                            _orientation.SetMinorStart(ref bounds, (minorStart - spaceAtLineStart) + (totalSpace / 2));
                            break;
                        }

                        case LineAlignment.SpaceAround:
                        {
                            var interItemSpace = countInLine >= 1 ? totalSpace / (countInLine * 2) : 0;
                            _orientation.SetMinorStart(
                                ref bounds,
                                (minorStart - spaceAtLineStart) + (interItemSpace * ((rangeIndex - lineStartIndex + 1) * 2 - 1)));
                            break;
                        }

                        case LineAlignment.SpaceBetween:
                        {
                            var interItemSpace = countInLine > 1 ? totalSpace / (countInLine - 1) : 0;
                            _orientation.SetMinorStart(
                                ref bounds,
                                (minorStart - spaceAtLineStart) + (interItemSpace * (rangeIndex - lineStartIndex)));
                            break;
                        }

                        case LineAlignment.SpaceEvenly:
                        {
                            var interItemSpace = countInLine >= 1 ? totalSpace / (countInLine + 1) : 0;
                            _orientation.SetMinorStart(
                                ref bounds,
                                (minorStart - spaceAtLineStart) + (interItemSpace * (rangeIndex - lineStartIndex + 1)));
                            break;
                        }
                        }
                    }
                }

                bounds = bounds.Translate(-_lastExtent.Position);

                if (!isWrapping)
                {
                    _orientation.SetMinorSize(
                        ref bounds,
                        Math.Max(_orientation.MinorSize(bounds), _orientation.Minor(finalSize)));
                }

                var element = _elementManager.GetAt(rangeIndex);
                element.Arrange(bounds);
            }
        }
Example #42
0
 /// <summary>
 /// Print aligned string inside the defined rectangle, truncating if bottom is reached
 /// </summary>
 /// <param name="str">String to print</param>
 /// <param name="x">x (Width) position of first character</param>
 /// <param name="y">y (Height) position of first character</param>
 /// <param name="w">Width of rectangle to print in</param>
 /// <param name="h">Height of rectangle to print in. If 0, string is only truncated if reaches bottom of console.</param>
 /// <param name="flag">Background flag</param>
 /// <param name="align">Alignment of string</param>
 /// <returns>Number of lines printed</returns>
 public int PrintLineRect(string str, int x, int y, int w, int h, Background flag, LineAlignment align)
 {
     switch (align)
     {
         case LineAlignment.Left:
             return TCOD_console_print_left_rect(m_consolePtr, x, y, w, h, flag.m_value, new StringBuilder(str));
         case LineAlignment.Center:
             return TCOD_console_print_center_rect(m_consolePtr, x, y, w, h, flag.m_value, new StringBuilder(str));
         case LineAlignment.Right:
             return TCOD_console_print_right_rect(m_consolePtr, x, y, w, h, flag.m_value, new StringBuilder(str));
         default:
             throw new Exception("Must Pass Alignment to PrintLineRect");
     }
 }
Example #43
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="alignment">输出对齐方式</param>
 public EscPosSetLineAlignment(LineAlignment alignment)
 {
     this.Alignment = alignment;
 }
Example #44
0
 /// <summary>
 /// Print aligned string inside the defined rectangle, truncating if bottom is reached
 /// </summary>
 /// <param name="str">String to print</param>
 /// <param name="x">x (Width) position of first character</param>
 /// <param name="y">y (Height) position of first character</param>
 /// <param name="w">Width of rectangle to print in</param>
 /// <param name="h">Height of rectangle to print in. If 0, string is only truncated if reaches bottom of console.</param>
 /// <param name="align">Alignment of string</param>
 /// <returns>Number of lines printed</returns>
 public int PrintLineRect(string str, int x, int y, int w, int h, LineAlignment align)
 {
     return PrintLineRect(str, x, y, w, h, Background.Set, align);
 }