private async Task UpdateCatalog_ExecuteAsync() { Reporter.StartBusy(); BulkData oracleBulkData = (await ScryfallService.GetBulkDataInfo(Reporter)).Data.Single(bd => bd.Name.Contains("Oracle")); List <Card> cards = await ScryfallService.GetBulkCards(oracleBulkData.PermalinkUri, Reporter); if (cards == null || cards.Count == 0) { Reporter.Report("Cards not found or empty", true); Reporter.StopBusy(); return; } Reporter.Report("Transcribing secrets of the fish men"); var catalog = new CardCatalog(oracleBulkData, cards, DateTime.Now); try { catalog.SaveToFile(); } catch (Exception e) { DisplayError(e, "Could not save card catalog to local disk."); Reporter.Report(e.Message, true); Reporter.StopBusy(); return; } OracleCatalog = catalog; Reporter.Report("Secrets hidden in a safe place"); Reporter.StopBusy(); }
static void Main(string[] args) { CardCatalog bookCatalog = new CardCatalog(); Console.WriteLine("Enter a file name"); bookCatalog.FileName = Console.ReadLine(); bookCatalog.MenuDisplay(); Console.ReadLine(); }
static void Main(string[] args) { bool displayMenu = true; while (displayMenu == true) { displayMenu = CardCatalog.MainMenu(); } }
public void LoadDeck(CardCatalog cards) { foreach (var card in DeckList.Select(setCode => Library.Create(setCode, this))) { card.History = History; card.Zone = Deck; cards.RegisterCard(card); Deck.Add(card); } History.Add(new LoadDeck(this, new ReadOnlyCollection <Card>(Deck.ToList()))); }
/// <summary> /// Initializes a new instance of the <see cref="ViewModelLocator"/> class. /// </summary> public ViewModelLocator() { // Initialize other DialogService = new DialogService.DialogService(); Reporter = new ReporterNoLog(); // Initialize large/serialized objects CardCatalog = CardCatalog.CreateFromFile(); ArtworkPreferences = ArtworkPreferences.CreateFromFile(); // Initialize container dependencies. DialogService.Register <MessageDialogViewModel, MessageDialogView>(); DialogService.Register <YesNoDialogViewModel, YesNoDialogView>(); DialogService.Register <SettingsDialogViewModel, SettingsDialogView>(); DialogService.Register <ChooseCardDialogViewModel, ChooseCardDialogView>(); // Initialize View Models MainVm = new MainViewModel(DialogService, Reporter, CardCatalog, ArtworkPreferences); }
static void Main(string[] args) { // prompt user to enter the name of a file //this file will be used to save all the information //in the application when the user closes it Console.WriteLine("Please enter a file name:"); string userFileName = Console.ReadLine(); //user is presented with a numeric list of options //user should be able to enter a numeric choice //if user enters 1 or 2 then menu should redisplay //if user enters 3 then menu should close CardCatalog a = new CardCatalog(userFileName); Console.Clear(); Console.WriteLine("Please select an option below (choose by number 1 - 3):"); Console.Write("1: List All Books\n2: Add A Book\n3: Remove Book\n4: Save & Exit\nChoice: "); int number = Convert.ToInt32(Console.ReadLine()); switch (number) { case 1: a.ListBooks(); break; case 2: a.AddBook(); break; case 3: // Save Method should be placed here break; default: Console.WriteLine("Sorry, invalid selecton. Please enter 1, 2 or 3"); break; } }
/// <summary> /// Creates a new instance of <see cref="MainViewModel"/>. /// </summary> /// <param name="dialogService">Service for resolving and showing dialog windows from viewmodels.</param> /// <param name="reporter">Reports status and progress events to subscribers.</param> /// <param name="cardCatalog">Holds a queryable set of all oracle cards (no duplicate printings) to prevent excess queries to ScryfallAPI.</param> /// <param name="artworkPreferences">Holds a mapping of Oracle Ids to Card Ids to store and retrieve a user's preferred printing of a card.</param> public MainViewModel(IDialogService dialogService, IReporter reporter, CardCatalog cardCatalog, ArtworkPreferences artworkPreferences) { DialogService = dialogService; Reporter = reporter; OracleCatalog = cardCatalog; ArtPreferences = artworkPreferences; ZoomPercent = Settings.Default.ZoomPercent; if (ApplicationDeployment.IsNetworkDeployed) { Version version = ApplicationDeployment.CurrentDeployment.CurrentVersion; SoftwareVersion = $"{version.Major}.{version.Minor}.{version.Build}"; } else { SoftwareVersion = "Debug"; } Reporter.StatusReported += (sender, args) => LastStatus = args; Reporter.ProgressReported += (sender, args) => LastProgress = args; }
private static void Init() { CardCatalog.DefineCards(); }