internal static void SetWallpaperAspectRatio(WallpaperAspect ratio = DefaultAspectRatio) { switch (ratio) { case WallpaperAspect.EXTENDED: Setting_WallpaperStyle = "22"; Setting_TileWallpaper = "0"; break; case WallpaperAspect.FILLED: Setting_WallpaperStyle = "10"; Setting_TileWallpaper = "0"; break; case WallpaperAspect.FITED: Setting_WallpaperStyle = "6"; Setting_TileWallpaper = "0"; break; case WallpaperAspect.STRETCHED: Setting_WallpaperStyle = "2"; Setting_TileWallpaper = "0"; break; case WallpaperAspect.CENTERED: Setting_WallpaperStyle = "0"; Setting_TileWallpaper = "0"; break; case WallpaperAspect.TILED: Setting_WallpaperStyle = "0"; Setting_TileWallpaper = "1"; break; default: // Fallback to FITED Setting_WallpaperStyle = "6"; Setting_TileWallpaper = "0"; break; } }
private void LoadSettings() { try { #if DEBUG bool success = false; #endif string savePath = App.SettingsFilepath; if (File.Exists(savePath)) { string saved = File.ReadAllText(savePath, System.Text.Encoding.UTF8); if (!string.IsNullOrWhiteSpace(saved)) { string[] splitted = saved.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); if (splitted != null && splitted.Length == 5) { // Parse data values. switch (splitted[0]) { case "Best-Of": cbb_TypeFondEcran.SelectedIndex = 0; break; case "Page d'accueil": cbb_TypeFondEcran.SelectedIndex = 1; break; default: cbb_TypeFondEcran.SelectedIndex = 0; break; } ; InitTypeFondEcran = cbb_TypeFondEcran.SelectedIndex; if (int.TryParse(splitted[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out int interval)) { if (interval < 1 || interval > 99) { interval = 1; } tb_ChangeInterval.Text = interval.ToString(CultureInfo.InvariantCulture); InitChangeInterval = interval; } switch (splitted[2]) { case "jour(s)": cbb_ChangeIntervalType.SelectedIndex = 0; break; case "heure(s)": cbb_ChangeIntervalType.SelectedIndex = 1; break; case "minute(s)": cbb_ChangeIntervalType.SelectedIndex = 2; break; case "seconde(s)": cbb_ChangeIntervalType.SelectedIndex = 3; break; default: cbb_ChangeIntervalType.SelectedIndex = 1; break; } ; InitChangeIntervalType = cbb_ChangeIntervalType.SelectedIndex; switch (splitted[3]) { case "True": cb_StartWithWindows.IsChecked = true; break; case "False": cb_StartWithWindows.IsChecked = false; break; default: cb_StartWithWindows.IsChecked = true; break; } ; InitStartsWithWindows = cb_StartWithWindows.IsChecked != null && cb_StartWithWindows.IsChecked.HasValue && cb_StartWithWindows.IsChecked.Value; switch (splitted[4]) { case "Remplir": cbb_AspectRatioType.SelectedIndex = 0; break; case "Ajusté": cbb_AspectRatioType.SelectedIndex = 1; break; case "Étiré": cbb_AspectRatioType.SelectedIndex = 2; break; case "Centré": cbb_AspectRatioType.SelectedIndex = 3; break; case "Mosaïque": cbb_AspectRatioType.SelectedIndex = 4; break; case "Étendu": cbb_AspectRatioType.SelectedIndex = 5; break; default: cbb_AspectRatioType.SelectedIndex = (int)DesktopBackground.DefaultAspectRatio; break; } InitWallpaperAspect = (WallpaperAspect)cbb_AspectRatioType.SelectedIndex; // Enforce correct values. if (InitChangeIntervalType == 3) { if (InitChangeInterval < App.MIN_SECONDS) { InitChangeInterval = App.MIN_SECONDS; tb_ChangeInterval.Text = InitChangeInterval.ToString(CultureInfo.InvariantCulture); } } else if (InitChangeInterval < 1) { InitChangeInterval = 1; tb_ChangeInterval.Text = "1"; } #if DEBUG success = true; } } if (success) { Debug.WriteLine("Successfully loaded settings from [" + savePath + "]."); } else { Debug.WriteLine("Failed to load settings from [" + savePath + "] (incorrect data)."); } } else { Debug.WriteLine("Failed to load settings from [" + savePath + "] (file not found)."); } #else } }