예제 #1
0
        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;
            }
        }
예제 #2
0
        // 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);
        }
예제 #3
0
        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));
            }
        }
예제 #4
0
        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();
        }
예제 #5
0
 private void About_Click(object sender, EventArgs e)
 {
     NavigationServiceHelper.Navigate("/AboutPage.xaml");
 }
예제 #6
0
 private void Settings_Click(object sender, EventArgs e)
 {
     NavigationServiceHelper.Navigate("/ConfigurationPage.xaml");
 }
예제 #7
0
 private void BlackMarket_Click(object sender, EventArgs e)
 {
     NavigationServiceHelper.Navigate("/BlackMarketPage.xaml");
 }
예제 #8
0
 private void CardLookup_Click(object sender, EventArgs e)
 {
     NavigationServiceHelper.Navigate("/CardFilterPage.xaml");
 }
예제 #9
0
 /// <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);
 }
예제 #10
0
 static PickerViews()
 {
     NavigationServiceHelper.RegisterAll <PickerView>();
 }
예제 #11
0
 private void About_Click(object sender, EventArgs e)
 {
     NavigationServiceHelper.Navigate(PickerView.About);
 }
예제 #12
0
 private void Settings_Click(object sender, EventArgs e)
 {
     NavigationServiceHelper.Navigate(PickerView.Settings);
 }
예제 #13
0
 private void BlackMarket_Click(object sender, EventArgs e)
 {
     NavigationServiceHelper.Navigate(PickerView.BlackMarket);
 }
예제 #14
0
 private void CardLookup_Click(object sender, EventArgs e)
 {
     NavigationServiceHelper.Navigate(PickerView.CardFilter);
 }
예제 #15
0
 private void Debug_Click(object sender, EventArgs e)
 {
     NavigationServiceHelper.Navigate("/DebugPage.xaml");
 }
예제 #16
0
        public static async Task <Frame> RegisterAsync(this Frame frame, BackButton backButton = BackButton.Attach)
        {
            await NavigationServiceHelper.CreateAsync(BackButton.Attach, frame);

            return(frame);
        }
예제 #17
0
 public static void Go(this PickerView view)
 {
     NavigationServiceHelper <PickerView> .Navigate(view);
 }