public void LoadContent(IAssetManager assets)
 {
     _buffer.Clear();
     _assetManager = assets;
     _font = ToDispose<FontAsset>(assets.LoadFont(FONT_NAME, FONT_SIZE, FontWeight.Normal, FontStyle.Normal, FontStretch.Normal));
     _backgroundColor = ToDispose<BrushAsset>(assets.LoadBrush(BACKGROUND));
     _standardColor = ToDispose<BrushAsset>(assets.LoadBrush(NORMALTEXT));
     _errorColor = ToDispose<BrushAsset>(assets.LoadBrush(ERRORTEXT));
 }
        public override void LoadContent(IAssetManager assetManager)
        {
            base.LoadContent(assetManager);
            _assetManager = assetManager;

            switch (TextSize) {
                case TextSize.Large:
                    Font = assetManager.LoadFont(FontName, ControlManager.Config.WindowLargeFontSize, FontWeight.Normal, FontStyle.Normal, FontStretch.Normal);
                    break;

                case TextSize.Normal:
                    goto default;

                default:
                    Font = assetManager.LoadFont(FontName, ControlManager.Config.WindowStandardFontSize, FontWeight.Normal, FontStyle.Normal, FontStretch.Normal);
                    break;
            }

            if (!String.IsNullOrEmpty(ActiveTexturePath)) {
                _activeTexture = assetManager.LoadTexture(ActiveTexturePath);

                if (String.IsNullOrEmpty(InactiveTexturePath))
                    _inactiveTexture = _activeTexture;
                else
                    _inactiveTexture = assetManager.LoadTexture(InactiveTexturePath);

                if (String.IsNullOrEmpty(PressedTexturePath))
                    _pressedTexture = _activeTexture;
                else
                    _pressedTexture = assetManager.LoadTexture(PressedTexturePath);
            }

            if (_activeTexture == null) {
                _activeBackgroundBrush = assetManager.LoadBrush(this.ActiveBackgroundColor);
            } else {
                _activeBackgroundBrush = assetManager.LoadBrush(_activeTexture.Resource, new BitmapBrushProperties() {
                    ExtendModeX = ExtendMode.Wrap,
                    ExtendModeY = ExtendMode.Wrap,
                    InterpolationMode = BitmapInterpolationMode.Linear
                }, null);
            }
            _activeBorderBrush = assetManager.LoadBrush(this.ActiveBorderColor);

            if (_inactiveTexture == null) {
                _inactiveBackgroundBrush = assetManager.LoadBrush(this.InactiveBackgroundColor);
            } else {
                _inactiveBackgroundBrush = assetManager.LoadBrush(_inactiveTexture.Resource, new BitmapBrushProperties() {
                    ExtendModeX = ExtendMode.Wrap,
                    ExtendModeY = ExtendMode.Wrap,
                    InterpolationMode = BitmapInterpolationMode.Linear
                }, null);
            }
            _inactiveBorderBrush = assetManager.LoadBrush(this.InactiveBorderColor);
            _pressedBackgroundBrush = assetManager.LoadBrush(this.PressedBackgroundColor);
            _pressedBorderBrush = assetManager.LoadBrush(this.PressedBorderColor);
            _activeFontBrush = assetManager.LoadBrush(this.ActiveFontColor);
            _inactiveFontBrush = assetManager.LoadBrush(this.InactiveFontColor);
        }
        public override void Update(long ticks)
        {
            base.Update(ticks);
            if (_recalculateGeometry) {
                if (_backgroundGeometry != null && !_backgroundGeometry.IsDisposed)
                    _backgroundGeometry.Dispose();

                var rect = new DrawingRectangleF(0f, 0f, Width, Height);
                if (IsRounded) {
                    _backgroundGeometry = new RoundedRectangleGeometry(_assetManager.Factory2D, new RoundedRectangle() {
                        Rect = rect,
                        RadiusX = ControlManager.Config.WindowCornerRadius,
                        RadiusY = ControlManager.Config.WindowCornerRadius
                    });
                } else {
                    _backgroundGeometry = new RectangleGeometry(_assetManager.Factory2D, rect);
                }
                _recalculateGeometry = false;
            }
            if (_hasTextChanged && !String.IsNullOrEmpty(_text)) {
                if (RenderedText != null && !RenderedText.IsDisposed)
                    RenderedText.Dispose();

                RenderedText = _assetManager.MakeTextLayout(Font.Resource, _text, Width, Height);
                RenderedText.TextAlignment = this.TextAlignment;
                RenderedText.ParagraphAlignment = this.ParagraphAlignment;
                _hasTextChanged = false;
            }
            if (IsActive) {
                CurrentFontBrush = _activeFontBrush;
                if (IsPressed) {
                    CurrentBackgroundBrush = _pressedBackgroundBrush;
                    CurrentBorderBrush = _pressedBorderBrush;
                    CurrentBitmap = _pressedTexture;
                } else {
                    CurrentBackgroundBrush = _activeBackgroundBrush;
                    CurrentBorderBrush = _activeBorderBrush;
                    CurrentBitmap = _activeTexture;
                }
            } else {
                CurrentBackgroundBrush = _inactiveBackgroundBrush;
                CurrentBorderBrush = _inactiveBorderBrush;
                CurrentFontBrush = _inactiveFontBrush;
                CurrentBitmap = _inactiveTexture;
            }
        }
 public void LoadContent(IAssetManager assets)
 {
     _assetManager = assets;
     _font = ToDispose<FontAsset>(assets.LoadFont(FONT_NAME, FONT_SIZE, FontWeight.Normal, FontStyle.Normal, FontStretch.Normal));
     _currentLayout = ToDispose<TextLayout>(assets.MakeTextLayout(_font.Resource, "", float.MaxValue, float.MaxValue));
     _cursor = ToDispose<TextLayout>(assets.MakeTextLayout(_font.Resource, CURSOR, float.MaxValue, float.MaxValue));
     _lineSpacing = _cursor.Metrics.Height;
     _backgroundColor = ToDispose<BrushAsset>(assets.LoadBrush(BACKGROUND));
     _textColor = ToDispose<BrushAsset>(assets.LoadBrush(TEXT));
     Reset();
 }