Skip to content

Commit f5fc215

Browse files
committed
Added donate button
1 parent 9c1a746 commit f5fc215

3 files changed

Lines changed: 37 additions & 20 deletions

File tree

ZuneModdingHelper/App.xaml.cs

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,13 @@ namespace ZuneModdingHelper
1111
/// </summary>
1212
public partial class App : Application
1313
{
14-
public static string Title => "Zune Modding Helper";
14+
public static readonly string Title = "Zune Modding Helper";
1515

16-
public static Version VersionNum => new(2021, 5, 6, 0);
17-
public static string VersionStatus => "alpha";
18-
public static string Version => VersionNum.ToString() + (VersionStatus != string.Empty ? "-" + VersionStatus : string.Empty);
16+
public static readonly Version VersionNum = new(2021, 5, 6, 0);
17+
public static readonly string VersionStatus = "alpha";
18+
public static readonly string Version = VersionNum.ToString() + (VersionStatus != string.Empty ? "-" + VersionStatus : string.Empty);
1919

20-
public static bool CheckIfNewerVersion(string otherStr)
21-
{
22-
int idxSplit = otherStr.IndexOf('-');
23-
Version otherNum = new(otherStr[..idxSplit]);
24-
string otherStatus = otherStr[(idxSplit + 1)..];
25-
26-
// TODO: This assumes that the VersionStatus is "alpha"
27-
bool isNotAlpha = otherStatus != VersionStatus;
28-
bool isNewer = otherNum > VersionNum;
29-
return isNotAlpha || isNewer;
30-
}
20+
public static readonly string DonateLink = "https://www.paypal.com/donate?business=38QWBDS9PJUAQ&currency_code=USD";
3121

3222
protected override void OnStartup(StartupEventArgs e)
3323
{
@@ -42,5 +32,25 @@ protected override void OnStartup(StartupEventArgs e)
4232
AppCenter.SetEnabledAsync(false);
4333
#endif
4434
}
35+
36+
public static void OpenInBrowser(string url)
37+
{
38+
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(url)
39+
{
40+
UseShellExecute = true
41+
});
42+
}
43+
44+
public static bool CheckIfNewerVersion(string otherStr)
45+
{
46+
int idxSplit = otherStr.IndexOf('-');
47+
Version otherNum = new(otherStr[..idxSplit]);
48+
string otherStatus = otherStr[(idxSplit + 1)..];
49+
50+
// TODO: This assumes that the VersionStatus is "alpha"
51+
bool isNotAlpha = otherStatus != VersionStatus;
52+
bool isNewer = otherNum > VersionNum;
53+
return isNotAlpha || isNewer;
54+
}
4555
}
4656
}

ZuneModdingHelper/MainWindow.xaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@
2323

2424
<mah:MetroWindow.Flyouts>
2525
<mah:FlyoutsControl>
26-
<mah:Flyout x:Name="AboutFlyout" Header="About" Position="Right" IsModal="True" Theme="Adapt">
26+
<mah:Flyout x:Name="AboutFlyout" Position="Right" IsModal="True" Theme="Adapt">
27+
<mah:Flyout.Header>
28+
<Grid>
29+
<TextBlock Text="About" FontSize="26" FontWeight="Bold"/>
30+
<Button Content="Donate" Click="DonateButton_Click" ToolTip="Support development of this and other projects"
31+
Grid.Row="1" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Right" Margin="4"
32+
Style="{StaticResource MahApps.Styles.Button.MetroSquare.Accent}"/>
33+
</Grid>
34+
</mah:Flyout.Header>
2735
<TextBlock FontSize="14" Padding="16" TextWrapping="Wrap">
2836
<Run Text="{x:Static local:App.Title}" FontWeight="Bold" FontSize="16"/><LineBreak/>
2937
<Run Text="{x:Static local:App.Version}"/><LineBreak/>

ZuneModdingHelper/MainWindow.xaml.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,7 @@ private void AboutButton_Click(object sender, RoutedEventArgs e)
149149

150150
private void Link_RequestNavigate(object sender, RequestNavigateEventArgs e)
151151
{
152-
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)
153-
{
154-
UseShellExecute = true
155-
});
152+
App.OpenInBrowser(e.Uri.AbsoluteUri);
156153
e.Handled = true;
157154
}
158155

@@ -233,5 +230,7 @@ private async void UpdatesButton_Click(object sender, RoutedEventArgs e)
233230
{ "Accepted", acceptedUpdate.ToString() },
234231
});
235232
}
233+
234+
private void DonateButton_Click(object sender, RoutedEventArgs e) => App.OpenInBrowser(App.DonateLink);
236235
}
237236
}

0 commit comments

Comments
 (0)