Ejemplo n.º 1
0
        protected void UpdateInterfaceDrawers()
        {
            interfaceDrawers.Clear();

            if (ValueEntry == null)
            {
                return;
            }

            var interfaceTypes = ValueEntry.TypeOfValue.GetMostDerivedInterfaces();

            if (interfaceTypes.Length == 0)
            {
                return;
            }

            var ownerType = ValueEntry.TypeOfOwner;

            foreach (var interfaceType in interfaceTypes)
            {
                var drawerType = ValueDrawerTypes.GetOrBuild(ownerType, interfaceType, false);
                if (drawerType == null)
                {
                    continue;
                }

                var drawer = (ValueDrawer)Create(drawerType, interfaceType.GetReadableName(), this);
                drawer.ValueEntry   = ProxyValueEntryFactory.Create(ownerType, interfaceType, ValueEntry);
                drawer.ValueVisible = false;

                interfaceDrawers.Add(interfaceType, drawer);
            }
        }
Ejemplo n.º 2
0
        public void ChildrenUpdate(int itemCount)
        {
            int pageIndex = This.CurrentPageIndex, countPerPage = This.ItemCountPerPage;
            int countInPage = PageUtil.ItemCountInPage(itemCount, countPerPage, pageIndex);

            // Remove redundant child drawers.
            while (This.ChildCount > countInPage)
            {
                This.LastChild.Parent = null;
            }

            if (countInPage == 0)
            {
                return;
            }

            int startIndex = PageUtil.FirstItemIndexOfPage(countPerPage, pageIndex);
            int stopIndex  = PageUtil.LastItemIndexOfPage(itemCount, countPerPage, pageIndex);

            for (int index = startIndex; index <= stopIndex; ++index)
            {
                if (index >= itemCount)
                {
                    continue;
                }

                var itemType  = ItemTypeGetter(index);
                var childType = ValueDrawerTypes.GetOrBuild(typeof(TCollection), itemType);

                int childIndex = index - startIndex;
                var child      = This.GetChild(childIndex) as ValueDrawer;
                if (child != null)
                {
                    if (child.GetType() != childType)
                    {
                        child = (ValueDrawer)Drawer.Create(childType);
                        This.ReplaceChild(childIndex, child);
                    }
                    else
                    {
                        //if (child.DrawingValue )
                    }
                }
                else
                {
                    child = (ValueDrawer)Drawer.Create(childType);
                    child.ChangeParent(This, childIndex);
                }
                child.Name       = index.ToString();
                child.ValueEntry = ValueEntryCreator(index, This.TypedDrawingValue);
            }
        }
Ejemplo n.º 3
0
        public void UpdateChildrenImpl(IEnumerable <Component> components, bool verifyGameObject)
        {
            int componentCount = components != null?components.Count() : 0;

            // Remove redundant child drawers.
            while (ChildCount > componentCount)
            {
                LastChild.Parent = null;
            }

            if (componentCount > 0)
            {
                foreach (var component in components)
                {
                    if (verifyGameObject && component.gameObject != GameObject)
                    {
                        var msg = string.Format(
                            @"Components of ""{0}"" expected, got ""{1}"".",
                            GameObject, component.gameObject);
                        throw new ArgumentException(msg, "components");
                    }

                    var expectedChildType = ValueDrawerTypes.GetOrBuild(typeof(GameObject), component.GetType());
                    var child             = GetChild(component);
                    if (child != null && child.GetType() != expectedChildType)
                    {
                        child.Parent = null;
                        child        = null;
                    }
                    if (child == null)
                    {
                        child = (ValueDrawer)Create(expectedChildType, component.GetType().Name);
                    }
                    AddMapping(component, child, true);

                    child.ValueEntry = new FixedValueEntry <GameObject, Component>(GameObject, component);
                }
            }
            else
            {
                ClearChildren();
            }
        }
Ejemplo n.º 4
0
        public void ChildrenUpdate(TList list)
        {
            int countInPage = This.ItemCountInCurrentPage;

            // Remove redundant child drawers.
            while (This.ChildCount > countInPage)
            {
                This.LastChild.Parent = null;
            }

            int firstItemIndex = This.FirstItemIndexOfCurrentPage;

            for (int i = 0; i < countInPage; ++i)
            {
                int  itemIndex = firstItemIndex + i;
                Type itemType;
                ItemTypeGetter.GetValue(list, itemIndex, out itemType, DefaultItemType);
                var childType = ValueDrawerTypes.GetOrBuild(typeof(TList), itemType);

                var child = This.GetChild(i) as ValueDrawer;
                if (child != null)
                {
                    if (child.GetType() != childType)
                    {
                        child = (ValueDrawer)Drawer.Create(childType);
                        This.ReplaceChild(i, child);
                    }
                }
                else
                {
                    child = (ValueDrawer)Drawer.Create(childType);
                    child.ChangeParent(This, i);
                }
                child.Name       = itemIndex.ToString();
                child.ValueEntry = ChildValueEntryCreator(list, itemType, itemIndex);
            }
        }
Ejemplo n.º 5
0
        protected static ValueDrawer CreateImpl(Type ownerType, Type valueType, bool useRootAsDefault = true)
        {
            var type = ValueDrawerTypes.GetOrBuild(ownerType, valueType, useRootAsDefault);

            return((ValueDrawer)CreateImpl(type));
        }