public override void Draw(DeviceContext graphics, Entity entity, Universe universe, Vector2 origin, SpriteBatch spriteBatch, Vector2 mouseLocation, Rectangle scissor) { if (_caret != null) { if (_caretIndex == 0) { if (_drawCaret) { spriteBatch.Draw(_caret.GetTexture(graphics), origin, _color); } spriteBatch.DrawString(_font, _text, origin + new Vector2(_caret.Width, 0), _color); } else if (_caretIndex == _text.Length) { spriteBatch.DrawString(_font, _text, origin, _color); if (_drawCaret) { spriteBatch.Draw(_caret.GetTexture(graphics), origin + new Vector2(_font.MeasureString(_text).X, 0), _color); } } else { spriteBatch.DrawString(_font, _text.Substring(0, (int)_caretIndex), origin, _color); if (_drawCaret) { spriteBatch.Draw(_caret.GetTexture(graphics), origin + new Vector2(_font.MeasureString(_text.Substring(0, (int)_caretIndex)).X, 0), _color); } spriteBatch.DrawString(_font, _text.Substring((int)_caretIndex), origin + new Vector2( _font.MeasureString(_text.Substring(0, (int)_caretIndex)).X + _caret.Width, 0), _color); } } else { if (_drawUpsideDown) { spriteBatch.DrawString(_font, new StringBuilder(_text), origin, _color, 0.0f, Vector2.Zero, Vector2.One, SpriteEffects.FlipHorizontally, 0.0f); } else { spriteBatch.DrawString(_font, _text, origin, _color); } } }
public void Draw(DeviceContext graphics, Vector2 origin, Vector2 size, SpriteBatch spriteBatch, Color color) { var stretchWidth = 0; var stretchHeight = 0; var minSize = GetMinSize(); var originI = new Vector2I((int)Math.Ceiling(origin.X), (int)Math.Ceiling(origin.Y)); var sizeI = new Vector2I((int)Math.Ceiling(size.X), (int)Math.Ceiling(size.Y)); var minI = new Vector2I((int)Math.Ceiling(minSize.X), (int)Math.Ceiling(minSize.Y)); if (minI.X < sizeI.X) { stretchWidth = sizeI.X - minI.X; } if (minI.Y < sizeI.Y) { stretchHeight = sizeI.Y - minI.Y; } spriteBatch.Draw(TopLeft.GetTexture(graphics), new Vector2(originI.X, originI.Y), color); if (stretchWidth != 0) { spriteBatch.Draw(TopMiddle.GetTexture(graphics), new Rectangle(originI.X + TopLeft.Width, originI.Y, stretchWidth, TopLeft.Height), color); } spriteBatch.Draw(TopRight.GetTexture(graphics), new Vector2(originI.X + TopLeft.Width + stretchWidth, originI.Y), color); if (stretchHeight != 0) { spriteBatch.Draw(MiddleLeft.GetTexture(graphics), new Rectangle(originI.X, originI.Y + TopLeft.Height, TopLeft.Width, stretchHeight), color); if (stretchWidth != 0) { spriteBatch.Draw(MiddleMiddle.GetTexture(graphics), new Rectangle(originI.X + TopLeft.Width, originI.Y + TopLeft.Height, stretchWidth, stretchHeight), color); } spriteBatch.Draw(MiddleRight.GetTexture(graphics), new Rectangle(originI.X + TopLeft.Width + stretchWidth, originI.Y + TopLeft.Height, TopLeft.Width, stretchHeight), color); } spriteBatch.Draw(BottomLeft.GetTexture(graphics), new Vector2(originI.X, originI.Y + stretchHeight + TopLeft.Height), color); if (stretchWidth != 0) { spriteBatch.Draw(BottomMiddle.GetTexture(graphics), new Rectangle(originI.X + TopLeft.Width, originI.Y + stretchHeight + TopLeft.Height, stretchWidth, TopLeft.Height), color); } spriteBatch.Draw(BottomRight.GetTexture(graphics), new Vector2(originI.X + stretchWidth + BottomLeft.Width, originI.Y + stretchHeight + TopLeft.Height), color); }
public override void Update(Universe universe, Vector2 origin, AvatarController avatar, List <ScanCode> input, bool ctrl, bool shift, IReadOnlyList <InterfaceLogicalButton> inputPressed, Vector2 mouseLocation, bool click, bool clickHold) { if (!Window.CallUpdates && !Window.Visible) { return; } var location = Helpers.VectorLocation(origin, new Vector2(origin.X + _colorWheel.Width, origin.Y + _colorWheel.Height), mouseLocation); if (location.X == -1 || location.Y == -1) { return; } Color color; try { color = Helpers.GetColorByCoordinate(_colorWheel.GetTexture(null), location); } catch { return; } if (color == Color.Transparent) { return; } ColorHover?.Invoke(color); if (click || clickHold) { ColorClick?.Invoke(color); } }