Esempio n. 1
0
        private void HandleAsk(IAsker asker, object context, string caption, string text, bool warning, RequestOptions options)
        {
            MessageBoxButtons       buttons;
            MessageBoxDefaultButton defaultButton;

            switch (options)
            {
            case RequestOptions.YesNo:
                buttons       = MessageBoxButtons.YesNo;
                defaultButton = MessageBoxDefaultButton.Button2;
                break;

            case RequestOptions.YesNoCancel:
                buttons       = MessageBoxButtons.YesNoCancel;
                defaultButton = MessageBoxDefaultButton.Button3;
                break;

            case RequestOptions.OkCancel:
                buttons       = MessageBoxButtons.OKCancel;
                defaultButton = MessageBoxDefaultButton.Button2;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(options), options, null);
            }

            var result = MessageBox.Show(Form.ActiveForm, text, caption, buttons,
                                         warning ? MessageBoxIcon.Warning : MessageBoxIcon.Information, defaultButton);

            AnswerType answer;

            switch (result)
            {
            case DialogResult.OK:
                answer = AnswerType.Ok;
                break;

            case DialogResult.Cancel:
                answer = AnswerType.Cancel;
                break;

            case DialogResult.Yes:
                answer = AnswerType.Yes;
                break;

            case DialogResult.No:
                answer = AnswerType.No;
                break;

            default:
                answer = AnswerType.None;
                break;
            }

            asker.Answer(context, answer);
        }
 private void InitAsker()
 {
     _asker = new Asker(_key, _accessToken);
 }