public static void RemoveLibrary(Library libraryToRemove) { if (UtilityBox.IsSteamRunning()) { ErrorHandler.Instance.ShowNotificationMessage("Turn Off Steam removing steam library."); return; } RealSizeOnDiskTask.Instance.Cancel(); LibraryDetector.Refresh(); Library refreshedLibraryToRemove = null; foreach (Library library in BindingDataContext.Instance.LibraryList) { if (libraryToRemove.LibraryDirectory.Equals(library.LibraryDirectory, StringComparison.CurrentCultureIgnoreCase)) { refreshedLibraryToRemove = library; } } if (refreshedLibraryToRemove == null) { ErrorHandler.Instance.ShowErrorMessage("Library you are trying to remove is already removed."); return; } string newLibraryDirectory = refreshedLibraryToRemove.LibraryDirectory + "_removed"; newLibraryDirectory = StringOperations.RenamePathWhenExists(newLibraryDirectory, "_removed"); FileSystem.RenameDirectory(refreshedLibraryToRemove.LibraryDirectory, Path.GetFileName(newLibraryDirectory)); BindingDataContext.Instance.LibraryList.Remove(refreshedLibraryToRemove); RealSizeOnDiskTask.Instance.Start(); SteamConfigFileWriter.WriteLibraryList(); ErrorHandler.Instance.ShowNotificationMessage("Library will still exist on harddrive. It is only removed from the list."); Process.Start(refreshedLibraryToRemove.LibraryDirectory + "_removed"); }
public static void AddLibrary() { if (UtilityBox.IsSteamRunning()) { ErrorHandler.Instance.ShowNotificationMessage("Turn Off Steam removing steam library."); return; } RealSizeOnDiskTask.Instance.Cancel(); LibraryDetector.Refresh(); RealSizeOnDiskTask.Instance.Start(); FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); folderBrowserDialog.Description = "Create or select new Steam library folder:"; bool isSelectedPathValidated = false; string selectedPath; while (folderBrowserDialog.ShowDialog() == DialogResult.OK) { selectedPath = folderBrowserDialog.SelectedPath; isSelectedPathValidated = ValidateSelectedPath(selectedPath); if (isSelectedPathValidated) { break; } } if (!isSelectedPathValidated) { return; } selectedPath = folderBrowserDialog.SelectedPath; if (selectedPath.EndsWith("_removed")) { selectedPath = StringOperations.RemoveStringAtEnd(selectedPath, "_removed"); selectedPath = StringOperations.RenamePathWhenExists(selectedPath); FileSystem.RenameDirectory(folderBrowserDialog.SelectedPath, Path.GetFileName(selectedPath)); } Library library = new Library(); library.GamesList = new SortableBindingList <Game>(); library.LibraryDirectory = selectedPath; Directory.CreateDirectory(selectedPath + "\\steamapps"); RealSizeOnDiskTask.Instance.Cancel(); BindingDataContext.Instance.LibraryList.Add(library); SteamConfigFileWriter.WriteLibraryList(); LibraryDetector.Refresh(); RealSizeOnDiskTask.Instance.Start(); }