public NSIndexPath Remove(HMActionSet actionSet)
        {
            var indexPath = IndexPathOfObject(actionSet);

            ActionSets.RemoveAt(indexPath.Row);
            return(indexPath);
        }
 public void DidRemoveActionSet(HMHome home, HMActionSet actionSet)
 {
     if (actionSet == ActionSet)
     {
         DismissViewController(true, null);
     }
 }
Exemple #3
0
 async void TryRemove(HMActionSet actionSet)
 {
     try {
         await Home.RemoveActionSetAsync(actionSet);
     } catch (NSErrorException ex) {
         DisplayError(ex.Error);
         Add(actionSet);
     }
 }
		public static int CompareWitBuiltIn (this HMActionSet actionSet, HMActionSet anotherBuiltIn)
		{
			var index = Array.IndexOf (BuiltInActionSetTypes, actionSet.ActionSetType);
			var anotherIndex = Array.IndexOf (BuiltInActionSetTypes, anotherBuiltIn.ActionSetType);

			if (index < 0 || anotherIndex < 0)
				throw new InvalidOperationException ();

			return anotherIndex - index;
		}
        public static int CompareWitBuiltIn(this HMActionSet actionSet, HMActionSet anotherBuiltIn)
        {
            var index        = Array.IndexOf(BuiltInActionSetTypes, actionSet.ActionSetType);
            var anotherIndex = Array.IndexOf(BuiltInActionSetTypes, anotherBuiltIn.ActionSetType);

            if (index < 0 || anotherIndex < 0)
            {
                throw new InvalidOperationException();
            }

            return(anotherIndex - index);
        }
        // Checks to see if an action already exists to modify the same characteristic
        // as the action passed in. If such an action exists, the method tells the
        // existing action to update its target value. Otherwise, the new action is
        // simply added to the action set.
        void AddAction(HMCharacteristicWriteAction action, HMActionSet actionSet, Action <NSError> completion)
        {
            var existingAction = ExistingActionInActionSetMatchingAction(action);

            if (existingAction != null)
            {
                existingAction.UpdateTargetValue(action.TargetValue, completion);
            }
            else
            {
                actionSet.AddAction(action, completion);
            }
        }
		// Adds all of the actions that have been requested to the Action Set, then runs a completion block.
		void SaveActionSet (HMActionSet actionSet)
		{
			var actions = ActionsFromMapTable ();
			foreach (var action in actions) {
				saveActionSetGroup.Enter ();
				AddAction (action, actionSet, error => {
					if (error != null) {
						Console.WriteLine ("HomeKit: Error adding action: {0}", error.LocalizedDescription);
						SaveError = error;
					}
					saveActionSetGroup.Leave ();
				});
			}
		}
Exemple #8
0
        void ExecuteActionSet(HMActionSet actionSet)
        {
            if (actionSet.Actions.Count == 0)
            {
                DisplayMessage("Empty Scene",
                               "This scene is empty. To set this scene, first add some actions to it.");
                return;
            }

            Home.ExecuteActionSet(actionSet, error => {
                if (error != null)
                {
                    DisplayError(error);
                }
            });
        }
        // Adds all of the actions that have been requested to the Action Set, then runs a completion block.
        void SaveActionSet(HMActionSet actionSet)
        {
            var actions = ActionsFromMapTable();

            foreach (var action in actions)
            {
                saveActionSetGroup.Enter();
                AddAction(action, actionSet, error => {
                    if (error != null)
                    {
                        Console.WriteLine("HomeKit: Error adding action: {0}", error.LocalizedDescription);
                        SaveError = error;
                    }
                    saveActionSetGroup.Leave();
                });
            }
        }
Exemple #10
0
        static int ActionSetComparision(HMActionSet x, HMActionSet y)
        {
            bool xBuiltIn = x.IsBuiltIn();
            bool yBuiltIn = y.IsBuiltIn();

            // If comparing a built-in and a user-defined, the built-in is ranked first.
            if (xBuiltIn != yBuiltIn)
            {
                return(xBuiltIn.CompareTo(yBuiltIn));
            }

            // If comparing two built-ins, we follow a standard ranking
            if (xBuiltIn && yBuiltIn)
            {
                return(x.CompareWitBuiltIn(y));
            }

            // If comparing two user-defines, sort by localized name.
            return(x.Name.CompareTo(y.Name));
        }
Exemple #11
0
 public void DidUpdateNameForActionSet(HMHome home, HMActionSet actionSet)
 {
     ReloadRowAt(ObjectCollection.IndexPathOfObject(actionSet));
 }
Exemple #12
0
 public void DidRemoveActionSet(HMHome home, HMActionSet actionSet)
 {
     DeleteRowAt(ObjectCollection.Remove(actionSet));
 }
Exemple #13
0
 public void DidAddActionSet(HMHome home, HMActionSet actionSet)
 {
     Add(actionSet);
 }
Exemple #14
0
 void Add(HMActionSet actionSet)
 {
     InsertRowAt(ObjectCollection.Add(actionSet));
 }
		// Checks to see if an action already exists to modify the same characteristic
		// as the action passed in. If such an action exists, the method tells the
		// existing action to update its target value. Otherwise, the new action is
		// simply added to the action set.
		void AddAction (HMCharacteristicWriteAction action, HMActionSet actionSet, Action<NSError>completion)
		{
			var existingAction = ExistingActionInActionSetMatchingAction (action);
			if (existingAction != null)
				existingAction.UpdateTargetValue (action.TargetValue, completion);
			else
				actionSet.AddAction (action, completion);
		}
		public NSIndexPath IndexPathOfObject (HMActionSet actionSet)
		{
			var index = ActionSets.IndexOf (actionSet);
			return index < 0 ? null : BuildIndexPath (index, HomeKitObjectSection.ActionSet);
		}
 public NSIndexPath Add(HMActionSet actionSet)
 {
     ActionSets.Add(actionSet);
     ActionSets.SortByTypeAndLocalizedName();
     return(IndexPathOfObject(actionSet));
 }
		void ExecuteActionSet (HMActionSet actionSet)
		{
			if (actionSet.Actions.Count == 0) {
				DisplayMessage ("Empty Scene",
					"This scene is empty. To set this scene, first add some actions to it.");
				return;
			}

			Home.ExecuteActionSet (actionSet, error => {
				if (error != null)
					DisplayError (error);
			});
		}
		void Add (HMActionSet actionSet)
		{
			InsertRowAt (ObjectCollection.Add (actionSet));
		}
		async void TryRemove (HMActionSet actionSet)
		{
			try {
				await Home.RemoveActionSetAsync (actionSet);
			} catch (NSErrorException ex) {
				DisplayError (ex.Error);
				Add (actionSet);
			}
		}
		public ActionSetCreator (HMActionSet actionSet, HMHome home)
		{
			ActionSet = actionSet;
			Home = home;
		}
		public NSIndexPath Add (HMActionSet actionSet)
		{
			ActionSets.Add (actionSet);
			ActionSets.SortByTypeAndLocalizedName ();
			return IndexPathOfObject (actionSet);
		}
		public NSIndexPath Remove (HMActionSet actionSet)
		{
			var indexPath = IndexPathOfObject (actionSet);
			ActionSets.RemoveAt (indexPath.Row);
			return indexPath;
		}
 public ActionSetCreator(HMActionSet actionSet, HMHome home)
 {
     ActionSet = actionSet;
     Home      = home;
 }
		public void DidAddActionSet (HMHome home, HMActionSet actionSet)
		{
			Add (actionSet);
		}
        public NSIndexPath IndexPathOfObject(HMActionSet actionSet)
        {
            var index = ActionSets.IndexOf(actionSet);

            return(index < 0 ? null : BuildIndexPath(index, HomeKitObjectSection.ActionSet));
        }
 // returns: `true` if the action set is built-in; `false` otherwise.
 public static bool IsBuiltIn(this HMActionSet actionSet)
 {
     return(Array.IndexOf(BuiltInActionSetTypes, actionSet.ActionSetType) >= 0);
 }
		public void DidRemoveActionSet (HMHome home, HMActionSet actionSet)
		{
			DeleteRowAt (ObjectCollection.Remove (actionSet));
		}
		public void DidRemoveActionSet (HMHome home, HMActionSet actionSet)
		{
			if (actionSet == ActionSet)
				DismissViewController (true, null);
		}
		public void DidUpdateNameForActionSet (HMHome home, HMActionSet actionSet)
		{
			ReloadRowAt (ObjectCollection.IndexPathOfObject (actionSet));
		}