當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。