Ejemplo n.º 1
0
        private void CreateNewDeck()
        {
            Deck deck = new Deck();

            deck.CardList = new List<DeckCard>();

            this.deckLayout.Tag = deck;

            this.deckLayout.LargeImageList = new ImageList();
            //this.deckLayout.SmallImageList = new ImageList();
            //this.deckLayout.StateImageList = new ImageList();

            this.deckLayout.Groups.Add("Creatures", "Creatures ({0} cards)".FormatIt(0));
            this.deckLayout.Groups.Add("Spells", "Spells ({0} cards)".FormatIt(0));
            this.deckLayout.Groups.Add("Lands", "Lands ({0} cards)".FormatIt(0));
            this.deckLayout.Groups.Add("Sideboard", "Sideboard ({0} cards)".FormatIt(0));
        }
Ejemplo n.º 2
0
        private string GenerateFileContent(Deck deck, FileType fileType)
        {
            FileHandler fileHandler;

            switch(fileType) {
                case FileType.MagicWorkstation:
                    fileHandler = new MagicWorkstationFileHandler();
                    break;

                case FileType.Cockatrice:
                    fileHandler = new CockatriceFileHandler();
                    break;

                case FileType.MagicOnline:
                    fileHandler = new MagicOnlineFileHandler();
                    break;

                case FileType.Apprentice:
                default:
                    fileHandler = new ApprenticeFileHandler();
                    break;
            }

            return fileHandler.Generate(deck);
        }
Ejemplo n.º 3
0
        public void LoadDeckToDeckViewer(Deck deck, List<string> archeTypes)
        {
            this.deckLayout.Clear();

            /*
             * Create Group Titles
             */
            int sideboard = 0;
            int creatures = 0;
            int lands = 0;
            int spells = 0;
            int mainboard = 0;

            if(deck != null) {
                foreach(DeckCard card in deck.CardList) {
                    if(card.Sideboard) {
                        sideboard += card.Amount;
                    }
                    else {
                        switch(card.Card.MainType) {
                            case "Creature":
                                creatures += card.Amount;
                                break;

                            case "Land":
                                lands += card.Amount;
                                break;

                            default:
                                spells += card.Amount;
                                break;
                        }

                        mainboard += card.Amount;
                    }
                }

                this.deckLayout.Groups.Add("Creatures", "Creatures ({0} cards)".FormatIt(creatures));
                this.deckLayout.Groups.Add("Spells", "Spells ({0} cards)".FormatIt(spells));
                this.deckLayout.Groups.Add("Lands", "Lands ({0} cards)".FormatIt(lands));
                this.deckLayout.Groups.Add("Sideboard", "Sideboard ({0} cards)".FormatIt(sideboard));

                /*
                 * Load Deck
                 */
                this.txtName.Text = deck.Name;
                this.txtAuthor.Text = deck.Author;
                this.txtComment.Text = deck.Comment;

                this.lbArchetypes.Items.Clear();

                foreach(string archeType in archeTypes) {
                    this.lbArchetypes.Items.Add(archeType);
                }

                var orderedList =
                    from item in deck.CardList
                    orderby item.Card.ConvertedCastingCost ascending, item.Card.Name ascending
                    select item;

                this.deckLayout.LargeImageList = new ImageList();
                //this.deckLayout.SmallImageList = new ImageList();
                //this.deckLayout.StateImageList = new ImageList();

                // -----------------------------

                ListViewItem[] itemList = new ListViewItem[orderedList.Count()];
                int index = 0;

                foreach(var item in orderedList) {
                    DeckCard card = (DeckCard)item;

                    //this.AddCardToDeck(card, true);

                    ListViewItem listItem = new ListViewItem();

                    listItem.Name = card.Card.Name;
                    listItem.Text = card.Amount + " " + card.Card.Name;
                    listItem.Tag = card;

                    if(card.Card.FirstEditionFromList != null) {
                        string filename = Toenda.Lhurgoyf.Utility.Helper.CreateImageFilename(
                            card.Card.FirstEditionFromList.Shortname,
                            card.Card.Name
                        );

                        if(!File.Exists(filename)) {
                            if(!Directory.Exists("img\\" + card.Card.FirstEditionFromList.Shortname + "\\")) {
                                Directory.CreateDirectory("img\\" + card.Card.FirstEditionFromList.Shortname + "\\");
                            }

                            ImageLoader.DownloadImage(
                                card.Card.FirstEditionImageFromList.Url.AbsoluteUri,
                                filename,
                                card.Card.MainType
                            );
                        }

                        Bitmap bmpToShrink = new Bitmap(filename);

                        Bitmap bmp = this._imageGenerator.GenerateNewResolution(bmpToShrink, 48);

                        this.deckLayout.LargeImageList.Images.Add(card.Card.Name, bmp);
                        //this.deckLayout.SmallImageList.Images.Add(card.Card.Name, bmp);
                        //this.deckLayout.StateImageList.Images.Add(card.Card.Name, bmp);

                        listItem.ImageKey = card.Card.Name;
                    }

                    ListViewGroup group = null;

                    if(card.Sideboard) {
                        group = this.deckLayout.Groups["Sideboard"];
                    }
                    else {
                        switch(card.Card.MainType) {
                            case "Creature":
                                group = this.deckLayout.Groups["Creatures"];
                                break;

                            case "Land":
                                group = this.deckLayout.Groups["Lands"];
                                break;

                            default:
                                group = this.deckLayout.Groups["Spells"];
                                break;
                        }
                    }

                    listItem.Group = group;

                    itemList[index] = listItem;

                    index++;
                }

                this.deckLayout.Items.AddRange(itemList);

                this.deckLayout.Refresh();
                this.deckLayout.Update();

                // -----------------------------

                this.closeToolStripMenuItem.Enabled = true;
                this.saveToolStripMenuItem.Enabled = true;
                this.saveAsToolStripMenuItem.Enabled = true;

                this.deckLayout.Tag = deck;

                this.SetDeckCardAmountLabel();
            }
        }