Source/TextMarkup/TextElement.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Drawing;
using System.Text;

#if AdvTree
namespace DevComponents.Tree.TextMarkup
#elif DOTNETBAR
namespace DevComponents.DotNetBar.TextMarkup
#endif
{
    internal class TextElement : MarkupElement
    {
        #region Private Variables
        private string m_Text = "";
        private bool m_TrailingSpace = false;
        private bool m_EnablePrefixHandling = true;
        #endregion

        #region Internal Implementation
        public override void Measure(System.Drawing.Size availableSize, MarkupDrawContext d)
        {
            StringFormat format = new StringFormat(StringFormat.GenericTypographic);
            format.FormatFlags = StringFormatFlags.NoWrap;
            if (d.HotKeyPrefixVisible || !m_EnablePrefixHandling)
                format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;
            else
                format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Hide;

            if (m_TrailingSpace)
            {
                if (d.CurrentFont.Italic)
                {
                    Size size=Size.Ceiling(d.Graphics.MeasureString(m_Text, d.CurrentFont, 0, format));
                    size.Width += (int)(d.Graphics.MeasureString("|", d.CurrentFont).Width / 4);
                    this.Bounds = new Rectangle(Point.Empty, size);
                }
                else
                    this.Bounds = new Rectangle(Point.Empty, Size.Ceiling(d.Graphics.MeasureString(m_Text + "|", d.CurrentFont, 0, format)));
            }
            else
                this.Bounds = new Rectangle(Point.Empty, Size.Ceiling(d.Graphics.MeasureString(m_Text, d.CurrentFont, 0, format)));
            
            IsSizeValid = true;
        }

        public override void Render(MarkupDrawContext d)
        {
            Rectangle r = this.Bounds;
            r.Offset(d.Offset);

            if (!d.ClipRectangle.IsEmpty && !r.IntersectsWith(d.ClipRectangle))
                return;
            
            StringFormat format = new StringFormat(StringFormat.GenericTypographic);
            format.FormatFlags = StringFormatFlags.NoWrap;
            if (d.RightToLeft) format.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
            if (d.HotKeyPrefixVisible)
                format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;
            else
                format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Hide;
后面还有 60 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。