Exemplo n.º 1
0
        /// <summary>
        ///     Remove (Delete) this plugin
        /// </summary>
        public void Remove(bool forceRefresh = true)
        {
            if (!ProcessHandler.RequestServerStop())
            {
                return;
            }

            if (Directory.Exists(Fl.Location(RequestFile.Plugindir) + Name))
            {
                switch (
                    MetroMessageBox.Show(null,
                                         "This folder seems to be associated with the " + Name + " plugin." + '\n' +
                                         "Do you want to delete this folder?", "Delete plugin folder", MessageBoxButtons.YesNoCancel,
                                         MessageBoxIcon.Question))
                {
                case DialogResult.Cancel:
                    return;

                case DialogResult.Yes:
                    Directory.Delete(Fl.Location(RequestFile.Plugindir) + Name);
                    break;

                case DialogResult.No:
                    break;
                }
            }
            File.Delete(Path);

            if (forceRefresh)
            {
                InstalledPluginManager.RefreshAllInstalledPluginsAsync();
            }
        }
Exemplo n.º 2
0
 private void UninstallSelectedPlugins(object sender, EventArgs e)
 {
     if (slvPlugins.SelectedItems.Count < 0)
     {
         return;
     }
     foreach (ListViewItem item in slvPlugins.SelectedItems)
     {
         InstalledPlugin plugin = (InstalledPlugin)item.Tag;
         if (
             MetroMessageBox.Show(Application.OpenForms[0],
                                  "Are you sure you want to delete this plugin?" + Environment.NewLine + plugin.Name,
                                  "Delete this plugin?",
                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             plugin.Remove(false);
         }
     }
     InstalledPluginManager.RefreshAllInstalledPluginsAsync();
     slvPlugins_SelectedIndexChanged(null, null);             // force index check to disable buttons if needed
 }
Exemplo n.º 3
0
        /// <summary>
        ///     Update each plugin, if it's checked
        /// </summary>
        /// <remarks></remarks>
        private void Plugins_Update(object sender, EventArgs e)
        {
            try
            {
                if (InvokeRequired)
                {
                    Invoke((MethodInvoker)(() => Plugins_Update(sender, e)));
                }
                else
                {
                    Logger.Log(LogLevel.Info, "PluginUpdater", "Starting plugins update");
                    if (SlvPlugins.CheckedItems.Count < 1)
                    {
                        return;
                    }
                    UInt16 i = 1;
                    foreach (ListViewItem item in SlvPlugins.CheckedItems)
                    {
                        if (item.Tag != null)
                        {
                            InstalledPlugin     plugin  = (InstalledPlugin)item.Tag;
                            BukgetPluginVersion version = _pluginLinkDictionary[plugin].LastVersion;

                            if (version == null)
                            {
                                continue;
                            }


                            SetStatus(T.Tr("Updating plugin") + " " + plugin.Name + " " +
                                      T.Tr("to version") + " " + version.VersionNumber +
                                      " (" + i + "/" + SlvPlugins.CheckedItems.Count + ")");

                            Logger.Log(LogLevel.Info, "PluginUpdater", "Updating plugin:" + plugin.Name);
                            BukgetPluginInstaller.Install(version, plugin.Path, false,
                                                          false);
                        }

                        else
                        {
                            SetStatus(T.Tr("Skipping plugin") + " " + item.SubItems[0].Text + " - " +
                                      T.Tr("cannot update") + "(" + i +
                                      1 + " / " + _pluginLinkDictionary.Count + ")");
                            Logger.Log(LogLevel.Info, "PluginUpdater", "Skipping plugin:" + item.SubItems[0].Text);
                        }
                        double tmpp = Math.Round(100 * ((i + 1) / (double)_pluginLinkDictionary.Count));
                        if (tmpp > 100)
                        {
                            tmpp = 100;
                        }
                        SetProgress(Convert.ToByte(tmpp));
                        i++;
                    }


                    SetStatus(T.Tr("Idle"));

                    if (BtnClose != null && !(Disposing || IsDisposed) && !(BtnClose.Disposing || BtnClose.IsDisposed))
                    {
                        BtnClose.Enabled = true;
                    }

                    InstalledPluginManager.RefreshAllInstalledPluginsAsync();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(T.Tr("Something went wrong while updating. Please check if all plugins are updated."),
                                T.Tr("Something went wrong"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                Logger.Log(LogLevel.Warning, "PluginUpdater", "Severe exception in Update routine!", ex.Message);
            }
            CloseThisForm(null, null);
        }
Exemplo n.º 4
0
 private void ReloadInstalledPlugins(object sender, EventArgs e)
 {
     InstalledPluginManager.RefreshAllInstalledPluginsAsync();
 }