Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use events for that.</p> <p>Booking action will fire an event that will indicate that a facility is booked.<br> Form1 will have an event handler registered to it and change the button's image to reflect the state of the facility.</p> <p><strong>Edit</strong> (how to do this with events):</p> <pre><code>public class FacilityStateChangeEventArgs : EventArgs { public FacilityStateChangeEventArgs(bool booked) { this.Booked = booked; } public bool Booked { get; protected set; } // ... other properties if you need them } public class Facility { private bool booked = false; public bool Booked { get { return this.booked; } protected set { if (this.booked == value) return; // Changes the state and fires the event. this.booked = value; FireChange(); } } public event EventHandler&lt;FacilityStateChangeEventArgs&gt; StateChange; // You will use this method when booked gets changed public void FireChange() { if (this.StateChange != null) this.StateChange(this, new FacilityStateChangeEventArgs(this.Booked)); } } // The form with the image button. public class FormWithButton { Button button1 = new Button(); public void Whatever() { // You will get the facility from your bussiness instances. Facility facility = new Facility(); facility.StateChange += new EventHandler&lt;FacilityStateChangeEventArgs&gt;(facility_StateChange); } void facility_StateChange(object sender, FacilityStateChangeEventArgs e) { if (e.Booked) button1.Image = null; // booked image else button1.Image = null; // free image } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload