i got a Problem here with Events,
before your write "duplicate", im going to say that i ve done it alrdy and im not that good at programming thats why am i asking yet.
Problem is that my Event doesnt fire
debugger says :=> "OnCollision is Null"
EDIT: DEBUGGER PART
OnCollision is my Event
thanks for help :D
Thats my EventArgs
public class CollisionEventArgs : EventArgs
{
public bool Hit { get { return hit; } }
private bool hit;
public CollisionEventArgs(bool _hit)
{
this.hit = _hit;
}
}
HitControl
public delegate void CollisionHandler(object current, CollisionEventArgs cea);
public class HitControl : Button
{
public event CollisionHandler OnCollision;
public bool IsHit
{
get { return isHit; }
set
{
if (OnCollision != null)
{
if (this.Width > 100)
OnCollision(this, new CollisionEventArgs(true));
}
}
}
public bool isHit;
public HitControl()
{ }
}
Method
private void hitControl1_OnCollision_1(object current, CollisionEventArgs cea)
{
MessageBox.Show("a");
}
Code in Designer [Sub]
//
// hitControl1
//
this.hitControl1.IsHit = false;
this.hitControl1.Location = new System.Drawing.Point(115, 183);
this.hitControl1.Name = "hitControl1";
this.hitControl1.Size = new System.Drawing.Size(175, 23);
this.hitControl1.TabIndex = 1;
this.hitControl1.Text = "hitControl1";
this.hitControl1.UseVisualStyleBackColor = true;
this.hitControl1.OnCollision += new CollisionHandler(this.hitControl1_OnCollision_1);