Added donate button

This commit is contained in:
Joshua Askharoun
2021-05-06 04:34:46 -05:00
parent 9c1a7460ed
commit f5fc215b8f
3 changed files with 37 additions and 20 deletions
+25 -15
View File
@@ -11,23 +11,13 @@ namespace ZuneModdingHelper
/// </summary>
public partial class App : Application
{
public static string Title => "Zune Modding Helper";
public static readonly string Title = "Zune Modding Helper";
public static Version VersionNum => new(2021, 5, 6, 0);
public static string VersionStatus => "alpha";
public static string Version => VersionNum.ToString() + (VersionStatus != string.Empty ? "-" + VersionStatus : string.Empty);
public static readonly Version VersionNum = new(2021, 5, 6, 0);
public static readonly string VersionStatus = "alpha";
public static readonly string Version = VersionNum.ToString() + (VersionStatus != string.Empty ? "-" + VersionStatus : string.Empty);
public static bool CheckIfNewerVersion(string otherStr)
{
int idxSplit = otherStr.IndexOf('-');
Version otherNum = new(otherStr[..idxSplit]);
string otherStatus = otherStr[(idxSplit + 1)..];
// TODO: This assumes that the VersionStatus is "alpha"
bool isNotAlpha = otherStatus != VersionStatus;
bool isNewer = otherNum > VersionNum;
return isNotAlpha || isNewer;
}
public static readonly string DonateLink = "https://www.paypal.com/donate?business=38QWBDS9PJUAQ&currency_code=USD";
protected override void OnStartup(StartupEventArgs e)
{
@@ -42,5 +32,25 @@ namespace ZuneModdingHelper
AppCenter.SetEnabledAsync(false);
#endif
}
public static void OpenInBrowser(string url)
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(url)
{
UseShellExecute = true
});
}
public static bool CheckIfNewerVersion(string otherStr)
{
int idxSplit = otherStr.IndexOf('-');
Version otherNum = new(otherStr[..idxSplit]);
string otherStatus = otherStr[(idxSplit + 1)..];
// TODO: This assumes that the VersionStatus is "alpha"
bool isNotAlpha = otherStatus != VersionStatus;
bool isNewer = otherNum > VersionNum;
return isNotAlpha || isNewer;
}
}
}
+9 -1
View File
@@ -23,7 +23,15 @@
<mah:MetroWindow.Flyouts>
<mah:FlyoutsControl>
<mah:Flyout x:Name="AboutFlyout" Header="About" Position="Right" IsModal="True" Theme="Adapt">
<mah:Flyout x:Name="AboutFlyout" Position="Right" IsModal="True" Theme="Adapt">
<mah:Flyout.Header>
<Grid>
<TextBlock Text="About" FontSize="26" FontWeight="Bold"/>
<Button Content="Donate" Click="DonateButton_Click" ToolTip="Support development of this and other projects"
Grid.Row="1" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Right" Margin="4"
Style="{StaticResource MahApps.Styles.Button.MetroSquare.Accent}"/>
</Grid>
</mah:Flyout.Header>
<TextBlock FontSize="14" Padding="16" TextWrapping="Wrap">
<Run Text="{x:Static local:App.Title}" FontWeight="Bold" FontSize="16"/><LineBreak/>
<Run Text="{x:Static local:App.Version}"/><LineBreak/>
+3 -4
View File
@@ -149,10 +149,7 @@ namespace ZuneModdingHelper
private void Link_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)
{
UseShellExecute = true
});
App.OpenInBrowser(e.Uri.AbsoluteUri);
e.Handled = true;
}
@@ -233,5 +230,7 @@ namespace ZuneModdingHelper
{ "Accepted", acceptedUpdate.ToString() },
});
}
private void DonateButton_Click(object sender, RoutedEventArgs e) => App.OpenInBrowser(App.DonateLink);
}
}