Example #1
0
        /// <summary>
        /// Runs when app is deactivated and put in the background by
        /// the SBUI system, stops rendering (if active) and sets
        /// the suspended tracking field to start back up after
        /// app activates again.
        /// </summary>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">Event arguments.</param>
        private void OnAppDeactivated(object sender, AppEventEventArgs e)
        {
            if (!Active)
            {
                return;
            }

            _log.Debug("App is deactivating, suspending rendering...");
            Stop();
            _suspended = true;
        }
Example #2
0
 /// <summary>
 /// This event handler is fired when an app event happens
 /// </summary>
 /// <param name="sender">The object that called this event</param>
 /// <param name="appEventArgs">The arguments that give details as to the app event</param>
 private static void OnAppEvent(object sender, AppEventEventArgs e)
 {
     /* Just an example here.  If the app becomes deactivated, is closed or force quit, then close the app.
      * Potentially you could run a App Lifecycle here where when it's deactivated, it unbinds any data connection
      * And when the app is activated again, it reloads the data source and opens back up
      */
     if (e.Type == RazerAPI.AppEventType.Deactivated || e.Type == RazerAPI.AppEventType.Close ||
         e.Type == RazerAPI.AppEventType.Exit)
     {
         Application.Current.Shutdown();
     }
 }
Example #3
0
        /// <summary>
        /// Runs when app is activated from a suspended state, starts
        /// rendering back up if it was suspended by us when app was
        /// deactivated.
        /// </summary>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">Event arguments.</param>
        private void OnAppActivated(object sender, AppEventEventArgs e)
        {
            if (_suspended)
            {
                _log.Debug("Starting back up from being suspended.");
                Start();
            }

            // We set the suspended tracking field to false regardless of above
            // outcome, to avoid possible errors on next deactivation.
            _suspended = false;
        }
Example #4
0
        private static void OnAppEvent(object sender, AppEventEventArgs e)
        {
            if (e.EventType == _lastEventType)
                return;

            switch (e.EventType)
            {
                case RazerAPI.AppEventType.Activated:
                    if (CurrentWindow == null)
                        Application.Current.Shutdown();
                    else
                        CurrentWindow.ActivateApp();
                    break;
                case RazerAPI.AppEventType.Deactivated:
                    if (CurrentWindow == null)
                        Application.Current.Shutdown();
                    else
                        CurrentWindow.DeactivateApp();
                    break;
                case RazerAPI.AppEventType.Close:
                case RazerAPI.AppEventType.Exit:
                    FriendViewModel.ClearCache();
                    if (_steam != null)
                        _steam.Dispose();
                    Application.Current.Shutdown();
                    break;
            }

            _lastEventType = e.EventType;
        }