当前位置: 首页>>代码示例>>C#>>正文


C# GUI.StyledText类代码示例

本文整理汇总了C#中NetGore.Graphics.GUI.StyledText的典型用法代码示例。如果您正苦于以下问题:C# StyledText类的具体用法?C# StyledText怎么用?C# StyledText使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StyledText类属于NetGore.Graphics.GUI命名空间,在下文中一共展示了StyledText类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StyledText

        /// <summary>
        /// Initializes a new instance of the <see cref="StyledText"/> class.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="sourceStyle">The StyledText to copy the style from.</param>
        public StyledText(string text, StyledText sourceStyle)
        {
            text = text.Replace("\r\n", "\n");
            text = text.Replace("\r", "\n");

            _text = text;
            _color = sourceStyle.Color;
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:13,代码来源:StyledText.cs

示例2: ConcastTestA

        public void ConcastTestA()
        {
            var s1 = new StyledText("abcd", Color.Black);
            var s2 = new StyledText("123", Color.Black);
            var s3 = new StyledText("xyz", Color.Black);
            var concat = StyledText.Concat(new StyledText[] { s1, s2, s3 });

            Assert.AreEqual(1, concat.Count());
            Assert.AreEqual(s1.Text + s2.Text + s3.Text, concat.First().Text);
            Assert.IsTrue(s1.HasSameStyle(concat.First()));
        }
开发者ID:Furt,项目名称:netgore,代码行数:11,代码来源:StyledTextTests.cs

示例3: ConstructorCopyStyleTest

        public void ConstructorCopyStyleTest()
        {
            const string originalString = "asdf werljk xov  .qw 120 xcv;z";
            var s = new StyledText(originalString, Color.Black);
            var s2 = new StyledText("ffjfjfj", s);

            Assert.AreEqual(originalString, s.Text);
            Assert.AreEqual("ffjfjfj", s2.Text);

            Assert.AreEqual(Color.Black, s.Color);
            Assert.AreEqual(Color.Black, s2.Color);
        }
开发者ID:Furt,项目名称:netgore,代码行数:12,代码来源:StyledTextTests.cs

示例4: ConcastTestB

        public void ConcastTestB()
        {
            var s1 = new StyledText("abcd", Color.Black);
            var s2 = new StyledText("123", Color.Black);
            var s3 = new StyledText("xyz", Color.White);
            var concat = StyledText.Concat(new StyledText[] { s1, s2, s3 }).ToArray();

            Assert.AreEqual(2, concat.Count());
            Assert.AreEqual(s1.Text + s2.Text, concat[0].Text);
            Assert.AreEqual(s3.Text, concat[1].Text);
            Assert.IsTrue(s1.HasSameStyle(concat[0]));
            Assert.IsTrue(s3.HasSameStyle(concat[1]));
        }
开发者ID:Furt,项目名称:netgore,代码行数:13,代码来源:StyledTextTests.cs

示例5: SubstringWithLengthTest

        public void SubstringWithLengthTest()
        {
            const string originalString = "asdf werljk xov  .qw 120 xcv;z";
            var s = new StyledText(originalString, Color.Black);
            var s2 = s.Substring(5, 4);

            Assert.AreEqual(s.Text, originalString);
            Assert.AreEqual(Color.Black, s.Color);

            Assert.AreEqual(originalString.Substring(5, 4), s2.Text);
            Assert.AreEqual(Color.Black, s2.Color);
        }
开发者ID:Furt,项目名称:netgore,代码行数:12,代码来源:StyledTextTests.cs

示例6: ToStringTest

        public void ToStringTest()
        {
            var a = new StyledText("abc", Color.Red);
            var b = new StyledText("123", a);

            Assert.AreEqual("abc", a.ToString());
            Assert.AreEqual("123", b.ToString());
        }
开发者ID:Furt,项目名称:netgore,代码行数:8,代码来源:StyledTextTests.cs

示例7: IEnumerableToStringTest

        public void IEnumerableToStringTest()
        {
            var a = new StyledText("abc");
            var b = new StyledText("123");
            var c = new StyledText("xyz");
            var v = new StyledText[] { a, b, c };

            Assert.AreEqual("abc123xyz", StyledText.ToString(v));
        }
开发者ID:Furt,项目名称:netgore,代码行数:9,代码来源:StyledTextTests.cs

示例8: ToMultiline

        public static List<StyledText> ToMultiline(StyledText text)
        {
            var ret = new List<StyledText>();

            var split = text.Split('\n');
            foreach (var s in split)
            {
                var newS = new StyledText(s.Text.Replace('\r'.ToString(), string.Empty), s);
                ret.Add(newS);
            }

            return ret;
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:13,代码来源:StyledText.cs

示例9: SplitAt

        /// <summary>
        /// Splits the <see cref="StyledText"/> at the given index into two parts. The character at the given
        /// <paramref name="charIndex"/> will end up in the <paramref name="right"/> side.
        /// </summary>
        /// <param name="charIndex">The 0-based character index to split at.</param>
        /// <param name="left">The left side of the split.</param>
        /// <param name="right">The right side of the split.</param>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="charIndex"/> is less than 0 or greater
        /// than the length of the <see cref="Text"/>.</exception>
        public void SplitAt(int charIndex, out StyledText left, out StyledText right)
        {
            if (charIndex < 0 || charIndex > Text.Length)
                throw new ArgumentOutOfRangeException("charIndex");

            if (charIndex == 0)
            {
                left = new StyledText(string.Empty, this);
                right = this;
            }
            else if (charIndex == Text.Length)
            {
                left = this;
                right = new StyledText(string.Empty, this);
            }
            else
            {
                left = Substring(0, charIndex);
                right = Substring(charIndex);
            }
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:30,代码来源:StyledText.cs

示例10: Split

        /// <summary>
        /// Splits the <see cref="StyledText"/> into multiple pieces using the given <paramref name="separator"/>.
        /// </summary>
        /// <param name="separator">An array of Unicode characters that delimit the substrings in this instance,
        /// an empty array that contains no delimiters, or null.</param>
        /// <param name="count">The maximum number of substrings to return.</param>
        /// <returns>An array containing the pieces of the <see cref="StyledText"/> split using the given
        /// <paramref name="separator"/>.</returns>
        public StyledText[] Split(char[] separator, int count)
        {
            var strings = Text.Split(separator, count);

            var ret = new StyledText[strings.Length];
            for (var i = 0; i < ret.Length; i++)
            {
                if (strings[i] == Text)
                    ret[i] = this;
                else
                    ret[i] = new StyledText(strings[i], Color);
            }

            return ret;
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:23,代码来源:StyledText.cs

示例11: Concat

        public static List<StyledText> Concat(StyledText[] input)
        {
            var ret = new List<StyledText>(input.Length);

            for (var i = 0; i < input.Length; i++)
            {
                var current = input[i];
                while (i + 1 < input.Length && current.HasSameStyle(input[i + 1]))
                {
                    current += input[i + 1].Text;
                    i++;
                }
                ret.Add(current);
            }

            return ret;
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:17,代码来源:StyledText.cs

示例12: Insert

 /// <summary>
 /// Inserts the <paramref name="text"/> into the <see cref="TextBox"/> at the current cursor position.
 /// </summary>
 /// <param name="text">The text to insert.</param>
 public void Insert(StyledText text)
 {
     _lines.CurrentLine.Insert(text, CursorLinePosition);
     ((IEditableText)this).MoveCursor(MoveCursorDirection.Right);
     _numCharsToDraw.Invalidate();
     TruncateIfNeeded();
 }
开发者ID:mateuscezar,项目名称:netgore,代码行数:11,代码来源:TextBox.cs

示例13: Append

        /// <summary>
        /// Appends the <paramref name="text"/> to the <see cref="TextBox"/> at the end.
        /// </summary>
        /// <param name="text">The text to append.</param>
        public void Append(StyledText text)
        {
            if (text.Text.Length == 0)
                return;

            if (!IsMultiLine)
                _lines.LastLine.Append(text.ToSingleline());
            else
            {
                var textLines = StyledText.ToMultiline(text);
                _lines.LastLine.Append(textLines[0]);

                for (var i = 1; i < textLines.Count; i++)
                {
                    var newLine = new TextBoxLine(_lines);
                    _lines.Insert(_lines.Count, newLine);
                    newLine.Append(textLines[i]);
                }

                TruncateIfNeeded();
            }

            _numCharsToDraw.Invalidate();

            _hasTextChanged = true;
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:30,代码来源:TextBox.cs

示例14: SplitStringsWithOptionsTest

        public void SplitStringsWithOptionsTest()
        {
            const string originalString = "asdf werljk xov  .qw 120 xcv;z";
            var s = new StyledText(originalString, Color.Black);
            var split = s.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            var expected = originalString.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);

            for (var i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(s.Color, split[i].Color);
                Assert.AreEqual(expected[i], split[i].Text);
            }
        }
开发者ID:Furt,项目名称:netgore,代码行数:13,代码来源:StyledTextTests.cs

示例15: SplitCharsWithCountTest

        public void SplitCharsWithCountTest()
        {
            const string originalString = "asdf werljk xov  .qw 120 xcv;z";
            var s = new StyledText(originalString, Color.Black);
            var split = s.Split(new char[] { ' ' }, 2);
            var expected = originalString.Split(new char[] { ' ' }, 2);

            for (var i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(s.Color, split[i].Color);
                Assert.AreEqual(expected[i], split[i].Text);
            }
        }
开发者ID:Furt,项目名称:netgore,代码行数:13,代码来源:StyledTextTests.cs


注:本文中的NetGore.Graphics.GUI.StyledText类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。