public void DidUpdateReachability(HMAccessory accessory) { if (accessory == Service.Accessory && !accessory.Reachable) { NavigationController.PopToRootViewController(true); } }
public void DidUpdateReachability(HMAccessory accessory) { if (Accessory == accessory) { NavigationController.PopViewController(true); } }
public void DidRemoveAccessory(HMHome home, HMAccessory accessory) { if (accessory == Service.Accessory) { NavigationController.PopToRootViewController(true); } }
public NSIndexPath Remove(HMAccessory accessory) { var indexPath = IndexPathOfObject(accessory); Accessories.RemoveAt(indexPath.Row); return(indexPath); }
/// Sends the accessory to the next view. void ConfigureAccessory(HMAccessory accessory) { if (displayedAccessories.Contains(Accessory.CreateHomeKitObject(accessory))) { PerformSegue(AddAccessorySegue, accessory); } }
public void DisplayAccessory(HMAccessory accessory) { // Update the UI AvailableName.Text = accessory.Name; // Set icon based on the name if (accessory.Name.Contains("Light")) { AvailableImage.Image = UIImage.FromFile("61-brightness.png"); } else if (accessory.Name.Contains("Garage")) { AvailableImage.Image = UIImage.FromFile("24-circle-north.png"); } if (accessory.Name.Contains("Thermostat")) { AvailableImage.Image = UIImage.FromFile("81-dashboard.png"); } else if (accessory.Name.Contains("Switch")) { AvailableImage.Image = UIImage.FromFile("51-power.png"); } else if (accessory.Name.Contains("Lock")) { AvailableImage.Image = UIImage.FromFile("54-lock.png"); } }
public void DidAddAccessory(HMHome home, HMAccessory accessory) { if (accessory.Room == room) { accessory.Delegate = this; DidAssignAccessory(accessory); } }
async void TryRemove(HMAccessory accessory) { try { await Home.RemoveAccessoryAsync(accessory); } catch (NSErrorException ex) { DisplayError(ex.Error); Add(accessory); } }
// Finds an accessory in the internal array of accessories and updates its row in the table view. void DidModifyAccessory(HMAccessory accessory) { var index = Accessories.IndexOf(accessory); if (index >= 0) { TableView.ReloadRows(new [] { NSIndexPath.FromRowSection(index, 0) }, UITableViewRowAnimation.Automatic); } }
public static Accessory CreateHomeKitObject(HMAccessory accessory) { return(new Accessory { Type = AccessoryType.HomeKit, AccessoryObject = accessory, HomeKitAccessoryObject = accessory, nameGetter = () => accessory.Name }); }
public void DidRemoveAccessory(HMHome home, HMAccessory accessory) { if (home.Accessories.Length == 0) { NavigationController.DismissViewController(true, null); } ReloadTable(); }
// Provides an array of favorite `HMCharacteristic`s within a given accessory. public HMCharacteristic[] FavoriteCharacteristicsForAccessory(HMAccessory accessory) { var result = accessory.Services .SelectMany(s => s.Characteristics) .Where(c => c.IsFavorite()) .ToArray(); Array.Sort(result, CharacteristicOrderedBefore); return(result); }
public void DidAddAccessory(HMHome home, HMAccessory accessory) { // Bridged accessories don't call the original completion handler if their // bridges are added to the home. We must respond to `HMHomeDelegate`'s // `home:didAddAccessory:` and assign bridged accessories properly. if (selectedRoom != null) { AssignAccessory(home, accessory, selectedRoom); } }
public void DidUpdateNameForService(HMAccessory accessory, HMService service) { var index = displayedServices.IndexOf(service); if (index >= 0) { var path = NSIndexPath.FromRowSection(index, (int)AccessoryTableViewSection.Services); TableView.ReloadRows(new [] { path }, UITableViewRowAnimation.Automatic); } }
// Assigns the current room back into `roomForEntireHome`. void UnassignAccessory(HMAccessory accessory) { DidUnassignAccessory(accessory); Home.AssignAccessory(accessory, Home.GetRoomForEntireHome(), error => { if (error != null) { DisplayError(error); DidAssignAccessory(accessory); } }); }
public void DidRemoveAccessory(HMHome home, HMAccessory accessory) { if (ShouldPopViewController()) { DismissViewController(true, null); } else { TableView.ReloadData(); } }
public void DidUpdateRoom(HMHome home, HMRoom room, HMAccessory accessory) { if (room == Room) { DidAssignAccessory(accessory); } else if (Accessories.Contains(accessory)) { DidUnassignAccessory(accessory); } }
public void DidUpdateValueForCharacteristic(HMAccessory accessory, HMService service, HMCharacteristic characteristic) { var index = Array.IndexOf(service.Characteristics, characteristic); if (index >= 0) { var indexPath = NSIndexPath.FromRowSection(index, 0); var cell = (CharacteristicCell)TableView.CellAt(indexPath); cell.SetValue(characteristic.Value, false); } }
// Assigns an accessory to the current room. void AssignAccessory(HMAccessory accessory) { DidAssignAccessory(accessory); Home.AssignAccessory(accessory, room, error => { if (error != null) { DisplayError(error); DidUnassignAccessory(accessory); } }); }
// Removes an accessory from the internal list of accessory (if it exists) and deletes the row from the table view. void DidUnassignAccessory(HMAccessory accessory) { var accessoryIndex = Accessories.IndexOf(accessory); if (accessoryIndex >= 0) { Accessories.RemoveAt(accessoryIndex); var accessoryIndexPath = NSIndexPath.FromRowSection(accessoryIndex, 0); TableView.DeleteRows(new [] { accessoryIndexPath }, UITableViewRowAnimation.Automatic); } }
// Adds an accessory into the internal list of accessories and inserts the row into the table view. void DidAssignAccessory(HMAccessory accessory) { Accessories.Add(accessory); SortAccessories(); var newAccessoryIndex = Accessories.IndexOf(accessory); if (newAccessoryIndex >= 0) { var newAccessoryIndexPath = NSIndexPath.FromRowSection(newAccessoryIndex, 0); TableView.InsertRows(new [] { newAccessoryIndexPath }, UITableViewRowAnimation.Automatic); } }
public void DidRemoveNewAccessory(HMAccessoryBrowser browser, HMAccessory accessory) { var removedAccessory = Accessory.CreateHomeKitObject(accessory); var removedIndex = displayedAccessories.IndexOf(removedAccessory); if (removedIndex < 0) { return; } var removedIndexPath = NSIndexPath.FromRowSection(removedIndex, 0); displayedAccessories.RemoveAt(removedIndex); TableView.DeleteRows(new [] { removedIndexPath }, UITableViewRowAnimation.Automatic); }
// Searches through the home's accessories to find the accessory that is bridging the provided accessory. public static HMAccessory BridgeForAccessory (this HMHome self, HMAccessory accessory) { if (!accessory.Bridged) return null; foreach (var bridge in self.Accessories) { var bridgedIds = bridge.UniqueIdentifiersForBridgedAccessories; foreach (var id in bridgedIds) { if (accessory.UniqueIdentifier == id) return bridge; } } return null; }
// Assigns the given accessory to the provided room. This method will enter and leave the saved dispatch group. void AssignAccessory(HMHome home, HMAccessory accessory, HMRoom room) { if (accessory.Room == room) { return; } saveAccessoryGroup.Enter(); home.AssignAccessory(accessory, room, error => { if (error != null) { DisplayError(error); didEncounterError = true; } saveAccessoryGroup.Leave(); }); }
// Updates the accessories name. This function will enter and leave the saved dispatch group. // If the accessory's name is already equal to the passed-in name, this method does nothing. void UpdateName(string name, HMAccessory accessory) { if (accessory.Name == name) { return; } saveAccessoryGroup.Enter(); accessory.UpdateName(name, error => { if (error != null) { DisplayError(error); didEncounterError = true; } saveAccessoryGroup.Leave(); }); }
public void DisplayAccessory(HMAccessory accessory) { // Update the UI AvailableName.Text = accessory.Name; // Set icon based on the name if (accessory.Name.Contains ("Light")) { AvailableImage.Image = UIImage.FromFile ("61-brightness.png"); } else if (accessory.Name.Contains ("Garage")) { AvailableImage.Image = UIImage.FromFile ("24-circle-north.png"); } if (accessory.Name.Contains ("Thermostat")) { AvailableImage.Image = UIImage.FromFile ("81-dashboard.png"); } else if (accessory.Name.Contains ("Switch")) { AvailableImage.Image = UIImage.FromFile ("51-power.png"); } else if (accessory.Name.Contains ("Lock")) { AvailableImage.Image = UIImage.FromFile ("54-lock.png"); } }
public void DidFindNewAccessory(HMAccessoryBrowser browser, HMAccessory accessory) { var newAccessory = Accessory.CreateHomeKitObject(accessory); if (displayedAccessories.Contains(newAccessory)) { return; } displayedAccessories.Add(newAccessory); displayedAccessories.SortByLocalizedName(a => a.Name); var newIndex = displayedAccessories.IndexOf(newAccessory); if (newIndex >= 0) { var newIndexPath = NSIndexPath.FromRowSection(newIndex, 0); TableView.InsertRows(new [] { newIndexPath }, UITableViewRowAnimation.Automatic); } }
// Searches through the home's accessories to find the accessory that is bridging the provided accessory. public static HMAccessory BridgeForAccessory(this HMHome self, HMAccessory accessory) { if (!accessory.Bridged) { return(null); } foreach (var bridge in self.Accessories) { var bridgedIds = bridge.UniqueIdentifiersForBridgedAccessories; foreach (var id in bridgedIds) { if (accessory.UniqueIdentifier == id) { return(bridge); } } } return(null); }
public void DidUpdateValueForCharacteristic(HMAccessory accessory, HMService service, HMCharacteristic characteristic) { var s = characteristic.Service; if (s == null) { return; } var a = service.Accessory; if (a == null) { return; } var indexOfAccessory = Array.IndexOf(favoriteAccessories, accessory); if (indexOfAccessory < 0) { return; } var favoriteCharacteristics = FavoritesManager.SharedManager.FavoriteCharacteristicsForAccessory(accessory); var indexOfCharacteristic = Array.IndexOf(favoriteCharacteristics, characteristic); if (indexOfCharacteristic < 0) { return; } var indexPath = NSIndexPath.FromRowSection(indexOfCharacteristic, indexOfAccessory); var cell = (CharacteristicCell)TableView.CellAt(indexPath); cell.SetValue(characteristic.Value, false); }
// Updates the accessories name. This function will enter and leave the saved dispatch group. // If the accessory's name is already equal to the passed-in name, this method does nothing. void UpdateName (string name, HMAccessory accessory) { if (accessory.Name == name) return; saveAccessoryGroup.Enter (); accessory.UpdateName (name, error => { if (error != null) { DisplayError (error); didEncounterError = true; } saveAccessoryGroup.Leave (); }); }
public void DidUpdateReachability (HMAccessory accessory) { ReloadData (); }
public void DidUpdateName(HMAccessory accessory) { ResetNameField(); }
// Provides an array of favorite `HMCharacteristic`s within a given accessory. public HMCharacteristic[] FavoriteCharacteristicsForAccessory (HMAccessory accessory) { var result = accessory.Services .SelectMany (s => s.Characteristics) .Where (c => c.IsFavorite ()) .ToArray (); Array.Sort (result, CharacteristicOrderedBefore); return result; }
public void DidUpdateName (HMAccessory accessory) { ReloadData (); }
public void DidUpdateServices (HMAccessory accessory) { ReloadData (); }
public void DidUpdateName(HMAccessory accessory) { DidModifyAccessory(accessory); }
public NSIndexPath Remove (HMAccessory accessory) { var indexPath = IndexPathOfObject (accessory); Accessories.RemoveAt (indexPath.Row); return indexPath; }
// Removes an accessory from the internal list of accessory (if it exists) and deletes the row from the table view. void DidUnassignAccessory (HMAccessory accessory) { var accessoryIndex = Accessories.IndexOf (accessory); if (accessoryIndex >= 0) { Accessories.RemoveAt (accessoryIndex); var accessoryIndexPath = NSIndexPath.FromRowSection (accessoryIndex, 0); TableView.DeleteRows (new [] { accessoryIndexPath }, UITableViewRowAnimation.Automatic); } }
public void DidUpdateName (HMAccessory accessory) { DidModifyAccessory (accessory); }
public void DidUpdateReachability (HMAccessory accessory) { DidModifyAccessory (accessory); }
public void DidUpdateRoom (HMHome home, HMRoom room, HMAccessory accessory) { if (room == Room) DidAssignAccessory (accessory); else if (Accessories.Contains (accessory)) DidUnassignAccessory (accessory); }
public void DidRemoveAccessory (HMHome home, HMAccessory accessory) { DidUnassignAccessory (accessory); }
// Assigns an accessory to the current room. void AssignAccessory (HMAccessory accessory) { DidAssignAccessory (accessory); Home.AssignAccessory (accessory, room, error => { if (error != null) { DisplayError (error); DidUnassignAccessory (accessory); } }); }
public NSIndexPath IndexPathOfObject (HMAccessory accessory) { var index = Accessories.IndexOf (accessory); return index < 0 ? null : BuildIndexPath (index, HomeKitObjectSection.Accessory); }
public void DidAddAccessory (HMHome home, HMAccessory accessory) { accessory.Delegate = this; ReloadData (); }
public NSIndexPath Add (HMAccessory accessory) { Accessories.Add (accessory); Accessories.SortByLocalizedName (a => a.Name); return IndexPathOfObject (accessory); }
public void DidRemoveAccessory (HMHome home, HMAccessory accessory) { ReloadData (); }
// Adds an accessory into the internal list of accessories and inserts the row into the table view. void DidAssignAccessory (HMAccessory accessory) { Accessories.Add (accessory); SortAccessories (); var newAccessoryIndex = Accessories.IndexOf (accessory); if (newAccessoryIndex >= 0) { var newAccessoryIndexPath = NSIndexPath.FromRowSection (newAccessoryIndex, 0); TableView.InsertRows (new []{ newAccessoryIndexPath }, UITableViewRowAnimation.Automatic); } }
public void DidUpdateNameForService (HMAccessory accessory, HMService service) { ReloadData (); }
public void DidUpdateName (HMAccessory accessory) { ResetNameField (); }
public void DidUpdateAssociatedServiceType (HMAccessory accessory, HMService service) { ReloadData (); }
public void DidAddAccessory (HMHome home, HMAccessory accessory) { // Bridged accessories don't call the original completion handler if their // bridges are added to the home. We must respond to `HMHomeDelegate`'s // `home:didAddAccessory:` and assign bridged accessories properly. if (selectedRoom != null) AssignAccessory (home, accessory, selectedRoom); }
public void DidUnblockAccessory(HMHome home, HMAccessory accessory) { TableView.ReloadData(); }
// Assigns the given accessory to the provided room. This method will enter and leave the saved dispatch group. void AssignAccessory (HMHome home, HMAccessory accessory, HMRoom room) { if (accessory.Room == room) return; saveAccessoryGroup.Enter (); home.AssignAccessory (accessory, room, error => { if (error != null) { DisplayError (error); didEncounterError = true; } saveAccessoryGroup.Leave (); }); }
// Assigns the current room back into `roomForEntireHome`. void UnassignAccessory (HMAccessory accessory) { DidUnassignAccessory (accessory); Home.AssignAccessory (accessory, Home.GetRoomForEntireHome (), error => { if (error != null) { DisplayError (error); DidAssignAccessory (accessory); } }); }
public void DidRemoveAccessory (HMHome home, HMAccessory accessory) { if (ShouldPopViewController ()) DismissViewController (true, null); else TableView.ReloadData (); }
public void DidAddAccessory (HMHome home, HMAccessory accessory) { TableView.ReloadData (); }
// Finds an accessory in the internal array of accessories and updates its row in the table view. void DidModifyAccessory (HMAccessory accessory) { var index = Accessories.IndexOf (accessory); if (index >= 0) TableView.ReloadRows (new []{ NSIndexPath.FromRowSection (index, 0) }, UITableViewRowAnimation.Automatic); }
public void DidUpdateValueForCharacteristic (HMAccessory accessory, HMService service, HMCharacteristic characteristic) { var s = characteristic.Service; if (s == null) return; var a = service.Accessory; if (a == null) return; var indexOfAccessory = Array.IndexOf (favoriteAccessories, accessory); if (indexOfAccessory < 0) return; var favoriteCharacteristics = FavoritesManager.SharedManager.FavoriteCharacteristicsForAccessory (accessory); var indexOfCharacteristic = Array.IndexOf (favoriteCharacteristics, characteristic); if (indexOfCharacteristic < 0) return; var indexPath = NSIndexPath.FromRowSection (indexOfCharacteristic, indexOfAccessory); var cell = (CharacteristicCell)TableView.CellAt (indexPath); cell.SetValue (characteristic.Value, false); }
public void DidAddAccessory (HMHome home, HMAccessory accessory) { if (accessory.Room == room) { accessory.Delegate = this; DidAssignAccessory (accessory); } }