日期:2009-06-04  浏览次数:20477 次

using System;

namespace testform
{
    /// <summary>

    /// Event source
    /// </summary>
    public class Bird
    {
        public Bird()
        {
        }
        public void Flying()
        {
            this.OnBirdEvent(BirdStatus.Flying);
        }
        public void Dead()
        {
            this.OnBirdEvent(BirdStatus.Dead);

        }
        public void Sleep()
        {
            this.OnBirdEvent(BirdStatus.Sleeping);
        }
        private void OnBirdEvent(BirdStatus s)
        {
            if(this.BirdEvent!=null)
            {
                this.BirdEvent(this,new BirdEventArgs(s));
            }
        }
        public event BirdEventHandler BirdEvent;
    }
    public delegate void BirdEventHandler(object sender,BirdEventArgs e);
    public class BirdEventArgs:EventArgs
    {
        private BirdStatus _s;
        
        public BirdEventArgs(BirdStatus s)
        {
            this._s=s;
        
        }
        
        public BirdStatus Status
        {
            get
            {
                return this._s;
            }
        }
    
    }
    public enum BirdStatus
    {
        Flying,
        Sleeping,
        Dead
    }
    /// <summary>
    /// Event Target
    /// </summary>
 &