Esempio n. 1
0
        /// <summary>
        /// Get a new copy whose background color was set.
        /// </summary>
        /// <returns>new instance</returns>
        public TextDecoration GetCopyWithBackColor(ColorSpec backColor)
        {
            GAttr    newAttr;
            GColor24 newColor24 = new GColor24();

            newColor24.ForeColor = _color24.ForeColor;

            switch (backColor.ColorType)
            {
            case ColorType.Custom8bit:
                newAttr = _attr.CopyWith8bitBackColor(backColor.ColorCode);
                break;

            case ColorType.Custom24bit:
                newAttr = _attr.CopyWith24bitBackColor();
                newColor24.BackColor = backColor.Color;
                break;

            default:
            case ColorType.Default:
                newAttr = _attr.CopyWithDefaultBackColor();
                break;
            }
            return(new TextDecoration(newAttr, newColor24));
        }
Esempio n. 2
0
 private Color DetermineNormalForeColor(GAttr attr, GColor24 color24)
 {
     if (attr.Has(GAttrFlags.Use8bitForeColor))
     {
         return(GetESForeColor(attr.ForeColor));
     }
     if (attr.Has(GAttrFlags.Use24bitForeColor))
     {
         return(color24.ForeColor);
     }
     return(this.ForeColor);
 }
Esempio n. 3
0
 private Color DetermineNormalBackColor(GAttr attr, GColor24 color24)
 {
     if (attr.Has(GAttrFlags.Use8bitBackColor))
     {
         return(GetESBackColor(attr.BackColor));
     }
     if (attr.Has(GAttrFlags.Use24bitBackColor))
     {
         return(color24.BackColor);
     }
     return(this.BackColor);
 }
Esempio n. 4
0
        public TextDecoration(Color backColor, Color foreColor, bool underline, bool bold)
        {
            _color24           = new GColor24();
            _color24.ForeColor = foreColor;
            _color24.BackColor = backColor;
            GAttrFlags flags = GAttrFlags.Use24bitBackColor | GAttrFlags.Use24bitForeColor;

            if (underline)
            {
                flags = flags | GAttrFlags.Underlined;
            }
            if (bold)
            {
                flags = flags | GAttrFlags.Bold;
            }
            _attr = new GAttr(0, 1, flags);
        }
Esempio n. 5
0
        internal void DetermineColors(GAttr attr, GColor24 color24, Caret caret, Color baseBackColor, out Color backColor, out Color foreColor)
        {
            if (_brush == null)
            {
                CreateBrushes();
            }

            bool inverted = attr.Has(GAttrFlags.Inverted) ^ attr.Has(GAttrFlags.Selected);

            bool blinkStatus = caret.IsActiveTick;

            if (attr.Has(GAttrFlags.Cursor) && (!caret.Blink || blinkStatus))
            {
                if (inverted)
                {
                    // paint as normal
                    backColor = DetermineActualBackColor(caret.Color.IsEmpty ? DetermineNormalBackColor(attr, color24) : caret.Color, baseBackColor);
                    foreColor = DetermineNormalForeColor(attr, color24);
                }
                else
                {
                    // paint as inverted
                    backColor = DetermineActualBackColor(caret.Color.IsEmpty ? DetermineNormalForeColor(attr, color24) : caret.Color, baseBackColor);
                    foreColor = DetermineNormalBackColor(attr, color24);
                }
            }
            else
            {
                bool isHidden = attr.Has(GAttrFlags.Hidden) || (attr.Has(GAttrFlags.Blink) && !blinkStatus);

                if (inverted)
                {
                    backColor = DetermineActualBackColor(DetermineNormalForeColor(attr, color24), baseBackColor);
                    foreColor = isHidden ? Color.Transparent : DetermineNormalBackColor(attr, color24);
                }
                else
                {
                    backColor = DetermineActualBackColor(DetermineNormalBackColor(attr, color24), baseBackColor);
                    foreColor = isHidden ? Color.Transparent : DetermineNormalForeColor(attr, color24);
                }
            }
        }
Esempio n. 6
0
 private TextDecoration(GAttr attr, GColor24 color24)
 {
     _attr    = attr;
     _color24 = color24;
 }