PanelData CreatePanel(DocumentWindow documentWindow, bool willSelected)
        {
            PanelData panel = new PanelData();

            panel.documentWindow = documentWindow;

            panels.Add(panel);
            panelByDocumentWindow.Add(panel.documentWindow, panel);

            //create control
            OnCreatePanelControl(panel);

            if (!willSelected && panel.control != null)
            {
                panel.control.Visible = false;
                panel.control.Enabled = false;
            }

            return(panel);
        }
Exemplo n.º 2
0
        IEnumerable <Item> GetNewItems(object[] objects)
        {
            var itemByGroupName = new Dictionary <string, HCItemGroup>();
            var itemByMember    = new Dictionary <Metadata.Member, HCItemMember>();

            foreach (var item in rootItems)
            {
                var groupItem = item as HCItemGroup;
                if (groupItem != null)
                {
                    itemByGroupName.Add(groupItem.Name, groupItem);
                }
                var memberItem = item as HCItemMember;
                if (memberItem != null)
                {
                    itemByMember.Add(memberItem.Member, memberItem);
                }
            }

            var groups = new EDictionary <string, List <Metadata.Member> >();
            //var members = MetadataManager.MetadataGetMembers( obj );
            //if( ReverseItems )
            //	members = members.Reverse();

            var firstObject = objects[0];

            var membersToAdd = new EDictionary <Metadata.Member, int>(128);

            //foreach( var member in members )
            foreach (var member in MetadataManager.MetadataGetMembers(firstObject))
            {
                if (contentMode == ContentModeEnum.Properties && !(member is Metadata.Property))
                {
                    continue;
                }
                if (contentMode == ContentModeEnum.Events && !(member is Metadata.Event))
                {
                    continue;
                }

                if (EditorUtility.IsMemberVisible(member))
                {
                    bool skip = false;

                    //Type Settings filter
                    var component = firstObject as Component;
                    if (component != null && !component.TypeSettingsIsPublicMember(member))
                    {
                        skip = true;
                    }
                    //if( component != null )
                    //{
                    //var baseComponentType = component.BaseType as Metadata.ComponentTypeInfo;
                    //if( baseComponentType != null && baseComponentType.BasedOnObject.TypeSettingsIsPrivateObject( member ) )
                    //	skip = true;
                    //}

                    if (!skip)
                    {
                        membersToAdd[member] = 1;
                    }
                }
            }

            for (int nObject = 1; nObject < objects.Length; nObject++)
            {
                var obj = objects[nObject];
                foreach (var member in MetadataManager.MetadataGetMembers(obj))
                {
                    if (membersToAdd.TryGetValue(member, out var counter))
                    {
                        membersToAdd[member] = counter + 1;
                    }
                }
            }

            foreach (var pair in membersToAdd)
            {
                var member  = pair.Key;
                var counter = pair.Value;
                if (counter == objects.Length)
                {
                    var groupName = TypeUtility.GetUserFriendlyCategory(member);

                    List <Metadata.Member> list;
                    if (!groups.TryGetValue(groupName, out list))
                    {
                        list = new List <Metadata.Member>();
                        groups.Add(groupName, list);
                    }
                    list.Add(member);
                }
            }

            ////foreach( var member in members )
            //foreach( var member in MetadataManager.MetadataGetMembers( obj ) )
            //{
            //	if( contentMode == ContentModeEnum.Properties && !( member is Metadata.Property ) )
            //		continue;
            //	if( contentMode == ContentModeEnum.Events && !( member is Metadata.Event ) )
            //		continue;

            //	if( EditorUtility.IsMemberVisible( member ) )
            //	{
            //		bool skip = false;

            //		//Type Settings filter
            //		var component = obj as Component;
            //		if( component != null && !component.TypeSettingsIsPublicMember( member ) )
            //			skip = true;
            //		//if( component != null )
            //		//{
            //		//var baseComponentType = component.BaseType as Metadata.ComponentTypeInfo;
            //		//if( baseComponentType != null && baseComponentType.BasedOnObject.TypeSettingsIsPrivateObject( member ) )
            //		//	skip = true;
            //		//}

            //		if( !skip )
            //		{
            //			var groupName = TypeUtility.GetUserFriendlyCategory( member );

            //			List<Metadata.Member> list;
            //			if( !groups.TryGetValue( groupName, out list ) )
            //			{
            //				list = new List<Metadata.Member>();
            //				groups.Add( groupName, list );
            //			}
            //			list.Add( member );
            //		}
            //	}
            //}

            //!!!!change order

            //reverse groups for Events mode
            if (ReverseGroups)             //if( contentMode == ContentModeEnum.Events )
            {
                var newGroups = new EDictionary <string, List <Metadata.Member> >(groups.Count);
                foreach (var pair in groups.Reverse())
                {
                    newGroups.Add(pair.Key, pair.Value);
                }
                groups = newGroups;
            }

            foreach (var groupPair in groups)
            {
                var groupName = groupPair.Key;
                var list      = groupPair.Value;

                //update group
                if (DisplayGroups)
                {
                    if (!itemByGroupName.TryGetValue(groupName, out HCItemGroup groupItem))
                    {
                        groupItem = new HCItemGroup(this, null, groupName);
                    }
                    yield return(groupItem);
                }

                //update properties of the group
                foreach (var member in list)
                {
                    if (!itemByMember.TryGetValue(member, out var item))
                    {
                        Type itemType = GetSuitableItemType(member);
                        //var originalType = property.Type.GetNetType();
                        //var unrefType = ReferenceUtils.GetUnreferencedType( originalType );
                        //Type itemType = HCPropertyItemTypes.GetSuitableType( unrefType );

                        //!!!!может быть null. Component.MetadataGetMembers в _InvokeMember
                        if (itemType != null)
                        {
                            var property = member as Metadata.Property;
                            if (property != null)
                            {
                                var constructor = itemType.GetConstructor(new Type[] {
                                    typeof(HierarchicalContainer),
                                    typeof(Item),
                                    typeof(object[]),
                                    typeof(Metadata.Property),
                                    typeof(object[])
                                });

                                item = (HCItemMember)constructor.Invoke(new object[] { this, null, SelectedObjects, property, property.Indexers });
                            }

                            var _event = member as Metadata.Event;
                            if (_event != null)
                            {
                                var constructor = itemType.GetConstructor(new Type[] {
                                    typeof(HierarchicalContainer),
                                    typeof(Item),
                                    typeof(object[]),
                                    typeof(Metadata.Event)
                                });

                                item = (HCItemMember)constructor.Invoke(new object[] { this, null, SelectedObjects, _event });
                            }
                        }
                    }

                    if (item != null)
                    {
                        yield return(item);
                    }
                }
            }
        }