protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            string isolatedStorageFileName = this.LoadState<string>(IsolatedStorageFileNameKey);
            if (!string.IsNullOrEmpty(isolatedStorageFileName))
            {
                MainViewModel.Instance.IsolatedStorageFileName = isolatedStorageFileName;
                MainViewModel.Instance.GameMode = this.LoadState<GameModes>(GameModeKey);

                // load stream from isolated storage
                MainViewModel.Instance.LoadDeckFromIsolatedStorage();
            }

            LearningGameViewModel game = new LearningGameViewModel(MainViewModel.Instance.Decks.SelectedDeck);

            if (!string.IsNullOrEmpty(isolatedStorageFileName))
            {
                game.Index = this.LoadState<int>(LearningGameCardPairIndexKey);
                game.SelectedCardPair = MainViewModel.Instance.Decks.SelectedDeck.Collection[game.Index];
            }

            MainViewModel.Instance.GameMode = GameModes.LearningGame;
            MainViewModel.Instance.CurrentView = game;
            DataContext = MainViewModel.Instance.CurrentView;
        }
Esempio n. 2
0
        public CardDeck()
        {
            _cardPairs = new ObservableCollection<CardPair>();

            #if !SILVERLIGHT
            CreateNewCardPair = new DelegateCommand(() =>
            {
                CardPair cp = new CardPair() { IsInEdit = true , Card1 = new Card() , Card2 = new Card() ,ParentDeck = this ,IsSelected = true};
                cp.Initialize();
                _cardPairs.Add(cp);
                SelectedCardPair = cp;
                IsDirty = true;
            });

            EditDeck = new DelegateCommand(() =>
            {
                MainViewModel.Instance.CurrentView = this;
                Taskbar.AddEntryToJumpList(ZipPath, Title);
            });

            CancelCommand = new DelegateCommand(CancelEdit);

            DeleteDeck = new DelegateCommand(DeleteTheDeck);

            SaveDeck = new DelegateCommand(() =>
            {
                SaveTheDeck();
            });

            ShareDeck = new DelegateCommand(() =>
            {
                if (ShareClicked != null)
                {
                    ShareClicked(this, EventArgs.Empty);
                }
            });
            #endif
            ShowHelp = new DelegateCommand(() =>
            {
                MessageBox.Show((string)Application.Current.Resources["Resource_MessageBox_ShowHelp"]);
            });

            LearningGame = new DelegateCommand(() =>
            {
            #if !WINDOWS_PHONE
                LearningGameViewModel game = new LearningGameViewModel(this);
                MainViewModel.Instance.CurrentView = game;
            #else
                MainViewModel.Instance.GameMode = GameModes.LearningGame;
            #endif

            #if !SILVERLIGHT
                Taskbar.AddEntryToJumpList(ZipPath, Title);
            #endif
                this.IsSelected = false;
            }, () => { return Count > 0; });

            MatchingGame = new DelegateCommand(() =>
            {
            #if !WINDOWS_PHONE
                MatchingGameViewModel game = new MatchingGameViewModel(this, true);
                MainViewModel.Instance.CurrentView = game;
            #else
                MainViewModel.Instance.GameMode = GameModes.MatchingGame;
            #endif
            #if !SILVERLIGHT
                Taskbar.AddEntryToJumpList(ZipPath, Title);
            #endif
                this.IsSelected = false;
            }, () => { return Count >= 6; });

            MemoryGame = new DelegateCommand(() =>
            {
            #if !WINDOWS_PHONE
                MatchingGameViewModel game = new MatchingGameViewModel(this ,false);
                MainViewModel.Instance.CurrentView = game;
            #else
                MainViewModel.Instance.GameMode = GameModes.MemoryGame;
            #endif

            #if !SILVERLIGHT
                Taskbar.AddEntryToJumpList(ZipPath, Title);
            #endif
                this.IsSelected = false;
            }, () => { return Count >= 6; });
        }
Esempio n. 3
0
        public CardDeck()
        {
            _cardPairs = new ObservableCollection <CardPair>();

#if !SILVERLIGHT
            CreateNewCardPair = new DelegateCommand(() =>
            {
                CardPair cp = new CardPair()
                {
                    IsInEdit = true, Card1 = new Card(), Card2 = new Card(), ParentDeck = this, IsSelected = true
                };
                cp.Initialize();
                _cardPairs.Add(cp);
                SelectedCardPair = cp;
                IsDirty          = true;
            });

            EditDeck = new DelegateCommand(() =>
            {
                MainViewModel.Instance.CurrentView = this;
                Taskbar.AddEntryToJumpList(ZipPath, Title);
            });

            CancelCommand = new DelegateCommand(CancelEdit);

            DeleteDeck = new DelegateCommand(DeleteTheDeck);

            SaveDeck = new DelegateCommand(() =>
            {
                SaveTheDeck();
            });

            ShareDeck = new DelegateCommand(() =>
            {
                if (ShareClicked != null)
                {
                    ShareClicked(this, EventArgs.Empty);
                }
            });
#endif
            ShowHelp = new DelegateCommand(() =>
            {
                MessageBox.Show((string)Application.Current.Resources["Resource_MessageBox_ShowHelp"]);
            });


            LearningGame = new DelegateCommand(() =>
            {
#if !WINDOWS_PHONE
                LearningGameViewModel game         = new LearningGameViewModel(this);
                MainViewModel.Instance.CurrentView = game;
#else
                MainViewModel.Instance.GameMode = GameModes.LearningGame;
#endif

#if !SILVERLIGHT
                Taskbar.AddEntryToJumpList(ZipPath, Title);
#endif
                this.IsSelected = false;
            }, () => { return(Count > 0); });

            MatchingGame = new DelegateCommand(() =>
            {
#if !WINDOWS_PHONE
                MatchingGameViewModel game         = new MatchingGameViewModel(this, true);
                MainViewModel.Instance.CurrentView = game;
#else
                MainViewModel.Instance.GameMode = GameModes.MatchingGame;
#endif
#if !SILVERLIGHT
                Taskbar.AddEntryToJumpList(ZipPath, Title);
#endif
                this.IsSelected = false;
            }, () => { return(Count >= 6); });

            MemoryGame = new DelegateCommand(() =>
            {
#if !WINDOWS_PHONE
                MatchingGameViewModel game         = new MatchingGameViewModel(this, false);
                MainViewModel.Instance.CurrentView = game;
#else
                MainViewModel.Instance.GameMode = GameModes.MemoryGame;
#endif

#if !SILVERLIGHT
                Taskbar.AddEntryToJumpList(ZipPath, Title);
#endif
                this.IsSelected = false;
            }, () => { return(Count >= 6); });
        }