Example #1
0
        // Code to execute when the application is activated (brought to foreground)
        // This code will not execute when the application is first launched
        private void Application_Activated(object sender, ActivatedEventArgs e)
        {
            if (puzzleAdapter == null)
            {
                puzzleAdapter = new PuzzleAdapter();
                puzzleAdapter.load(null);
            }
            if (PhoneApplicationService.Current.State.ContainsKey("selectedPuzzleId"))
            {
                puzzleAdapter.selectedPuzzle = (int)PhoneApplicationService.Current.State["selectedPuzzleId"];
            }
            else
            {
                puzzleAdapter.selectedPuzzle = puzzleAdapter.puzzle[0].id;
            }

            if (PhoneApplicationService.Current.State.ContainsKey("selectedPuzzleDiff"))
            {
                puzzleAdapter.selectedDifficulty = (Difficulty)PhoneApplicationService.Current.State["selectedPuzzleDiff"];
            }
            else
            {
                puzzleAdapter.selectedDifficulty = Difficulty.EASY;
            }
        }
Example #2
0
        public ScoresPage()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(ScoresPage_Loaded);

            puzzleAdapter = (Application.Current as mPuzzle.App).puzzleAdapter;
            restService   = new RestService();
        }
Example #3
0
        public ScoresPage()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(ScoresPage_Loaded);

            puzzleAdapter = (Application.Current as mPuzzle.App).puzzleAdapter;
            restService = new RestService();
        }
Example #4
0
 // Code to execute when the application is launching (eg, from Start)
 // This code will not execute when the application is reactivated
 private void Application_Launching(object sender, LaunchingEventArgs e)
 {
     if (puzzleAdapter == null)
     {
         puzzleAdapter = new PuzzleAdapter();
         puzzleAdapter.load(null);
     }
 }
Example #5
0
 // Code to execute when the application is launching (eg, from Start)
 // This code will not execute when the application is reactivated
 private void Application_Launching(object sender, LaunchingEventArgs e)
 {
     if (puzzleAdapter == null)
     {
         puzzleAdapter = new PuzzleAdapter();
         puzzleAdapter.load(null);
     }
 }
Example #6
0
 public SettingsPage()
 {
     InitializeComponent();
     restService   = new RestService();
     puzzleAdapter = (Application.Current as mPuzzle.App).puzzleAdapter;
     Loaded       += new RoutedEventHandler(SettingsPage_Loaded);
     nicknameDialog.username.KeyDown   += new KeyEventHandler(username_KeyDown);
     nicknameDialog.buttonOk.Click     += onNicknameOk;
     nicknameDialog.buttonCancel.Click += onNicknameCancel;
 }
Example #7
0
 public SettingsPage()
 {
     InitializeComponent();
     restService = new RestService();
     puzzleAdapter = (Application.Current as mPuzzle.App).puzzleAdapter;
     Loaded += new RoutedEventHandler(SettingsPage_Loaded);
     nicknameDialog.username.KeyDown += new KeyEventHandler(username_KeyDown);
     nicknameDialog.buttonOk.Click += onNicknameOk;
     nicknameDialog.buttonCancel.Click += onNicknameCancel;
 }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            puzzleAdapter = (Application.Current as mPuzzle.App).puzzleAdapter;
            puzzleId = puzzleAdapter.selectedPuzzle;
            curPuzzle = puzzleAdapter.puzzleDic[puzzleId];
            ImageBrush ib = new ImageBrush();
            Uri imageUri = new Uri(curPuzzle.puzzleThumbnail, UriKind.Relative);
            puzzleThumbnail.Source = new BitmapImage(imageUri);
        }
Example #9
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            puzzleAdapter = (Application.Current as mPuzzle.App).puzzleAdapter;
            puzzleId      = puzzleAdapter.selectedPuzzle;
            curPuzzle     = puzzleAdapter.puzzleDic[puzzleId];
            ImageBrush ib       = new ImageBrush();
            Uri        imageUri = new Uri(curPuzzle.puzzleThumbnail, UriKind.Relative);

            puzzleThumbnail.Source = new BitmapImage(imageUri);
        }
Example #10
0
 public GamePortraitPage()
 {
     InitializeComponent();
     puzzleAdapter   = (Application.Current as mPuzzle.App).puzzleAdapter;
     dtimer          = new DispatcherTimer();
     dtimer.Tick    += new EventHandler(uploadingOnTimer);
     dtimer.Interval = new TimeSpan(0, 0, 0, 0, 600);
     restService     = new RestService();
     nicknameDialog  = new NicknameDialog();
     nicknameDialog.username.KeyDown   += new KeyEventHandler(username_KeyDown);
     nicknameDialog.buttonOk.Click     += onNicknameOk;
     nicknameDialog.buttonCancel.Click += onNicknameCancel;
     nicknameDialog.Visibility          = Visibility.Collapsed;
 }
 public GamePortraitPage()
 {
     InitializeComponent();
     puzzleAdapter = (Application.Current as mPuzzle.App).puzzleAdapter;
     dtimer = new DispatcherTimer();
     dtimer.Tick += new EventHandler(uploadingOnTimer);
     dtimer.Interval = new TimeSpan(0, 0, 0, 0, 600);
     restService = new RestService();
     nicknameDialog = new NicknameDialog();
     nicknameDialog.username.KeyDown += new KeyEventHandler(username_KeyDown);
     nicknameDialog.buttonOk.Click += onNicknameOk;
     nicknameDialog.buttonCancel.Click += onNicknameCancel;
     nicknameDialog.Visibility = Visibility.Collapsed;
 }
Example #12
0
        // Code to execute when the application is activated (brought to foreground)
        // This code will not execute when the application is first launched
        private void Application_Activated(object sender, ActivatedEventArgs e)
        {
            if (puzzleAdapter == null)
            {
                puzzleAdapter = new PuzzleAdapter();
                puzzleAdapter.load(null);
            }
            if (PhoneApplicationService.Current.State.ContainsKey("selectedPuzzleId"))
                puzzleAdapter.selectedPuzzle = (int)PhoneApplicationService.Current.State["selectedPuzzleId"];
            else
                puzzleAdapter.selectedPuzzle = puzzleAdapter.puzzle[0].id;

            if (PhoneApplicationService.Current.State.ContainsKey("selectedPuzzleDiff"))
                puzzleAdapter.selectedDifficulty = (Difficulty)PhoneApplicationService.Current.State["selectedPuzzleDiff"];
            else
                puzzleAdapter.selectedDifficulty = Difficulty.EASY;
        }
 protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     puzzleAdapter = (Application.Current as mPuzzle.App).puzzleAdapter;
 }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            reload = State.ContainsKey("assembled");

            // reload puzzles and page state
            if (reload)
            {
                itime = (long)State["itime"];
                imoves = (int)State["imoves"];
                nextPuzzleOpened = (bool)State["nextPuzzleOpened"];
                time = Utils.formatTime(itime);
                moves = imoves.ToString();
                assembled = (bool)State["assembled"];
                if (assembled)
                {
                    prevTime = (long)State["prevTime"];
                    prevMoves = (int)State["prevMoves"];
                    uploaded = (bool)State["uploaded"];
                    if (uploaded)
                    {
                        internetBestMoves = (int)State["internetBestMoves"];
                        internetBestTime = (long)State["internetBestTime"];
                        internetPlace = (int)State["internetPlace"];
                    }
                }
            }

            puzzleAdapter = (Application.Current as mPuzzle.App).puzzleAdapter;

            puzzle = puzzleAdapter.puzzleDic[puzzleAdapter.selectedPuzzle];
            diff = puzzleAdapter.selectedDifficulty;

            gameViewController = new GameViewController(3 + (int)diff, 5 + (int)diff, gameCanvas, Dispatcher);
            gameController = new GameController(3 + (int)diff, 5 + (int)diff, puzzle, gameViewController, this);

            if (reload)
            {
                gameViewController.digout(this.State);
                gameController.digout(this.State);

                if (assembled)
                {
                    if (uploaded)
                    {
                        scorePanelInternet.Visibility = Visibility.Visible;
                        resPlace.Text = internetPlace.ToString();
                        res4.Text = " Time: " + Utils.formatTime(internetBestTime) + "; Moves: " + internetBestMoves;
                        scorePanelInternet.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        buttonUpload.Visibility = Visibility.Visible;
                    }

                    bool betterScore = (imoves < prevMoves) || (imoves == prevMoves && itime < prevTime) || (prevMoves == 0 && prevTime == 0);
                    if (betterScore)
                        beterScoreText.Text = " Better score achieved!";
                    else
                        beterScoreText.Text = " ";

                    res1.Text = " Time: " + time + "; Moves: " + moves;
                    res2.Text = " Time: " + Utils.formatTime(prevTime) + "; Moves: " + prevMoves;

                    scorePanel.Visibility = Visibility.Visible;

                    if (nextPuzzleOpened)
                        buttonNextPuzzle.Visibility = Visibility.Visible;

                    buttonPause.Visibility = Visibility.Collapsed;
                }

                movesText.Text = moves;
                timeText.Text = time;
            }

            Uri bitmapUri = new Uri(puzzle.puzzleImage, UriKind.Relative);
            BitmapImage bitmap = new BitmapImage(bitmapUri);
            bitmap.ImageOpened += new EventHandler<RoutedEventArgs>(bitmap_Loaded);
            gameViewController.setBitmap(bitmap);
        }
 public ScoreUserListPage()
 {
     InitializeComponent();
     puzzleAdapter = (Application.Current as mPuzzle.App).puzzleAdapter;
     Loaded       += new RoutedEventHandler(ScoreUserListPage_Loaded);
 }
 protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     puzzleAdapter = (Application.Current as mPuzzle.App).puzzleAdapter;
 }
 public ScoreUserListPage()
 {
     InitializeComponent();
     puzzleAdapter = (Application.Current as mPuzzle.App).puzzleAdapter;
     Loaded += new RoutedEventHandler(ScoreUserListPage_Loaded);
 }
Example #18
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            reload = State.ContainsKey("assembled");

            // reload puzzles and page state
            if (reload)
            {
                itime            = (long)State["itime"];
                imoves           = (int)State["imoves"];
                nextPuzzleOpened = (bool)State["nextPuzzleOpened"];
                time             = Utils.formatTime(itime);
                moves            = imoves.ToString();
                assembled        = (bool)State["assembled"];
                if (assembled)
                {
                    prevTime  = (long)State["prevTime"];
                    prevMoves = (int)State["prevMoves"];
                    uploaded  = (bool)State["uploaded"];
                    if (uploaded)
                    {
                        internetBestMoves = (int)State["internetBestMoves"];
                        internetBestTime  = (long)State["internetBestTime"];
                        internetPlace     = (int)State["internetPlace"];
                    }
                }
            }

            puzzleAdapter = (Application.Current as mPuzzle.App).puzzleAdapter;

            puzzle = puzzleAdapter.puzzleDic[puzzleAdapter.selectedPuzzle];
            diff   = puzzleAdapter.selectedDifficulty;

            gameViewController = new GameViewController(3 + (int)diff, 5 + (int)diff, gameCanvas, Dispatcher);
            gameController     = new GameController(3 + (int)diff, 5 + (int)diff, puzzle, gameViewController, this);

            if (reload)
            {
                gameViewController.digout(this.State);
                gameController.digout(this.State);

                if (assembled)
                {
                    if (uploaded)
                    {
                        scorePanelInternet.Visibility = Visibility.Visible;
                        resPlace.Text = internetPlace.ToString();
                        res4.Text     = " Time: " + Utils.formatTime(internetBestTime) + "; Moves: " + internetBestMoves;
                        scorePanelInternet.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        buttonUpload.Visibility = Visibility.Visible;
                    }

                    bool betterScore = (imoves < prevMoves) || (imoves == prevMoves && itime < prevTime) || (prevMoves == 0 && prevTime == 0);
                    if (betterScore)
                    {
                        beterScoreText.Text = " Better score achieved!";
                    }
                    else
                    {
                        beterScoreText.Text = " ";
                    }

                    res1.Text = " Time: " + time + "; Moves: " + moves;
                    res2.Text = " Time: " + Utils.formatTime(prevTime) + "; Moves: " + prevMoves;

                    scorePanel.Visibility = Visibility.Visible;

                    if (nextPuzzleOpened)
                    {
                        buttonNextPuzzle.Visibility = Visibility.Visible;
                    }

                    buttonPause.Visibility = Visibility.Collapsed;
                }

                movesText.Text = moves;
                timeText.Text  = time;
            }

            Uri         bitmapUri = new Uri(puzzle.puzzleImage, UriKind.Relative);
            BitmapImage bitmap    = new BitmapImage(bitmapUri);

            bitmap.ImageOpened += new EventHandler <RoutedEventArgs>(bitmap_Loaded);
            gameViewController.setBitmap(bitmap);
        }