//private bool triggerResizeSlider = true;
 public PropertyEditPanel(InspectorArea insArea, GroupPanel grouppanel)
 {
     //this.sidebar = sidebar;
     this.insArea = insArea;
     this.grouppanel = grouppanel;
     panelControls = new Dictionary<string, Control>();
 }
        public void Initialize()
        {
            manager.Initialize();

            #region /// Master ///
            master = new SideBar(manager);
            master.Init();
            master.Name = "Sidebar";
            master.Width = Width;
            master.Height = OrbIt.game.MainWindow.ClientArea.Height;
            master.Visible = true;
            master.Anchor = Anchors.Top | Anchors.Left | Anchors.Bottom;

            ui.game.MainWindow.Add(master);
            #endregion

            #region  /// tabcontrol ///
            tbcMain = new TabControl(manager);
            tbcMain.Init();
            //tbcMain.BackColor = Color.Transparent;
            //tbcMain.Color = Color.Transparent;
            tbcMain.Parent = master;
            tbcMain.Left = 0;
            tbcMain.Top = 0;
            tbcMain.Width = master.Width - 5;
            tbcMain.Height = master.Height - 40;
            tbcMain.Anchor = Anchors.All;
            activeTabControl = tbcMain;
            #endregion

            #region  /// Page1 ///

            tbcMain.AddPage();
            tbcMain.TabPages[0].Text = "First";
            TabPage first = tbcMain.TabPages[0];
            tbcMain.SelectedIndex = 0;

            #region  /// Title ///
            title1 = new Label(manager);
            title1.Init();
            title1.Parent = first;

            title1.Top = HeightCounter;
            title1.Text = "Node List";
            title1.Width = 130;
            title1.Left = first.Width / 2 - title1.Width / 2; //TODO : Center auto
            HeightCounter += VertPadding + title1.Height;
            title1.Anchor = Anchors.Left;
            #endregion

            #region  /// List Main ///
            lstMain = new ListBox(manager);
            lstMain.Init();
            lstMain.Parent = first;

            lstMain.Top = HeightCounter;
            lstMain.Left = LeftPadding;
            lstMain.Width = first.Width - LeftPadding * 2;
            lstMain.Height = first.Height / 5; HeightCounter += VertPadding + lstMain.Height;
            lstMain.Anchor = Anchors.Top | Anchors.Left | Anchors.Bottom;

            lstMain.HideSelection = false;
            lstMain.ItemIndexChanged += lstMain_ItemIndexChanged;
            lstMain.Click += lstMain_Click;
            lstMain.Refresh();
            //room.nodes.CollectionChanged += nodes_Sync;

            mainNodeContextMenu = new ContextMenu(manager);
            ConvertIntoList = new MenuItem("Make Default of new Group.");
            ConvertIntoList.Click += ConvertIntoList_Click;
            PromoteToDefault = new MenuItem("Make Default of current Group");
            PromoteToDefault.Click += PromoteToDefault_Click;
            mainNodeContextMenu.Items.Add(ConvertIntoList);
            lstMain.ContextMenu = mainNodeContextMenu;

            ui.SetScrollableControl(lstMain, lstMain_ChangeScrollPosition);
            #endregion

            #region  /// List Picker ///

            cbListPicker = new ComboBox(manager);
            cbListPicker.Init();
            cbListPicker.Parent = first;
            cbListPicker.MaxItems = 20;

            cbListPicker.Width = first.Width - LeftPadding * 6;
            cbListPicker.Left = LeftPadding;
            cbListPicker.Top = HeightCounter;
            cbListPicker.Items.Add("Other Objects");
            cbListPicker.ItemIndex = 0;
            //cbListPicker.
            cbListPicker.Click += cbListPicker_Click;
            cbListPicker.ItemIndexChanged += cbListPicker_ItemIndexChanged;

            #endregion

            #region /// Delete Group Button ///

            btnDeleteGroup = new Button(manager);
            btnDeleteGroup.Init();
            btnDeleteGroup.Parent = first;
            btnDeleteGroup.Left = LeftPadding + cbListPicker.Width + 5;
            btnDeleteGroup.Width = 15;
            btnDeleteGroup.Height = cbListPicker.Height;
            btnDeleteGroup.Top = HeightCounter; HeightCounter += VertPadding + cbListPicker.Height;
            btnDeleteGroup.Text = "X";
            btnDeleteGroup.Click += btnDeleteGroup_Click;

            #endregion

            #region  /// Remove Node Button ///
            btnRemoveNode = new Button(manager);
            btnRemoveNode.Init();
            btnRemoveNode.Parent = first;

            btnRemoveNode.Top = HeightCounter;
            btnRemoveNode.Width = first.Width / 2 - LeftPadding;
            btnRemoveNode.Height = 24;
            btnRemoveNode.Left = LeftPadding;

            btnRemoveNode.Text = "Remove Node";
            btnRemoveNode.Click += btnRemoveNode_Click;
            #endregion

            #region  /// Remove All Nodes Button ///
            btnRemoveAllNodes = new Button(manager);
            btnRemoveAllNodes.Init();
            btnRemoveAllNodes.Parent = first;

            btnRemoveAllNodes.Top = HeightCounter;
            //btnRemoveAllNodes.Width = first.Width / 2 - LeftPadding;
            btnRemoveAllNodes.Width = first.Width / 2 - LeftPadding;
            btnRemoveAllNodes.Height = 24; HeightCounter += VertPadding + btnRemoveAllNodes.Height;
            btnRemoveAllNodes.Left = LeftPadding + btnRemoveNode.Width;

            btnRemoveAllNodes.Text = "Remove All";
            btnRemoveAllNodes.Click += btnRemoveAllNodes_Click;
            #endregion

            #region  /// Add Componenet ///
            btnAddComponent = new Button(manager);
            btnAddComponent.Init();
            btnAddComponent.Parent = first;

            btnAddComponent.Top = HeightCounter;
            btnAddComponent.Width = first.Width / 2 - LeftPadding;
            btnAddComponent.Height = 20;
            btnAddComponent.Left = LeftPadding;

            btnAddComponent.Text = "Add Component";
            btnAddComponent.Click += btnAddComponent_Click;
            #endregion

            #region  /// Default Node ///
            btnDefaultNode = new Button(manager);
            btnDefaultNode.Init();
            btnDefaultNode.Parent = first;

            btnDefaultNode.Top = HeightCounter;
            btnDefaultNode.Width = first.Width / 2 - LeftPadding;
            btnDefaultNode.Height = 20; HeightCounter += VertPadding + btnDefaultNode.Height;
            btnDefaultNode.Left = LeftPadding + btnRemoveNode.Width;

            btnDefaultNode.Text = "Default Node";
            btnDefaultNode.Click += btnDefaultNode_Click;
            #endregion

            #region  /// Presets Dropdown ///
            cbPresets = new ComboBox(manager);
            cbPresets.Init();
            cbPresets.Parent = first;
            cbPresets.MaxItems = 20;
            cbPresets.Width = 160;
            cbPresets.Left = LeftPadding;
            cbPresets.Top = HeightCounter; HeightCounter += cbPresets.Height;
            Assets.NodePresets.CollectionChanged += NodePresets_Sync;
            cbPresets.ItemIndexChanged += cbPresets_ItemIndexChanged;
            cbPresets.Click += cmbPresets_Click;
            #endregion

            inspectorArea = new InspectorArea(this, first, LeftPadding, HeightCounter);

            HeightCounter += inspectorArea.Height;

            #region  /// Apply to Group ///
            btnApplyToAll = new Button(manager);
            btnApplyToAll.Init();
            btnApplyToAll.Parent = first;

            btnApplyToAll.Text = "Apply To Group";
            btnApplyToAll.Top = HeightCounter;
            btnApplyToAll.Width = first.Width / 2 - LeftPadding;
            btnApplyToAll.Height = 20; //HeightCounter += VertPadding + btnApplyToAll.Height;
            btnApplyToAll.Left = LeftPadding;
            btnApplyToAll.Click += applyToAllNodesMenuItem_Click;
            #endregion

            #region  /// Save as Preset ///
            btnSaveNode = new Button(manager);
            btnSaveNode.Init();
            btnSaveNode.Text = "Save Node";
            btnSaveNode.Top = HeightCounter;
            btnSaveNode.Width = first.Width / 2 - LeftPadding;
            btnSaveNode.Height = 20; HeightCounter += VertPadding + btnSaveNode.Height;
            btnSaveNode.Left = LeftPadding + btnApplyToAll.Width;
            btnSaveNode.Parent = first;
            btnSaveNode.Click += btnSaveNode_Click;
            #endregion

            #endregion

            #region  /// Page 2 ///
            tbcMain.AddPage();
            tbcMain.TabPages[1].Text = "Second";
            TabPage second = tbcMain.TabPages[1];
            HeightCounter = 0;

            #endregion

            inspectorArea.ResetInspectorBox(ActiveDefaultNode);

            InitializeSecondPage();
            InitializeThirdPage();
        }
        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 void InitializeSecondPage()
        {
            stackview = new StackView();
            TabPage second = tbcMain.TabPages[1];
            second.Text = "Links";

            backPanel = new Panel(manager);
            backPanel.Height = second.Height;
            backPanel.Width = second.Width;
            //backPanel.Width = second.Width + 20;
            backPanel.AutoScroll = true;
            backPanel.Init();
            //backPanel.Color = master.BackColor;
            second.Add(backPanel);

            HeightCounter3 = 0;
            VertPadding3 = 0;

            SourceTarget = new CollapsePanel(manager, backPanel, "Source      |   Target"); stackview.AddPanel(SourceTarget);
            LinkPalette = new CollapsePanel(manager, backPanel, "Link Palette"); stackview.AddPanel(LinkPalette);
            //c3 = new CollapsePanel(manager, backPanel, "third", extended: false); stackview.AddPanel(c3);
            //c4 = new CollapsePanel(manager, backPanel, "fourth", extended: false); stackview.AddPanel(c4);
            //c5 = new CollapsePanel(manager, backPanel, "fifth", extended: false); stackview.AddPanel(c5);
            //c6 = new CollapsePanel(manager, backPanel, "sixth", extended: false); stackview.AddPanel(c6);
            //c7 = new CollapsePanel(manager, backPanel, "seventh", extended: false); stackview.AddPanel(c7);
            //c8 = new CollapsePanel(manager, backPanel, "eighth", extended: false); stackview.AddPanel(c8);

            backPanel.Color = UserInterface.TomDark;

            tbcMain.SelectedPage = tbcMain.TabPages[1];

            #region /// Source | Target ///

            int left = backPanel.Left;
            int middle = backPanel.Left + backPanel.Width / 2 - 15;
            int right = backPanel.Width - 15;

            SourceTarget.ExpandedHeight += 60;

            #region /// Source Side ///

            lblSource = new Label(manager);
            lblSource.Init();
            lblSource.Left = left;
            lblSource.Top = HeightCounter3; HeightCounter3 += lblSource.Height + VertPadding3;
            lblSource.Text = "   Source";
            lblSource.Parent = SourceTarget.panel;

            lblGroupS = new Label(manager);
            lblGroupS.Init();
            lblGroupS.Left = left;
            lblGroupS.Top = HeightCounter3; HeightCounter3 += lblGroupS.Height + VertPadding3;
            lblGroupS.Text = "Group";
            lblGroupS.Parent = SourceTarget.panel;

            cbGroupS = new ComboBox(manager);
            cbGroupS.Init();
            cbGroupS.Left = left;
            cbGroupS.Top = HeightCounter3; HeightCounter3 += cbGroupS.Height + VertPadding3;
            cbGroupS.Width = middle;
            cbGroupS.Parent = SourceTarget.panel;
            cbGroupS.ItemIndexChanged += cbGroupS_ItemIndexChanged;
            cbGroupS.MaxItems = 100;

            lblNodeS = new Label(manager);
            lblNodeS.Init();
            lblNodeS.Left = left;
            lblNodeS.Top = HeightCounter3; HeightCounter3 += lblNodeS.Height + VertPadding3;
            lblNodeS.Text = "Node";
            lblNodeS.Parent = SourceTarget.panel;

            cbNodeS = new ComboBox(manager);
            cbNodeS.Init();
            cbNodeS.Left = left;
            cbNodeS.Top = HeightCounter3; HeightCounter3 += cbNodeS.Height + VertPadding3;
            cbNodeS.Width = middle;
            cbNodeS.Parent = SourceTarget.panel;

            GroupBox radioBoxSource = new GroupBox(manager);
            radioBoxSource.Init();
            radioBoxSource.Left = left;
            radioBoxSource.Top = HeightCounter3 - 7;
            radioBoxSource.Width = middle;
            radioBoxSource.Height = 75;
            radioBoxSource.Text = "";
            radioBoxSource.Parent = SourceTarget.panel;

            HeightCounter3 = 5;

            rdGroupS = new RadioButton(manager);
            rdGroupS.Init();
            rdGroupS.Left = left;
            rdGroupS.Top = HeightCounter3; HeightCounter3 += rdGroupS.Height + VertPadding3;
            rdGroupS.Width = middle;
            rdGroupS.Text = "Group";
            rdGroupS.Parent = radioBoxSource;
            rdGroupS.Click += rdGroupS_Click;

            rdNodeS = new RadioButton(manager);
            rdNodeS.Init();
            rdNodeS.Left = left;
            rdNodeS.Top = HeightCounter3; HeightCounter3 += rdNodeS.Height + VertPadding3;
            rdNodeS.Width = middle;
            rdNodeS.Text = "Node";
            rdNodeS.Parent = radioBoxSource;
            rdNodeS.Click += rdNodeS_Click;

            chSelectionS = new CheckBox(manager);
            chSelectionS.Init();
            chSelectionS.Left = left;
            chSelectionS.Top = HeightCounter3; HeightCounter3 += chSelectionS.Height + VertPadding3;
            chSelectionS.Width = middle;
            chSelectionS.Text = "Selection";
            chSelectionS.Parent = radioBoxSource;
            chSelectionS.Click += chSelectionS_Click;

            #endregion

            #region /// Target Side ///

            HeightCounter3 = 0;

            lblTarget = new Label(manager);
            lblTarget.Init();
            lblTarget.Left = middle;
            lblTarget.Top = HeightCounter3; HeightCounter3 += lblTarget.Height + VertPadding3;
            lblTarget.Text = "|   Target";
            lblTarget.Parent = SourceTarget.panel;

            lblGroupT = new Label(manager);
            lblGroupT.Init();
            lblGroupT.Left = middle;
            lblGroupT.Top = HeightCounter3; HeightCounter3 += lblGroupT.Height + VertPadding3;
            lblGroupT.Text = "Group";
            lblGroupT.Parent = SourceTarget.panel;

            cbGroupT = new ComboBox(manager);
            cbGroupT.Init();
            cbGroupT.Left = middle;
            cbGroupT.Top = HeightCounter3; HeightCounter3 += cbGroupT.Height + VertPadding3;
            cbGroupT.Width = middle;
            cbGroupT.Parent = SourceTarget.panel;
            cbGroupT.ItemIndexChanged += cbGroupT_ItemIndexChanged;
            cbGroupT.MaxItems = 100;

            lblNodeT = new Label(manager);
            lblNodeT.Init();
            lblNodeT.Left = middle;
            lblNodeT.Top = HeightCounter3; HeightCounter3 += lblNodeT.Height + VertPadding3;
            lblNodeT.Text = "Node";
            lblNodeT.Parent = SourceTarget.panel;

            cbNodeT = new ComboBox(manager);
            cbNodeT.Init();
            cbNodeT.Left = middle;
            cbNodeT.Top = HeightCounter3; HeightCounter3 += cbNodeT.Height + VertPadding3;
            cbNodeT.Width = middle;
            cbNodeT.Parent = SourceTarget.panel;

            GroupBox radioBoxTarget = new GroupBox(manager);
            radioBoxTarget.Init();
            radioBoxTarget.Left = middle;
            radioBoxTarget.Top = HeightCounter3 - 7;
            radioBoxTarget.Width = middle;
            radioBoxTarget.Height = 75;
            radioBoxTarget.Text = "";
            radioBoxTarget.Parent = SourceTarget.panel;

            HeightCounter3 = 5;

            rdGroupT = new RadioButton(manager);
            rdGroupT.Init();
            rdGroupT.Left = left;
            rdGroupT.Top = HeightCounter3; HeightCounter3 += rdGroupT.Height + VertPadding3;
            rdGroupT.Width = middle;
            rdGroupT.Text = "Group";
            rdGroupT.Parent = radioBoxTarget;
            rdGroupT.Click += rdGroupT_Click;

            rdNodeT = new RadioButton(manager);
            rdNodeT.Init();
            rdNodeT.Left = left;
            rdNodeT.Top = HeightCounter3; HeightCounter3 += rdNodeT.Height + VertPadding3;
            rdNodeT.Width = middle;
            rdNodeT.Text = "Node";
            rdNodeT.Parent = radioBoxTarget;
            rdNodeT.Click += rdNodeT_Click;

            chSelectionT = new CheckBox(manager);
            chSelectionT.Init();
            chSelectionT.Left = left;
            chSelectionT.Top = HeightCounter3; HeightCounter3 += chSelectionT.Height + VertPadding3;
            chSelectionT.Width = middle;
            chSelectionT.Text = "Selection";
            chSelectionT.Parent = radioBoxTarget;
            chSelectionT.Click += chSelectionT_Click;

            #endregion

            #endregion

            #region /// Link Palette ///

            LinkPalette.ExpandedHeight += 130;
            HeightCounter3 = 5;
            GroupPanel parent3 = LinkPalette.panel;

            cbLinkList = new ComboBox(manager);
            cbLinkList.Init();
            cbLinkList.Top = HeightCounter3; HeightCounter3 += cbLinkList.Height;
            cbLinkList.Left = 0;
            cbLinkList.Width = 150;
            cbLinkList.Parent = parent3;
            cbLinkList.Items.AddRange(new List<object>() { "Palette Links", "Source's Links", "Target's Links", "All Active Links" });
            cbLinkList.ItemIndexChanged += cbLinkList_ItemIndexChanged;

            btnCreateLink = new Button(manager);
            btnCreateLink.Init();
            btnCreateLink.Top = HeightCounter3; //HeightCounter3 += btnCreateLink.Height;
            btnCreateLink.Left = 0;
            btnCreateLink.Width = (parent3.Width - 10) / 2;
            btnCreateLink.Text = "Create Link";
            btnCreateLink.Parent = parent3;
            btnCreateLink.Click += btnCreateLink_Click;

            btnOpenGenerator = new Button(manager);
            btnOpenGenerator.Init();
            btnOpenGenerator.Top = HeightCounter3; HeightCounter3 += btnOpenGenerator.Height;
            btnOpenGenerator.Left = btnCreateLink.Width;
            btnOpenGenerator.Width = btnCreateLink.Width;
            btnOpenGenerator.Text = "Generator";
            btnOpenGenerator.Parent = parent3;
            btnOpenGenerator.Click += btnOpenGenerator_Click;

            insArea2 = new InspectorArea(this, parent3, 0, HeightCounter3);
            //insArea2.backPanel.AutoScroll = true;
            LinkPalette.ExpandedHeight = HeightCounter3 + insArea2.Height + 20;

            cbLinkList.ItemIndex = 0;

            rdGroupS.Checked = true;
            rdGroupT.Checked = true;
            rdGroupS_Click(null, null);
            rdGroupT_Click(null, null);

            #endregion

            backPanel.Refresh();
            tbcMain.SelectedPage = tbcMain.TabPages[0];
        }