Esempio n. 1
0
        private void Init()
        {
            AddToLog("Initializing...");

            _backgroundWorker.DoWork             += new DoWorkEventHandler(BackgroundWorker_DoWork);
            _backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorker_RunWorkerCompleted);

            _heightInPoints = 249.449f;
            _widthInPoints  = 178.583f;

            _downloadURL = @"https://www.underworldsdb.com/cards/";

            AddToLog("Download URL: " + _downloadURL);

            _decksFolderPath     = AppDomain.CurrentDomain.BaseDirectory;
            _decksFolder         = "decks";
            _decksFolderFullPath = _decksFolderPath + _decksFolder + "\\";

            AddToLog("Decks folder: " + _decksFolderFullPath);

            _deckFile          = "Deck";
            _deckFileExtension = ".pdf";

            _decklistsFolderPath     = AppDomain.CurrentDomain.BaseDirectory;
            _decklistsFolder         = "decklists";
            _decklistsFolderFullPath = _decklistsFolderPath + _decklistsFolder + "\\";

            AddToLog("Decklists folder: " + _decklistsFolderFullPath);

            _decklistFile          = "Decklist";
            _decklistFileExtension = ".pdf";

            _cardsFolderPath     = AppDomain.CurrentDomain.BaseDirectory;
            _cardsFolder         = "cards";
            _cardsFolderFullPath = _cardsFolderPath + _cardsFolder + "\\";

            AddToLog("Cards folder: " + _cardsFolderFullPath);

            _cardFileExtension = ".png";

            _fightersFolderPath     = AppDomain.CurrentDomain.BaseDirectory;
            _fightersFolder         = "fighters";
            _fightersFolderFullPath = _fightersFolderPath + _fightersFolder + "\\";

            AddToLog("Fighters folder: " + _fightersFolderFullPath);

            _fighterFileExtension = ".png";

            _maxFighters = 9;

            _warbandsFolderPath     = AppDomain.CurrentDomain.BaseDirectory;
            _warbandsFolder         = "warbands";
            _warbandsFolderFullPath = _warbandsFolderPath + _warbandsFolder + "\\";

            AddToLog("Warbands folder: " + _warbandsFolderFullPath);

            _warbandFileExtension = ".pdf";

            _underworldsDBFilePath     = AppDomain.CurrentDomain.BaseDirectory;
            _underworldsDBFile         = "UnderworldsDB.csv";
            _underworldsDBFileFullPath = _underworldsDBFilePath + _underworldsDBFile;

            AddToLog("UnderworldsDB file: " + _underworldsDBFileFullPath);

            AddToLog("Reading UnderworldsDB file...");
            CardList = new ObservableCollection <Card>(File.ReadAllLines(_underworldsDBFileFullPath).Skip(1).Select(v => Card.FromCsv(v)).ToList());

            List <Card> cardDeleteList = CardList.Where(card => string.IsNullOrEmpty(card.Name)).ToList();

            foreach (Card card in cardDeleteList)
            {
                CardList.Remove(card);
            }

            foreach (Card currentCard in CardList)
            {
                string oldWarband = WarbandList.Where(x => x == currentCard.Faction).FirstOrDefault();

                if (oldWarband == null && currentCard.Faction != "Universal")
                {
                    WarbandCount++;
                    WarbandList.Add(currentCard.Faction);
                }
            }

            WarbandList = new ObservableCollection <string>(WarbandList.OrderBy(i => i));

            WarbandList.Insert(0, "-- Select Warband --");
            WarbandList.Insert(1, "-- All Warbands --");

            AddToLog("Finished reading UnderWorldsDB file: " + CardList.Count.ToString() + " cards / " + WarbandCount.ToString() + " warbands");

            AddToLog("Initialized");

            FilteredCardList = CardList;
        }