Esempio n. 1
0
        private void makeAllListEntries()
        {
            IDataBindingOutputReadonly <IList> db = GetBinding() as IDataBindingOutputReadonly <IList>;
            IList boundList = db.GetValue();

            for (int i = 0; i < boundList.Count; i++)
            {
                updateReceivers[i] = makeListEntry(i);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Will trigger an update. Will pull value from the viewmodel and trigger the update
 /// action.
 /// </summary>
 public void ForceUpdate()
 {
     try
     {
         IDataBindingOutputReadonly <ReceivingType> db =
             Context.GetBinding(BindingPath) as IDataBindingOutputReadonly <ReceivingType>;
         UpdateAction(db.GetValue());
     }
     catch (ArgumentException)
     {
         Debug.LogWarning("Binding at '" + this.GetAbsoluteDataPath() + "' not found.");
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Triggered by managing DataNode if there is an value update.
        /// </summary>
        /// <param name="updatedPath">Path that has been updated.</param>
        public void OnUpdate(Path updatedPath)
        {
            // Check if this is for the list
            if (BindingPath.IsSamePath(updatedPath))
            {
                // We might have to adjust the amount of children (list size expands / shrinks)
                IDataBindingOutputReadonly <IList> db = GetBinding() as IDataBindingOutputReadonly <IList>;
                IList boundList = db.GetValue();
                int   oldCount  = updateReceivers.Count;
                int   newCount  = boundList.Count;

                int countDifference = oldCount - newCount;
                if (countDifference > 0)
                {
                    // We have to remove some of the children
                    for (int i = 0; i < countDifference; i++)
                    {
                        int removeIndex = oldCount - 1 - i;
                        removeListEntryAt(removeIndex);
                    }
                }
                if (countDifference < 0)
                {
                    // We have to add some children
                    for (int i = 0; i < -countDifference; i++)
                    {
                        int addIndex = oldCount + i;
                        updateReceivers[addIndex] = makeListEntry(addIndex);
                    }
                }
                ForceUpdate();
            }
            else if (updatedPath.IsSubpathOf(BindingPath))
            {
                Path subPath = updatedPath.GetSlice(BindingPath.PathElements.Count);

                PathElement indexPathElement = subPath.PathElements.First();
                if (indexPathElement.Type != PathElement.PathElementType.Index)
                {
                    throw new ArgumentException("Error at path '" + updatedPath.ToString() + "'. List has to be accessed by index.");
                }

                int index = indexPathElement.Index;
                updateReceivers[index].OnUpdate(subPath);
            }
        }