/// <summary> /// Send a user specified message when the wait cursor count down has reached zero. /// </summary> public static void ElapsedEvent(int countDownMs, GUIMessage message) { _eventTarget = SendElapsedEventMessage; _eventParam = message; _countValue = countDownMs / 1000; _countDown = (countDownMs > 0); _startTime = DXUtil.timeGetTime(); _elapsedEventRunning = true; // The count label depends on font rendering. If the users callback involves reloading fonts then we need to reallocate // the labels resources to be sure everything calculates okay (e.g., the x,y position of the control). _countLabel.Dispose(); _countLabel.AllocResources(); Show(); }
public static void Render() { if (_showCount <= 0) { return; } GUIGraphicsContext.SetScalingResolution(0, 0, false); if (_countDown) { // Set the count label value and position in the center of the window. _timeElapsed = DXUtil.timeGetTime() - _startTime; if (_timeElapsed >= ONE_SECOND) { _startTime = DXUtil.timeGetTime(); _timeElapsed = 0.0f; _countValue--; if (_countValue < 0) { // Invoke the users callback method and disable the cursor. // The callback must be invoked in a separte thread otherwise it gets executed in the window render loop which // can cause conflicts (especially if the users callback method makes calls that may change the window rendering). guiWaitCursorThread = new Thread(GUIWaitCursorElapsedEventThread); guiWaitCursorThread.IsBackground = true; guiWaitCursorThread.Name = "WaitcursorElapsedEvent"; guiWaitCursorThread.Start(); Hide(); return; } } int offset = 5; int xPos = (GUIGraphicsContext.Width / 2) - 48; int yPos = (GUIGraphicsContext.Height / 2) - 48 + offset; _countLabel.SetPosition(xPos, yPos); _countLabel.Label = _countValue.ToString(); _countLabel.Render(GUIGraphicsContext.TimePassed); } _animation.Render(GUIGraphicsContext.TimePassed); }