public void CreateNewItem(InspectorInfo item)
 {
     int top = 0;
     if (viewItems.Count > 0)
     {
         top = (viewItems[0].itemHeight - 4) * viewItems.Count;
     }
     DetailedItem detailedItem = new DetailedItem(manager, this, item, backPanel, top, LeftPadding);
     if (item.ToolTip.Length > 0) detailedItem.panel.ToolTip.Text = item.ToolTip;
     viewItems.Add(detailedItem);
     SetupScroll(detailedItem);
 }
        public void DoubleClickItem(InspectorArea inspectorArea)
        {
            //if (inspectorArea.sidebar.userLevel == UserLevel.User || inspectorArea.sidebar.userLevel == UserLevel.Advanced) return;

            bool haschildren = hasChildren();
            if (haschildren)
            {
                if (extended)
                {
                    prefix = "+";
                    RemoveChildren();
                }
                else
                {
                    GenerateChildren(GenerateFields:inspectorArea.GenerateFields, userLevel: UserLevel.Debug);
                    prefix = "-";

                    if (masterList != null)
                    {
                        inspectorArea.ActiveInspectorParent = this;
                        foreach (object item in masterList.ToList())
                        {
                            masterList.Remove(item);
                        }
                        if (parentItem != null)
                        {
                            InspectorInfo uplevel = new InspectorInfo(masterList, "...", sidebar);
                            uplevel.parentItem = this;
                            uplevel.membertype = member_type.previouslevel;
                            masterList.Add(uplevel);
                        }
                        foreach (InspectorInfo subitem in children)
                        {
                            //masterList.Insert(position + i++, subitem);
                            masterList.Add(subitem);
                        }
                    }
                }
                //extended = !extended;
            }
            else if (membertype == member_type.previouslevel)
            {
                if (parentItem != null && parentItem.parentItem != null)
                {
                    parentItem.parentItem.DoubleClickItem(inspectorArea);
                }
            }
            else if (!haschildren)
            {
                if (masterList != null)
                {
                    foreach (InspectorInfo subitem in children)
                    {
                        //masterList.Insert(position + i++, subitem);
                        masterList.Remove(subitem);
                    }
                }
            }
        }
        public static void InsertItemSorted(List<InspectorInfo> itemList, InspectorInfo item)
        {
            int length = itemList.Count;
            int weight = (int)item.datatype;

            if (weight == 0)
            {
                itemList.Add(item);
                return;
            }
            for (int i = 0; i < length; i++)
            {
                int itemweight = (int)((InspectorInfo)itemList.ElementAt(i)).datatype;
                if (weight < itemweight)
                {
                    itemList.Insert(i, item);
                    return;
                }
            }
            itemList.Add(item);
        }
        public static List<InspectorInfo> GenerateList(object parent, InspectorInfo parentItem = null, bool GenerateFields = false, UserLevel? userLevel = null)
        {
            UserLevel userlevel = OrbIt.ui.sidebar.userLevel;
            if (userLevel != null) userlevel = (UserLevel)userLevel;

            List<InspectorInfo> list = new List<InspectorInfo>();
            //char a = (char)164;
            //System.Console.WriteLine(a);
            //string space = "|";
            //if (parentItem != null) space += parentItem.whitespace;
            //List<FieldInfo> fieldInfos = o.GetType().GetFields().ToList(); //just supporting properties for now
            data_type dt = data_type.obj; //if this item is the root, we should give it it's real type in.steam of assuming it's an object
            if (parentItem != null) dt = parentItem.datatype;

            if (dt == data_type.collection)
            {
                dynamic collection = parent;
                foreach (object o in collection)
                {
                    InspectorInfo iitem = new InspectorInfo(parentItem.masterList, parentItem, o);
                    if (iitem.CheckForChildren()) iitem.prefix = "+";
                    InsertItemSorted(list, iitem);
                }

            }
            else if (dt == data_type.array)
            {
                dynamic array = parent;
                foreach (object o in array)
                {
                    InspectorInfo iitem = new InspectorInfo(parentItem.masterList, parentItem, o);
                    if (iitem.CheckForChildren()) iitem.prefix = "+";
                    InsertItemSorted(list, iitem);
                }

            }
            else if (dt == data_type.dict)
            {
                //dynamic dict = iitem.fpinfo.GetValue(iitem.parentItem);
                dynamic dict = parent;
                foreach (dynamic key in dict.Keys)
                {
                    //System.Console.WriteLine(key.ToString());
                    InspectorInfo iitem = new InspectorInfo(parentItem.masterList, parentItem, dict[key], key);
                    //iitem.GenerateChildren();
                    //list.Add(iitem);
                    if (iitem.CheckForChildren()) iitem.prefix = "+";
                    InsertItemSorted(list, iitem);
                }
            }
            else if (dt == data_type.obj)
            {
                ///// PROPERTIES
                List<PropertyInfo> propertyInfos;
                //if the object isn't a component, then we only want to see the 'declared' properties (not inherited)
                if (!(parent is Component || parent is Player))// || parent is Process))
                {
                    propertyInfos = parent.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).ToList();
                }
                else
                {
                    propertyInfos = parent.GetType().GetProperties().ToList();
                }

                foreach (PropertyInfo pinfo in propertyInfos)
                {
                    string tooltip = "";
                    object[] attributes = pinfo.GetCustomAttributes(false);
                    var abstractions = pinfo.GetCustomAttributes(typeof(Info), false);
                    if (abstractions.Length > 0)
                    {
                        Info info = (Info)abstractions[0];
                        if ((int)info.userLevel > (int)userlevel) continue;
                        tooltip = info.summary;

                    }
                    else if (userlevel != UserLevel.Debug)
                    {
                        continue;
                    }
                    //if (pinfo.Name.Equals("Item")) continue;
                    InspectorInfo iitem = new InspectorInfo(parentItem.masterList, parentItem, pinfo.GetValue(parent, null), pinfo);
                    if (tooltip.Length > 0) iitem.ToolTip = tooltip;
                    if (iitem.CheckForChildren()) iitem.prefix = "+";
                    InsertItemSorted(list, iitem);
                }
                ////// FIELDS
                List<FieldInfo> fieldInfos;
                //if the object isn't a component, then we only want to see the 'declared' properties (not inherited)
                if (!(parent is Component || parent is Player))// || parent is Process))
                {
                    fieldInfos = parent.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).ToList();
                }
                else
                {
                    fieldInfos = parent.GetType().GetFields().ToList();
                }

                foreach (FieldInfo finfo in fieldInfos)
                {
                    //if (finfo.GetCustomAttributes(typeof(DoNotInspect), false).Length > 0) continue;
                    var abstractions = finfo.GetCustomAttributes(typeof(Info), false);
                    if (abstractions.Length > 0)
                    {
                        if ((int)(abstractions[0] as Info).userLevel > (int)userlevel) continue;
                    }
                    else if (userlevel != UserLevel.Debug)
                    {
                        continue;
                    }
                    InspectorInfo iitem = new InspectorInfo(parentItem.masterList, parentItem, finfo.GetValue(parent), finfo);
                    if (iitem.CheckForChildren()) iitem.prefix = "+";
                    InsertItemSorted(list, iitem);
                }
                ////METHODS
                List<MethodInfo> methodInfos;
                //if the object isn't a component, then we only want to see the 'declared' properties (not inherited)
                if (!(parent is Component || parent is Player))// || parent is Process))
                {
                    methodInfos = parent.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).ToList();
                }
                else
                {
                    methodInfos = parent.GetType().GetMethods().ToList();
                }

                foreach (MethodInfo minfo in methodInfos)
                {
                    //if (finfo.GetCustomAttributes(typeof(DoNotInspect), false).Length > 0) continue;
                    var abstractions = minfo.GetCustomAttributes(typeof(Clickable), false);
                    if (abstractions.Length == 0)
                    {
                        continue;
                    }
                    InspectorInfo iitem = new InspectorInfo(parentItem.masterList, parentItem, minfo);
                    InsertItemSorted(list, iitem);
                }

            }
            //if it's just a normal primitive, it will return an empty list
            if (list.Count > 0) parentItem.prefix = "+";
            return list;
        }
 //method
 public InspectorInfo(IList<object> masterList, InspectorInfo parentItem, MethodInfo methodInfo)
 {
     this.membertype = member_type.method;
     this.methodInfo = methodInfo;
     this.whitespace = "|";
     if (parentItem != null) this.whitespace += parentItem.whitespace;
     this.obj = null;
     this.parentItem = parentItem;
     this.masterList = masterList;
     this.children = new List<InspectorInfo>();
     this.showValueToString = parentItem.showValueToString;
     CheckItemType();
     prefix = "" + ((char)164);
     //this.inspectorArea = parentItem.inspectorArea;
     this.sidebar = parentItem.sidebar;
 }
        public void SwitchNode(Node node, bool group)
        {
            ClearView();
            if (node == null) return;

            this.rootNode = node;
            if (!group)
            {
                GroupSync = false;
                insView.GroupSync = false;
                this.activeGroup = null;
            }
            //int selected = sidebar.tbcMain.SelectedIndex;
            //if (selected != 3) sidebar.tbcMain.SelectedIndex = 3;
            int heightCount = 0;
            int itemCount = node.comps.Count + 2;
            InspectorInfo rootItem = new InspectorInfo(null, node, sidebar);
            int height = 0;
            if (sidebar.userLevel == UserLevel.Debug)
            {
                CreateItem(new DetailedItem(manager, this, rootItem, backPanel, heightCount, LeftPadding));
                heightCount += viewItems[0].itemHeight - 2;
            }
            InspectorInfo bodyItem = new InspectorInfo(null, rootItem, node.body, node.GetType().GetProperty("body"));
            CreateItem(new DetailedItem(manager, this, bodyItem, backPanel, heightCount, LeftPadding));
            Info inf = Utils.GetInfoClass(node.body);
            if (inf != null) viewItems[0].toolTip = inf.summary;

            height = (viewItems[0].itemHeight - 2);

            InspectorInfo dictItem = new InspectorInfo(null, rootItem, node.comps, node.GetType().GetProperty("comps"));
            foreach (Type c in node.comps.Keys)
            {
                string tooltip = "";
                Info info = Utils.GetInfoClass(node.comps[c]);
                if (info != null)
                {
                    if ((int)info.userLevel > (int)sidebar.userLevel) continue;
                    tooltip = info.summary;
                }
                heightCount += height;
                InspectorInfo cItem = new InspectorInfo(null, dictItem, node.comps[c], c);
                DetailedItem di = new DetailedItem(manager, this, cItem, backPanel, heightCount, LeftPadding);
                di.toolTip = tooltip;
                CreateItem(di);
            }
            ScrollPosition = 0;
            backPanel.ScrollTo(backPanel.ScrollBarValue.Horizontal, 0);
            SetVisible(false);
            backPanel.Refresh();
            //if (selected != 3) sidebar.tbcMain.SelectedIndex = selected;
        }
 public void BuildItemsPath(InspectorInfo item, List<InspectorInfo> itemspath)
 {
     InspectorInfo temp = item;
     itemspath.Insert(0, temp);
     while (temp.parentItem != null)
     {
         temp = temp.parentItem;
         itemspath.Insert(0, temp);
     }
 }
        public void ClearInspectorBox()
        {
            InsBox.ItemIndex = 0;
            rootitem = null;
            ActiveInspectorParent = null;
            foreach (object o in InsBox.Items.ToList())
            {
                InsBox.Items.Remove(o);
            }
            lblInspectorAddress.Text = "/";

            propertyEditPanel.DisableControls();
        }
 private void FieldOrPropertyInitilize(IList<object> masterList, InspectorInfo parentItem, object obj)
 {
     this.whitespace = "|";
     if (parentItem != null) this.whitespace += parentItem.whitespace;
     this.obj = obj;
     this.parentItem = parentItem;
     this.masterList = masterList;
     this.children = new List<InspectorInfo>();
     this.showValueToString = parentItem.showValueToString;
     CheckItemType();
     prefix = "" + ((char)164);
     //this.inspectorArea = parentItem.inspectorArea;
     this.sidebar = parentItem.sidebar;
 }
 public void SetRootInspectorItem(InspectorInfo insItem)
 {
     rootItem = insItem;
     ClearView();
     if (insItem == null) return;
     insItem.GenerateChildren();
     foreach (InspectorInfo i in insItem.children)
     {
         CreateNewItem(i);
     }
 }
 public void SetRootObject(object obj)
 {
     ClearView();
     if (obj == null)
     {
         rootItem = null;
         return;
     }
     if (obj is InspectorInfo)
     {
         SetRootInspectorItem((InspectorInfo)obj);
         return;
     }
     InspectorInfo insItem = new InspectorInfo(null, obj, sidebar);
     SetRootInspectorItem(insItem);
 }
        public void UpdatePanel(InspectorInfo inspectorItem)
        {
            //if (activeInspectorItem == inspectorItem) return;
            if (inspectorItem.membertype == member_type.previouslevel) return;

            if (panelControls.Keys.Count > 0) DisableControls();

            grouppanel.Visible = true;
            grouppanel.Refresh();

            activeInspectorItem = inspectorItem;

            //grouppanel.Text = activeInspectorItem.ToString(); //.Name();
            grouppanel.Text = activeInspectorItem.Name();

            if (!activeInspectorItem.HasPanelElements()) return;

            editType = activeInspectorItem.obj.GetType();
            object value = activeInspectorItem.GetValue();
            if (value == null) return;

            if (editType == typeof(int) || editType == typeof(Single) || editType == typeof(string) || editType == typeof(byte))
            {
                //System.Console.WriteLine("It's an int or float.");
                TextBox txtbox = new TextBox(grouppanel.Manager);
                txtbox.Init();
                txtbox.Parent = grouppanel;
                txtbox.Left = LeftPadding;
                txtbox.Top = 10;
                txtbox.Width = 80;
                txtbox.Height = txtbox.Height + 3;
                txtbox.KeyUp += delegate (object sender, KeyEventArgs e) {
                    if (!txtbox.Text.Equals("") && e.Key == Microsoft.Xna.Framework.Input.Keys.Enter)
                    {
                        btnModify_Click(sender, e);
                    }
                };

                //txtbox.BackColor = Color.Green;

                //txtbox.DrawBorders = true;
                //txtbox.Text = activeInspectorItem.obj.ToString();

                txtbox.Text = value.ToString();

                Button btnModify = new Button(grouppanel.Manager);
                btnModify.Init();
                btnModify.Parent = grouppanel;
                btnModify.Left = LeftPadding * 2 + txtbox.Width;
                btnModify.Top = 10;
                btnModify.Width = 80;
                btnModify.Text = "Modify";
                btnModify.Click += btnModify_Click;

                panelControls.Add("txtbox", txtbox);
                panelControls.Add("btnModify", btnModify);

                if (editType == typeof(int) || editType == typeof(Single) || editType == typeof(byte))
                {
                    Slider trkMain = new Slider(grouppanel.Manager);
                    trkMain.Init();
                    trkMain.Parent = grouppanel;
                    trkMain.Left = LeftPadding;
                    trkMain.Top = 20 + btnModify.Height;
                    trkMain.Width = txtbox.Width + btnModify.Width + LeftPadding;
                    trkMain.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
                    int val = Convert.ToInt32(value);

                    //int range = Math.Max(100, val * 2);
                    trkMain.Range = Math.Max(100, val * 2);

                    trkMain.Value = val;
                    //trkMain.
                    trkMain.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(trkMain_ValueChanged);
                    trkMain.Click += delegate(object sender, TomShane.Neoforce.Controls.EventArgs e)
                    {
                        MouseEventArgs me = (MouseEventArgs)e;
                        if (me.Button != MouseButton.Right) return;
                        int relpos = me.Position.X - 810; //MAGIC NUMBER HACK OMG
                        int sliderpos = (int)(((float)trkMain.Value / (float)trkMain.Range) * trkMain.Width);
                        if (relpos < sliderpos) trkMain.Range = trkMain.Range / 2;
                        else trkMain.Range = trkMain.Range * 2;
                    };
                    //trkMain.
                    trkMain.btnSlider.MouseUp += trkMain_MouseUp;
                    //trkMain.btnSlider.MouseUp += new TomShane.Neoforce.Controls.MouseEventHandler(trkMain_MouseUp);
                    panelControls.Add("trkMain", trkMain);
                }

            }
            else if (editType == typeof(bool))
            {
                //System.Console.WriteLine("It's a boolean.");
                CheckBox chkbox = new CheckBox(grouppanel.Manager);
                chkbox.Init();
                chkbox.Parent = grouppanel;
                chkbox.Left = LeftPadding;
                chkbox.Top = 10;
                chkbox.Width = 120;
                chkbox.Checked = (bool)value;
                chkbox.Text = activeInspectorItem.Name() + " (" + value + ")";
                chkbox.CheckedChanged += new TomShane.Neoforce.Controls.EventHandler(chkbox_CheckedChanged);
                panelControls.Add("chkbox", chkbox);

            }
            else if (editType.IsSubclassOf(typeof(Enum)))
            {
                //System.Console.WriteLine("ENUM!");
                ComboBox cb = new ComboBox(grouppanel.Manager);
                cb.Init();
                cb.Parent = grouppanel;
                cb.MaxItems = 20;
                cb.Left = LeftPadding;
                cb.Top = 10;
                cb.Width = 120;
                foreach (string enumname in Enum.GetNames(editType))
                {
                    cb.Items.Add(enumname);
                }
                cb.ItemIndex = (int)value;
                cb.ItemIndexChanged += cb_ItemIndexChanged;
                panelControls.Add("cb", cb);
            }

            grouppanel.Refresh();
        }
 public override void SelectItem(DetailedItem item)
 {
     InspectorInfo ii;
     if (item.obj is InspectorInfo && (ii = (InspectorInfo)item.obj).obj is Node)
     {
         Node n = (Node)ii.obj;
         InspectorInfo metaitem = new InspectorInfo(null, n.meta, sidebar);
         insView.SetRootInspectorItem(metaitem);
         base.SelectItem(item);
     }
 }
        public void InitializePlayers()
        {
            ClearView();

            int heightCount = 0;
            if (viewItems != null)
            {
                foreach (DetailedItem item in viewItems)
                {
                    backPanel.Remove(item.panel);
                }
            }

            viewItems = new List<DetailedItem>();
            int itemCount = playerGroup.entities.Count;
            int width = backPanel.Width - 4; //#magic number
            if (itemCount >= 10)
                width -= 18;
            foreach (Node p in playerGroup.entities)
            {
                InspectorInfo cItem = new InspectorInfo(null, p, sidebar);
                DetailedItem di = new DetailedItem(manager, this, cItem, backPanel, heightCount, LeftPadding);
                CreateItem(di);
                di.label.Text = p.name;
                heightCount += (viewItems[0].itemHeight - 2);
            }
            //heightCount += compItems[0].label.Height;
            //compItems.Add(new ComponentItem(manager, this, null, compsBackPanel, heightCount, LeftPadding));
            ScrollPosition = 0;
            backPanel.ScrollTo(backPanel.ScrollBarValue.Horizontal, 0);
            SetVisible(true);
            backPanel.Refresh();
        }
 public bool ReferenceExists(InspectorInfo parent, object reference)
 {
     if (parent == null)
     {
         return false;
     }
     if (parent.obj == reference)
     {
         return true;
     }
     return ReferenceExists(parent.parentItem, reference);
 }
 //a field
 public InspectorInfo(IList<object> masterList, InspectorInfo parentItem, object obj, FieldInfo fieldInfo)
 {
     this.membertype = member_type.field;
     this.fpinfo = new FPInfo(fieldInfo);
     FieldOrPropertyInitilize(masterList, parentItem, obj);
 }
        public void ApplyToAllNodes(Group group)
        {
            if (group == null) return;
            List<InspectorInfo> itemspath = new List<InspectorInfo>();
            InspectorInfo item = (InspectorInfo)InsBox.Items.ElementAt(InsBox.ItemIndex);
            object value = item.GetValue();

            BuildItemsPath(item, itemspath);

            group.ForEachAllSets(delegate(Node n)
            {
                if (n == itemspath.ElementAt(0).obj) return;
                InspectorInfo temp = new InspectorInfo(null, n, sidebar);
                int count = 0;
                foreach (InspectorInfo pathitem in itemspath)
                {
                    if (temp.obj.GetType() != pathitem.obj.GetType())
                    {
                        Console.WriteLine("The paths did not match while applying to all. {0} != {1}", temp.obj.GetType(), pathitem.obj.GetType());
                        break;
                    }
                    if (count == itemspath.Count - 1) //last item
                    {
                        if (pathitem.membertype == member_type.dictentry)
                        {
                            dynamic dict = temp.parentItem.obj;
                            dynamic key = pathitem.key;
                            if (!dict.ContainsKey(key)) break;
                            if (dict[key] is Component)
                            {
                                dict[key].active = ((Component)value).active;
                            }
                            else if (temp.IsPanelType())
                            {
                                dict[key] = value;
                            }
                        }
                        else
                        {
                            if (value is Component)
                            {
                                ((Component)temp.obj).active = ((Component)value).active;
                            }
                            else if (temp.IsPanelType())
                            {
                                temp.fpinfo.SetValue(value, temp.parentItem.obj);
                            }
                        }
                    }
                    else
                    {
                        InspectorInfo next = itemspath.ElementAt(count + 1);
                        if (next.membertype == member_type.dictentry)
                        {
                            dynamic dict = temp.obj;
                            dynamic key = next.key;
                            if (!dict.ContainsKey(key)) break;
                            temp = new InspectorInfo(null, temp, dict[key], key);
                        }
                        else
                        {
                            temp = new InspectorInfo(null, temp, next.fpinfo.GetValue(temp.obj), next.fpinfo.propertyInfo);
                        }
                    }
                    count++;
                }
            });
        }
 //obj = null
 //a dictionary entry
 public InspectorInfo(IList<object> masterList, InspectorInfo parentItem, object obj, object key)
 {
     this.whitespace = "|";
     if (parentItem != null) this.whitespace += parentItem.whitespace;
     this.parentItem = parentItem;
     this.obj = obj;
     this.masterList = masterList;
     this.fpinfo = null;
     this.children = new List<InspectorInfo>();
     //this.inspectorArea = parentItem.inspectorArea;
     this.sidebar = parentItem.sidebar;
     this.showValueToString = parentItem.showValueToString;
     Type t = parentItem.obj.GetType();
     if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Dictionary<,>))
     {
         membertype = member_type.dictentry;
         this.key = key;
         CheckItemType();
         prefix = "" + ((char)164);
         //System.Console.WriteLine(this);
         //children = GenerateList(obj, whitespace, this);
     }
     else
     {
         System.Console.WriteLine("Unexpected: InspectorInfo with no obj reference was not a dictionary entry");
         membertype = member_type.unimplemented;
     }
 }
        public void ResetInspectorBox(object rootobj)
        {
            if (rootobj == null)
            {
                ClearInspectorBox();
                return;
            }
            InsBox.ItemIndex = 0;
            InspectorInfo root = new InspectorInfo(InsBox.Items, rootobj, sidebar);
            root.showValueToString = true;
            this.rootitem = root;
            root.GenerateChildren(GenerateFields, userLevel: UserLevel.Debug);
            ActiveInspectorParent = root;

            foreach (object o in InsBox.Items.ToList())
            {
                InsBox.Items.Remove(o);
            }
            foreach (object o in root.children.ToList())
            {
                InsBox.Items.Add(o);
            }
            InsBox.Refresh();
            if (rootobj is Node)
            {
                editNode = (Node)rootobj;
                lblInspectorAddress.Text = "/" + editNode.ToString();
            }
            else
            {
                lblInspectorAddress.Text = rootobj.GetType().ToString();
            }

            if (OverrideString.Item1)
            {
                lblInspectorAddress.Text = OverrideString.Item2;
                lblInspectorAddress.Height = labelDoubleHeight / 2;
            }
            else
            {
                lblInspectorAddress.Height = labelDoubleHeight;
            }
        }
        //obj = null
        //a IEnumberable entry
        public InspectorInfo(IList<object> masterList, InspectorInfo parentItem, object obj)
        {
            this.whitespace = "|";
            if (parentItem != null) this.whitespace += parentItem.whitespace;
            this.parentItem = parentItem;
            this.obj = obj;
            this.masterList = masterList;
            this.fpinfo = null;
            this.children = new List<InspectorInfo>();
            //this.inspectorArea = parentItem.inspectorArea;
            this.sidebar = parentItem.sidebar;
            this.showValueToString = parentItem.showValueToString;
            Type t = parentItem.obj.GetType();

            if (t.GetInterfaces()
                .Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IEnumerable<>)))
            {
                //Console.WriteLine("IEnumerable : {0}", obj.GetType());
                membertype = member_type.collectionentry;
                CheckItemType();
                prefix = "" + ((char)164);
            }
            else
            {
                System.Console.WriteLine("Unexpected: InspectorInfo with no obj reference was not a collection entry");
                membertype = member_type.unimplemented;
            }
        }
        //TODO: fix the relection copying reference types
        void applyToAllNodesMenuItem_Click(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            List<InspectorInfo> itemspath = new List<InspectorInfo>();
            InspectorInfo item = (InspectorInfo)inspectorArea.InsBox.Items.ElementAt(inspectorArea.InsBox.ItemIndex);
            object value = item.GetValue();

            BuildItemsPath(item, itemspath);

            Group activeGroup = GetActiveGroup();
            if (activeGroup == null) return;
            activeGroup.ForEachAllSets(delegate(Node o)
            {
                Node n = (Node)o;
                if (n == itemspath.ElementAt(0).obj) return;
                InspectorInfo temp = new InspectorInfo(null, n, this);
                int count = 0;
                foreach (InspectorInfo pathitem in itemspath)
                {
                    if (temp.obj.GetType() != pathitem.obj.GetType())
                    {
                        Console.WriteLine("The paths did not match while applying to all. {0} != {1}", temp.obj.GetType(), pathitem.obj.GetType());
                        break;
                    }
                    if (count == itemspath.Count - 1) //last item
                    {
                        if (pathitem.membertype == member_type.dictentry)
                        {
                            dynamic dict = temp.parentItem.obj;
                            dynamic key = pathitem.key;
                            if (!dict.ContainsKey(key)) break;
                            if (dict[key] is Component)
                            {
                                dict[key].active = ((Component)value).active;
                            }
                            else if (temp.IsPanelType())
                            {
                                dict[key] = value;
                            }
                        }
                        else
                        {
                            if (value is Component)
                            {
                                ((Component)temp.obj).active = ((Component)value).active;
                            }
                            else if (temp.IsPanelType())
                            {
                                temp.fpinfo.SetValue(value, temp.parentItem.obj);
                            }
                        }
                    }
                    else
                    {
                        InspectorInfo next = itemspath.ElementAt(count + 1);
                        if (next.membertype == member_type.dictentry)
                        {
                            dynamic dict = temp.obj;
                            dynamic key = next.key;
                            if (!dict.ContainsKey(key)) break;
                            temp = new InspectorInfo(null, temp, dict[key], key);
                        }
                        //else if (next.membertype == member_type.collectionentry)
                        //{
                        //    dynamic coll = temp.obj;
                        //
                        //}
                        else
                        {
                            if (next.fpinfo.propertyInfo == null)
                            {
                                temp = new InspectorInfo(null, temp, next.fpinfo.GetValue(temp.obj), next.fpinfo.fieldInfo);
                            }
                            else
                            {
                                temp = new InspectorInfo(null, temp, next.fpinfo.GetValue(temp.obj), next.fpinfo.propertyInfo);
                            }
                        }
                    }
                    count++;
                }
            });
        }
 public void SwitchLink(Link link)
 {
     ClearView();
     if (link == null) return;
     this.rootLink = link;
     this.GroupSync = false;
     insView.GroupSync = false;
     this.activeGroup = null;
     int heightCount = 0, height = 0;
     int itemCount = link.components.Count;
     InspectorInfo rootItem = new InspectorInfo(null, link, sidebar);
     CreateItem(new DetailedItem(manager, this, rootItem, backPanel, heightCount, LeftPadding));
     height = viewItems[0].itemHeight - 2;
     heightCount += height;
     InspectorInfo formationItem = new InspectorInfo(null, rootItem, link.formation, link.GetType().GetProperty("formation"));
     CreateItem(new DetailedItem(manager, this, formationItem, backPanel, heightCount, LeftPadding));
     InspectorInfo dictItem = new InspectorInfo(null, rootItem, link.components, link.GetType().GetProperty("components"));
     foreach (Type t in link.components.Keys)
     {
         string tooltip = "";
         Info info = Utils.GetInfoClass(link.components[t]);
         if (info != null)
         {
             if ((int)info.userLevel > (int)sidebar.userLevel) continue;
             tooltip = info.summary;
         }
         heightCount += height;
         InspectorInfo cItem = new InspectorInfo(null, dictItem, link.components[t], t);
         DetailedItem di = new DetailedItem(manager, this, cItem, backPanel, heightCount, LeftPadding);
         di.toolTip = tooltip;
         CreateItem(di);
     }
     ScrollPosition = 0;
     backPanel.ScrollTo(backPanel.ScrollBarValue.Horizontal, 0);
     SetVisible(false);
     backPanel.Refresh();
 }