示例#1
0
        public override void Render(Container c, GuiStyle s)
        {
            Color fg, bg;

            if (IsSelected)
            {
                fg = c.Back;
                bg = front;
            }
            else
            {
                fg = front;
                bg = c.Back;
            }

            var str = text.Substring(0, Math.Min(textWidth, text.Length)).PadRight(textWidth);

            Screen.DrawString(position, str, fg, bg);

            var valStr        = currentValue.ToString();
            var valStrCropped = valStr.Substring(0, Math.Min(valueWidth, valStr.Length)).PadLeft(valueWidth);

            var valStrComplete = $"<{valStrCropped}>";

            Screen.DrawString(position + new Position(textWidth + 1, 0), valStrComplete, front, c.Back);
        }
示例#2
0
        public override void Render(Container c, GuiStyle s)
        {
            // Retrieve colors to use for renderering
            Color fg = style.OverrideForegroundColor ? style.Foreground : s.Foreground;
            Color bg = style.OverrideBackgroundColor ? style.Background : s.Background;

            // Invert colors on selection if requested
            if (IsSelected && style.InvertOnSelection)
            {
                fg.Swap(ref bg);
            }

            // Determine width
            var width = style.Width == ButtonStyle.AutoWidth ? text.Length : style.Width;

            // Create button string from appropiate template
            var template = IsSelected ? style.SelectedTemplate : style.NonSelectedTemplate;

            // The user can specify a special text color for inverted color mode.
            // If that is the case, only the actual button text is colored with this
            // special color, not any of the characters that might be present in the template
            // string.
            if (style.OverrideInvertedForegroundColor && IsSelected)
            {
                var pos = template.IndexOf("{0}");

                var prefix  = template.Substring(0, pos);
                var postfix = template.Substring(pos + 3);

                var buttonText = text.Substring(0, Math.Min(width, text.Length)).PadBoth(width);

                Screen.DrawString(position, prefix, fg, bg);
                Screen.DrawString(position + new Position(prefix.Length, 0), buttonText, style.InvertedForeground, bg);
                Screen.DrawString(position + new Position(prefix.Length + buttonText.Length, 0), postfix, fg, bg);
            }
            else // Normal case, everything is colored in the same way
            {
                var buttonText = String.Format(template,
                                               text.Substring(0, Math.Min(width, text.Length)).PadBoth(width));

                // Center text and draw to screen
                Screen.DrawString(position, buttonText, fg, bg);
            }
        }
示例#3
0
 public abstract void Render(Container c, GuiStyle s);
示例#4
0
 public override void Render(Container c, GuiStyle s)
 {
     Screen.DrawString(position, text, front, c.Back);
 }
示例#5
0
 public GuiStyle(GuiStyle other)
 {
     Background  = other.Background;
     Foreground  = other.Foreground;
     ButtonStyle = new ButtonStyle(other.ButtonStyle);
 }