Ejemplo n.º 1
0
 /// <summary>
 /// Renders the element using the specified renderer.
 /// </summary>
 /// <param name="renderer">The renderer.</param>
 /// <param name="element">The element.</param>
 /// <param name="x">The X coordinate (in pixels) of the upper left corner of the region the element should be rendered to.</param>
 /// <param name="y">The Y coordinate (in pixels) of the upper left corner of the region the element should be rendered to.</param>
 /// <param name="width">The width (in pixels) of the region the element should be rendered to.</param>
 /// <param name="height">The height (in pixels) of the region the element should be rendered to.</param>
 public virtual void Render(UserInterfaceRenderer renderer, Element element, int x, int y, int width, int height) {
     Color4 color = new Color4(1.0f, 1.0f, 1.0f);
     renderer.RenderRectangle(x, y, width, height, color);
     renderer.RenderString(element.Label, 0, 0, new Color4(1.0f, 0.0f, 0.0f));
 }
Ejemplo n.º 2
0
    	/// <summary>
        /// Runs the sample.
        /// </summary>
        public void Run() {
            _configuration = OnConfigure();
        	_form = CreateForm(_configuration);

        	currentFormWindowState = _form.WindowState;

            bool isFormClosed = false;
            bool formIsResizing = false;

            _form.MouseClick += HandleMouseClick;
            _form.KeyDown += HandleKeyDown;
            _form.KeyUp += HandleKeyUp;
            _form.Resize += ( o, args ) => {
                if( _form.WindowState != currentFormWindowState ) {
                    HandleResize( o, args );
                }

                currentFormWindowState = _form.WindowState;
            };

            _form.ResizeBegin += ( o, args ) => { formIsResizing = true; };
            _form.ResizeEnd += ( o, args ) => {
                formIsResizing = false;
                HandleResize( o, args );
            };

            _form.Closed += ( o, args ) => { isFormClosed = true; };

            userInterface = new UserInterface();
            var stats = new Element();
            stats.SetBinding( "Label", framesPerSecond );
            userInterface.Container.Add( stats );

            OnInitialize();
            OnResourceLoad();

            clock.Start();
            MessagePump.Run( _form, () => {
                if( isFormClosed ) {
                    return;
                }

                Update();
                if( !formIsResizing )
                    Render();
            } );

            OnResourceUnload();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Measures the element, returning the size (in pixels) it would occupy if
 /// rendered with the specified renderer.
 /// </summary>
 /// <param name="renderer">The renderer.</param>
 /// <param name="element">The element.</param>
 /// <returns>The size of the element (in pixels).</returns>
 public virtual Vector2 Measure(UserInterfaceRenderer renderer, Element element) {
     return renderer.MeasureString(element.Label);
 }