コード例 #1
0
        public void InitializeExamComponent(CSettings set, IMonitor mon, StateManager sm)
        {
            this.settings = (MotorSignalSettings)set;
            this.monitor  = (MotorMonitor)mon;
            this.statemgr = (IMotorStateManager)sm;

            monitor.RegMonitor(this);
            statemgr.RegExamObserver(this);

            ganbm[0] = new Bitmap(Application.StartupPath + "\\" + settings.ModelAppearance.Gan.Normal);
            ganbm[1] = new Bitmap(Application.StartupPath + "\\" + settings.ModelAppearance.Gan.Error);
            ganbm[2] = new Bitmap(Application.StartupPath + "\\" + settings.ModelAppearance.Gan.Shield);

            for (int i = 0; i < 5; i++)
            {
                gan[i]         = new CGanFairy(ganbm);
                gan[i].GanName = (i + 1).ToString();
            }

            for (int i = 0; i < 5; i++)
            {
                XianPosition x = settings.InitPosition.Xian[i];
                xian[i]          = new CLineFairy(x.X1, x.Y1, x.X2, x.Y2);
                xian[i].LineName = (i + 1).ToString();
                cdm.RegDisplay(xian[i]);
            }

            for (int i = 0; i < 5; i++)
            {
                GanPosition gp = settings.InitPosition.Gan[i];
                gan[i].X = gp.X;
                gan[i].Y = gp.Y - 10;
                cdm.RegDisplay(gan[i]);
            }

            che = new CBmpFairy(settings.ModelAppearance.Che.Normal);
            cdm.RegDisplay(che);

            ResetElements();

            stateDuration = new int[4];

            stateDuration[0] = settings.StateDuration[0];
            stateDuration[1] = settings.StateDuration[1];
            stateDuration[2] = settings.StateDuration[2];
            stateDuration[3] = settings.StateDuration[3];

            timer       = new Timer();
            timer.Tick += new EventHandler(timer_Tick);
            timer.Start();//屏幕刷新启动
        }