private Timer timer; //used to periodically check door staus #endregion Fields #region Constructors public LaserSynrad(Form parent) { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); this.parent = parent; this.parent.Move += new EventHandler(ParentMoved); this.synrad = new SynMhAtx(); this.nextIndex = 0; this.drawing = new Hashtable(); this.connected = false; this.doorStatus = LaserHardwareDoorStatus.Unknown; this.timer = new Timer(); this.timer.Interval = 250; this.timer.Stop(); this.timer.Tick += new EventHandler(Timer_Tick); LaserMarker.Instance.StateChanged += new EventHandler(MarkerStateChanged); }
public LaserSim(Form Parent) { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); this.connected = false; this.parent = Parent; this.parent.Move += new EventHandler(ParentMoved); this.doorStatus = LaserHardwareDoorStatus.Closed; //populate mark result listbox string[] results = LaserMarkResult.GetNames(typeof(LaserMarkResult)); foreach (string result in results) { this.listBoxResult.Items.Add(result); } this.listBoxResult.SelectedIndex = 0; this.Hide(); }
/// <summary> /// Gets the door status when the timer ticks /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Timer_Tick(object sender, EventArgs e) { if (this.connected == true) { short result = this.synrad.GetDigitalBit(3); if (result == 1) { this.doorStatus = LaserHardwareDoorStatus.Closed; } else { this.doorStatus = LaserHardwareDoorStatus.Open; } this.labelDoorStatus.Text = this.doorStatus.ToString(); //fire door changed event DoorChangedEventArgs args = new DoorChangedEventArgs(this.doorStatus); if (this.DoorChanged != null) { this.DoorChanged(this, args); } } }
/// <summary> /// toggle the door status /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ButtonDoorToggleClick(object sender, System.EventArgs e) { if (this.doorStatus == LaserHardwareDoorStatus.Closed) { this.doorStatus = LaserHardwareDoorStatus.Open; } else { this.doorStatus = LaserHardwareDoorStatus.Closed; } //fire door changed event this.labelDoorStatus.Text = this.doorStatus.ToString(); DoorChangedEventArgs args = new DoorChangedEventArgs(this.doorStatus); if (this.DoorChanged != null) { this.DoorChanged(this, args); } }
public DoorChangedEventArgs(LaserHardwareDoorStatus status) { this.Status = status; }
/// <summary> /// Toggle the door status /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ChkDoorClick(object sender, System.EventArgs e) { if (this.chkDoor.Checked) { this.chkDoor.Text = "Door Closed"; this.doorStatus = LaserHardwareDoorStatus.Closed; } else { this.chkDoor.Text = "Door Open"; this.doorStatus = LaserHardwareDoorStatus.Open; } //fire door changed event DoorChangedEventArgs args = new DoorChangedEventArgs(this.doorStatus); if (this.DoorChanged != null) { this.DoorChanged(this, args); } }