예제 #1
0
        private void installFromckanToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog open_file_dialog = new OpenFileDialog {
                Filter = Resources.CKANFileFilter
            };

            if (open_file_dialog.ShowDialog() == DialogResult.OK)
            {
                var        path = open_file_dialog.FileName;
                CkanModule module;

                try
                {
                    module = CkanModule.FromFile(path);
                }
                catch (Kraken kraken)
                {
                    currentUser.RaiseError(kraken.InnerException == null
                        ? kraken.Message
                        : $"{kraken.Message}: {kraken.InnerException.Message}");

                    return;
                }
                catch (Exception ex)
                {
                    currentUser.RaiseError(ex.Message);
                    return;
                }

                // We'll need to make some registry changes to do this.
                RegistryManager registry_manager = RegistryManager.Instance(CurrentInstance);

                // Remove this version of the module in the registry, if it exists.
                registry_manager.registry.RemoveAvailable(module);

                // Sneakily add our version in...
                registry_manager.registry.AddAvailable(module);

                var changeset = new List <ModChange>
                {
                    new ModChange(
                        new GUIMod(module, registry_manager.registry, CurrentInstance.VersionCriteria()),
                        GUIModChangeType.Install, null)
                };

                menuStrip1.Enabled = false;

                RelationshipResolverOptions install_ops = RelationshipResolver.DefaultOpts();
                install_ops.with_recommends = false;

                installWorker.RunWorkerAsync(
                    new KeyValuePair <List <ModChange>, RelationshipResolverOptions>(
                        changeset, install_ops));

                changeSet = null;

                UpdateChangesDialog(null, installWorker);
                ShowWaitDialog();
            }
        }
예제 #2
0
        private void installFromckanToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog open_file_dialog = new OpenFileDialog()
            {
                Filter      = Resources.CKANFileFilter,
                Multiselect = true,
            };

            if (open_file_dialog.ShowDialog() == DialogResult.OK)
            {
                // We'll need to make some registry changes to do this.
                RegistryManager registry_manager = RegistryManager.Instance(CurrentInstance);

                foreach (string path in open_file_dialog.FileNames)
                {
                    CkanModule module;

                    try
                    {
                        module = CkanModule.FromFile(path);
                    }
                    catch (Kraken kraken)
                    {
                        currentUser.RaiseError(kraken.InnerException == null
                            ? kraken.Message
                            : $"{kraken.Message}: {kraken.InnerException.Message}");

                        continue;
                    }
                    catch (Exception ex)
                    {
                        currentUser.RaiseError(ex.Message);
                        continue;
                    }

                    // Don't add metapacakges to the registry
                    if (!module.IsMetapackage)
                    {
                        // Remove this version of the module in the registry, if it exists.
                        registry_manager.registry.RemoveAvailable(module);

                        // Sneakily add our version in...
                        registry_manager.registry.AddAvailable(module);
                    }

                    if (module.IsDLC)
                    {
                        currentUser.RaiseError(Properties.Resources.MainCantInstallDLC, module);
                        continue;
                    }

                    menuStrip1.Enabled = false;

                    InstallModuleDriver(registry_manager.registry, module);
                }
                registry_manager.Save(true);
            }
        }
예제 #3
0
파일: Main.cs 프로젝트: majortoruqe/CKAN
        private void installFromckanToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog open_file_dialog = new OpenFileDialog {
                Filter = Resources.CKANFileFilter
            };

            if (open_file_dialog.ShowDialog() == DialogResult.OK)
            {
                var        path = open_file_dialog.FileName;
                CkanModule module;

                try
                {
                    module = CkanModule.FromFile(path);
                }
                catch (Kraken kraken)
                {
                    currentUser.RaiseError(kraken.InnerException == null
                        ? kraken.Message
                        : $"{kraken.Message}: {kraken.InnerException.Message}");

                    return;
                }
                catch (Exception ex)
                {
                    currentUser.RaiseError(ex.Message);
                    return;
                }

                // We'll need to make some registry changes to do this.
                RegistryManager registry_manager = RegistryManager.Instance(CurrentInstance);

                // Remove this version of the module in the registry, if it exists.
                registry_manager.registry.RemoveAvailable(module);

                // Sneakily add our version in...
                registry_manager.registry.AddAvailable(module);

                menuStrip1.Enabled = false;

                InstallModuleDriver(registry_manager.registry, module);
            }
        }
예제 #4
0
파일: Main.cs 프로젝트: sibaar/CKAN
        private async void installFromckanToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog open_file_dialog = new OpenFileDialog {
                Filter = Resources.CKANFileFilter
            };

            if (open_file_dialog.ShowDialog() == DialogResult.OK)
            {
                var        path = open_file_dialog.FileName;
                CkanModule module;

                try
                {
                    module = CkanModule.FromFile(path);
                }
                catch (Kraken kraken)
                {
                    currentUser.RaiseError(kraken.InnerException == null
                        ? kraken.Message
                        : $"{kraken.Message}: {kraken.InnerException.Message}");

                    return;
                }
                catch (Exception ex)
                {
                    currentUser.RaiseError(ex.Message);
                    return;
                }

                // We'll need to make some registry changes to do this.
                RegistryManager registry_manager = RegistryManager.Instance(CurrentInstance);

                // Remove this version of the module in the registry, if it exists.
                registry_manager.registry.RemoveAvailable(module);

                // Sneakily add our version in...
                registry_manager.registry.AddAvailable(module);

                menuStrip1.Enabled = false;

                RelationshipResolverOptions install_ops = RelationshipResolver.DefaultOpts();
                install_ops.with_recommends = false;

                try
                {
                    // Resolve the provides relationships in the dependencies
                    List <ModChange> fullChangeSet = new List <ModChange>(
                        await mainModList.ComputeChangeSetFromModList(
                            registry_manager.registry,
                            new HashSet <ModChange>()
                    {
                        new ModChange(
                            new GUIMod(
                                module,
                                registry_manager.registry,
                                CurrentInstance.VersionCriteria()
                                ),
                            GUIModChangeType.Install,
                            null
                            )
                    },
                            ModuleInstaller.GetInstance(CurrentInstance, GUI.user),
                            CurrentInstance.VersionCriteria()
                            )
                        );
                    if (fullChangeSet != null && fullChangeSet.Count > 0)
                    {
                        installWorker.RunWorkerAsync(
                            new KeyValuePair <List <ModChange>, RelationshipResolverOptions>(
                                fullChangeSet,
                                install_ops
                                )
                            );
                        ShowWaitDialog();
                    }
                }
                catch
                {
                    // If we failed, do the clean-up normally done by PostInstallMods.
                    HideWaitDialog(false);
                    menuStrip1.Enabled = true;
                }
                finally
                {
                    changeSet = null;
                }
            }
        }