Esempio n. 1
0
        private void OnPromptChanged(object sender, EventArgs e)
        {
            var prompt           = m_updater.CurrentPrompt;
            var description      = m_updater.GameDescription;
            var previousUsername = m_updater.PreviouslyEnteredUsername;
            var previousPassword = m_updater.PreviouslyEnteredPassword;

            this.BeginInvoke((Action) delegate
            {
                if (prompt == GameUpdatePrompt.Username ||
                    prompt == GameUpdatePrompt.Password ||
                    prompt == GameUpdatePrompt.UsernameAndPassword)
                {
                    // Show the dialog
                    var dialog = new CredentialsForm(
                        (prompt != GameUpdatePrompt.Password) ?
                        ((previousUsername != null) ? previousUsername : "") :
                        null,
                        (prompt != GameUpdatePrompt.Username) ?
                        ((previousPassword != null) ? previousPassword : "") :
                        null
                        );
                    var result = dialog.ShowDialog(this);

                    // Inform the updater
                    if (result == DialogResult.OK)
                    {
                        m_updater.AnswerPrompt(true, dialog.Username, dialog.Password);
                    }
                    else
                    {
                        m_updater.AnswerPrompt(false);
                    }
                }
                else
                {
                    // Show the messagebox
                    var result = MessageBox.Show(
                        this,
                        prompt.GetQuestion(Program.Language, description),
                        Program.Language.Translate("window.title", description),
                        //MessageBoxButtons.YesNoCancel,
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question
                        );

                    // Inform the updater
                    if (result == DialogResult.Cancel)
                    {
                        m_updater.Cancel();
                        m_updater.AnswerPrompt(false);
                    }
                    else
                    {
                        m_updater.AnswerPrompt(result == DialogResult.Yes);
                    }
                }
            });
        }
        private void OnPromptChanged( object sender, EventArgs e )
        {
            var prompt = m_updater.CurrentPrompt;
            var customMessage = m_updater.CustomMessage;
            var description = m_updater.GameDescription;
            var previousUsername = m_updater.PreviouslyEnteredUsername;
            var previousPassword = m_updater.PreviouslyEnteredPassword;
            this.BeginInvoke( (Action)delegate
            {
                if( prompt == GameUpdatePrompt.Username ||
                    prompt == GameUpdatePrompt.Password ||
                    prompt == GameUpdatePrompt.UsernameAndPassword )
                {
                    // Show credentials dialog
                    var dialog = new CredentialsForm(
                        (prompt != GameUpdatePrompt.Password) ?
                            ((previousUsername != null) ? previousUsername : "") :
                            null,
                        (prompt != GameUpdatePrompt.Username) ?
                            ((previousPassword != null) ? previousPassword : "") :
                            null
                    );
                    var result = dialog.ShowDialog( this );

                    // Inform the updater
                    if( result == DialogResult.OK )
                    {
                        m_updater.AnswerPrompt( true, dialog.Username, dialog.Password );
                    }
                    else
                    {
                        m_updater.AnswerPrompt( false );
                    }
                }
                else if( prompt == GameUpdatePrompt.CustomMessage )
                {
                    // Show message dialog
                    MessageBox.Show(
                        this,
                        customMessage,
                        Program.Language.Translate( "window.title", description ),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information
                    );

                    // Inform the updater
                    m_updater.AnswerPrompt( true );
                }
                else
                {
                    // Show question dialog
                    var result = MessageBox.Show(
                        this,
                        prompt.GetQuestion( Program.Language, description ),
                        Program.Language.Translate( "window.title", description ),
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question
                    );

                    // Inform the updater
                    if( result == DialogResult.Cancel )
                    {
                        m_updater.Cancel();
                        m_updater.AnswerPrompt( false );
                    }
                    else
                    {
                        m_updater.AnswerPrompt( result == DialogResult.Yes );
                    }
                }
            } );
        }