Ejemplo n.º 1
0
        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;
            }
            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;
            }
            cm.Start();                         //接收信号线程启动
            isstart = false;
            timer1.Start();                     //屏幕刷新启动
            Hkey = new CHotkeyApp(this.Handle); //热键系统启动
            toolStripStatusLabel1.Text  = "状态:准备考试";
            this.pictureBoxTrace.Paint += new PaintEventHandler(myTrace.DrawTrace);
        }
Ejemplo n.º 2
0
 public virtual void Che_xh()
 {
     StateManager.SwitchState("StateEnd");
     che.SetWeizhi(che.X, che.Y);
     eform.KaoShiEndFun(0, "熄火");
 }