private async void DownloadPlugin() { IsBusy = true; try { var moduleContent = await http.GetStringAsync(entry.Module); var modulePath = await Hunterpie.Instance.InstallPlugin(moduleContent); #if !DEBUG // we don't actually care if this request is failed, nor interested in value, so we will not await it _ = PluginRegistryService.Instance.ReportInstall(entry.InternalName); #endif DownloadReadme(modulePath); // when plugin is installed, we can open it's directory openDirAction = new PluginActionViewModel( GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_PLUGIN_DIRECTORY']"), Application.Current.FindResource("ICON_FOLDER") as ImageSource, new ArglessRelayCommand(() => Process.Start(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "modules", this.InternalName))) ); this.Actions.Insert(0, openDirAction); pluginList.UpdatePluginsArrangement(); OnPropertyChanged(nameof(CanDelete)); OnPropertyChanged(nameof(CanInstall)); } finally { IsBusy = false; } }
public static bool TryParseGithubLink(string readme, out PluginActionViewModel action) { var regex = new Regex(@"https://raw.githubusercontent.com/([^/]+)/([^/]+)"); if (readme != null) { var match = regex.Match(readme); if (match.Success) { var url = $"https://github.com/{match.Groups[1]}/{match.Groups[2]}"; action = ParseLink(url); return(true); } } action = null; return(false); }
public void Delete() { try { PluginManager.DeleteNonPreloadedPlugin(entry.InternalName); // when plugin is removed, we shouldn't be able to open it's folder anymore if (openDirAction != null) { this.Actions.Remove(openDirAction); openDirAction = null; } pluginList.UpdatePluginsArrangement(); OnPropertyChanged(nameof(CanDelete)); OnPropertyChanged(nameof(CanInstall)); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error on delete", MessageBoxButton.OK, MessageBoxImage.Error); PluginManager.MarkForRemoval(entry.InternalName); pluginList.UpdatePluginsArrangement(); OnPropertyChanged(nameof(CanDelete)); OnPropertyChanged(nameof(CanInstall)); } }