Skip to content

Commit

Permalink
Crash reporting and v1
Browse files Browse the repository at this point in the history
  • Loading branch information
judge2020 committed Dec 4, 2016
1 parent 7b12a53 commit 31e8053
Showing 1 changed file with 40 additions and 17 deletions.
57 changes: 40 additions & 17 deletions Export-To-Web/Class1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,55 @@ public static void OnLoad()

private static async void ExportHearthpwn()
{
var deck = DeckList.Instance.ActiveDeck;
var deckUrl = "http://www.hearthpwn.com/deckbuilder/"+deck.Class.ToLower()+"#";
foreach(var card in deck.Cards)
try
{
var cardId = CardDictionary[card.Name];
deckUrl = deckUrl + cardId + ":" + card.Count + ";";
}
var dialogResult = await OpenCopy();
if (dialogResult == MessageDialogResult.Affirmative)
{
Helper.TryOpenUrl(deckUrl);
var deck = DeckList.Instance.ActiveDeck;
var deckUrl = "http://www.hearthpwn.com/deckbuilder/"+deck.Class.ToLower()+"#";
foreach(var card in deck.Cards)
{
var cardId = CardDictionary[card.Name];
deckUrl=deckUrl+cardId+":"+card.Count+";";
}
var dialogResult = await OpenCopy();
if(dialogResult==MessageDialogResult.Affirmative)
{
Helper.TryOpenUrl(deckUrl);
}
if(dialogResult==MessageDialogResult.Negative)
{
Clipboard.SetText(deckUrl);
}
}
if (dialogResult == MessageDialogResult.Negative)
catch(Exception e)
{
Clipboard.SetText(deckUrl);
var dialogResult = await Error();
if (dialogResult == MessageDialogResult.Affirmative)
{
var url = "https://github.com/judge2020/Export-To-Web-HDT/issues/new?title=Crash Report&body=" + e.Message + " | Stacktrace: " + e.StackTrace;
Helper.TryOpenUrl(url);
}
}

}

private static async Task<MessageDialogResult> OpenCopy()
{
MetroDialogSettings messaSettings = new MetroDialogSettings();
messaSettings.AffirmativeButtonText = "Open URL";
messaSettings.NegativeButtonText = "Copy to clipboard";
return await Core.MainWindow.ShowMessageAsync("Hearthpwn URL created", "Would you like to Open the URL or copy it to clipboard?", MessageDialogStyle.AffirmativeAndNegative, messaSettings);
MetroDialogSettings messaSettings = new MetroDialogSettings
{
AffirmativeButtonText = "Open URL",
NegativeButtonText = "Copy to clipboard"
};
return await Core.MainWindow.ShowMessageAsync("Hearthpwn URL created", "Would you like to Open the URL or copy it to clipboard?", MessageDialogStyle.AffirmativeAndNegative, messaSettings);
}
private static async Task<MessageDialogResult> Error()
{
MetroDialogSettings messaSettings = new MetroDialogSettings
{
AffirmativeButtonText = "Send report",
NegativeButtonText = "don't send"
};
return await Core.MainWindow.ShowMessageAsync("Unable to create URL","Would you like to send the crash report?",MessageDialogStyle.AffirmativeAndNegative,messaSettings);
}

private static void DownloadHearthpwn()
{
Expand Down Expand Up @@ -97,7 +120,7 @@ public MenuItem MenuItem
{
var menuItem = new MenuItem()
{
Header = "Export to Hearthpwn".ToUpper()
Header = "Export \"active\" deck to Hearthpwn".ToUpper()
};


Expand Down

0 comments on commit 31e8053

Please sign in to comment.