public override void OnRender(Microsoft.SPOT.Presentation.Media.DrawingContext dc) { if (pushed) { dc.DrawRectangle(new SolidColorBrush(OnBackgroundColor), new Pen(BorderColor), 0, 0, ActualWidth, ActualHeight); } else { dc.DrawRectangle(new SolidColorBrush(NormalBackgroundColor), new Pen(BorderColor), 0, 0, ActualWidth, ActualHeight); } }
public override void OnRender(Microsoft.SPOT.Presentation.Media.DrawingContext dc) { // Saving performance create fill brush only once if (gradientBrush == null) gradientBrush = new LinearGradientBrush(startColor, endColor, 0, this.Height / 2, 0, this.Height); // Gradient fill dc.DrawRectangle(gradientBrush, null , 0, 0, this.Width, this.Height); // Left line separator dc.DrawRectangle(solidBrush, null, 0, 0, 2, this.Height); }
public override void OnRender(Microsoft.SPOT.Presentation.Media.DrawingContext dc) { // Draw outline rectangle dc.DrawRectangle(_fillBrush, _linePen, 0, 0, COLUMN_WIDTH * COLUMNS, ROW_HEIGHT * ROWS); // Performance tunning - save all property calls to variables int blockCols = _universe.NextBlock.Columns; int blockRows = _universe.NextBlock.Rows; int offsetX = (Width - (blockCols * COLUMN_WIDTH) + 2) / 2; int offsetY = (Height - (blockRows * ROW_HEIGHT) + 2) / 2; // Draw block for (int row = 0; row < blockRows; row++) for (int col = 0; col < blockCols; col++) { int brushType = _universe.NextBlock.GetCell(row, col) - 1; if (brushType >= 0) dc.DrawRectangle(BlockBrushes.Instance.GetBrush(brushType), _blockPen, (col * COLUMN_WIDTH) + offsetX, (row * ROW_HEIGHT) + offsetY, COLUMN_WIDTH - 1, ROW_HEIGHT - 1); } base.OnRender(dc); }
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch batch) { batch.DrawHorizontalBar(new Rectangle(10, TGame.ScreenHeight - 20, TGame.ScreenWidth - 20, 10), Health / MaxHealth, Color.White, Color.Red, 1); base.Draw(batch); if(inputState == InputStates.Character) { if (newItemTimer > 0) { Vector2 center = (TGame.Instance.MainFont.MeasureString(itemDisplay) * 0.5f); batch.DrawString(TGame.Instance.MainFont, itemDisplay, new Vector2(TGame.ScreenWidth * 0.5f, TGame.ScreenHeight - 32), Color.White, 0, center, 0.3f, Microsoft.Xna.Framework.Graphics.SpriteEffects.None, 0); } } else if(inputState == InputStates.Inventory) { batch.DrawRectangle(new Rectangle(10, 10, TGame.ScreenWidth - 20, TGame.ScreenHeight - 40), Color.Gray); string name = ""; if (menuIndex >= 3) { name = Inventory.GetSelectedName(menuIndex - 3); } if (menuIndex == 0 && Inventory.EquippedWeapon != null) name = Inventory.EquippedWeapon.DisplayName; if (menuIndex == 1 && Inventory.EquippedArmor != null) name = Inventory.EquippedArmor.DisplayName; if (menuIndex == 2 && Inventory.EquippedOffhand != null) name = Inventory.EquippedOffhand.DisplayName; Vector2 center = (TGame.Instance.MainFont.MeasureString(name) * 0.5f); batch.DrawString(TGame.Instance.MainFont, name, new Vector2(TGame.ScreenWidth * 0.75f, TGame.ScreenHeight * 0.25f), Color.White, 0, center, 0.3f, Microsoft.Xna.Framework.Graphics.SpriteEffects.None, 0); batch.DrawRectangle(new Rectangle(20 + 10, 10 + 10, 32, 32), menuIndex == 0? Color.Red : Color.LightGray); if(Inventory.EquippedWeapon != null) Inventory.EquippedWeapon.Draw(batch, new Rectangle(20 + 10, 10 + 10, 32, 32)); batch.DrawRectangle(new Rectangle(20 + 10 + 42, 10 + 10, 32, 32), menuIndex == 1 ? Color.Red : Color.LightGray); if (Inventory.EquippedArmor != null) Inventory.EquippedArmor.Draw(batch, new Rectangle(20 + 10 + 42, 10 + 10, 32, 32)); batch.DrawRectangle(new Rectangle(20 + 10 + 84, 10 + 10, 32, 32), menuIndex == 2 ? Color.Red : Color.LightGray); //inv items equipped if (Inventory.EquippedOffhand != null) Inventory.EquippedOffhand.Draw(batch, new Rectangle(20 + 10 + 84, 10 + 10, 32, 32)); for (int x = 0; x < Inventory.gridWidth; x++) { for (int y = 0; y < Inventory.gridHeight; y++) { batch.DrawRectangle(new Rectangle(20 + (x * 42), 64 + (y * 42), 32, 32), Color.LightGray); } } for (int i = 0; i < Inventory.maxItems; i++) { int xP = i; int yP = 0; while (xP >= Inventory.gridWidth) { xP -= Inventory.gridWidth; yP++; } if (menuIndex - 3 == i) batch.DrawRectangle(new Rectangle(20 + (xP * 42), 64 + (yP * 42), 32, 32), Color.Red); } for(int i = 0; i < Inventory.Items.Count; i++) { if (Inventory.Items[i] != null) { int xP = i; int yP = 0; while (xP >= Inventory.gridWidth) { xP -= Inventory.gridWidth; yP++; } Inventory.Items[i].Draw(batch, new Rectangle(20 + (xP * 42), 64 + (yP * 42), 32, 32)); } } } }
protected override void DrawSelf(GameTime gameTime, Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch) { base.DrawSelf(gameTime, spriteBatch); spriteBatch.DrawRectangle(GlobalPosition + Transform, ContentSize, Color.White, 1); }