示例#1
0
        private void deleteRegistryKey_Click(object sender, EventArgs e)
        {
            // prompt user to confirm delete
            string msg     = "Are you sure you want to permanently delete this key and all of its subkeys?";
            string caption = "Confirm Key Delete";
            var    answer  = MessageBox.Show(msg, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (answer == DialogResult.Yes)
            {
                string parentPath = tvRegistryDirectory.SelectedNode.Parent.FullPath;

                _registryHandler.DeleteRegistryKey(parentPath, tvRegistryDirectory.SelectedNode.Name);
            }
        }
            private void UnlinkBackup()
            {
                var gbPath = BackupService.GetGameBackupPath(Game, false, false, forceReturnPath: true);

                Log.Information($@"User is attempting to unlink backup for {Game}");
                var message      = M3L.GetString(M3L.string_dialog_unlinkingBackup, Utilities.GetGameName(Game), gbPath, Utilities.GetGameName(Game));
                var shouldUnlink = M3L.ShowDialog(window, message, M3L.GetString(M3L.string_unlinkingBackup), MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes;

                if (shouldUnlink)
                {
                    // Unlink
                    Log.Information($@"Unlinking backup for {Game}");
                    if (gbPath != null)
                    {
                        var cmmVanilla = Path.Combine(gbPath, @"cmm_vanilla");
                        if (File.Exists(cmmVanilla))
                        {
                            Log.Information(@"Deleted cmm_vanilla file: " + cmmVanilla);
                            File.Delete(cmmVanilla);
                        }
                    }
                    switch (Game)
                    {
                    case MEGame.ME1:
                    case MEGame.ME2:
                        RegistryHandler.DeleteRegistryKey(Registry.CurrentUser, @"Software\ALOTAddon",
                                                          Game + @"VanillaBackupLocation");
                        break;

                    case MEGame.ME3:
                        RegistryHandler.DeleteRegistryKey(Registry.CurrentUser, @"Software\Mass Effect 3 Mod Manager",
                                                          @"VanillaCopyLocation");
                        break;
                    }
                    BackupService.RefreshBackupStatus(window, Game);
                }
            }