UI event : EventArgs : GUI Windows Forms C# Examples


C# Examples » GUI Windows Forms » EventArgs »

 

UI event









    
using  System;

public  class  UIEvent  :  EventArgs
{
        public  UIEvent(  string  filename  )  {
                this.filename  =  filename;
        }

        private  string  filename;
        public  string  Filename  {
                get  {  return  filename;  }
        }
}

public  class  MyUI
{
        public  event  EventHandler<UIEvent>  PlayEvent;

        public  void  UserPressedPlay()  {
                OnPlay();
        }

        protected  virtual  void  OnPlay()  {
                EventHandler<UIEvent>  localHandler  =  PlayEvent;
                if(  localHandler  !=  null  )  {
                        localHandler(  this,  new  UIEvent("somefile.wav")  );
                }
        }
}

public  class  MainClass
{
        public  static  void  Main()  {
                MyUI  ui  =  new  MyUI();
                ui.PlayEvent  +=  PlaySomething;
        }
        private  static  void  PlaySomething(  object  source,  UIEvent  args  )  {
                Console.WriteLine("Play  the  file");
        }

}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo GUI Windows Forms
» EventArgs