示例#1
0
        //激活事件的方法,创建了FireEventArgs 对象,发起事件,并将事件参数对象传递过去
        public void ActivateFireAlarm(string room, int ferocity)
        {
            FireEventArgs fireArgs = new FireEventArgs(room, ferocity);

            //执行对象事件处理函数指针,事件触发
            FireEvent(this, fireArgs);
        }
示例#2
0
        // 灭火
        private void ExtinguishFire(object sender, FireEventArgs fe)
        {
            int    ferocity = fe.ferocity; //得到火情
            string room     = fe.room;

            if (ferocity <= 5)
            {
                string report = String.Format(@"群众在{0} 发现火情,级别为{1},群众自行控制住了火势。", room, ferocity);
                fireText.AppendText(report + "\n");
            }
            else
            {
                string report = String.Format(@"群众在{0} 发现火情,级别为{1},群众无法控制火势。消防官兵赶来灭火", room, ferocity);
                fireText.AppendText(report + "\n");
            }
        }