private static void ModMoveConflictResolve(AIR_API.Mod ExistingMod, AIR_API.Mod NewMod, string newPath) { var result = new ItemConflictDialog().ShowDialog(ExistingMod, NewMod); if (result == DialogResult.Yes) { DeleteOldMod(); MoveMod(); } else if (result == DialogResult.No) { MakeModCopy(); } else { //Don't Import the Mod } #region Inside Methods void MakeModCopy() { string OriginalFolderName = ExistingMod.FolderName; string NewFolderName = ExistingMod.FolderName; string PathLocation = Directory.GetParent(newPath).FullName; int index = 1; while (Directory.Exists(PathLocation + "\\" + NewFolderName)) { NewFolderName = $"{OriginalFolderName}({index})"; } string ModPath = PathLocation + "\\" + NewFolderName; Directory.Move(ExistingMod.FolderPath, ModPath); } void MoveMod() { Directory.Move(ExistingMod.FolderPath, newPath); } void DeleteOldMod() { Management.FileManagement.WipeFolderContents(newPath); Directory.Delete(newPath); } #endregion }
public static void ApplyLanguage(ref ItemConflictDialog form) { form.CancelButton.Content = Program.LanguageResource.GetString("Cancel_Button"); form.OverwriteButton.Content = Program.LanguageResource.GetString("OverwriteButton"); form.MakeCopyButton.Content = Program.LanguageResource.GetString("MakeCopyButton"); }
private static void ModImportConflictResolve(string meta, string file) { string ModPath = Path.GetFileNameWithoutExtension(file); string existingMeta = Management.ProgramPaths.Sonic3AIRModsFolder + "\\" + ModPath + "\\" + "mod.json"; AIR_API.Mod ExistingMod = null; AIR_API.Mod NewMod = null; if (File.Exists(Management.ProgramPaths.Sonic3AIRModsFolder + "\\" + ModPath + "\\" + "mod.json")) { ExistingMod = new AIR_API.Mod(new FileInfo(existingMeta)); NewMod = new AIR_API.Mod(new FileInfo(meta)); } else { NewMod = new AIR_API.Mod(new FileInfo(meta)); } var result = new ItemConflictDialog().ShowDialog(ExistingMod, NewMod); if (result == DialogResult.Yes) { DeleteOldMod(); MoveMod(); } else if (result == DialogResult.No) { MakeModCopy(); } else { //Don't Import the Mod } #region Inside Methods void MakeModCopy() { int index = 1; string OriginalPath = ModPath; while (Directory.Exists(Management.ProgramPaths.Sonic3AIRModsFolder + "\\" + ModPath)) { ModPath = $"{ModPath}({index})"; } MoveMod(); } void MoveMod() { Directory.Move(System.IO.Path.GetDirectoryName(meta), Management.ProgramPaths.Sonic3AIRModsFolder + "\\" + ModPath); } void DeleteOldMod() { Directory.Delete(Management.ProgramPaths.Sonic3AIRModsFolder + "\\" + ModPath, true); } #endregion }