Exemple #1
0
        private void ClearCKANCacheButton_Click(object sender, EventArgs e)
        {
            YesNoDialog deleteConfirmationDialog = new YesNoDialog();
            string      confirmationText         = String.Format
                                                   (
                "Do you really want to delete {0} files from the cache for a total of {1} MB?",
                m_cacheFileCount,
                m_cacheSize / 1024 / 1024
                                                   );

            if (deleteConfirmationDialog.ShowYesNoDialog(confirmationText) == System.Windows.Forms.DialogResult.Yes)
            {
                var cachePath = Path.Combine(Main.Instance.CurrentInstance.CkanDir(), "downloads");
                foreach (var file in Directory.GetFiles(cachePath))
                {
                    try
                    {
                        File.Delete(file);
                    }
                    catch (Exception)
                    {
                    }
                }

                UpdateCacheInfo();
            }
        }
Exemple #2
0
        private void PurgeAllMenuItem_Click(object sender, EventArgs e)
        {
            YesNoDialog deleteConfirmationDialog = new YesNoDialog();
            string      confirmationText         = String.Format
                                                   (
                Properties.Resources.SettingsDialogDeleteConfirm,
                m_cacheFileCount,
                CkanModule.FmtSize(m_cacheSize)
                                                   );

            if (deleteConfirmationDialog.ShowYesNoDialog(confirmationText) == DialogResult.Yes)
            {
                // tell the cache object to nuke itself
                Main.Instance.Manager.Cache.RemoveAll();

                // forcibly tell all mod rows to re-check cache state
                foreach (DataGridViewRow row in Main.Instance.ModList.Rows)
                {
                    var mod = row.Tag as GUIMod;
                    mod?.UpdateIsCached();
                }

                // finally, clear the preview contents list
                Main.Instance.UpdateModContentsTree(null, true);

                UpdateCacheInfo(config.DownloadCacheDir);
            }
        }
Exemple #3
0
        private void ClearCKANCacheButton_Click(object sender, EventArgs e)
        {
            YesNoDialog deleteConfirmationDialog = new YesNoDialog();
            string confirmationText = String.Format
            (
                "Do you really want to delete {0} files from the cache for a total of {1} MiB?",
                m_cacheFileCount,
                m_cacheSize / 1024 / 1024
            );

            if (deleteConfirmationDialog.ShowYesNoDialog(confirmationText) == System.Windows.Forms.DialogResult.Yes)
            {
                var cachePath = Path.Combine(Main.Instance.CurrentInstance.CkanDir(), "downloads");
                foreach (var file in Directory.GetFiles(cachePath))
                {
                    try
                    {
                        File.Delete(file);
                    }
                    catch (Exception)
                    {
                    }
                }

                UpdateCacheInfo();
            }
        }
Exemple #4
0
        private void reinstallToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUIMod module = ModInfoTabControl.SelectedModule;

            if (module == null || !module.IsCKAN)
            {
                return;
            }

            YesNoDialog reinstallDialog  = new YesNoDialog();
            string      confirmationText = $"Do you want to reinstall {module.Name}?";

            if (reinstallDialog.ShowYesNoDialog(confirmationText) == DialogResult.No)
            {
                return;
            }

            IRegistryQuerier registry = RegistryManager.Instance(CurrentInstance).registry;

            // Build the list of changes, first the mod to remove:
            List <ModChange> toReinstall = new List <ModChange>()
            {
                new ModChange(module, GUIModChangeType.Remove, null)
            };
            // Then everything we need to re-install:
            var revdep = registry.FindReverseDependencies(new List <string>()
            {
                module.Identifier
            });
            var goners = revdep.Union(
                registry.FindRemovableAutoInstalled(
                    registry.InstalledModules.Where(im => !revdep.Contains(im.identifier))
                    ).Select(im => im.Module.identifier)
                );

            foreach (string id in goners)
            {
                toReinstall.Add(new ModChange(
                                    mainModList.full_list_of_mod_rows[id]?.Tag as GUIMod,
                                    GUIModChangeType.Install,
                                    null
                                    ));
            }
            // Hand off to centralized [un]installer code
            installWorker.RunWorkerAsync(
                new KeyValuePair <List <ModChange>, RelationshipResolverOptions>(
                    toReinstall,
                    RelationshipResolver.DependsOnlyOpts()
                    )
                );
        }
Exemple #5
0
        private void ClearCKANCacheButton_Click(object sender, EventArgs e)
        {
            YesNoDialog deleteConfirmationDialog = new YesNoDialog();
            string      confirmationText         = String.Format
                                                   (
                "Do you really want to delete {0} cached files, freeing {1} MB?",
                m_cacheFileCount,
                m_cacheSize / 1024 / 1024
                                                   );

            if (deleteConfirmationDialog.ShowYesNoDialog(confirmationText) == System.Windows.Forms.DialogResult.Yes)
            {
                foreach (var file in Directory.GetFiles(Main.Instance.CurrentInstance.DownloadCacheDir()))
                {
                    try
                    {
                        File.Delete(file);
                    }
                    catch (Exception)
                    {
                    }
                }

                // tell the cache object to nuke itself
                Main.Instance.CurrentInstance.Cache.OnCacheChanged();

                // forcibly tell all mod rows to re-check cache state
                foreach (DataGridViewRow row in Main.Instance.ModList.Rows)
                {
                    var mod = row.Tag as GUIMod;
                    mod?.UpdateIsCached();
                }

                // finally, clear the preview contents list
                Main.Instance.UpdateModContentsTree(null, true);

                UpdateCacheInfo();
            }
        }
Exemple #6
0
 public bool YesNoDialog(string text, string yesText = null, string noText = null)
 {
     return(yesNoDialog.ShowYesNoDialog(text, yesText, noText) == DialogResult.Yes);
 }
Exemple #7
0
 public bool YesNoDialog(string text)
 {
     return(yesNoDialog.ShowYesNoDialog(text) == DialogResult.Yes);
 }