/// <summary>
        /// Draws a multiline text using the Primitives spritebatch.
        /// </summary>
        /// <param name="text">Text to be drawn.</param>
        /// <param name="rectangle">The rectangle bounding the text.</param>
        /// <param name="color">Text color.</param>
        /// <param name="font">Text font (Verdana 14, if null).</param>
        /// <param name="alignment">Text alignment.</param>
        public static void DrawMultiLineText(
            string text,
            Rectangle rectangle,
            Color color,
            FontFamily font         = FontFamily.Small,
            TextAlignment alignment = TextAlignment.TopLeft)
        {
            Rectangle       empty;
            MultilineString ms = new MultilineString(text, rectangle, alignment, font, Vector2.Zero, true, null, color);

            foreach (MultilineString msCache in multilineStringCache)
            {
                if (ms.Equals(msCache))
                {
                    foreach (MultilineFragment line in msCache.CachedLines)
                    {
                        if (line.Icon != null)
                        {
                            spriteBatch.Draw(line.Icon,
                                             new Rectangle(rectangle.X + (int)line.PositionOffset.X, rectangle.Y + (int)line.PositionOffset.Y,
                                                           line.IconWidth, line.IconWidth), Color.White);
                        }
                        else
                        {
                            if (line.Color != color)
                            {
                                /*
                                 * Color shadowColor = line.Color.Alpha(120);
                                 * spriteBatch.DrawString(line.Font, line.Text,
                                 *  new Vector2(rectangle.X + (int)line.PositionOffset.X - 1,
                                 *  rectangle.Y + (int)line.PositionOffset.Y - 1), shadowColor);
                                 * spriteBatch.DrawString(line.Font, line.Text,
                                 *  new Vector2(rectangle.X + (int)line.PositionOffset.X + 1,
                                 *  rectangle.Y + (int)line.PositionOffset.Y - 1), shadowColor);
                                 * spriteBatch.DrawString(line.Font, line.Text,
                                 *  new Vector2(rectangle.X + (int)line.PositionOffset.X - 1,
                                 *  rectangle.Y + (int)line.PositionOffset.Y + 1), shadowColor);
                                 * spriteBatch.DrawString(line.Font, line.Text,
                                 *  new Vector2(rectangle.X + (int)line.PositionOffset.X + 1,
                                 *  rectangle.Y + (int)line.PositionOffset.Y + 1), shadowColor);
                                 */
                            }
                            spriteBatch.DrawString(line.Font, line.Text,
                                                   new Vector2(rectangle.X + (int)line.PositionOffset.X,
                                                               rectangle.Y + (int)line.PositionOffset.Y), line.Color);
                        }
                    }
                    return;
                }
            }
            List <MultilineFragment> cachedLines;

            Primitives.SetupNewMultilineString(font, text, rectangle, color, alignment, out empty, out cachedLines);
            multilineStringCache.Add(new MultilineString(text, rectangle, alignment, font, Vector2.Zero, true, cachedLines, color));
            Primitives.DrawMultiLineText(text, rectangle, color, font, alignment);
        }
コード例 #2
0
        public override void Draw()
        {
            IsMouseOverThis = Root.IsMouseOver(Rectangle);
            bool  pressed          = IsMouseOverThis && Root.Mouse_NewState.LeftButton == ButtonState.Pressed;
            Color outerBorderColor = IsMouseOverThis ? Skin.OuterBorderColorMouseOver : Skin.OuterBorderColor;
            Color innerBorderColor = pressed ? Skin.InnerBorderColorMousePressed : (IsMouseOverThis ? Skin.InnerBorderColorMouseOver : Skin.InnerBorderColor);
            Color innerButtonColor = IsMouseOverThis ? Skin.GreyBackgroundColorMouseOver: Skin.GreyBackgroundColor;
            Color textColor        = IsMouseOverThis ? Skin.TextColorMouseOver : Skin.TextColor;

            Primitives.FillRectangle(Rectangle, innerBorderColor);
            Primitives.DrawRectangle(Rectangle, outerBorderColor, Skin.OuterBorderThickness);
            Primitives.DrawAndFillRectangle(InnerRectangleWithBorder, innerButtonColor, outerBorderColor, Skin.OuterBorderThickness);
            Primitives.DrawMultiLineText(Caption, InnerRectangle, textColor, Skin.Font, Primitives.TextAlignment.Middle);
        }
コード例 #3
0
        public override void Draw(SpriteBatch sb, Game game, float elapsedSeconds)
        {
            Rectangle rectBox   = new Rectangle(TopLeftX, TopLeftY, Width, Height);
            Rectangle rectTitle = new Rectangle(TopLeftX, TopLeftY, Width, 28);

            Primitives.DrawAndFillRectangle(rectBox, Skin.DialogBackgroundColor, Skin.OuterBorderColor, Skin.OuterBorderThickness);
            Primitives.DrawAndFillRectangle(rectTitle, Skin.InnerBorderColor, Skin.OuterBorderColor, Skin.OuterBorderThickness);
            Primitives.DrawSingleLineText(Caption, new Vector2(TopLeftX + 5, TopLeftY + 3), Skin.TextColor, Skin.Font);
            if (Icon != GUIIcon.None)
            {
                sb.Draw(Library.GetTexture2DFromGUIIcon(Icon), new Rectangle(rectBox.X + 5, rectBox.Y + 60, 45, 45), Color.White);
            }
            Primitives.DrawMultiLineText(Text, new Rectangle(rectBox.X + 55, rectBox.Y + 50, rectBox.Width - 65, rectBox.Height - 40), Skin.TextColor, Skin.Font, Primitives.TextAlignment.Top);
            foreach (Button b in Buttons)
            {
                b.Draw();
            }
            base.Draw(sb, game, elapsedSeconds);
        }
コード例 #4
0
ファイル: Textbox.cs プロジェクト: Soothsilver/flutter
        public override void Draw()
        {
            string txt = Text;

            if (IsPassword)
            {
                txt = "";
                for (int i = 0; i < Text.Length; i++)
                {
                    txt += "*";
                }
            }
            Color outerBorderColor = Skin.OuterBorderColor;
            Color innerBorderColor = Skin.InnerBorderColor;
            Color innerButtonColor = Skin.WhiteBackgroundColor;
            Color textColor        = Skin.TextColor;

            Primitives.FillRectangle(Rectangle, Color.FromNonPremultiplied(226, 187, 50, 255));//Color.White);
            Primitives.DrawRectangle(Rectangle, Color.Black, 2);
            //     Primitives.DrawAndFillRectangle(InnerRectangleWithBorder, innerButtonColor, outerBorderColor, Skin.OuterBorderThickness);
            Primitives.DrawMultiLineText(txt + ((int)(Root.SecondsSinceStart * 2) % 2 == 0 && IsActive ? "|" : ""), new Rectangle(Rectangle.X + 8, Rectangle.Y + 3 + 2, Rectangle.Width - 10, Rectangle.Height - 4), textColor, Library.FontConsoleNormal, Primitives.TextAlignment.TopLeft);
        }