示例#1
0
        /// <summary>
        /// Renders the specified user interface.
        /// </summary>
        /// <param name="userInterface">The user interface to render.</param>
        public void Render(UserInterface userInterface) {
            if (userInterface == null)
                throw new ArgumentNullException("userInterface");

            int y = 0;
            foreach (Element element in userInterface.Container) {
                IElementVisual visual = new DefaultVisual();
                Vector2 size = visual.Measure(this, element);
                visual.Render(this, element, 0, y, (int)size.X, (int)size.Y);
                y += (int)size.Y;
            }

            Flush();
        }
示例#2
0
文件: Sample.cs 项目: zhandb/slimdx
    	/// <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();
        }