Esempio n. 1
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            AppSettingsService.Initialize();

            App.Current.RequestedTheme =
                (int)AppSettingsService.GetSetting(AppSettingsService.THEME_SETTINGS) == 0 ? ApplicationTheme.Dark : ApplicationTheme.Light;
        }
Esempio n. 2
0
        private async Task ActivateAsync(IActivatedEventArgs e)
        {
            bool rootFrameCreated = false;

            if (!(Window.Current.Content is Frame rootFrame))
            {
                rootFrame = CreateRootFrame(e);
                Window.Current.Content = rootFrame;
                rootFrameCreated       = true;

                ThemeSettingsService.Initialize();
                AppSettingsService.Initialize();
            }

            var appLaunchSettings = new Dictionary <string, string>()
            {
                { "OSArchitecture", SystemInformation.OperatingSystemArchitecture.ToString() },
                { "OSVersion", $"{SystemInformation.OperatingSystemVersion.Major}.{SystemInformation.OperatingSystemVersion.Minor}.{SystemInformation.OperatingSystemVersion.Build}" },
                { "UseWindowsTheme", ThemeSettingsService.UseWindowsTheme.ToString() },
                { "ThemeMode", ThemeSettingsService.ThemeMode.ToString() },
                { "UseWindowsAccentColor", ThemeSettingsService.UseWindowsAccentColor.ToString() },
                { "AppBackgroundTintOpacity", $"{(int) (ThemeSettingsService.AppBackgroundPanelTintOpacity * 10.0) * 10}" },
                { "ShowStatusBar", AppSettingsService.ShowStatusBar.ToString() },
                { "IsSessionSnapshotEnabled", AppSettingsService.IsSessionSnapshotEnabled.ToString() },
                { "IsShadowWindow", (!IsPrimaryInstance && !IsGameBarWidget).ToString() },
                { "IsGameBarWidget", IsGameBarWidget.ToString() },
                { "AlwaysOpenNewWindow", AppSettingsService.AlwaysOpenNewWindow.ToString() },
                { "IsHighlightMisspelledWordsEnabled", AppSettingsService.IsHighlightMisspelledWordsEnabled.ToString() },
                { "IsSmartCopyEnabled", AppSettingsService.IsSmartCopyEnabled.ToString() }
            };

            LoggingService.LogInfo($"[{nameof(App)}] Launch settings: \n{string.Join("\n", appLaunchSettings.Select(x => x.Key + "=" + x.Value).ToArray())}.");
            Analytics.TrackEvent("AppLaunch_Settings", appLaunchSettings);

            var appLaunchEditorSettings = new Dictionary <string, string>()
            {
                { "EditorDefaultLineEnding", AppSettingsService.EditorDefaultLineEnding.ToString() },
                { "EditorDefaultEncoding", EncodingUtility.GetEncodingName(AppSettingsService.EditorDefaultEncoding) },
                { "EditorDefaultTabIndents", AppSettingsService.EditorDefaultTabIndents.ToString() },
                { "EditorDefaultDecoding", AppSettingsService.EditorDefaultDecoding == null ? "Auto" : EncodingUtility.GetEncodingName(AppSettingsService.EditorDefaultDecoding) },
                { "EditorFontFamily", AppSettingsService.EditorFontFamily },
                { "EditorFontSize", AppSettingsService.EditorFontSize.ToString() },
                { "EditorFontStyle", AppSettingsService.EditorFontStyle.ToString() },
                { "EditorFontWeight", AppSettingsService.EditorFontWeight.Weight.ToString() },
                { "EditorDefaultSearchEngine", AppSettingsService.EditorDefaultSearchEngine.ToString() },
                { "DisplayLineHighlighter", AppSettingsService.EditorDisplayLineHighlighter.ToString() },
                { "DisplayLineNumbers", AppSettingsService.EditorDisplayLineNumbers.ToString() },
            };

            LoggingService.LogInfo($"[{nameof(App)}] Editor settings: \n{string.Join("\n", appLaunchEditorSettings.Select(x => x.Key + "=" + x.Value).ToArray())}.");
            Analytics.TrackEvent("AppLaunch_Editor_Settings", appLaunchEditorSettings);

            try
            {
                await ActivationService.ActivateAsync(rootFrame, e);
            }
            catch (Exception ex)
            {
                var diagnosticInfo = new Dictionary <string, string>()
                {
                    { "Message", ex?.Message },
                    { "Exception", ex?.ToString() },
                };
                Analytics.TrackEvent("AppFailedToActivate", diagnosticInfo);
                Crashes.TrackError(ex, diagnosticInfo);
                throw;
            }

            if (rootFrameCreated)
            {
                ExtendViewIntoTitleBar();
                Window.Current.Activate();
            }
        }