// Configures the table view and initializes view elements. public override void ViewDidLoad () { base.ViewDidLoad (); TableView.EstimatedRowHeight = 44; TableView.RowHeight = UITableView.AutomaticDimension; selectedRoom = Accessory.Room ?? Home.GetRoomForEntireHome (); // If the accessory belongs to the home already, we are in 'edit' mode. editingExistingAccessory = AccessoryHasBeenAddedToHome (); // Show 'save' instead of 'add.' // If we're not editing an existing accessory, then let the back button show in the left. if (editingExistingAccessory) AddButton.Title = "Save"; else NavigationItem.LeftBarButtonItem = null; // Put the accessory's name in the 'name' field. ResetNameField (); // Register a cell for the rooms. TableView.RegisterClassForCellReuse (typeof(UITableViewCell), RoomCell); }
public void DidRemoveRoomFromZone(HMHome home, HMRoom room, HMZone zone) { if (zone == HomeZone) { DidRemoveRoom(room); } }
public void DidRemoveRoom(HMHome home, HMRoom room) { if (room == Room) { NavigationController.PopViewController(true); } }
public void DidUpdateNameForRoom(HMHome home, HMRoom room) { if (room == Room) { NavigationItem.Title = room.Name; } }
public NSIndexPath Remove(HMRoom room) { var indexPath = IndexPathOfObject(room); Rooms.RemoveAt(indexPath.Row); return(indexPath); }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { tableView.DeselectRow(indexPath, true); switch ((AddAccessoryTableViewSection)indexPath.Section) { case AddAccessoryTableViewSection.Rooms: if (!Home.IsAdmin()) { return; } selectedRoom = Home.GetAllRooms() [indexPath.Row]; var sections = NSIndexSet.FromIndex((nint)(int)AddAccessoryTableViewSection.Rooms); tableView.ReloadSections(sections, UITableViewRowAnimation.Automatic); break; case AddAccessoryTableViewSection.Identify: IdentifyAccessory(); break; case AddAccessoryTableViewSection.Name: break; default: throw new InvalidOperationException("Unexpected `AddAccessoryTableViewSection` value."); } }
public void DidAddRoomToZone(HMHome home, HMRoom room, HMZone zone) { if (zone == HomeZone) { DidAddRoom(room); } }
// Configures the table view and initializes view elements. public override void ViewDidLoad() { base.ViewDidLoad(); TableView.EstimatedRowHeight = 44; TableView.RowHeight = UITableView.AutomaticDimension; selectedRoom = Accessory.Room ?? Home.GetRoomForEntireHome(); // If the accessory belongs to the home already, we are in 'edit' mode. editingExistingAccessory = AccessoryHasBeenAddedToHome(); // Show 'save' instead of 'add.' // If we're not editing an existing accessory, then let the back button show in the left. if (editingExistingAccessory) { AddButton.Title = "Save"; } else { NavigationItem.LeftBarButtonItem = null; } // Put the accessory's name in the 'name' field. ResetNameField(); // Register a cell for the rooms. TableView.RegisterClassForCellReuse(typeof(UITableViewCell), RoomCell); }
// returns: All rooms in the home, including `roomForEntireHome`. public static HMRoom[] GetAllRooms (this HMHome self) { var rooms = self.Rooms; var allRooms = new HMRoom[rooms.Length + 1]; Array.Copy (rooms, allRooms, rooms.Length); allRooms [rooms.Length] = self.GetRoomForEntireHome (); return allRooms; }
// returns: All rooms in the home, including `roomForEntireHome`. public static HMRoom[] GetAllRooms(this HMHome self) { var rooms = self.Rooms; var allRooms = new HMRoom[rooms.Length + 1]; Array.Copy(rooms, allRooms, rooms.Length); allRooms [rooms.Length] = self.GetRoomForEntireHome(); return(allRooms); }
public void DidRemoveRoom(HMHome home, HMRoom room) { // Reset the selected room if ours was deleted. if (selectedRoom == room) { selectedRoom = HomeStore.Home.GetRoomForEntireHome(); } TableView.ReloadData(); }
async void TryRemove(HMRoom room) { try { await Home.RemoveRoomAsync(room); } catch (NSErrorException ex) { DisplayError(ex.Error); Add(room); } }
async void AddRoomWithName(string roomName) { try { HMRoom room = await Home.AddRoomAsync(roomName); Add(room); } catch (NSErrorException ex) { DisplayError(ex.Error); } }
// Reloads the cell corresponding a given room. void DidUpdateRoom(HMRoom room) { var roomIndex = rooms.IndexOf(room); if (roomIndex >= 0) { var roomIndexPath = NSIndexPath.FromRowSection(roomIndex, 0); TableView.ReloadRows(new [] { roomIndexPath }, UITableViewRowAnimation.Automatic); } }
public void DidUpdateRoom(HMHome home, HMRoom room, HMAccessory accessory) { if (room == Room) { DidAssignAccessory(accessory); } else if (Accessories.Contains(accessory)) { DidUnassignAccessory(accessory); } }
// Removes a room from HomeKit and updates the view. void RemoveRoom(HMRoom room) { DidRemoveRoom(room); HomeZone.RemoveRoom(room, error => { if (error != null) { DisplayError(error); DidAddRoom(room); } }); }
// Removes a room from the internal array of rooms and deletes the row from the table view. void DidRemoveRoom(HMRoom room) { var roomIndex = rooms.IndexOf(room); if (roomIndex >= 0) { rooms.RemoveAtIndex(roomIndex); var roomIndexPath = NSIndexPath.FromRowSection(roomIndex, 0); TableView.DeleteRows(new [] { roomIndexPath }, UITableViewRowAnimation.Automatic); } ReloadAddIndexPath(); }
// Adds a room to the internal array of rooms and inserts new row into the table view. void DidAddRoom(HMRoom room) { rooms.Add(room); SortRooms(); var newRoomIndex = rooms.IndexOf(room); if (newRoomIndex >= 0) { var newRoomIndexPath = NSIndexPath.FromRowSection(newRoomIndex, 0); TableView.InsertRows(new [] { newRoomIndexPath }, UITableViewRowAnimation.Automatic); } ReloadAddIndexPath(); }
// 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(); }); }
public NSIndexPath IndexPathOfObject(HMRoom room) { var index = Rooms.IndexOf(room); return(index < 0 ? null : BuildIndexPath(index, HomeKitObjectSection.Room)); }
public void DidUpdateNameForRoom(HMHome home, HMRoom room) { DidUpdateRoom(room); }
public NSIndexPath IndexPathOfObject (HMRoom room) { var index = Rooms.IndexOf (room); return index < 0 ? null : BuildIndexPath (index, HomeKitObjectSection.Room); }
public void DidAddRoom(HMHome home, HMRoom room) { ReloadAddIndexPath(); }
public void DidRemoveRoom(HMHome home, HMRoom room) { DidRemoveRoom(room); }
public void DidRemoveRoom (HMHome home, HMRoom room) { DeleteRowAt (ObjectCollection.Remove (room)); }
public void DidRemoveRoom (HMHome home, HMRoom room) { DidRemoveRoom (room); }
// Reloads the cell corresponding a given room. void DidUpdateRoom (HMRoom room) { var roomIndex = rooms.IndexOf (room); if (roomIndex >= 0) { var roomIndexPath = NSIndexPath.FromRowSection (roomIndex, 0); TableView.ReloadRows (new []{ roomIndexPath }, UITableViewRowAnimation.Automatic); } }
public void DidAddRoom (HMHome home, HMRoom room) { Add (room); }
public void DidUpdateNameForRoom (HMHome home, HMRoom room) { DidUpdateRoom (room); }
// 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 (); }); }
public void DidRemoveRoomFromZone (HMHome home, HMRoom room, HMZone zone) { if (zone == HomeZone) DidRemoveRoom (room); }
public override void RowSelected (UITableView tableView, NSIndexPath indexPath) { tableView.DeselectRow (indexPath, true); switch ((AddAccessoryTableViewSection)indexPath.Section) { case AddAccessoryTableViewSection.Rooms: if (!Home.IsAdmin ()) return; selectedRoom = Home.GetAllRooms () [indexPath.Row]; var sections = NSIndexSet.FromIndex ((nint)(int)AddAccessoryTableViewSection.Rooms); tableView.ReloadSections (sections, UITableViewRowAnimation.Automatic); break; case AddAccessoryTableViewSection.Identify: IdentifyAccessory (); break; case AddAccessoryTableViewSection.Name: break; default: throw new InvalidOperationException ("Unexpected `AddAccessoryTableViewSection` value."); } }
public void DidUpdateNameForRoom(HMHome home, HMRoom room) { TableView.ReloadData(); }
public void DidUpdateNameForRoom (HMHome home, HMRoom room) { TableView.ReloadData (); }
public void DidAddRoom (HMHome home, HMRoom room) { TableView.ReloadData (); }
public void DidRemoveRoom (HMHome home, HMRoom room) { // Reset the selected room if ours was deleted. if (selectedRoom == room) selectedRoom = HomeStore.Home.GetRoomForEntireHome (); TableView.ReloadData (); }
void Add(HMRoom room) { InsertRowAt(ObjectCollection.Add(room)); }
void Add (HMRoom room) { InsertRowAt (ObjectCollection.Add (room)); }
public NSIndexPath Remove (HMRoom room) { var indexPath = IndexPathOfObject (room); Rooms.RemoveAt (indexPath.Row); return indexPath; }
public void DidUpdateNameForRoom (HMHome home, HMRoom room) { ResetDisplayedRooms (); }
public NSIndexPath Add (HMRoom room) { Rooms.Add (room); Rooms.SortByLocalizedName (r => r.Name); return IndexPathOfObject (room); }
public void DidRemoveRoom (HMHome home, HMRoom room) { ResetDisplayedRooms (); }
public NSIndexPath Add(HMRoom room) { Rooms.Add(room); Rooms.SortByLocalizedName(r => r.Name); return(IndexPathOfObject(room)); }
public void DidAddRoomToZone (HMHome home, HMRoom room, HMZone zone) { ResetDisplayedRooms (); }
// Removes a room from the internal array of rooms and deletes the row from the table view. void DidRemoveRoom (HMRoom room) { var roomIndex = rooms.IndexOf (room); if (roomIndex >= 0) { rooms.RemoveAtIndex (roomIndex); var roomIndexPath = NSIndexPath.FromRowSection (roomIndex, 0); TableView.DeleteRows (new []{ roomIndexPath }, UITableViewRowAnimation.Automatic); } ReloadAddIndexPath (); }
public void DidRemoveRoomFromZone (HMHome home, HMRoom room, HMZone zone) { ResetDisplayedRooms (); }
// Removes a room from HomeKit and updates the view. void RemoveRoom (HMRoom room) { DidRemoveRoom (room); HomeZone.RemoveRoom (room, error => { if (error != null) { DisplayError (error); DidAddRoom (room); } }); }
public void DidAddRoomToZone(HMHome home, HMRoom room, HMZone zone) { ResetDisplayedRooms(); }
public void DidAddRoom (HMHome home, HMRoom room) { ReloadAddIndexPath (); }
public void DidRemoveRoom (HMHome home, HMRoom room) { if (room == Room) NavigationController.PopViewController (true); }
public void DidAddRoomToZone (HMHome home, HMRoom room, HMZone zone) { if (zone == HomeZone) DidAddRoom (room); }
public void DidUpdateNameForRoom (HMHome home, HMRoom room) { if (room == Room) NavigationItem.Title = room.Name; }
// Adds a room to the internal array of rooms and inserts new row into the table view. void DidAddRoom (HMRoom room) { rooms.Add (room); SortRooms (); var newRoomIndex = rooms.IndexOf (room); if (newRoomIndex >= 0) { var newRoomIndexPath = NSIndexPath.FromRowSection (newRoomIndex, 0); TableView.InsertRows (new []{ newRoomIndexPath }, UITableViewRowAnimation.Automatic); } ReloadAddIndexPath (); }
public void DidAddRoom(HMHome home, HMRoom room) { Add(room); }
public void DidRemoveRoomFromZone(HMHome home, HMRoom room, HMZone zone) { ResetDisplayedRooms(); }
public void DidRemoveRoom(HMHome home, HMRoom room) { DeleteRowAt(ObjectCollection.Remove(room)); }
public void DidAddRoom(HMHome home, HMRoom room) { TableView.ReloadData(); }
public void DidUpdateNameForRoom(HMHome home, HMRoom room) { ReloadRowAt(ObjectCollection.IndexPathOfObject(room)); }
public void DidUpdateRoom (HMHome home, HMRoom room, HMAccessory accessory) { if (room == Room) DidAssignAccessory (accessory); else if (Accessories.Contains (accessory)) DidUnassignAccessory (accessory); }
public void DidUpdateNameForRoom (HMHome home, HMRoom room) { ReloadRowAt (ObjectCollection.IndexPathOfObject (room)); }