private void Uninstall(PluginManagerViewItem item) { if (_oNode != 0) { var a = PluginManagerUtils.IsInstalled(item.Hash); if (a == null) { return; } var f = new FileInfo(a.Location); var fn = Path.Combine(f.DirectoryName, Path.GetFileNameWithoutExtension(f.Name) + ".tmp"); f.MoveTo(fn); Process.Start(Application.ExecutablePath, $"--removePlugin \"{Path.GetFileName(f.FullName)}\""); Application.Exit(); } }
private void SetInstalled() { _pluginsView.Items.Clear(); SetLoading(true, Language.Language._110); _pluginsView.SuspendLayout(); Task.Run(() => { var plugins = PluginManagerUtils.GetInstalledPlugins(); Invoke(new MethodInvoker(delegate() { for (int i = 0; i < plugins.Count; i++) { var item = PluginManagerViewItem.PluginToPluginManagerViewItem(plugins[i]); item.Installed = true; _pluginsView.Items.Add(item); } SetLoading(false); _pluginsView.ResumeLayout(); })); }); }
private void Install(PluginManagerViewItem item) { if (_onlinePlugins == null) { return; } SetLoading(true, Language.Language._114); Task.Run(install); void install() { try { var src = PluginManagerUtils.GetArchiveURL(_onlinePlugins.Archive_URL, item.Name); this?.Invoke(new MethodInvoker(delegate() { SetLoading(true, string.Format(Language.Language._115, src)); loadingProgressBar.Style = ProgressBarStyle.Blocks; })); var client = new WebClient(); client.DownloadProgressChanged += Client_DownloadProgressChanged; client.DownloadFileCompleted += Client_DownloadFileCompleted; var path = Path.Combine(Plugin.Extract.PluginDirectory.FullName, Path.GetFileNameWithoutExtension(item.Name) + ".tmp"); if (File.Exists(path)) { File.Delete(path); } else if (Directory.Exists(path)) { Directory.Delete(path, true); } _tempFile = path; Debug.WriteLine($"download plugin {src}"); client.DownloadFileTaskAsync(src, path); } catch (Exception ex) { MessageBox.Show($"Download failed\n{ex}", ":(", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }