示例#1
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.
        /// </summary>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            // Start app diagnostics.

            var stopwatch = new Stopwatch();

            stopwatch.Start();
            Diagnostics = new DiagnosticService();

            // Load the database.

            if (ApplicationData.Current.LocalSettings.Values.TryGetValue(
                    "data_source", out object dataSource))
            {
                switch (dataSource.ToString())
                {
                case "Rest": UseRest(); break;

                default: UseSqlite(); break;
                }
            }
            else
            {
                UseSqlite();
            }

            // Prepare the app shell and window content.

            AppShell shell = Window.Current.Content as AppShell ?? new AppShell();

            shell.Language         = ApplicationLanguages.Languages[0];
            Window.Current.Content = shell;

            if (shell.AppFrame.Content == null)
            {
                // When the navigation stack isn't restored, navigate to the first page
                // suppressing the initial entrance animation.

                shell.AppFrame.Navigate(typeof(CustomerListPage), e.Arguments,
                                        new SuppressNavigationTransitionInfo());
            }

            Window.Current.Activate();
            Diagnostics.TrackLaunch(stopwatch.Elapsed);
        }