private void all_kaluts_lst_SelectedIndexChanged(object sender, EventArgs e)
        {
            KalutInfo item = all_kaluts_lst.SelectedItem as KalutInfo;

            if (item != null)
            {
                all_desk_lbl.Text = item.Description;
                all_name_lbl.Text = item.Name;
            }
        }
        private void my_kaluts_lst_SelectedValueChanged(object sender, EventArgs e)
        {
            KalutInfo item = my_kaluts_lst.SelectedItem as KalutInfo;

            if (item != null)
            {
                my_desc_lbl.Text  = item.Description;
                my_title_lbl.Text = item.Name;
            }
        }
Пример #3
0
        private void save_quiz_btn_Click(object sender, EventArgs e)
        {
            PleaseWait           w  = new PleaseWait("Uploading quiz...");
            List <KalutQuestion> qs = new List <KalutQuestion>();

            for (int i = 0; i < qs_lstbox.Items.Count; i++)
            {
                qs.Add((KalutQuestion)qs_lstbox.Items[i]);
            }
            if (uid == 0)
            {
                uid = -1;
            }
            KalutInfo info = new KalutInfo(uid.ToString(), quiz_name_txt.Text, quiz_desc_txt.Text, ((int)player_timeout_val.Value).ToString());
            KalutQuiz quiz = new KalutQuiz(info, qs);

            if (new_quiz)
            {
                var worker = Communicator.Communicator.AddKalut(
                    Properties.Settings.Default.Username,
                    Properties.Settings.Default.Password,
                    JsonConvert.SerializeObject(info),
                    JsonConvert.SerializeObject(qs));
                worker.ContinueWith(t =>
                {
                    w.Close();
                    if (t.IsCanceled || t.IsFaulted)
                    {
                        MessageBox.Show("Unexpected error.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        StandartResponse rsp = t.Result;
                        if (rsp.Status == "OK")
                        {
                            MessageBox.Show("Uploaded successfully!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            ResetQuizMaker();
                            ResetQuestion();
                            EnableQuestion(false);
                        }
                        else
                        {
                            MessageBox.Show("Error: " + rsp.ErrMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                },
                                    TaskScheduler.FromCurrentSynchronizationContext());
            }
            else
            {
                var worker = Communicator.Communicator.SaveKalut(
                    Properties.Settings.Default.Username,
                    Properties.Settings.Default.Password,
                    JsonConvert.SerializeObject(info),
                    JsonConvert.SerializeObject(qs));
                worker.ContinueWith(t =>
                {
                    w.Close();
                    if (t.IsFaulted || t.IsCanceled)
                    {
                        MessageBox.Show("Unexpected error.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show("Saved!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        parent.Close();
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
            w.ShowDialog();
        }