Ejemplo n.º 1
0
        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 Initialize()
        {
            HeightCounter = 0;
            Width = parent.Width - LeftPadding * 2;

            #region /// GroupBox (back panel) ///
            backPanel = new Panel(manager);
            backPanel.Init();
            //backPanel.Left = Left;//change
            backPanel.Top = Top;
            backPanel.Width = Width;
            backPanel.Parent = parent;
            backPanel.Text = "";
            backPanel.Color = sidebar.master.BackColor;

            #endregion

            int WidthReduction = 15; //change

            #region  /// Inspector Address Label ///
            lblInspectorAddress = new Label(manager);
            lblInspectorAddress.Init();
            //lblInspectorAddress.Visible = false; //change
            lblInspectorAddress.Parent = backPanel;
            lblInspectorAddress.Top = HeightCounter; //HeightCounter += VertPadding + lblInspectorAddress.Height + 10;
            lblInspectorAddress.Width = Width - WidthReduction;
            lblInspectorAddress.Height = lblInspectorAddress.Height * 2; //HeightCounter += lblInspectorAddress.Height;
            labelDoubleHeight = lblInspectorAddress.Height;
            //lblInspectorAddress.Left = LeftPadding;
            //lblInspectorAddress.Anchor = Anchors.Left;
            lblInspectorAddress.Text = ">No Node Selected<";
            bool changed = false;
            lblInspectorAddress.TextChanged += delegate(object s, EventArgs e)
            {
                if (!changed)
                {
                    changed = true;
                    Label l = (Label)s;
                    l.Text = l.Text.wordWrap(25);
                }
                changed = false;
            };
            #endregion
            //btnToggleFields = new Button(manager);
            //btnToggleFields.Init();
            //btnToggleFields.Parent = backPanel;
            //btnToggleFields.Left = LeftPadding + backPanel.Width - 30;
            //btnToggleFields.Width = 15;
            //btnToggleFields.Height = 20;
            //btnToggleFields.Top = HeightCounter + 10;
            //btnToggleFields.Text = "F";
            //btnToggleFields.Click += delegate(object s, EventArgs e)
            //{
            //    this.GenerateFields = !this.GenerateFields;
            //    //ResetInspectorBox(ActiveInspectorParent.obj);
            //    ActiveInspectorParent.DoubleClickItem(this);
            //};

            HeightCounter += lblInspectorAddress.Height;

            #region  /// Component List ///
            InsBox = new ListBox(manager);
            InsBox.Init();
            //manager.Add(InsBox);
            InsBox.Parent = backPanel;

            InsBox.Top = HeightCounter;
            InsBox.Left = 10;
            InsBox.Width = Width - WidthReduction;
            InsBox.Height = 140; HeightCounter += InsBox.Height;

            InsBox.HideSelection = false;
            InsBox.ItemIndexChanged += InsBox_ItemIndexChanged;
            InsBox.Click += InsBox_Click;
            InsBox.DoubleClick += InsBox_DoubleClick;
            InsBox.Refresh();

            sidebar.ui.SetScrollableControl(InsBox, InsBox_ChangeScrollPosition);

            #region  /// Context Menu ///
            contextMenuInsBox = new ContextMenu(manager);
            applyToAllNodesMenuItem = new MenuItem("Apply to Group");
            applyToAllNodesMenuItem.Click += applyToAllNodesMenuItem_Click;
            toggleComponentMenuItem = new MenuItem("Toggle Component");
            toggleComponentMenuItem.Click += toggleComponentMenuItem_Click;
            removeComponentMenuItem = new MenuItem("Remove Component");
            removeComponentMenuItem.Click += removeComponentMenuItem_Click;
            toggleBoolMenuItem = new MenuItem("Toggle");
            toggleBoolMenuItem.Click += toggleBoolMenuItem_Click;
            toggleLinkMenuItem = new MenuItem("Toggle link");
            toggleLinkMenuItem.Click += toggleLinkMenuItem_Click;
            removeLinkMenuItem = new MenuItem("Delete link");
            removeLinkMenuItem.Click += removeLinkMenuItem_Click;
            addComponentToLinkMenuItem = new MenuItem("Add Link Component");
            addComponentToLinkMenuItem.Click += AddComponentToLinkMenuItem_Click;

            contextMenuInsBox.Items.Add(applyToAllNodesMenuItem);

            InsBox.ContextMenu = contextMenuInsBox;
            #endregion

            #endregion

            #region  /// GroupPanel ///
            GroupPanel groupPanel = new GroupPanel(manager);
            groupPanel.Init();
            groupPanel.Parent = backPanel;
            //groupPanel.Visible = false;//change
            groupPanel.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
            groupPanel.Width = Width - WidthReduction;
            groupPanel.Top = HeightCounter;
            groupPanel.Height = 90; HeightCounter += VertPadding + groupPanel.Height;
            groupPanel.Left = InsBox.Left;
            groupPanel.Text = "Inspector Property";
            #endregion

            #region  /// PropertyEditPanel ///
            propertyEditPanel = new PropertyEditPanel(this, groupPanel);
            #endregion

            backPanel.Height = groupPanel.Top + groupPanel.Height;
        }