Skip to content

Commit

Permalink
Missing image handling
Browse files Browse the repository at this point in the history
Displays blank card, message about which card image is missing.
  • Loading branch information
thquinn committed Mar 2, 2015
1 parent 6f4a87a commit 933c825
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
Binary file modified IsochronDrafter.suo
Binary file not shown.
1 change: 1 addition & 0 deletions IsochronDrafter/DraftServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public bool IsValidSet()
public void PrintServerStartMessage()
{
// Get public IP address of server.
serverWindow.PrintLine("Looking up public IP...");
string url = "http://checkip.dyndns.org";
System.Net.WebRequest req = System.Net.WebRequest.Create(url);
System.Net.WebResponse resp = req.GetResponse();
Expand Down
13 changes: 12 additions & 1 deletion IsochronDrafter/DraftWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace IsochronDrafter
public partial class DraftWindow : Form
{
private static Dictionary<string, Image> cardImages = new Dictionary<string, Image>();
private static Image blankCard = Image.FromStream(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("IsochronDrafter.blank.jpg"));
public CardWindow cardWindow;
public DraftClient draftClient;
public bool canPick = true, chatBlank = true;
Expand Down Expand Up @@ -67,7 +68,17 @@ public static void LoadImage(string cardName)
if (cardImages.ContainsKey(cardName))
return;
HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(Util.imageDirectory + cardName.Replace(",", "").Replace("’", "") + ".full.jpg");
HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse();
HttpWebResponse httpWebReponse;
try
{
httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse();
}
catch (WebException ex)
{
MessageBox.Show("Couldn't find image for card " + cardName + " at URL " + httpWebRequest.RequestUri.ToString() + ".");
cardImages.Add(cardName, blankCard);
return;
}
Stream stream = httpWebReponse.GetResponseStream();
cardImages.Add(cardName, Image.FromStream(stream));
}
Expand Down
1 change: 1 addition & 0 deletions IsochronDrafter/IsochronDrafter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="blank.jpg" />
<Content Include="isochron.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
Binary file added IsochronDrafter/blank.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 933c825

Please sign in to comment.