public static void RetrieveImage(MagicCardBase card)
        {
            using (CardImagesDbContext context = new CardImagesDbContext(card.Edition))
            {
                var imageBytes = (from i in context.CardImages
                                  where i.uuid == card.uuid
                                  select i).FirstOrDefault()?.CardImageBytes;

                if (imageBytes != null)
                {
                    var img = ImageExtensions.FromByteArray(imageBytes);
                    EventManager.OnCardImageRetrieved(new CardImageRetrievedEventArgs {
                        uuid = card.uuid, CardImage = img
                    });
                }
                else
                {
                    string displayName;
                    if (card is FullInventoryCard fullInventoryCard)
                    {
                        displayName = fullInventoryCard.DisplayName;
                    }
                    else
                    {
                        displayName = card.DisplayName;
                    }
                    Globals.Forms.TasksForm.TaskManager.AddTask(new DownloadResourceTask {
                        AddFirst = true, Caption = $"Card Image: {displayName}", URL = $"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid={card.multiverseId}&type=card", TaskObject = new BasicCardArgs {
                            uuid = card.uuid, MultiverseId = card.multiverseId, Edition = card.Edition
                        }, OnTaskCompleted = EventManager.ImageDownloadCompleted
                    });
                }
            }
        }
示例#2
0
        private static string GetHTMLForPart(MagicCardBase card)
        {
            string html =
                $"<tr>" +
                $"<td>{ManaCostToImgs(card.manaCost)}</td>" +
                $"</tr>" +
                $"<tr>" +
                $"<td><b>{card.name}</b></td>" +
                $"</tr>" +
                $"<tr>" +
                $"<td><b>{card.type}</b></td>" +
                $"</tr>";

            if (card.power != null && card.toughness != null)
            {
                html += $"<tr>" +
                        $"<td><b>{card.power} / {card.toughness}</b></td>" +
                        $"</tr>";
            }
            html += $"<tr>" +
                    $"<td><br><br>{card.text?.Replace("\n", "<br>")}</td>" +
                    $"</tr>";
            if (card.flavorText != null)
            {
                html += $"<tr>" +
                        $"<td><br><br><i>{card.flavorText}</i></td>" +
                        $"</tr>";
            }
            html += "<tr><td><br><div style='font-size: 2px;'><hr>&nbsp;</div></td></tr>";
            return(html);
        }
示例#3
0
 private static string GetHTMLFooter(MagicCardBase card)
 {
     return("<tr>" +
            $"<td><b>{card.Edition} [{card.SetCode.ToUpper()}] - #{card.number}</b></td>" +
            $"</tr>" +
            $"<tr>" +
            $"<td>Artist: {card.artist}</td>" +
            $"</tr>");
 }
示例#4
0
 private void flipButton_Click(object sender, System.EventArgs e)
 {
     if (DisplayedCard == MagicCard)
     {
         DisplayedCard = MagicCard.PartB;
         CardManager.RetrieveImage(MagicCard.PartB);
     }
     else
     {
         DisplayedCard = MagicCard;
         CardManager.RetrieveImage(MagicCard);
     }
 }
示例#5
0
        public void CardSelected(MagicCardBase card)
        {
            MagicCard = DisplayedCard = card;
            if (card.layout == "transform")
            {
                flipButton.Visible    = true;
                cardTextHtmlPanel.Top = flipButton.Bottom + 5;
            }
            else
            {
                flipButton.Visible    = false;
                cardTextHtmlPanel.Top = cardPictureBox.Bottom + 5;
            }
            string html = $"<table width='100%'>" + GetHTMLForPart(card);

            if (card.PartB != null)
            {
                html += GetHTMLForPart(card.PartB);
            }

            html += GetHTMLFooter(card) + "</table>";
            cardTextHtmlPanel.Text = html;
        }