public CompactModListItem(Mod mod) : base(mod) { InitializeComponent(); // Get the version to display and edit the name and short description Mod.ModVersion version = mod.Latest; ModTitle.Text = version.Name; // Update the local status icons (Up to date, update available) if (mod.IsInstalled) { LocalStatusIcon.Text = mod.UpToDate ? SegoeGlyphs.Checkmark : SegoeGlyphs.Repeat; LocalStatusIcon.Foreground = new SolidColorBrush(mod.UpToDate ? Colors.Green : Colors.DarkOrange); } else if (version.IncompatibleInstalledMods.Any()) { LocalStatusIcon.Text = ""; } else { LocalStatusIcon.Text = SegoeGlyphs.Download; LocalStatusIcon.Style = (Style)Application.Current.Resources["BaseTextBlockStyle"]; } }
public LargeModListItem(Mod mod, bool showIcon) : base(mod) { InitializeComponent(); // Get the version to display and edit the name and short description Mod.ModVersion version = mod.Latest; ModTitle.Text = version.Name; ModShortDescription.Text = version.ShortDescription; if (showIcon) { // Set the icon if (version.IconUrl is not null) { try { var bi = new BitmapImage(); bi.BeginInit(); bi.UriSource = new Uri(version.IconUrl, UriKind.Absolute); bi.CacheOption = BitmapCacheOption.OnLoad; bi.DecodePixelHeight = 64; bi.DecodePixelWidth = 64; bi.EndInit(); ModImage.Source = bi; } catch (IOException) { // Ignored. Happens when it can't create a temporary file to download the image. } } } else { ModImage.Visibility = Visibility.Collapsed; } // Update the local status icons (Up to date, update available) if (mod.IsInstalled) { LocalStatusIcon.Text = mod.UpToDate ? SegoeGlyphs.Checkmark : SegoeGlyphs.Repeat; LocalStatusIcon.Foreground = new SolidColorBrush(mod.UpToDate ? Colors.Green : Colors.DarkOrange); } else if (version.IncompatibleInstalledMods.Any()) { LocalStatusIcon.Text = ""; } else { LocalStatusIcon.Text = SegoeGlyphs.Download; LocalStatusIcon.Style = (Style)Application.Current.Resources["BaseTextBlockStyle"]; } }
public override async Task <FetchedVersion> GetLatestVersion(Mod.ModVersion mod) { HtmlDocument page = await new HtmlWeb().LoadFromWebAsync(mod.SourceUrl); HtmlNode modData = page.GetElementbyId("mod-data"); string version = modData.SelectSingleNode("div[8]/div[2]").InnerHtml; string downloadUrl = "https://bonetome.com" + page.GetElementbyId("download-button").ParentNode.Attributes["href"].Value; return(new FetchedVersion { Version = SanitizeVersionString(version), DownloadUrl = downloadUrl }); }
public override async Task <FetchedVersion> GetLatestVersion(Mod.ModVersion mod) { string[] split = mod.SourceUrl.Split("/"); Release latest = await _client.Repository.Release.GetLatest(split[3], split[4]); Version version = SanitizeVersionString(latest.TagName); // Do some filtering to determine the asset to use if there is more than one ReleaseAsset asset; if (latest.Assets.Count > 1) { ReleaseAsset[] assets = latest.Assets .Where(x => Regex.IsMatch( mod.DownloadUrl, Regex.Replace(Regex.Escape(x.Name), @"\d(?:\\\.\d)+", ".*") ) ).ToArray(); if (assets.Length > 1) { throw new Exception("There was more than one asset and the correct one could not be determined."); } asset = assets[0]; } else { asset = latest.Assets[0]; } return(new FetchedVersion { Version = version, DownloadUrl = asset.BrowserDownloadUrl }); }
public abstract Task <FetchedVersion> GetLatestVersion(Mod.ModVersion mod);