Example #1
0
        private void DoFirstTimeTurn(GuiGame guiGame)
        {
            Trace.WriteLine("starting...");

            this.Invoke(new Action(() =>
            {
                var dialogResult = MessageBox.Show("This is your first turn." + Environment.NewLine + "Launch Steam ?", "first turn", MessageBoxButtons.YesNo);
                if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    Trace.WriteLine("launching steam (takes a while)");
                    this.m_MainViewModel.CoreMainViewModel.LaunchSteam.Execute();
                }
            }));

            this.Invoke(new Action(() =>
            {
                FileInfo uploadThisFile;
                bool doUploadThisFile = this.TryGetFileToUpload(out uploadThisFile);

                if ((doUploadThisFile) && (null != uploadThisFile))
                {
                    //upload and finish
                    Trace.WriteLine("uploading (takes a while)");
                    SubmitTurnCommand submitTurncmd = this.m_MainViewModel.GMRMainViewModel.SubmitTurn;

                    submitTurncmd.Execute(new SubmitTurnCommandParam(guiGame.Game.GameId, m_Config.keepFilesInArchiveFolder, uploadThisFile));

                    SubmitTurnResult submitTurnResult = submitTurncmd.Result;

                    this.Invoke(new Action(() =>
                    {
                        MessageBox.Show("Result: " + submitTurnResult.ResultType.ToString() + " Points: " + submitTurnResult.PointsEarned.ToString());
                    }));
                }
            }));

            this.Invoke(new Action(() =>
            {
                this.FreezeUI(false);
                this.ResumeLayout(false);
                this.UpdateUI();

                Trace.TraceInformation("finished");
            }));
        }
Example #2
0
        private void AnyTurnButTheFirstOne(GuiGame guiGame)
        {
            Trace.WriteLine("starting...");

            Trace.WriteLine("downloading game (takes a while)");
            DownloadGame(guiGame);

            Trace.WriteLine("finished downloading game");

            this.Invoke(new Action(() =>
            {
                var dialogResult = MessageBox.Show("Launch Steam ?", "Launch Steam", MessageBoxButtons.YesNo);
                if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    Trace.WriteLine("launching steam (takes a while)");
                    this.m_MainViewModel.CoreMainViewModel.LaunchSteam.Execute();
                }
            }));

            this.Invoke(new Action(() =>
            {
                SubmitTurnCommand submitTurncmd  = this.m_MainViewModel.GMRMainViewModel.SubmitTurn;
                SubmitTurnCommandParam parameter = new SubmitTurnCommandParam(guiGame.Game.GameId, this.m_Config.keepFilesInArchiveFolder);

                var dialogResult = MessageBox.Show("Submit Turn ?", "Submit Turn", MessageBoxButtons.YesNo);
                if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    bool askTheUserAgainAndAgain = false;
                    do
                    {
                        if (submitTurncmd.CanExecute(parameter))
                        {
                            askTheUserAgainAndAgain = false;
                            Trace.WriteLine("submitting turn (takes a while)");

                            submitTurncmd.Execute(parameter);

                            SubmitTurnResult submitTurnResult = submitTurncmd.Result;

                            this.Invoke(new Action(() =>
                            {
                                MessageBox.Show("Result: " + submitTurnResult.ResultType.ToString() + " Points: " + submitTurnResult.PointsEarned.ToString());
                            }));
                        }
                        else
                        {
                            var resultuploadDialog  = MessageBox.Show("It is not possible to upload the file." + Environment.NewLine + "Did you overwrite your downloaded game ?", "I will not uploadthe game", MessageBoxButtons.RetryCancel);
                            askTheUserAgainAndAgain = resultuploadDialog == System.Windows.Forms.DialogResult.Retry;
                        }
                    }while(askTheUserAgainAndAgain);
                }
            }));

            this.Invoke(new Action(() =>
            {
                this.FreezeUI(false);
                this.ResumeLayout(false);
                this.UpdateUI();

                Trace.TraceInformation("finished");
            }));
        }