From 7503919fb35c975bd77a674a1a3b90690f623785 Mon Sep 17 00:00:00 2001 From: Assistant Date: Tue, 18 Jun 2019 13:59:16 -0700 Subject: [PATCH] Added promotion links --- ModAssistant/Classes/Promotions.cs | 28 ++++++++++++++++++++++++++++ ModAssistant/ModAssistant.csproj | 1 + ModAssistant/Pages/Mods.xaml | 17 ++++++++++++++++- ModAssistant/Pages/Mods.xaml.cs | 25 +++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 ModAssistant/Classes/Promotions.cs diff --git a/ModAssistant/Classes/Promotions.cs b/ModAssistant/Classes/Promotions.cs new file mode 100644 index 0000000..518ee7b --- /dev/null +++ b/ModAssistant/Classes/Promotions.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ModAssistant +{ + class Promotions + { + public static Promotion[] ActivePromotions = + { + new Promotion + { + ModName = "YUR Fit Calorie Tracker", + Text = "Join our Discord!", + Link = "https://yur.chat" + } + }; + } + + class Promotion + { + public string ModName; + public string Text; + public string Link; + } +} diff --git a/ModAssistant/ModAssistant.csproj b/ModAssistant/ModAssistant.csproj index bd1889c..ee3d9ed 100644 --- a/ModAssistant/ModAssistant.csproj +++ b/ModAssistant/ModAssistant.csproj @@ -63,6 +63,7 @@ MSBuild:Compile Designer + diff --git a/ModAssistant/Pages/Mods.xaml b/ModAssistant/Pages/Mods.xaml index 376190b..e44c6ab 100644 --- a/ModAssistant/Pages/Mods.xaml +++ b/ModAssistant/Pages/Mods.xaml @@ -31,7 +31,22 @@ - + + + + + + + + + + + + + + + + diff --git a/ModAssistant/Pages/Mods.xaml.cs b/ModAssistant/Pages/Mods.xaml.cs index f25607d..b763e73 100644 --- a/ModAssistant/Pages/Mods.xaml.cs +++ b/ModAssistant/Pages/Mods.xaml.cs @@ -241,6 +241,15 @@ namespace ModAssistant.Pages Category = mod.category }; + foreach (Promotion promo in Promotions.ActivePromotions) + { + if (mod.name == promo.ModName) + { + ListItem.PromotionText = promo.Text; + ListItem.PromotionLink = promo.Link; + } + } + foreach (Mod installedMod in InstalledMods) { if (mod.name == installedMod.name) @@ -500,6 +509,16 @@ namespace ModAssistant.Pages } } + public string PromotionText { get; set; } + public string PromotionLink { get; set; } + public string PromotionMargin + { + get + { + if (String.IsNullOrEmpty(PromotionText)) return "0"; + return "0,0,5,0"; + } + } } private void ModsListView_SelectionChanged(object sender, SelectionChangedEventArgs e) @@ -563,5 +582,11 @@ namespace ModAssistant.Pages view.Refresh(); } } + + private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e) + { + Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); + e.Handled = true; + } } } \ No newline at end of file