/// <summary> /// Wireups the events. /// </summary> private void WireupEvents() { // Already wired up? if (_wiredup) { return; } // Display the new value Stepper.ValueChanged += (sender, e) => { SubTitle.Text = Stepper.Value.ToString(); // Set updated value to the characteristic Characteristic.WriteValue(NSObject.FromObject(Stepper.Value), (err) => { // Was there an error? if (err != null) { // Yes, inform user AlertView.PresentOKAlert("Update Error", err.LocalizedDescription, Controller); } }); }; // Mark as wired up _wiredup = true; }
/// <summary> /// Adds the home. /// </summary> private void AddNewHome() { // Has a name been entered? if (HomeName.Text == "") { // No, inform the user that they must create a home first AlertView.PresentOKAlert("Home Name Error", "You must enter a name for the home before it can be created.", this); return; } // Add new home to HomeKit ThisApp.HomeManager.AddHome(HomeName.Text, (home, error) => { // Did an error occur if (error != null) { // Yes, inform user AlertView.PresentOKAlert("Add Home Error", string.Format("Error adding {0}: {1}", HomeName.Text, error.LocalizedDescription), this); return; } // Make the primary house ThisApp.HomeManager.UpdatePrimaryHome(home, (err) => { // Error? if (err != null) { // Inform user of error AlertView.PresentOKAlert("Add Home Error", string.Format("Unable to make this the primary home: {0}", err.LocalizedDescription), this); return; } }); // Close the window when the home is created DismissViewController(true, null); }); }
/// <Docs>Table view containing the row.</Docs> /// <summary> /// Rows the selected. /// </summary> /// <param name="tableView">Table view.</param> /// <param name="indexPath">Index path.</param> public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { // Add the requested accessory to the home ThisApp.HomeManager.PrimaryHome.AddAccessory(_controller.AccessoryBrowser.DiscoveredAccessories [indexPath.Row], (err) => { // Did an error occur if (err != null) { // Inform user of error AlertView.PresentOKAlert("Add Accessory Error", err.LocalizedDescription, _controller); } }); }
/// <summary> /// Wireups the events. /// </summary> private void WireupEvents() { // Already wired up? if (_wiredup) { return; } // Wire text field Text.ShouldReturn += (UITextField field) => { field.ResignFirstResponder(); // Set updated value to the characteristic Characteristic.WriteValue(NSObject.FromObject(Text.Text), (err) => { // Was there an error? if (err != null) { // Yes, inform user AlertView.PresentOKAlert("Update Error", err.LocalizedDescription, Controller); } }); return(true); }; Text.ShouldEndEditing += (UITextField field) => { field.ResignFirstResponder(); // Set updated value to the characteristic Characteristic.WriteValue(NSObject.FromObject(Text.Text), (err) => { // Was there an error? if (err != null) { // Yes, inform user AlertView.PresentOKAlert("Update Error", err.LocalizedDescription, Controller); } }); return(true); }; // Mark as wired up _wiredup = true; }
/// <summary> /// Wireups the events. /// </summary> private void WireupEvents() { // Already wired up? if (_wiredup) { return; } // Display the new value Slider.ValueChanged += (sender, e) => { var value = Math.Round(Slider.Value, 0); SubTItle.Text = value.ToString(); }; // Send change of value on end of change Slider.TouchUpInside += (sender, e) => { // Is a characteristic attached? if (Characteristic == null) { return; } // Set updated value to the characteristic var value = Math.Round(Slider.Value, 0); Characteristic.WriteValue(NSObject.FromObject(value), (err) => { // Was there an error? if (err != null) { // Yes, inform user AlertView.PresentOKAlert("Update Error", err.LocalizedDescription, Controller); } }); }; // Mark as wired up _wiredup = true; }