public void SetInstallByPath(string path) { try { path = Path.GetFullPath(path); } catch { } if (!string.IsNullOrEmpty(path)) { var matchingInstall = BeatSaberLocations.Where(i => string.Equals(Path.GetFullPath(i.InstallPath), path, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault(); if (matchingInstall != null) { ChosenInstall = matchingInstall; } else { var newInstall = new BeatSaberInstall(path, InstallType.Manual); BeatSaberLocations.Add(newInstall); ChosenInstall = newInstall; } } else { ChosenInstall = BeatSaberLocations.FirstOrDefault(); } }
private bool RemoveLocation(BeatSaberInstall install) { bool result = BeatSaberLocations.Remove(install); if (ChosenInstall == install) { ChosenInstall = null; } NewLocationIsValid = CanAddLocation(NewLocationInput); return(result); }
private bool AddLocation(BeatSaberInstall beatSaberInstall) { bool hadEmptyList = BeatSaberLocations.Count == 0; BeatSaberLocations.Add(beatSaberInstall); if (BeatSaberLocations.Any(i => i.InstallPath == NewLocationInput.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar))) { NewLocationIsValid = false; } if (hadEmptyList) { ChosenInstall = beatSaberInstall; } return(true); }