コード例 #1
0
        private async void OnLoad(object sender, EventArgs e)
        {
            RequestWaiting requestWaiting = new RequestWaiting("Getting Translations");

            this.BeginInvoke(new Action(() => requestWaiting.ShowDialog()));
            await PopulatePhrases(foreignWord);

            requestWaiting.Invoke(new Action(() => requestWaiting.Close()));
        }
コード例 #2
0
        private async Task PopulateLanguages()
        {
            RequestWaiting requestWaiting = new RequestWaiting("Receiving languages");

            if (!requestWaiting.IsHandleCreated)
            {
                requestWaiting.CreateControl();
            }
            this.BeginInvoke(new Action(() => requestWaiting.ShowDialog()));
            var languages = await Controller.GetLanguages();

            foreach (var language in languages)
            {
                listBoxLanguages.Items.Add(language.Name);
            }
            requestWaiting.Close();
        }
コード例 #3
0
        private async void startToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Hide();
            RequestWaiting requestWaiting = new RequestWaiting("Generating Quiz");

            this.BeginInvoke(new Action(() => requestWaiting.ShowDialog()));
            if (Controller.GetCurrentLanguage() == null || await Controller.GetWordPrioritiesCount() < 20)
            {
                return;
            }
            Quiz quiz = new Quiz(await Controller.GenerateQuiz());

            this.Invoke(new Action(() => requestWaiting.Close()));
            quiz.ShowDialog();
            this.Invoke(new Action(() => this.Show()));
            pageCounter = 0;
            await ChangePageNumber();
            await PopulateWordPriorities();
        }
コード例 #4
0
        private async void buttonLogin_Click(object sender, EventArgs e)
        {
            bool           success = false;
            RequestWaiting requestWaiting;

            if (newUser)
            {
                requestWaiting = new RequestWaiting("Registering new user");
                if (!requestWaiting.IsHandleCreated)
                {
                    requestWaiting.CreateControl();
                }
                this.BeginInvoke(new Action(() => requestWaiting.ShowDialog()));
                success = await Register();

                requestWaiting.Close();
            }
            else
            {
                requestWaiting = new RequestWaiting("Logging in");
                if (!requestWaiting.IsHandleCreated)
                {
                    requestWaiting.CreateControl();
                }
                this.BeginInvoke(new Action(() =>
                {
                    requestWaiting.ShowDialog();
                }));
                success = await Login();

                requestWaiting.Close();
            }
            if (success)
            {
                DialogResult = DialogResult.OK;
            }
            Close();
        }