예제 #1
0
파일: ExamForm.cs 프로젝트: wpmyj/Zhuangkao
        public void myinit(int chetype)
        {
            // Graphics g = this.pictureBox1.CreateGraphics();


            CDM         = new CDisplayManager();
            cm          = new CMonitor();
            cm.Che_Type = chetype;
            cm.RegMonitor(this);
            myInvoke   = new InvokeDelegate(Invokefun);
            formInvoke = new InvokeDelegate(formInvokefun);

            //-----------初始化线数据-----------------------------
            xian = new CLineFairy[9];

            xian[0]          = new CLineFairy(170, 125, 170, 370);
            xian[0].LineName = "1";
            xian[0].Linex    = xian[0].X1 - 9;
            xian[0].Liney    = xian[0].Y1 - 120;
            CDM.RegDisplay(xian[0]);


            xian[1]          = new CLineFairy(260, 125, 260, 370);
            xian[1].LineName = "2";
            xian[1].Linex    = xian[1].X1 - 9;
            xian[1].Liney    = xian[1].Y1 - 120;
            CDM.RegDisplay(xian[1]);

            xian[2]          = new CLineFairy(350, 125, 350, 370);
            xian[2].LineName = "3";
            xian[2].Linex    = xian[2].X1 - 9;
            xian[2].Liney    = xian[2].Y1 - 120;
            CDM.RegDisplay(xian[2]);

            xian[3]          = new CLineFairy(20, 125, 170, 125);
            xian[3].LineName = "4";
            xian[3].Linex    = xian[3].X1 - 20;
            xian[3].Liney    = xian[3].Y1 - 7;
            CDM.RegDisplay(xian[3]);


            xian[6] = new CLineFairy(170, 125, 260, 125);
            CDM.RegDisplay(xian[6]);
            xian[7] = new CLineFairy(260, 125, 350, 125);
            CDM.RegDisplay(xian[7]);
            xian[8] = new CLineFairy(350, 125, 508, 125);
            CDM.RegDisplay(xian[8]);


            xian[4]          = new CLineFairy(170, 370, 350, 370);
            xian[4].LineName = "5";
            xian[4].Linex    = xian[4].X1 - 30;
            xian[4].Liney    = xian[4].Y1 - 7;
            CDM.RegDisplay(xian[4]);

            xian[5]          = new CLineFairy(20, 30, 508, 30);
            xian[5].LineName = "6";
            xian[5].Linex    = xian[5].X1 - 20;
            xian[5].Liney    = xian[5].Y1 - 7;
            CDM.RegDisplay(xian[5]);


            //-----------线数据初始化结束-----------------------------
            // 车初始化
            if (chetype == 0)
            {
                che = new CBmpFairy(".\\img\\scar00.gif");
            }
            else
            {
                che = new CBmpFairy(".\\img\\car00.gif");
            }
            che.SetWeizhi(445, 75);
            CDM.RegDisplay(che);
            che.Speed  = 1;
            che.RSpeed = 3;;


            //-----------初始化杆数据-----------------------------
            ganbm    = new Bitmap[3];
            ganbm[0] = new Bitmap(".\\img\\green2.gif");
            ganbm[1] = new Bitmap(".\\img\\red2.gif");
            ganbm[2] = new Bitmap(".\\img\\gray2.gif");
            for (int i = 0; i < 3; i++)
            {
                Color backcolor = ganbm[i].GetPixel(1, 1);
                ganbm[i].MakeTransparent(backcolor);
            }
            gan = new CGanFairy[6];
            for (int i = 0; i < 6; i++)
            {
                gan[i] = new CGanFairy(ganbm);
                CDM.RegDisplay(gan[i]);
                gan[i].GanName = Convert.ToString(i + 1);
            }

            gan[0].X = 160;
            gan[0].Y = 115;

            gan[1].X = 250;
            gan[1].Y = 115;

            gan[2].X = 340;
            gan[2].Y = 115;


            gan[3].X = 160;
            gan[3].Y = 360;

            gan[4].X = 250;
            gan[4].Y = 360;

            gan[5].X = 340;
            gan[5].Y = 360;

            //------杆数据初始化完成
            //---读配置文件屏蔽杆,线,车信号
            for (int i = 0; i < 6; i++)
            {
                if (((settings.PbGan_s >> i) & 1) == 1)
                {
                    cm.Shield(0, i + 1);
                    gan[i].Stat = -1;
                }
                if (((settings.PbXian_s >> i) & 1) == 1)
                {
                    cm.Shield(1, i + 1);
                    xian[i].Stat = -1;
                }
                if (i < 4)
                {
                    if (((settings.PbChe_s >> i) & 1) == 1)
                    {
                        cm.Shield(2, i + 1);
                    }
                }
            }


            //--------各状态初始化----------
            double horRate = (double)pictureBoxTrace.Width / (double)pictureBox1.Width;
            double virRate = (double)pictureBoxTrace.Height / (double)pictureBox1.Height;

            myTrace      = new Trace(horRate, virRate, che, xian);
            che.CarTrace = myTrace;
            statemanager = new StateManager(gan, xian, che, this);
            StateManager.SwitchState("State0");
            StateTime = new int[20];
            if (chetype == 0)
            {
                StateTime[2]  = settings.State2_Time_s;
                StateTime[3]  = settings.State3_Time_s;
                StateTime[4]  = settings.State4_Time_s;
                StateTime[5]  = settings.State5_Time_s;
                StateTime[6]  = settings.State6_Time_s;
                StateTime[7]  = settings.State7_Time_s;
                StateTime[8]  = settings.State8_Time_s;
                StateTime[9]  = settings.State9_Time_s;
                StateTime[10] = settings.State10_Time_s;
                StateTime[11] = settings.State11_Time_s;
                StateTime[12] = settings.State12_Time_s;
                StateTime[13] = settings.State13_Time_s;
                StateTime[14] = settings.State14_Time_s;
                StateTime[15] = settings.State15_Time_s;
                StateTime[16] = settings.State16_Time_s;
                StateTime[17] = settings.State4i_Time_s;
                StateTime[18] = settings.State14i_Time_s;
                StateTime[19] = settings.State11i_Time_s;
            }
            else
            {
                StateTime[2]  = settings.State2_Time_l;
                StateTime[3]  = settings.State3_Time_l;
                StateTime[4]  = settings.State4_Time_l;
                StateTime[5]  = settings.State5_Time_l;
                StateTime[6]  = settings.State6_Time_l;
                StateTime[7]  = settings.State7_Time_l;
                StateTime[8]  = settings.State8_Time_l;
                StateTime[9]  = settings.State9_Time_l;
                StateTime[10] = settings.State10_Time_l;
                StateTime[11] = settings.State11_Time_l;
                StateTime[12] = settings.State12_Time_l;
                StateTime[13] = settings.State13_Time_l;
                StateTime[14] = settings.State14_Time_l;
                StateTime[15] = settings.State15_Time_l;
                StateTime[16] = settings.State16_Time_l;
                StateTime[17] = settings.State4i_Time_l;
                StateTime[18] = settings.State14i_Time_l;
                StateTime[19] = settings.State11i_Time_l;
            }
            cm.Start();                         //接收信号线程启动
            isstart = false;
            timer1.Start();                     //屏幕刷新启动
            Hkey = new CHotkeyApp(this.Handle); //热键系统启动
            toolStripStatusLabel1.Text  = "状态:准备考试";
            this.pictureBoxTrace.Paint += new PaintEventHandler(myTrace.DrawTrace);
        }
예제 #2
0
파일: ExamForm.cs 프로젝트: wpmyj/Zhuangkao
        public void KaoShiEndFun(int kscj, string sm)//考试结束处理函数
        {
            displaycomm.ShowText(sm);
            StateManager.Close();
            isstart = false;
            Hkey.StopHotkey();
            //MessageBox.Show(sm+"考试结束!");
            //button1.Enabled = true;
            if (_isExam)
            {
                //在此处添加摄像停止并保存功能
                //videoTimer.Stop();
                //string videoDir = Environment.CurrentDirectory + @"\Video\";
                //if (!Directory.Exists(videoDir))
                //    Directory.CreateDirectory(videoDir);
                //string destPath = videoDir + student.Lsh + Guid.NewGuid().ToString() + ".avi";

                //makeVideo(tempBmpDir, destPath);

                if ((kscj == 1) || (student.HuiHeShu == 2))
                {
                    //打印合格
                    //清除输入内容,解除输入框只读
                    //此处为河南省考表打印格式,需根据地方需求而改变
                    if (settings.Isprint && (kscj == 1))
                    {
                        myprint.ksddstr  = settings.Ksdd;
                        myprint.ksrqstr  = System.DateTime.Now.ToString();
                        myprint.ksxmstr  = student.Xm;
                        myprint.ksyxmstr = student.Ksy1;
                        myprint.kscjstr  = "合格";
                        myprint.Print();  //取消注释即可打印
                    }

                    //-----------写入考试结果到数据库--------------
                    if (student.HuiHeShu == 1)
                    {
                        student.KS1    = sm;
                        label_ks1.Text = "第一回合考试:" + sm;
                    }
                    else
                    {
                        student.KS2    = sm;
                        label_ks2.Text = "第二回合考试:" + sm;
                    }
                    //Bitmap bm = new Bitmap(pictureBoxTrace.Image);
                    //bm.Save(@"C:\" + Guid.NewGuid().ToString(null) + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
                    student.Kscj = kscj; //写入考试成绩
                    student.Kscs++;      //考试次数加1
                    student.Ksy1 = comboBox1.Text;
                    student.Ksy2 = comboBox2.Text;
                    if (student.Kscj == 1)
                    {
                        student.Zt = "1";
                    }
                    else
                    {
                        student.Zt = "2";
                    }
                    if (!student.SaveInfo())
                    {
                        MessageBox.Show("数据库写错误!");
                    }
                    else
                    {
                        //考试完成,发送kswc命令到点名中心
                        if (settings.IsNetwork)
                        {
                            CNetData tmpdata = new CNetData();
                            tmpdata.cmdCommand = Command.Kswc;
                            tmpdata.intDevnum  = settings.Devnum;
                            tmpdata.strZjbh    = student.Zkzmbh;
                            Client.SendData(tmpdata);
                            ButtonStart.Text    = "申请考试";
                            ButtonStart.Enabled = true;
                        }
                        InitStudent();
                    }
                    CVoice.Play(student.Xm + "?" + sm + "?考试结束");
                    MessageBox.Show(sm + "! 考试结束!");

                    //------------初始化输入信息----------------
                    //TextBox_Input.Enabled = true;
                    //TextBox_Input.Text = "";
                    //for (int i = 1; i < 7; i++)
                    //{
                    //    StudentText[i].ReadOnly = false;
                    //    StudentText[i].Text = "";
                    //}
                    //StudentText[0].Focus();
                    student.Clear();
                    label_ks1.Text = "第一回合考试:";
                    label_ks2.Text = "第二回合考试:";
                    student.GetKsNumber(); //得到考试人数
                    label_pass.Text   = "合格:" + student.PassNumber.ToString() + "人";
                    label_nopass.Text = "不合格:" + student.NoPassNumber.ToString() + "人";
                    label_sum.Text    = "共计:" + Convert.ToString(student.PassNumber + student.NoPassNumber) + "人";
                }
                else
                {
                    label_ks1.Text = "第一回合考试:" + sm;
                    CVoice.Play(student.Xm + "?" + sm + "?第一回合结束");
                    MessageBox.Show(sm + "! 第一回合结束!");
                    student.KS1         = sm;
                    student.HuiHeShu    = 2;
                    ButtonStart.Enabled = true;
                }
                if (!Directory.Exists(Environment.CurrentDirectory + @"\Trace\"))
                {
                    Directory.CreateDirectory(Environment.CurrentDirectory + @"\Trace\");
                }
                SaveTrace(Environment.CurrentDirectory + @"\Trace\" + student.Sfzmhm + "_" + Guid.NewGuid().ToString(null) + ".bmp");
            }
            else
            {
                if (kscj == 1)
                {
                    CVoice.Play("练习考试合格");
                    MessageBox.Show(sm + "!");
                }
                else
                {
                    CVoice.Play(sm + ",练习考试不合格");
                    MessageBox.Show(sm + ",练习考试不合格!");
                }
                buttonX4.Enabled = false;
            }
            ChangDiInit();
        }
예제 #3
0
 public virtual void Che_xh()
 {
     StateManager.SwitchState("StateEnd");
     che.SetWeizhi(che.X, che.Y);
     eform.KaoShiEndFun(0, "熄火");
 }