Example #1
0
        //-----------------------------------------------------------------------------------------------
        /// <summary>
        /// Do some visual setup to get the normalize the coordinate system, load default
        /// content, and then call out for any user-assigned work using the OnLoaded event.
        /// </summary>
        //-----------------------------------------------------------------------------------------------
        protected override void LoadContent()
        {
            Content = new EmbeddedContentManager(_graphics.GraphicsDevice)
            {
                RootDirectory = "Content"
            };
            // Set up a back buffer to render to
            _backBufferWidth  = GraphicsDevice.PresentationParameters.BackBufferWidth;
            _backBufferHeight = GraphicsDevice.PresentationParameters.BackBufferHeight;
            if ((float)_backBufferHeight / _backBufferWidth < 1.6)
            {
                _backBufferWidth   = (int)(_backBufferHeight / 1.6);
                _backBufferXOffset = (GraphicsDevice.PresentationParameters.BackBufferWidth - _backBufferWidth) / 2;
            }

            var scaleFactor = _backBufferWidth / 1000.0f;

            _scaleToNativeResolution = Matrix.CreateScale(new Vector3(scaleFactor, scaleFactor, 1));

            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _utilityBlockTexture = Content.Load <Texture2D>("_utility_block");
            _circleTexture       = Content.Load <Texture2D>("_utility_circle");
            _defaultFont         = Content.Load <SpriteFont>("_utility_SegoeUI");

            _fontsByName.Add("_utility_SegoeUI", _defaultFont);
            SelectFont();

            // Widgets
            _widgetSpace = new VarmintWidgetSpace(this, _bindingContext);

            _visualTree = _widgetSpace.GetScreen("_default_screen_", null);
            OnLoaded?.Invoke();
        }
 //-----------------------------------------------------------------------------------------------
 // GetScreen - return a screen object by name
 //-----------------------------------------------------------------------------------------------
 internal VarmintWidget GetScreen(string screenName, object bindingContext)
 {
     return(_widgetSpace.GetScreen(screenName, bindingContext));
 }