Ejemplo n.º 1
0
        protected override async void OnStartup(StartupEventArgs e)
        {
            AppCenter.Start(
                "fb05c4f9-9e96-4fc2-80c4-d99e2227a54b",
                typeof(Analytics),
                typeof(Crashes));

            var welcomeMessage = new WelcomeMessageService().GetRandomMessage();

            ((SplashScreenDataContext)RadSplashScreenManager.SplashScreenDataContext).Footer = welcomeMessage.Message;
            ((SplashScreenDataContext)RadSplashScreenManager.SplashScreenDataContext).HorizontalFooterAlignment = HorizontalAlignment.Center;
            ((SplashScreenDataContext)RadSplashScreenManager.SplashScreenDataContext).ImagePath = "/MvpApi.Wpf;component/Images/HeroBackground.png";
            ((SplashScreenDataContext)RadSplashScreenManager.SplashScreenDataContext).Content   = "starting up...";

            RadSplashScreenManager.Show();

            var refreshToken = StorageHelpers.Instance.LoadToken("refresh_token");

            // We have a refresh token from a previous session
            if (!string.IsNullOrEmpty(refreshToken))
            {
                Microsoft.AppCenter.Analytics.Analytics.TrackEvent("Refreshing Session On App Start");

                ((SplashScreenDataContext)RadSplashScreenManager.SplashScreenDataContext).Content = "Signing in...";

                var authorizationHeader = await LoginWindow.RequestAuthorizationAsync(refreshToken);

                // If the bearer token was returned
                if (!string.IsNullOrEmpty(authorizationHeader))
                {
                    await MainLoginWindow.InitializeMvpApiAsync(authorizationHeader);
                }
                else
                {
                    await MainLoginWindow.SignInAsync();
                }
            }
            else
            {
                await MainLoginWindow.SignInAsync();
            }

            RadSplashScreenManager.Close();

            this.MainWindow = new ShellWindow();
            this.MainWindow.Show();

            // TODO Ask user to send crash report from previous crash

            bool didAppCrash = await Crashes.HasCrashedInLastSessionAsync();

            if (didAppCrash)
            {
                ErrorReport crashReport = await Crashes.GetLastSessionCrashReportAsync();
            }

            base.OnStartup(e);
        }
Ejemplo n.º 2
0
 internal static void Close()
 {
     RadSplashScreenManager.Close();
     RadSplashScreenManager.Reset();
 }
Ejemplo n.º 3
0
        protected override async void OnStartup(StartupEventArgs e)
        {
            var dataContext = (SplashScreenDataContext)RadSplashScreenManager.SplashScreenDataContext;

            dataContext.ImagePath  = "/MediaFileManager.Desktop;component/Images/SplashscreenImage.png";
            dataContext.ImageWidth = 600;

            dataContext.Content = "Loading Media File Manager...";

            dataContext.IsIndeterminate = false;
            dataContext.MinValue        = 0;
            dataContext.MaxValue        = 100;

            RadSplashScreenManager.Show();

            // AppCenter
            AppCenter.Start(Settings.Default.AppCenterAnalyticsKey, typeof(Analytics), typeof(Crashes));

            // Just use general region, not actual location.
            AppCenter.SetCountryCode(RegionInfo.CurrentRegion.TwoLetterISORegionName);

            // Option 1 (good for beta releases) - Hard coding the choice for beta release of the app
            // Crashes.NotifyUserConfirmation(UserConfirmation.AlwaysSend);

            // Option 2 (good for production releases) - Wait until first time it crashes, then ask user what they want to do.
            var hasCrashed = await Crashes.HasCrashedInLastSessionAsync().ConfigureAwait(true);

            if (hasCrashed)
            {
                var result = MessageBox.Show("The app crashed the last time you ran it. Would you like the app to automatically send errors to us?",
                                             "Oh no! I crashed 😪", MessageBoxButton.YesNoCancel);

                switch (result)
                {
                case MessageBoxResult.Yes:
                    Crashes.NotifyUserConfirmation(UserConfirmation.AlwaysSend);
                    break;

                case MessageBoxResult.No:
                    Crashes.NotifyUserConfirmation(UserConfirmation.Send);
                    break;

                default:
                    Crashes.NotifyUserConfirmation(UserConfirmation.DontSend);
                    break;
                }
            }

            // Temporary faking the loading indicator
            for (var i = 0; i < 100; i++)
            {
                dataContext.ProgressValue = i;
                Thread.Sleep(30);

                dataContext.Footer = i < 50 ? "Hi! Loading resources, this will be quick." : "Just a little bit more...";
            }

            RadSplashScreenManager.Close();

            base.OnStartup(e);
        }
Ejemplo n.º 4
0
 internal static void Show()
 {
     (RadSplashScreenManager.HideAnimation as FadeAnimation).Duration = TimeSpan.FromMilliseconds(1000);
     RadSplashScreenManager.Show <QSFSplashScreen>();
 }