예제 #1
0
파일: Program.cs 프로젝트: returnres/exam
        public void OnMotoreSpento()
        {
            Console.WriteLine("OnMotoreSpento");

            MotoreSpento?.Invoke(this, new GiritMotoreEventArgs()
            {
                NumeroGiriRAggiunto = this._numerogiri
            });
        }
예제 #2
0
파일: TestEvent.cs 프로젝트: returnres/exam
 protected virtual void OnMotoreSpento()
 {
     //if (MotoreSpento != null)
     //{
     //    MotoreSpento(this, EventArgs.Empty);
     //}
     //oppure
     //MotoreSpento?.Invoke(this, EventArgs.Empty);
     //oppure
     MotoreSpento?.Invoke(this, new GiritMotoreEventArgs()
     {
         NumeroGiriRAggiunto = this._numerogiri
     });
 }
예제 #3
0
 public void Accellera()
 {
     if (this.EngineOn)
     {
         this.numeroGiri += 100;
         if (this.numeroGiri > 500)
         {
             /*
              * if (MotoreFuoriGiri != null)
              *  MotoreFuoriGiri(this, EventArgs.Empty);
              */
             MotoreFuoriGiri?.Invoke(this, EventArgs.Empty);
         }
     }
     else
     {
         MotoreSpento?.Invoke(this, EventArgs.Empty);
     }
 }
예제 #4
0
        public void Decellera()
        {
            if (this.EngineOn)
            {
                this.numeroGiri -= 100;
                if (this.numeroGiri < 100)
                {
                    this.numeroGiri = 0;
                    this.EngineOn   = false;

                    /*
                     * if (MotoreSpento != null)
                     *  MotoreSpento(this, EventArgs.Empty);
                     */
                    MotoreSpento?.Invoke(this, EventArgs.Empty);
                }
            }
            else
            {
                MotoreSpento?.Invoke(this, EventArgs.Empty);
            }
        }