public PlayerView(Sidebar sidebar, Control parent, int Left, int Top)
            : base(sidebar, parent, Left, Top, false)
        {
            playerGroup = sidebar.room.groups.player;

            btnEditAllPlayers = new Button(manager);
            btnEditAllPlayers.Init();
            btnEditAllPlayers.Parent = parent;
            btnEditAllPlayers.Text = "Edit All Players";
            btnEditAllPlayers.Width = 150;
            btnEditAllPlayers.Left = parent.Width / 2 - btnEditAllPlayers.Width / 2;
            btnEditAllPlayers.Top = Top + VertPadding * 2;
            HeightCounter +=  btnEditAllPlayers.Height * 2;
            btnEditAllPlayers.Click += (s, e) =>
            {
                editGroupWindow = new EditNodeWindow(sidebar, "All Players", room.groups.player.Name, ViewType.Group);
                editGroupWindow.componentView.SwitchGroup(room.groups.player);
                //editGroupWindow.componentView.SwitchNode(n, false);

            };

            lblPlayers = new Label(manager);
            lblPlayers.Init();
            lblPlayers.Parent = parent;
            lblPlayers.Text = "Players";
            lblPlayers.Width = 150;
            lblPlayers.Left = LeftPadding;
            lblPlayers.TextColor = Color.Black;
            lblPlayers.Top = HeightCounter;
            HeightCounter += lblPlayers.Height + VertPadding;
            Width = parent.Width - LeftPadding * 4;

            base.Initialize();

            insView = new InspectorView(sidebar, parent, Left, HeightCounter);
            insView.GroupSync = true;
            insView.Height = 120;
            insView.Width = Width;
            this.ItemCreator += ItemCreatorDelegate;

            InitializePlayers();
        }
        private void ItemCreatorDelegate(DetailedItem item, object obj)
        {
            //editGroupWindow = new EditNodeWindow(sidebar, "All Players", room.groups.playerGroup.Name);
            //editGroupWindow.componentView.SwitchGroup(room.groups.playerGroup);
            //editGroupWindow.componentView.SwitchNode(n, false);
            if (obj == null) return;
            if (obj is InspectorInfo)
            {
                InspectorInfo inspectorItem = (InspectorInfo)obj;

                if (inspectorItem.methodInfo != null)
                {
                    Button btnInvoke = new Button(manager);
                    btnInvoke.Init();
                    btnInvoke.Parent = item.panel;
                    btnInvoke.TextColor = Color.Blue;
                    btnInvoke.Width = 50;
                    btnInvoke.Left = item.panel.Width - btnInvoke.Width - btnInvoke.Width - 5;
                    btnInvoke.Height = item.buttonHeight;
                    btnInvoke.ToolTip.Text = "Invoke Method";
                    btnInvoke.Name = "method_button_invoke";
                    btnInvoke.Text = "Do";
                    item.AddControl(btnInvoke);
                }

                if (inspectorItem.obj == null) return;
                object o = inspectorItem.obj;
                bool isToggle = Utils.isToggle(o);

                if (o != null)
                {
                    if (o is Node)
                    {
                        //item.label.Text = "Root";
                        Node n = (Node)o;
                        Button btnEdit = new Button(manager);
                        btnEdit.Init();
                        btnEdit.Parent = item.panel;
                        btnEdit.Width = 30;
                        btnEdit.Left = item.panel.Width - btnEdit.Width - 10;
                        btnEdit.Top = 2;
                        btnEdit.Height = item.buttonHeight;

                        EventHandler editnode = (s, e) =>
                        {
                            //item.isSelected = true;
                            EditNodeWindow editNodeWindow = new EditNodeWindow(sidebar, inspectorItem.Name(), n.name, ViewType.Node);
                            editNodeWindow.componentView.SwitchNode(n, false);
                        };

                        btnEdit.Text = "Edit";
                        btnEdit.ToolTip.Text = "Edit";
                        btnEdit.TextColor = UserInterface.TomShanePuke;

                        btnEdit.Click += editnode;
                    }
                    else if (o is Link)
                    {
                        Link link = (Link)o;
                        Button btnEdit = new Button(manager);
                        btnEdit.Init();
                        btnEdit.Parent = item.panel;
                        btnEdit.Width = 30;
                        btnEdit.Left = item.panel.Width - btnEdit.Width - 10;
                        btnEdit.Top = 2;
                        btnEdit.Height = item.buttonHeight;
                        EventHandler editlink = (s, e) =>
                        {
                            EditLinkWindow editLinkWindow = new EditLinkWindow(sidebar, link, inspectorItem.Name());
                        };
                        btnEdit.Text = "Edit";
                        btnEdit.ToolTip.Text = "Edit";
                        btnEdit.TextColor = UserInterface.TomShanePuke;

                        btnEdit.Click += editlink;
                    }
                    else if (o is Body || o is Component)
                    {
                        item.label.Text = o.GetType().ToString().LastWord('.');
                    }
                    if (o is Component)
                    {
                        Component comp = (Component)o;

                        Button btnEnabled = new Button(manager);
                        btnEnabled.Init();
                        btnEnabled.Parent = item.panel;
                        btnEnabled.TextColor = Color.Red;
                        btnEnabled.Width = 25;
                        btnEnabled.Left = item.panel.Width - btnEnabled.Width - 20;
                        btnEnabled.Top = 3;
                        btnEnabled.Height = item.buttonHeight;
                        btnEnabled.ToolTip.Text = "Toggle Active";
                        btnEnabled.Name = "component_button_enabled";
                        SetButtonBool(btnEnabled, comp.active);
                        item.AddControl(btnEnabled);

                        //check for essential
                        if (!comp.isEssential())
                        {
                            Button btnRemove = new Button(manager);
                            btnRemove.Init();
                            btnRemove.Parent = item.panel;
                            btnRemove.TextColor = Color.Red;
                            btnRemove.Left = btnEnabled.Left - 20;
                            btnRemove.Top = 3;
                            btnRemove.Height = item.buttonHeight;
                            btnRemove.Width = item.buttonWidth;
                            btnRemove.Text = "-";
                            btnRemove.ToolTip.Text = "Remove";
                            btnRemove.Name = "component_button_remove";
                            item.AddControl(btnRemove);
                        }
                    }
                    else if (o is int || o is Single || o is byte || isToggle)
                    {
                        int w = 60;
                        TextBox textbox = new TextBox(manager);
                        textbox.ClientMargins = new Margins();
                        textbox.Init();
                        textbox.Parent = item.panel;
                        textbox.TextColor = UserInterface.TomShanePuke;
                        textbox.Left = backPanel.Width - w - 26;
                        textbox.Width = w;
                        textbox.Height = textbox.Height - 4;

                        textbox.Name = "number_textbox";
                        if (isToggle)
                        {
                            textbox.Name = "toggle_textbox";

                            Button btnEnabled = new Button(manager);
                            btnEnabled.Init();
                            btnEnabled.Parent = item.panel;
                            btnEnabled.TextColor = Color.Red;
                            btnEnabled.Width = 25;
                            btnEnabled.Left = textbox.Left - btnEnabled.Width;
                            //btnEnabled.Top = 3;
                            btnEnabled.Height = item.buttonHeight;
                            btnEnabled.ToolTip.Text = "Toggle Active";
                            btnEnabled.Name = "toggle_button_enabled";
                            SetButtonBool(btnEnabled, (o as dynamic).enabled);
                            item.AddControl(btnEnabled);

                            //item.AddControl(checkbox);

                            //textbox.Text = (o as dynamic).valueString(); // too slow.
                            textbox.Text = "...";
                        }
                        else textbox.Text = o.ToString();
                        textbox.ClientArea.Top += 2;
                        textbox.ClientArea.Left += 4;
                        textbox.FocusLost += delegate
                        {
                            textbox.SendMessage(Message.KeyUp, new KeyEventArgs(Microsoft.Xna.Framework.Input.Keys.Enter));
                        };
                        textbox.ClientArea.Move += delegate
                        {
                            marginalize(textbox);
                        };
                        item.AddControl(textbox);
                        Type primitiveType = !isToggle ? o.GetType() : ((dynamic)o).value.GetType();

                        Button up = new Button(manager);
                        up.SetSize(textbox.ClientArea.Height, textbox.ClientArea.Height / 2);
                        up.Anchor = Anchors.Right;
                        up.Init();
                        up.Left = textbox.ClientArea.Width - up.Width;
                        sidebar.ui.SetScrollableControl(up, List_ChangeScrollPosition);

                        up.ToolTip.Text = "Increment : RightClick = byOne, MiddleClick = byTen, RightClick = Double";
                        up.MouseDown += (s, e) =>
                        {
                            switch (e.Button)
                            {
                                case MouseButton.Left:
                                    textbox.Text = textbox.Text.increment(primitiveType, NumBoxMode.byOne);
                                    break;
                                case MouseButton.Right:
                                    textbox.Text = textbox.Text.increment(primitiveType, NumBoxMode.quadratic);
                                    break;
                                case MouseButton.Middle:
                                    textbox.Text = textbox.Text.increment(primitiveType, NumBoxMode.byTen);
                                    break;
                            }
                            textbox.SendMessage(Message.KeyUp, new KeyEventArgs(Microsoft.Xna.Framework.Input.Keys.Enter));
                            marginalize(textbox);
                        };
                        textbox.Add(up);

                        Button down = new Button(manager);
                        down.SetSize(textbox.ClientArea.Height, textbox.ClientArea.Height / 2);
                        down.Anchor = Anchors.Right;
                        down.Top = up.Height;
                        down.Init();
                        down.ToolTip.Text = "Decrement : RightClick = byOne, MiddleClick = byTen, RightClick = half";
                        down.MouseDown += (s, e) =>
                        {
                            switch (e.Button)
                            {
                                case MouseButton.Left:
                                    textbox.Text = textbox.Text.decrement(primitiveType, NumBoxMode.byOne);
                                    break;
                                case MouseButton.Right:
                                    textbox.Text = textbox.Text.decrement(primitiveType, NumBoxMode.quadratic);
                                    break;
                                case MouseButton.Middle:
                                    textbox.Text = textbox.Text.decrement(primitiveType, NumBoxMode.byTen);
                                    break;
                            }
                            textbox.SendMessage(Message.KeyUp, new KeyEventArgs(Microsoft.Xna.Framework.Input.Keys.Enter));
                            marginalize(textbox);
                        };
                        down.Left = textbox.ClientArea.Width - down.Width;
                        sidebar.ui.SetScrollableControl(down, List_ChangeScrollPosition);
                        textbox.Add(down);

                        //todo: make tiny + and - buttons
                    }
                    else if (o is string)
                    {
                        int w = 60;
                        TextBox textbox = new TextBox(manager);
                        textbox.ClientMargins = new Margins();
                        textbox.Init();
                        textbox.Parent = item.panel;
                        textbox.TextColor = UserInterface.TomShanePuke;
                        textbox.Left = backPanel.Width - w - 26;
                        textbox.Width = w;
                        textbox.Height = textbox.Height - 4;
                        textbox.Text = o.ToString();
                        textbox.Name = "string_textbox";
                        item.AddControl(textbox);

                        textbox.ClientArea.Top += 2;
                        textbox.ClientArea.Left += 2;
                        textbox.KeyPress += delegate
                        {
                            if (!textbox.Text.Equals(""))
                            {
                                textbox.ClientArea.Top += 2;
                                textbox.ClientArea.Left += 2;
                            }
                        };

                    }
                    else if (o is bool)
                    {
                        Button btnEnabled = new Button(manager);
                        btnEnabled.Init();
                        btnEnabled.Parent = item.panel;
                        btnEnabled.TextColor = Color.Red;
                        btnEnabled.Width = 25;
                        btnEnabled.Left = item.panel.Width - btnEnabled.Width - 20;
                        //btnEnabled.Top = 3;
                        btnEnabled.Height = item.buttonHeight;
                        btnEnabled.ToolTip.Text = "Toggle Enabled";
                        btnEnabled.Name = "bool_button_enabled";
                        SetButtonBool(btnEnabled, (bool)o);
                        item.AddControl(btnEnabled);
                    }
                    else if (o.GetType().IsEnum)
                    {
                        int w = 95;
                        ComboBox combobox = new ComboBox(manager);
                        combobox.ClientMargins = new Margins();
                        combobox.Init();
                        combobox.TextColor = UserInterface.TomShanePuke;
                        combobox.Parent = item.panel;
                        combobox.Left = backPanel.Width - w - 26;
                        combobox.Height = combobox.Height - 4;
                        combobox.Width = w;
                        combobox.MaxItems = 15;
                        int i = 0;
                        foreach(string s in Enum.GetNames(o.GetType()))
                        {
                            combobox.Items.Add(s);
                            if (s.Equals(o.ToString())) combobox.ItemIndex = i;
                            i++;
                        }
                        combobox.Name = "enum_combobox";
                        item.AddControl(combobox);

                        combobox.ClientArea.Top += 2;
                        combobox.ClientArea.Left += 2;
                        combobox.ItemIndexChanged += delegate
                        {
                            if (!combobox.Text.Equals(""))
                            {
                                combobox.ClientArea.Top += 2;
                                combobox.ClientArea.Left += 2;
                            }
                        };
                    }

                }
            }
        }
        private void ItemCreatorDelegate(DetailedItem item, object obj)
        {
            if (item.obj is InspectorInfo)
            {
                InspectorInfo ii = (InspectorInfo)item.obj;
                if (!(ii.obj is Node)) return;
                Node n = (Node)ii.obj;
                item.label.Text = n.name;
                Button btnEdit = new Button(manager);
                btnEdit.Init();
                btnEdit.Parent = item.panel;
                btnEdit.Width = 30;
                btnEdit.Left = item.panel.Width - btnEdit.Width - 10;
                btnEdit.Top = 2;
                btnEdit.Height = item.buttonHeight;

                btnEdit.Text = "Edit";
                btnEdit.ToolTip.Text = "Edit";
                btnEdit.Name = "Player Edit";
                btnEdit.TextColor = UserInterface.TomShanePuke;

                EventHandler editplayer = (s, e) =>
                {
                    item.isSelected = true;
                    //editGroupWindow = new EditGroupWindow(sidebar);
                    //editGroupWindow.componentView.SwitchGroup(g);
                    editGroupWindow = new EditNodeWindow(sidebar, "Player", n.name, ViewType.Node);
                    //editGroupWindow.componentView.SwitchGroup(g);
                    editGroupWindow.componentView.SwitchNode(n, false);
                };

                btnEdit.Click += editplayer;
                item.panel.DoubleClick += editplayer;

                Button btnEnabled = new Button(manager);
                btnEnabled.Init();
                btnEnabled.Parent = item.panel;
                btnEnabled.Width = 30;
                btnEnabled.Left = btnEdit.Left - btnEnabled.Width - 5;
                btnEnabled.Top = 2;
                btnEnabled.Height = item.buttonHeight;
                //btnEnabled.Draw += btnEnabled_Draw;

                //btnEnabled.Text = "On";
                SetButtonBool(btnEnabled, n.active);
                btnEnabled.ToolTip.Text = "Player Enabled";
                btnEnabled.TextColor = UserInterface.TomShanePuke;
                btnEnabled.Click += (s, e) =>
                {
                    n.active = GetButtonBool(btnEnabled);
                    SetButtonBool(btnEnabled, n.active);
                };
            }
        }
        private void ItemCreatorDelegate(DetailedItem item, object obj)
        {
            if (item.obj is Group)
            {
                Group g = (Group)item.obj;
                item.label.Text = g.Name;
                Button btnEdit = new Button(manager);
                btnEdit.Init();
                btnEdit.Parent = item.panel;
                btnEdit.Width = 30;
                btnEdit.Left = item.panel.Width - btnEdit.Width - 10;
                btnEdit.Top = 2;
                btnEdit.Height = item.buttonHeight;

                EventHandler editgroup = (s, e) =>
                {
                    item.isSelected = true;
                    if (parentGroup == room.groups.items)
                    {
                        editGroupWindow = new EditNodeWindow(sidebar, "Item Group", g.Name, ViewType.Group);
                    }
                    else
                    {
                        editGroupWindow = new EditNodeWindow(sidebar, g);
                    }
                    editGroupWindow.componentView.SwitchGroup(g);

                };

                btnEdit.Text = "Edit";
                btnEdit.ToolTip.Text = "Edit";
                btnEdit.TextColor = UserInterface.TomShanePuke;

                btnEdit.Click += editgroup;

                item.panel.DoubleClick += editgroup;

                Button btnEnabled = new Button(manager);
                btnEnabled.Init();
                btnEnabled.Parent = item.panel;
                btnEnabled.Width = 30;
                btnEnabled.Left = btnEdit.Left - btnEnabled.Width - 5;
                btnEnabled.Top = 2;
                btnEnabled.Height = item.buttonHeight;
                //btnEnabled.Draw += btnEnabled_Draw;

                //btnEnabled.Text = "On";
                SetButtonBool(btnEnabled, !g.Disabled);
                btnEnabled.ToolTip.Text = "Group Enabled";
                btnEnabled.TextColor = UserInterface.TomShanePuke;
                btnEnabled.Click += (s, e) =>
                {
                    g.Disabled = !GetButtonBool(btnEnabled);
                    SetButtonBool(btnEnabled, !g.Disabled);
                };

                if (!showRemoveButton) return;

                Button btnRemove = new Button(manager);
                btnRemove.Init();
                btnRemove.Parent = item.panel;
                btnRemove.Width = item.buttonWidth;
                btnRemove.Top = 2;
                btnRemove.Left = btnEnabled.Left - btnRemove.Width - 5;
                btnRemove.Height = item.buttonHeight;

                btnRemove.TextColor = Color.Red;
                btnRemove.Text = "-";
                btnRemove.ToolTip.Text = "Remove";
                btnRemove.Click += (s, e) =>
                {
                    g.EmptyGroup();
                    g.DeleteGroup();
                    UpdateGroups();
                };
            }
        }