private void FavoriteSetsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0) { // Just in case; this.MainView.CancelGeneration(); PickerResult result = (e.AddedItems[0] as FavoriteSet).Value; CardGroup kingdomCards = new CardGroup(CardGroupType.KingdomCard); CardGroup eventCards = new CardGroup(CardGroupType.Events); foreach (var card in result.Cards) { switch (card.Type) { case CardType.Event: case CardType.Landmark: card.Group = eventCards; break; default: card.Group = kingdomCards; break; } } this.MainView.Result = result; NavigationServiceHelper.Navigate(PickerView.Results); // Clear the selection this.FavoriteSetsListBox.SelectedItem = null; } }
// Constructor public MainPage() { this.InitializeComponent(); DispatcherHelper.Initialize(); var backgroundBrush = this.RequestReviewPopup.Background as SolidColorBrush; var backgroundColor = backgroundBrush.Color; backgroundColor.A = 0x66; backgroundBrush.Color = backgroundColor; // Set the data context of the listbox control to the sample data this.Loaded += this.MainPage_Loaded; this.Unloaded += this.MainPage_Unloaded; this.BackKeyPress += this.MainPage_BackKeyPress; // Create all the menu items this.ApplicationBar.AddMenuItem(Strings.Menu_CardLookup, this.CardLookup_Click); this.ApplicationBar.AddMenuItem(Strings.Menu_BlackMarket, this.BlackMarket_Click); this.ApplicationBar.AddMenuItem(Strings.Menu_Settings, this.Settings_Click); this.ApplicationBar.AddMenuItem(Strings.Menu_About, this.About_Click); if (Debugger.IsAttached) { this.ApplicationBar.AddMenuItem("Debug", (s, a) => NavigationServiceHelper.Navigate(PickerView.Debug)); } // Create all the app bar buttons as well. this.resetSettingsButton = ApplicationBarHelper.CreateIconButton( Strings.MainPage_Reset, @"\Images\appbar.reset.png", this.ResetSettings_Click); this.addFavoriteButton = ApplicationBarHelper.CreateIconButton( Strings.MainPage_Save, @"\Images\appbar.favs.addto.png", this.AddFavorite_Click); this.resetFavoritesButton = ApplicationBarHelper.CreateIconButton( Strings.MainPage_Reset, @"\Images\appbar.reset.png", this.ResetFavorites_Click); }
public MainPage() { // Force the resources to be initialized before anything tries to access them. var config = ConfigurationModel.Instance; Strings.EnsureLoaded(); CardDataStrings.EnsureLoaded(); PickerViews.Initialize(); Cards.EnsureLoaded().Wait(); this.InitializeComponent(); DispatcherHelper.Initialize(); // Set the data context of the listbox control to the sample data this.Loaded += this.MainPage_Loaded; this.SetsGrid.Loaded += this.SetsGrid_Loaded; if (Debugger.IsAttached) { (BottomAppBar as CommandBar).AddMenuItem("Debug", (s, a) => NavigationServiceHelper.Navigate(PickerView.Debug)); } }
private void StartGeneration() { // Start and show the progress bar, and change the create button //SystemTray.ProgressIndicator.IsVisible = true; this.CreateButton.Content = "Cancel"; // We don't want the generation to happen on the UI thread. // A background worker will enable stuff to continue (e.g. // quit the app) while the generation is happening. var generateWorker = new BackgroundWorker(); generateWorker.DoWork += (backgroundSender, backgroundArgs) => { try { if (this.MainView.GenerateCardList()) { // Navigation has to happen on the UI thread, so ask the Dispatcher to do it this.Dispatcher.BeginInvoke(() => NavigationServiceHelper.Navigate(PickerView.Results)); } else { this.Dispatcher.BeginInvoke( () => MessageBox.Show("Whoops! We couldn't generate a set with those options.")); } } finally { // And finally when everything is done, ask the UI thread to reenable // the buttons and hide the progress bar this.Dispatcher.BeginInvoke(this.StopGeneration); } }; generateWorker.RunWorkerAsync(); }
private void Debug_Click(object sender, EventArgs e) { NavigationServiceHelper.Navigate("/DebugPage.xaml"); }
private void About_Click(object sender, EventArgs e) { NavigationServiceHelper.Navigate("/AboutPage.xaml"); }
private void Settings_Click(object sender, EventArgs e) { NavigationServiceHelper.Navigate("/ConfigurationPage.xaml"); }
private void BlackMarket_Click(object sender, EventArgs e) { NavigationServiceHelper.Navigate("/BlackMarketPage.xaml"); }
private void CardLookup_Click(object sender, EventArgs e) { NavigationServiceHelper.Navigate("/CardFilterPage.xaml"); }
/// <summary> /// Extension method for PickerView to make it easy to navigate to the appropriate /// view associated with the given enum. /// </summary> /// <param name="view"></param> public static void Go(this PickerView view, object parameter = null) { NavigationServiceHelper.Navigate(view, parameter); }
private void About_Click(object sender, EventArgs e) { NavigationServiceHelper.Navigate(PickerView.About); }
private void Settings_Click(object sender, EventArgs e) { NavigationServiceHelper.Navigate(PickerView.Settings); }
private void BlackMarket_Click(object sender, EventArgs e) { NavigationServiceHelper.Navigate(PickerView.BlackMarket); }
private void CardLookup_Click(object sender, EventArgs e) { NavigationServiceHelper.Navigate(PickerView.CardFilter); }
public static void Go(this PickerView view) { NavigationServiceHelper <PickerView> .Navigate(view); }