private void btnConnect_Click(object sender, EventArgs e) { if (!Connected) { try { Controller = new IvyController(this.GetHashCode().ToString(), tbxAddress.Text, tbxPort.Text); Controller.PositionChanged += Controller_PositionChanged; Controller.OrientationChanged += Controller_OrientationChanged; Connected = true; } catch (Exception ex) { MessageBox.Show(String.Format("Error while loading IvyController: {0}", ex.Message)); Connected = false; } } else { Connected = false; } }
private void View_Load(object sender, EventArgs e) { //DL/ Create controller with a name corresponding to the hash code of the application this.Controller = new IvyController(this.GetHashCode().ToString()); Controller.PositionChanged += Controller_PositionChanged; Controller.OrientationChanged += Controller_OrientationChanged; }