Example #1
0
 public void DrawString(string text, Vector2 pos, float size, float align = 0, Color? color = null)
 {
     var c = color.GetValueOrDefault(Color.LightYellow);
     var valign = new Vector2(Font.MeasureString(text).X*align, 0);
     size *= FontScaleRatio;
     SpriteBatch.DrawString(
         Font,
         text,
         pos + Vector2.One,
         Color.Black*(c.A/255f),
         0,
         valign,
         size,
         SpriteEffects.None,
         0);
     SpriteBatch.DrawString(
         Font,
         text,
         pos,
         c,
         0,
         valign,
         size,
         SpriteEffects.None,
         0);
 }
Example #2
0
 private void logl(string msg, Color? color = null)
 {
     int start = LogBox.TextLength;
     LogBox.AppendText(msg);
     int end = LogBox.TextLength;
     LogBox.Select(start, end - start);
     LogBox.SelectionColor = color.GetValueOrDefault(Color.Black);
     LogBox.SelectionLength = 0;
 }
 public virtual INodeStyleSchema WithSubTitleFont(string font, int? fontsize, Color? color, FontStyle? style)
 {
     SubTitleFontStyle = style.GetValueOrDefault(SubTitleFontStyle);
     SubTitleFontSize = fontsize.GetValueOrDefault(SubTitleFontSize);
     SubTitleColor = color.GetValueOrDefault(SubTitleColor);
     if (!string.IsNullOrEmpty(font))
         SubTitleFont = font;
     return this;
 }
Example #4
0
        public static void TextShadow(SpriteBatch spritebatch, SpriteFont font, String text, Vector2 textPosition, Vector2? shadowPosition, Color textColor, Color? shadowColor)
        {
            if (shadowPosition == null)
            {
                shadowPosition = new Vector2(textPosition.X + 5, textPosition.Y + 5);
            }

            if (shadowColor == null)
            {
                shadowColor = Color.Black;
            }

            spritebatch.DrawString(font, text, shadowPosition.GetValueOrDefault(), shadowColor.GetValueOrDefault());
            spritebatch.DrawString(font, text, textPosition, textColor);
        }
Example #5
0
 public TileButton(string text, int row, int column, EventHandler handler = null, Color? color = null)
     : base(text, row, column)
 {
     this.color = color == null ? Color.White : color.GetValueOrDefault();
     ClickMethod += handler;
     label = new Label
     {
         Text = text,
         ForeColor = this.color,
         AutoSize = false,
         TextAlign = ContentAlignment.MiddleCenter,
         Dock = DockStyle.Fill,
         Font = new Font("Century Gothic", 14)
     };
     label.Click += ClickMethod;
 }
Example #6
0
 public static Color ToTransparentFromGrayScale(this Color color, Color? newRGBColor)
 {
     return Color.FromArgb(
         color.ToGrayScale().R,
         newRGBColor.GetValueOrDefault(color));
 }
Example #7
0
        public void Draw(
            Texture2D texture, Rectangle destRectangle,
            Rectangle? sourceRectangle = null, Color? multiplyColor = null, Color addColor = default(Color),
            float rotation = 0, float originX = 0, float originY = 0,
            bool mirrorX = false, bool mirrorY = false, float sortKey = 0,
            int? layer = null, bool? worldSpace = null,
            BlendState blendState = null, SamplerState samplerState = null
        )
        {
            var drawCall = new BitmapDrawCall(texture, new Vector2(destRectangle.X, destRectangle.Y));
            if (sourceRectangle.HasValue) {
                var sr = sourceRectangle.Value;
                drawCall.TextureRegion = texture.BoundsFromRectangle(ref sr);
                drawCall.Scale = new Vector2(destRectangle.Width / (float)sr.Width, destRectangle.Height / (float)sr.Height);
            } else {
                drawCall.Scale = new Vector2(destRectangle.Width / (float)texture.Width, destRectangle.Height / (float)texture.Height);
            }
            drawCall.MultiplyColor = multiplyColor.GetValueOrDefault(Color.White);
            drawCall.AddColor = addColor;
            drawCall.Rotation = rotation;
            drawCall.Origin = new Vector2(originX, originY);
            if (mirrorX || mirrorY)
                drawCall.Mirror(mirrorX, mirrorY);
            drawCall.SortKey = sortKey;

            Draw(ref drawCall, layer: layer, worldSpace: worldSpace, blendState: blendState, samplerState: samplerState);
        }
Example #8
0
        public void Draw(
            Texture2D texture, Vector2 position,
            Rectangle? sourceRectangle = null, Color? multiplyColor = null, Color addColor = default(Color),
            float rotation = 0, Vector2? scale = null, Vector2 origin = default(Vector2),
            bool mirrorX = false, bool mirrorY = false, float sortKey = 0,
            int? layer = null, bool? worldSpace = null, 
            BlendState blendState = null, SamplerState samplerState = null
        )
        {
            var drawCall = new BitmapDrawCall(texture, position);
            if (sourceRectangle.HasValue)
                drawCall.TextureRegion = texture.BoundsFromRectangle(sourceRectangle.Value);
            drawCall.MultiplyColor = multiplyColor.GetValueOrDefault(Color.White);
            drawCall.AddColor = addColor;
            drawCall.Rotation = rotation;
            drawCall.Scale = scale.GetValueOrDefault(Vector2.One);
            drawCall.Origin = origin;
            if (mirrorX || mirrorY)
                drawCall.Mirror(mirrorX, mirrorY);
            drawCall.SortKey = sortKey;

            Draw(ref drawCall, layer: layer, worldSpace: worldSpace, blendState: blendState, samplerState: samplerState);
        }
        /// <summary>
        /// Zeigt die Überlagerung an.
        /// </summary>
        /// <param name="bitmap">Im OSD anzuzeigende Daten.</param>
        /// <param name="left">Relative Position des OSD (linker Rand).</param>
        /// <param name="top">Relative Position des OSD (oberer Rand).</param>
        /// <param name="right">Relative Position des OSD (rechter Rand).</param>
        /// <param name="bottom">Relative Position des OSD (unterer Rand).</param>
        /// <param name="alpha">Transparenz des OSD. Befindet sich die Anwendung nicht im
        /// Vollbildmodus, wird dieser Parameter ignoriert und das OSD ist undurchsichtig.</param>
        /// <param name="transparent">Optional durchsichtige Farbe.</param>
        public void ShowOverlay( Bitmap bitmap, double left, double top, double right, double bottom, double? alpha, Color? transparent )
        {
            // Relative position
            m_OSDSize = new RectangleF( (float) left, (float) top, (float) (right - left), (float) (bottom - top) );

            // See if we are in full mode support
            if (!UseLegacyOverlay)
            {
                // Set transparency
                Opacity = alpha.GetValueOrDefault( 1 );

                // Set transparency key
                TransparencyKey = transparent.GetValueOrDefault( TTXPage.TransparentColor.Color );
                BackColor = TransparencyKey;
            }

            // Load
            using (picOSD.Image)
                picOSD.Image = new Bitmap( bitmap );

            // Call base
            if (!Visible)
                Show();

            // Update
            AdaptChanges( m_Reference, EventArgs.Empty );
        }
Example #10
0
 public ImageTinted(Texture2D tex, Rectangle? texCoords = null, Color? tint = null, Vector2? size = null)
     : base(tex, texCoords, size)
 {
     Tint = tint.GetValueOrDefault(Color.White);
 }