public MainPage() { this.InitializeComponent(); if (Settings.run == true) { SettingsPane.GetForCurrentView().CommandsRequested += OnSettingsPaneCommandRequested; Settings.run = false; } //Displays a random item from the XML file into the itemDisplay textbox DisplayRandomItem(itemDisplay); //fills the item list once the list is empty if (Settings.runFillList == true) { ItemListFiller creator = new ItemListFiller(); items = creator.ListFiller(); Settings.runFillList = false; } }
public ListPage() { this.InitializeComponent(); ItemListFiller creator = new ItemListFiller(); itemsList = creator.ListFiller(); int numberOfItems = itemsList.Count(); //populates the textblock with the items for (int i = 0; i <= numberOfItems - 1; i++) { itemListTextBlock.Text = itemListTextBlock.Text + Convert.ToString(i + 1) + ". " + itemsList[i] + "\n\n"; } }
public void DisplayRandomItem(TextBlock itemDisplay) { try { int numOfItems = items.Count(); Random rand = new Random(); //randThing is used to randomly pick an index number in the item list //The upper limit of randThing is determined by numOfItems. int randThing = rand.Next(0, numOfItems); //Displays the randomly picked item itemDisplay.Text = items[randThing]; //The displayed item is removed from the list so it won't display again items.RemoveAt(randThing); } //If the item list runs out. The list is repopulated and the method is run again. catch { ItemListFiller creator = new ItemListFiller(); items = creator.ListFiller(); DisplayRandomItem(itemDisplay); } }