Exemple #1
0
        private async static Task <string> CreateDefaultSettingsJson()
        {
            // TODO: Make this prettier
            var defaultSettings = await HolzShotsResources.ReadResourceAsString("HolzShots.Resources.DefaultSettings.json");

            defaultSettings = defaultSettings
                              .Replace("DEFAULT_SAVE_PATH", HolzShotsPaths.DefaultScreenshotSavePath.Replace(@"\", @"\\"))
                              .Replace("DEFAULT_UPLOAD_SERVICE", "directupload.net");
            return(defaultSettings);
        }
Exemple #2
0
        /// <returns>true if the default stuff was created.</returns>
        public static async Task CreateUserSettingsIfNotPresent()
        {
            if (File.Exists(HolzShotsPaths.UserSettingsFilePath))
            {
                return;
            }

            var createdAppData = HolzShotsPaths.EnsureAppDataDirectories();

            if (!createdAppData)
            {
                // Since the appdata (and the plugins dir) was just created, there is no demo uploader. So we need to place it there.
                // It's also referenced in the default settings, so it should better be there
                var contents = await HolzShotsResources.ReadResourceAsString("HolzShots.Resources.DirectUpload.net.hs.json");

                await File.WriteAllTextAsync(HolzShotsPaths.DemoCustomUploaderPath, contents);
            }

            using var fs = File.OpenWrite(HolzShotsPaths.UserSettingsFilePath);
            var defaultSettingsStr = await CreateDefaultSettingsJson().ConfigureAwait(false);

            var defaultSettings = Encoding.UTF8.GetBytes(defaultSettingsStr);
            await fs.WriteAsync(defaultSettings).ConfigureAwait(false);
        }