예제 #1
0
        public App()
        {
            this.UnhandledException += App_UnhandledException;
            this.Suspending         += this.OnSuspending;

#if DEBUG
            //disable application insights on debug
            TelemetryConfiguration.Active.DisableTelemetry = true;
#else
            //config application insights
            WindowsAppInitializer.InitializeAsync();//WindowsCollectors.Metadata | WindowsCollectors.Session | WindowsCollectors.UnhandledException);
#endif

            //application insights has always to be initialized
            TelemetryClient = new TelemetryClient();

            AppSettings.Instance.ThemeChanged               += (s, e) => { UpdateTheme(e.Theme); App.TelemetryClient.TrackMetric("Theme", AppSettings.Instance.Theme == ElementTheme.Light ? 1 : 2); };
            AppSettings.Instance.TransparentTileChanged     += (s, e) => NotificationsManager.UpdateDefaultTile(e.TransparentTile);
            AppSettings.Instance.TransparentNoteTileChanged += (s, e) => NotificationsManager.UpdateAllNoteTilesBackgroundColor(e.TransparentTile);

            AppData.NotesSaved       += (s, e) => SimulateStatusBarProgressComplete();
            AppData.NoteColorChanged += async(s, _e) => { await NotificationsManager.UpdateNoteTileBackgroundColor(_e.Note, AppSettings.Instance.TransparentNoteTile); };


            this.InitializeComponent();
        }
예제 #2
0
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            //user theme
            UpdateTheme(AppSettings.Instance.Theme);
            //HideStatusBar();

            ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible);

#if WINDOWS_UWP
            ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(320, 500));
            ApplicationView.PreferredLaunchViewSize      = new Size(380, 620);
            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Auto;
#endif

            //update default live tile (because I renamed the image, it was showing empty for some users)
            NotificationsManager.UpdateDefaultTile(AppSettings.Instance.TransparentTile);

            if (RootFrame.Content == null)
            {
                RootFrame.ContentTransitions = null;
                RootFrame.Navigated         += this.RootFrame_FirstNavigated;

                //await Windows.Storage.ApplicationData.Current.SetVersionAsync(AppSettings.Instance.Version - 1, (req) => { });

                //prepare app data
                await AppData.Init();

                AppData.LoadNotesIfNecessary();

                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!RootFrame.Navigate(typeof(MainPage), e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            //received parameters and the app was suspended
            else if (e.Arguments != null && !String.IsNullOrEmpty(e.Arguments.ToString()))
            {
                RootFrame.Navigate(typeof(MainPage), e.Arguments);
            }

            Window.Current.Activate();

            //System.Diagnostics.Debug.WriteLine("IsMobile={0}", Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1));
        }