Ejemplo n.º 1
0
        /// <summary>
        /// 答题开始或结束按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_answer_Click(object sender, EventArgs e)
        {
            if (this.button_answer.Text == "开始答题")
            {
                int    totalTopic = 1;
                byte[] topicType;
                bool   bRes = false;

                int index = comboBox1.SelectedIndex;
                switch (index)
                {
                case 0:
                {
                    topicType    = new byte[totalTopic];
                    topicType[0] = 1;
                    break;
                }

                case 1:
                {
                    topicType    = new byte[totalTopic];
                    topicType[0] = 2;
                    break;
                }

                case 2:
                {
                    topicType    = new byte[totalTopic];
                    topicType[0] = 3;
                    break;
                }

                case 3:
                {
                    totalTopic   = 3;
                    topicType    = new byte[totalTopic];
                    topicType[0] = 3;
                    topicType[1] = 2;
                    topicType[2] = 1;
                    break;
                }

                default:
                    totalTopic   = 3;
                    topicType    = new byte[totalTopic];
                    topicType[0] = 1;
                    topicType[1] = 2;
                    topicType[2] = 3;
                    break;
                }
                IntPtr ptr = Marshal.AllocHGlobal(totalTopic);
                Marshal.Copy(topicType, 0, ptr, totalTopic);

                bRes = rbtnet_.sendStartAnswer(1, totalTopic, ptr);
                if (bRes)
                {
                    this.button_answer.Text = "结束答题";
                }
                else
                {
                    MessageBox.Show("发送开始答题失败");
                }

                Marshal.FreeHGlobal(ptr);
                this.label3.Text = "进入答题模式,按键事件失效,只接收手写板确认提交答案的事件";
            }
            else
            {
                rbtnet_.sendEndAnswer();
                this.button_answer.Text = "开始答题";
                this.label3.Text        = "恢复到正常模式,开始响应按键事件";
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 答题开始或结束按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_start_Click(object sender, EventArgs e)
        {
            bool bRes = false;

            int type = comboBox_Qtype.SelectedIndex;

            int index      = comboBox_Qlist.SelectedIndex;
            int totalTopic = int.Parse(textBox_num.Text);

            byte[] topicType;

            List <int> qlist = new List <int>();

            if (index == 5)
            {
                totalTopic   = 8;
                topicType    = new byte[totalTopic];
                topicType[0] = 1;
                topicType[1] = 1;
                topicType[2] = 2;
                topicType[3] = 2;
                topicType[4] = 3;
                topicType[5] = 3;
                topicType[6] = 5;
                topicType[7] = 5;

                qlist.Add(7);
                qlist.Add(8);
            }
            else
            {
                topicType = new byte[totalTopic];
                for (int i = 0; i < totalTopic; i++)
                {
                    if (type == 2)
                    {
                        topicType[i] = Convert.ToByte(index + 2);
                    }
                    else
                    {
                        topicType[i] = Convert.ToByte(index + 1);
                    }

                    if (type == 2)
                    {
                        if (index == 4)
                        {
                            qlist.Add(i + 1);
                        }
                    }
                    else if (type == 0 || type == 4 || type == 5)
                    {
                        qlist.Add(i + 1);
                    }
                }
            }

            IntPtr ptr = Marshal.AllocHGlobal(totalTopic);

            Marshal.Copy(topicType, 0, ptr, totalTopic);

            bRes = rbtnet_.sendStartAnswer(type, totalTopic, ptr);
            Marshal.FreeHGlobal(ptr);
        }