⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rich_string.cs

📁 破解的飞信源代码
💻 CS
📖 第 1 页 / 共 3 页
字号:
            using (Font font2 = new Font("Times New Roman", font.Size, font.Style | FontStyle.Bold))
            {
                using (Brush brush = new SolidBrush(foreColor))
                {
                    g.MeasureString("...", font);
                    int num5 = this.rich_text.get_Count();
                    for (int i = 0; i < num5; i++)
                    {
                        pair<object, SizeF> pair = this.rich_text.get_Item(i);
                        if (left >= right)
                        {
                            if (!calcMode)
                            {
                                goto Label_02D0;
                            }
                            flag = false;
                        }
                        SizeF empty = SizeF.Empty;
                        if (pair.first is string)
                        {
                            empty = g.MeasureString(pair.first as string, font, 0x7fffffff, fmt);
                            if (flag)
                            {
                                RectangleF layoutRectangle = RectangleF.FromLTRB(left, top, right, bottom);
                                g.DrawString(pair.first as string, font, brush, layoutRectangle, fmt);
                            }
                        }
                        else
                        {
                            if (!(pair.first is AmigoImage))
                            {
                                throw new Exception("Unsupport rich_string inner object");
                            }
                            if (calcMode)
                            {
                                empty = new SizeF(16f, 16f);
                            }
                            if (flag)
                            {
                                float num7 = right;
                                if ((left + 16f) <= num7)
                                {
                                    g.DrawImage(((AmigoImage) pair.first).PreviewImage, (int) left, (int) (top + ((rc.Height - 16f) / 2f)), 0x10, 0x10);
                                    if ((i == 0) && flag2)
                                    {
                                        RectangleF ef4 = RectangleF.FromLTRB(left + 16f, top - 3f, right, bottom);
                                        fmt.Trimming = StringTrimming.None;
                                        g.DrawString("...", font2, brush, ef4, fmt);
                                        flag = false;
                                    }
                                }
                                else
                                {
                                    RectangleF ef5 = RectangleF.FromLTRB(left - 2f, top - 3f, right, bottom);
                                    g.DrawString("...", font2, brush, ef5, fmt);
                                    flag = false;
                                }
                            }
                        }
                        if (calcMode)
                        {
                            pair.second = empty;
                            this._szPrefered.Width += empty.Width;
                            if (this._szPrefered.Height < empty.Height)
                            {
                                this._szPrefered.Height = empty.Height;
                            }
                        }
                        left += pair.second.Width;
                    }
                }
            }
        Label_02D0:
            if (calcMode)
            {
                this._szPrefered.Width += 1f;
            }
            if (left > right)
            {
                left = right;
            }
            offset = (int) Math.Ceiling((double) left);
        }

        public void DrawMultiLineMode(Graphics g, Font font, Color foreColor, RectangleF rc, int maxLines)
        {
            float left = rc.Left;
            float top = rc.Top;
            int num3 = 0x12;
            using (Font font2 = new Font(font, font.Style | FontStyle.Underline))
            {
                using (Brush brush = new SolidBrush(Color.Blue))
                {
                    using (Brush brush2 = new SolidBrush(Color.Purple))
                    {
                        using (StringFormat stringFormat = new StringFormat())
                        {
                            using (Brush brush3 = new SolidBrush(foreColor))
                            {
                                stringFormat.Alignment = StringAlignment.Near;
                                stringFormat.LineAlignment = StringAlignment.Near;
                                stringFormat.FormatFlags = StringFormatFlags.NoWrap;
                                stringFormat.Trimming = StringTrimming.Character;
                                stringFormat.HotkeyPrefix = HotkeyPrefix.None;
                                int num4 = 0;
                                List<pair<object, SizeF>>.Enumerator enumerator = this.rich_text.GetEnumerator();
                                try
                                {
                                    while (enumerator.MoveNext())
                                    {
                                        pair<object, SizeF> pair = enumerator.get_Current();
                                        if ((pair.first is string) || (pair.first is rich_string_link))
                                        {
                                            string first = string.Empty;
                                            if (pair.first is string)
                                            {
                                                first = (string) pair.first;
                                            }
                                            else
                                            {
                                                first = ((rich_string_link) pair.first).URL;
                                            }
                                            bool flag = false;
                                            if ((first.Length > 2) && (first.Substring(first.Length - 2, 2) == "\r\n"))
                                            {
                                                flag = true;
                                            }
                                            string[] textArray = new string[] { "\r\n" };
                                            string[] textArray2 = first.Split(textArray, 1);
                                            int index = 0;
                                            int upperBound = textArray2.GetUpperBound(0);
                                            for (index = 0; index <= upperBound; index++)
                                            {
                                                int charactersFitted;
                                                int linesFilled;
                                                SizeF layoutArea;
                                                first = textArray2[index];
                                            Label_0154:
                                                layoutArea = new SizeF(rc.Right - left, (float) num3);
                                                SizeF ef2 = g.MeasureString(first, font, layoutArea, stringFormat, out charactersFitted, out linesFilled);
                                                if (ef2.Width > layoutArea.Width)
                                                {
                                                    charactersFitted = 0;
                                                }
                                                if (charactersFitted > 0)
                                                {
                                                    string text = first.Substring(0, charactersFitted);
                                                    Brush brush4 = brush3;
                                                    if (this._linkSupport && (pair.first is rich_string_link))
                                                    {
                                                        SizeF ef3 = g.MeasureString(text, font);
                                                        ((rich_string_link) pair.first).PosRect = RectangleF.FromLTRB(left, top, left + ef3.Width, top + ef3.Height);
                                                        if (((rich_string_link) pair.first).Clicked)
                                                        {
                                                            brush4 = brush2;
                                                        }
                                                        else
                                                        {
                                                            brush4 = brush;
                                                        }
                                                    }
                                                    if (num4 >= (maxLines - 1))
                                                    {
                                                        stringFormat.Trimming = StringTrimming.EllipsisCharacter;
                                                        g.DrawString(first, font, brush4, new RectangleF(left, top, layoutArea.Width, layoutArea.Height), stringFormat);
                                                    }
                                                    else
                                                    {
                                                        stringFormat.Trimming = StringTrimming.Character;
                                                        g.DrawString(text, font, brush4, left, top, stringFormat);
                                                    }
                                                }
                                                if (charactersFitted < first.Length)
                                                {
                                                    num4++;
                                                    if ((maxLines > 0) && (num4 >= maxLines))
                                                    {
                                                        return;
                                                    }
                                                    if (charactersFitted > 0)
                                                    {
                                                        first = first.Substring(charactersFitted);
                                                    }
                                                    left = rc.Left;
                                                    top += num3;
                                                    goto Label_0154;
                                                }
                                                left += ef2.Width;
                                                string text3 = first.Substring(0, charactersFitted);
                                                text3.ToLower();
                                                if ((text3.Length > 2) && (text3.Substring(text3.Length - 2, 2) == @"\r\n"))
                                                {
                                                    left = rc.Left;
                                                    top += num3;
                                                }
                                                if ((index != upperBound) && (left != 0f))
                                                {
                                                    num4++;
                                                    if ((maxLines > 0) && (num4 >= maxLines))
                                                    {
                                                        return;
                                                    }
                                                    left = rc.Left;
                                                    top += num3;
                                                }
                                            }
                                            if (flag && (left != 0f))
                                            {
                                                num4++;
                                                if ((maxLines > 0) && (num4 >= maxLines))
                                                {
                                                    return;
                                                }
                                                left = rc.Left;
                                                top += num3;
                                            }
                                        }
                                        else
                                        {
                                            if (!(pair.first is AmigoImage))
                                            {
                                                throw new Exception("Unsupport rich_string inner object");
                                            }
                                            if ((left + 16f) > rc.Right)
                                            {
                                                num4++;
                                                if ((maxLines > 0) && (num4 >= maxLines))
                                                {
                                                    return;
                                                }
                                                left = rc.Left;
                                                top += num3;
                                            }
                                            g.DrawImage(((AmigoImage) pair.first).PreviewImage, (int) left, (int) top, 0x10, 0x10);
                                            left += 16f;
                                            continue;
                                        }
                                    }
                                }
                                finally
                                {
                                    enumerator.Dispose();
                                }
                            }
                        }
                    }
                }
            }
        }

        public SizeF MeasureMultiLineMode(Graphics g, Font font, int width, int maxLines, out int line)
        {
            float num = 0f;
            int num2 = 0x12;
            SizeF ef = new SizeF(0f, (float) num2);
            line = 0;
            if (!string.IsNullOrEmpty(this.plane_text))
            {
                line++;
                using (StringFormat stringFormat = new StringFormat())
                {
                    stringFormat.Alignment = StringAlignment.Near;
                    stringFormat.LineAlignment = StringAlignment.Near;
                    stringFormat.FormatFlags = StringFormatFlags.NoClip | StringFormatFlags.LineLimit | StringFormatFlags.FitBlackBox;
                    stringFormat.Trimming = StringTrimming.None;
                    stringFormat.FormatFlags = StringFormatFlags.NoWrap;
                    stringFormat.Trimming = StringTrimming.Character;
                    stringFormat.HotkeyPrefix = HotkeyPrefix.None;
                    List<pair<object, SizeF>>.Enumerator enumerator = this.rich_text.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            pair<object, SizeF> pair = enumerator.get_Current();
                            if ((pair.first is string) || (pair.first is rich_string_link))
                            {
                                string first = string.Empty;
                                if (pair.first is string)
                                {
                                    first = (string) pair.first;
                                }
                                else
                                {
                                    first = ((rich_string_link) pair.first).URL;
                                }
                                string[] textArray = new string[] { "\r\n" };
                                string[] textArray2 = first.Split(textArray, 1);
                                int index = 0;
                                int upperBound = textArray2.GetUpperBound(0);
                                for (index = 0; index <= upperBound; index++)
                                {
                                    SizeF ef3;
                                    first = textArray2[index];
                                    while (true)
                                    {
                                        int charactersFitted;
                                        int linesFilled;
                                        SizeF layoutArea = new SizeF(width - num, (float) num2);
                                        ef3 = g.MeasureString(first, font, layoutArea, stringFormat, out charactersFitted, out linesFilled);
                                        if (ef3.Width > layoutArea.Width)
                                        {
                                            charactersFitted = 0;
                                        }
                                        if (charactersFitted >= first.Length)
                                        {
                                            break;
                                        }
                                        if (ef.Width < num)
                                        {
                                            ef.Width = num;
                                        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -