diff --git a/CVRMelonAssistant/App.xaml b/CVRMelonAssistant/App.xaml index 6d9666b..9f2d19e 100644 --- a/CVRMelonAssistant/App.xaml +++ b/CVRMelonAssistant/App.xaml @@ -25,6 +25,7 @@ + diff --git a/CVRMelonAssistant/CVRMelonAssistant.csproj b/CVRMelonAssistant/CVRMelonAssistant.csproj index 02ae264..c1b6cc1 100644 --- a/CVRMelonAssistant/CVRMelonAssistant.csproj +++ b/CVRMelonAssistant/CVRMelonAssistant.csproj @@ -116,6 +116,9 @@ + + en.xaml + ModInfoWindow.xaml @@ -123,6 +126,9 @@ Intro.xaml + + ContextMenusDictionary.xaml + Designer MSBuild:Compile @@ -182,6 +188,10 @@ MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -202,6 +212,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile diff --git a/CVRMelonAssistant/Classes/HyperlinkExtensions.cs b/CVRMelonAssistant/Classes/HyperlinkExtensions.cs index 3578779..05a22ca 100644 --- a/CVRMelonAssistant/Classes/HyperlinkExtensions.cs +++ b/CVRMelonAssistant/Classes/HyperlinkExtensions.cs @@ -1,7 +1,10 @@ +using System; using System.Diagnostics; using System.Threading.Tasks; using System.Windows; using System.Windows.Documents; +using System.Windows.Input; +using CVRMelonAssistant.Resources; namespace CVRMelonAssistant { @@ -45,5 +48,20 @@ public static void NoAwait(this Task task) } }); } + + public static Hyperlink Create(string uri) + { + var link = new Hyperlink(new Run(uri)) { NavigateUri = new Uri(uri) }; + link.RequestNavigate += Hyperlink_RequestNavigate; + link.MouseRightButtonUp += Hyperlink_RightClick; + return link; + } + + public static void Hyperlink_RightClick(object sender, MouseButtonEventArgs e) + { + var cm = ContextMenusDictionary.Instance.HyperlinkContextMenu; + cm.DataContext = sender; + cm.IsOpen = true; + } } } diff --git a/CVRMelonAssistant/Localisation/en.xaml b/CVRMelonAssistant/Localisation/en.xaml index 40c3b24..9b5e277 100644 --- a/CVRMelonAssistant/Localisation/en.xaml +++ b/CVRMelonAssistant/Localisation/en.xaml @@ -1,4 +1,5 @@ Feel free to join the - + ChilloutVR Modding Group discord for more info, help, and support. @@ -120,7 +121,7 @@ ChilloutVR Melon Assistant is a fork of Assistant's Mod Assistant for Beat Saber. Visit - + Mod Assistant GitHub repo to appreciate their hard work and/or throw some money at them! diff --git a/CVRMelonAssistant/Localisation/en.xaml.cs b/CVRMelonAssistant/Localisation/en.xaml.cs new file mode 100644 index 0000000..c67ce4f --- /dev/null +++ b/CVRMelonAssistant/Localisation/en.xaml.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace CVRMelonAssistant.Localisation { + public partial class en { + private void Hyperlink_RightClick(object sender, MouseButtonEventArgs e) { + HyperlinkExtensions.Hyperlink_RightClick(sender, e); + } + } +} diff --git a/CVRMelonAssistant/ModInfoWindow.xaml.cs b/CVRMelonAssistant/ModInfoWindow.xaml.cs index 7df44b1..1b2bde5 100644 --- a/CVRMelonAssistant/ModInfoWindow.xaml.cs +++ b/CVRMelonAssistant/ModInfoWindow.xaml.cs @@ -24,7 +24,7 @@ public void SetMod(Mod mod) DownloadLink.Text = (string) FindResource("ModInfoWindow:DownloadLink"); DownloadLink.Inlines.Add(new Run(" ")); if (dlLink?.StartsWith("http") == true) - DownloadLink.Inlines.Add(CreateHyperlink(dlLink)); + DownloadLink.Inlines.Add(HyperlinkExtensions.Create(dlLink)); else DownloadLink.Inlines.Add(new Run(dlLink)); @@ -32,19 +32,12 @@ public void SetMod(Mod mod) SourceCodeLink.Text = (string) FindResource("ModInfoWindow:SourceCodeLink"); SourceCodeLink.Inlines.Add(new Run(" ")); if (srcLink?.StartsWith("http") == true) - SourceCodeLink.Inlines.Add(CreateHyperlink(srcLink)); + SourceCodeLink.Inlines.Add(HyperlinkExtensions.Create(srcLink)); else SourceCodeLink.Inlines.Add(new Run(srcLink)); InternalIds.Text = string.Format((string) FindResource("ModInfoWindow:InternalIds"), mod._id, mod.versions[0]._version); } - - private static Hyperlink CreateHyperlink(string uri) - { - var link = new Hyperlink(new Run(uri)) {NavigateUri = new Uri(uri)}; - link.RequestNavigate += HyperlinkExtensions.Hyperlink_RequestNavigate; - return link; - } } } diff --git a/CVRMelonAssistant/Pages/About.xaml b/CVRMelonAssistant/Pages/About.xaml index fccf323..b9b779a 100644 --- a/CVRMelonAssistant/Pages/About.xaml +++ b/CVRMelonAssistant/Pages/About.xaml @@ -68,7 +68,7 @@ VerticalAlignment="Center" FontSize="20" FontWeight="Bold"> - + Assistant @@ -88,7 +88,7 @@ HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"> - + @@ -100,7 +100,7 @@ VerticalAlignment="Center" FontSize="20" FontWeight="Bold"> - + Umbranox @@ -120,7 +120,7 @@ HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"> - + @@ -132,7 +132,7 @@ VerticalAlignment="Center" FontSize="20" FontWeight="Bold"> - + lolPants @@ -158,7 +158,7 @@ HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"> - + @@ -170,7 +170,7 @@ VerticalAlignment="Center" FontSize="20" FontWeight="Bold"> - + Caeden117 @@ -184,7 +184,7 @@ HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"> - + @@ -196,7 +196,7 @@ VerticalAlignment="Center" FontSize="20" FontWeight="Bold"> - + Interz @@ -210,7 +210,7 @@ HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"> - + @@ -222,7 +222,7 @@ VerticalAlignment="Center" FontSize="20" FontWeight="Bold"> - + Megalon2D @@ -242,7 +242,7 @@ HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"> - + diff --git a/CVRMelonAssistant/Pages/About.xaml.cs b/CVRMelonAssistant/Pages/About.xaml.cs index 022d4fc..a37869c 100644 --- a/CVRMelonAssistant/Pages/About.xaml.cs +++ b/CVRMelonAssistant/Pages/About.xaml.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; +using System.Windows.Input; using System.Windows.Navigation; using static CVRMelonAssistant.Http; @@ -26,6 +27,10 @@ private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e e.Handled = true; } + public void Hyperlink_RightClick(object sender, MouseButtonEventArgs e) { + HyperlinkExtensions.Hyperlink_RightClick(sender, e); + } + private async void HeadpatsButton_Click(object sender, RoutedEventArgs e) { PatButton.IsEnabled = false; diff --git a/CVRMelonAssistant/Pages/Mods.xaml b/CVRMelonAssistant/Pages/Mods.xaml index ed3e2ae..d5412ca 100644 --- a/CVRMelonAssistant/Pages/Mods.xaml +++ b/CVRMelonAssistant/Pages/Mods.xaml @@ -108,7 +108,7 @@ - + diff --git a/CVRMelonAssistant/Pages/Mods.xaml.cs b/CVRMelonAssistant/Pages/Mods.xaml.cs index 1003790..b86e75e 100644 --- a/CVRMelonAssistant/Pages/Mods.xaml.cs +++ b/CVRMelonAssistant/Pages/Mods.xaml.cs @@ -507,6 +507,10 @@ private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e e.Handled = true; } + public void Hyperlink_RightClick(object sender, MouseButtonEventArgs e) { + HyperlinkExtensions.Hyperlink_RightClick(sender, e); + } + private void Page_Loaded(object sender, RoutedEventArgs e) { RefreshColumns(); diff --git a/CVRMelonAssistant/Resources/ContextMenusDictionary.xaml b/CVRMelonAssistant/Resources/ContextMenusDictionary.xaml new file mode 100644 index 0000000..ba8ff7d --- /dev/null +++ b/CVRMelonAssistant/Resources/ContextMenusDictionary.xaml @@ -0,0 +1,8 @@ + + + + + + diff --git a/CVRMelonAssistant/Resources/ContextMenusDictionary.xaml.cs b/CVRMelonAssistant/Resources/ContextMenusDictionary.xaml.cs new file mode 100644 index 0000000..fb5e7b8 --- /dev/null +++ b/CVRMelonAssistant/Resources/ContextMenusDictionary.xaml.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; + +namespace CVRMelonAssistant.Resources { + public partial class ContextMenusDictionary { + static ContextMenusDictionary _instance = null; + ContextMenu _hyperlinkContextMenu; + + public ContextMenu HyperlinkContextMenu => _hyperlinkContextMenu; + + public static ContextMenusDictionary Instance { + get { + if(_instance is null) + _instance = new ContextMenusDictionary(); + return _instance; + } + } + + public ContextMenusDictionary() { + InitializeComponent(); + _hyperlinkContextMenu = this["cmHyperlink"] as ContextMenu; + } + private void HyperLinkContextMenu_Open(object sender, RoutedEventArgs e) { + var menuItem = sender as MenuItem; + var link = menuItem.DataContext as Hyperlink; + link.DoClick(); + } + + private void HyperLinkContextMenu_Copy(object sender, RoutedEventArgs e) { + var menuItem = sender as MenuItem; + var link = menuItem.DataContext as Hyperlink; + Clipboard.SetText(link.NavigateUri.ToString()); + } + } +} diff --git a/CVRMelonAssistant/Styles/ContextMenu.xaml b/CVRMelonAssistant/Styles/ContextMenu.xaml new file mode 100644 index 0000000..244583d --- /dev/null +++ b/CVRMelonAssistant/Styles/ContextMenu.xaml @@ -0,0 +1,19 @@ + + + diff --git a/CVRMelonAssistant/Styles/MenuItem.xaml b/CVRMelonAssistant/Styles/MenuItem.xaml index a5b27c1..557dd03 100644 --- a/CVRMelonAssistant/Styles/MenuItem.xaml +++ b/CVRMelonAssistant/Styles/MenuItem.xaml @@ -9,7 +9,7 @@