示例#1
0
        public StateEditor(int Row, int Column)
            : base(StateID.Editor)
        {
            //Draw Cursor
            m_VisibleCursor = true;

            //Set Values
            BoardRow        = Row;
            BoardColumn     = Column;
            SelectedHeight  = 1;
            SelectedWidth   = 1;

            //Nulling Stuffs
            m_Data          = null;
            m_Buttons       = null;
            m_MenuButtons   = null;
            m_Sky           = null;
            m_SkyLayer      = null;
            m_Arrow         = null;
            m_Ships         = null;
            m_Board         = null;
            m_SideBar       = null;
            m_SideBarPanel  = null;
            m_Window        = null;
            m_Help          = null;
        }
        public ToolWindow(Sidebar sidebar)
        {
            this.sidebar = sidebar;
            this.manager = sidebar.manager;
            toolBar = new SideBar(manager);
            OrbIt.game.MainWindow.Add(toolBar);
            toolBar.MouseOver += delegate { UserInterface.tomShaneWasClicked = true; };
            toolBar.MouseOut += delegate { UserInterface.tomShaneWasClicked = false; };
            toolBar.Anchor = Anchors.Top | Anchors.Right | Anchors.Bottom;
            toolBar.Init();
            toolBar.Height = OrbIt.game.MainWindow.ClientArea.Height;
            toolBar.Width = 70;
            toolBar.Left = OrbIt.game.MainWindow.ClientArea.Width - toolBar.Width;

            buttonTextures["select"] = Assets.btnTextures[0, 0];
            buttonTextures["random"] = Assets.btnTextures[1, 0];
            buttonTextures["spawn"] = Assets.btnTextures[0, 1];
            buttonTextures["level"] = Assets.btnTextures[1, 1];
            buttonTextures["forceSpawn"] = Assets.btnTextures[0, 2];
            buttonTextures["forcePush"] = Assets.btnTextures[1, 2];
            buttonTextures["control"] = Assets.btnTextures[0, 3];
            buttonTextures["static"] = Assets.btnTextures[1, 3];
            buttonTextures["remove"] = Assets.btnTextures[0, 4];
            buttonTextures["resize"] = Assets.btnTextures[1, 4];
        }
        private EditNodeWindow(Sidebar sidebar, ViewType viewType)
        {
            this.sidebar = sidebar;
            this.manager = sidebar.manager;
            neoSidebar = new NeoSidebar(manager);
            neoSidebar.Init();
            int tomtom = 5;
            neoSidebar.ClientArea.BackColor = UserInterface.TomDark;
            neoSidebar.BackColor = Color.Black;
            neoSidebar.BevelBorder = BevelBorder.All;
            Margins tomtomtomtom = new Margins(tomtom, tomtom, tomtom, tomtom);
            neoSidebar.ClientMargins = tomtomtomtom;

            neoSidebar.Left = sidebar.master.Left;
            neoSidebar.Width = sidebar.Width;
            neoSidebar.Top = 0;
            neoSidebar.Resizable = false;
            neoSidebar.Movable = false;
            neoSidebar.Height = OrbIt.ScreenHeight;
            neoSidebar.Text = "Edit";
            manager.Add(neoSidebar);

            int width = 120;
            int offset = neoSidebar.Width - width - 20;

            titlePanelEditNode = new TitlePanel(sidebar, neoSidebar, "Edit", true);
            titlePanelEditNode.btnBack.Click += (s, e) =>
            {
                sidebar.groupsView.UpdateGroups();
                manager.Remove(neoSidebar);
            };

            HeightCounter += titlePanelEditNode.Height;

            lblName = new Label(manager);
            lblName.Init();
            lblName.Parent = neoSidebar;
            lblName.Left = LeftPadding;
            lblName.Top = HeightCounter;
            lblName.Width = width;

            txtName = new TextBox(manager);
            txtName.Init();
            txtName.Parent = neoSidebar;
            txtName.Top = HeightCounter;
            txtName.Width = width;
            txtName.Left = offset;
            HeightCounter += txtName.Height + LeftPadding;
            txtName.TextColor = Color.Black;
            txtName.Enabled = false;

            componentView = new ComponentView(sidebar, neoSidebar, 0, HeightCounter, viewType);
            componentView.Width = neoSidebar.Width - 20;
            componentView.insView.Height += componentView.insView.Height / 2;

            neoSidebar.Width += 100;
            neoSidebar.Width -= 100;
        }
        //, Control under)
        public LoadLevelWindow(Sidebar sidebar)
        {
            previouslyPaused = sidebar.ui.IsPaused;
            sidebar.ui.IsPaused = true;
            sidebar.master.Visible = false;
            Control par = sidebar.tbcViews.TabPages[0];
            UserInterface.GameInputDisabled = true;
            this.manager = sidebar.manager;
            this.sidebar = sidebar;
            tomShaneSidebar = new TomShaneSidebar(manager);
            tomShaneSidebar.Init();
            tomShaneSidebar.Left = sidebar.master.Left;
            tomShaneSidebar.Width = par.Width;
            tomShaneSidebar.Top = 20;
            tomShaneSidebar.Height = par.Height + 15;
            tomShaneSidebar.BevelBorder = BevelBorder.All;
            tomShaneSidebar.BevelColor = Color.Black;
            tomShaneSidebar.Left = LeftPadding;
            tomShaneSidebar.Text = "Load Level";
            tomShaneSidebar.BackColor = new Color(30, 60, 30);
            manager.Add(tomShaneSidebar);

            wallGroup = sidebar.room.groups.walls;
            foreach(Node n in wallGroup.entities)
            {
                previousWallNodes.Add(n);
            }

            TitlePanel titlePanelAddComponent = new TitlePanel(sidebar, tomShaneSidebar, "Load Level", false);
            //titlePanelAddComponent.btnBack.Click += Close;
            HeightCounter += titlePanelAddComponent.Height;

            normalView = new NormalView(sidebar, tomShaneSidebar, 0, 100, Height: 350);
            normalView.Width -= 15;
            PopulateLevelSaves();

            normalView.OnSelectionChanged += normalView_OnSelectionChanged;

            btnLoad = new Button(manager);
            btnLoad.Init();
            tomShaneSidebar.Add(btnLoad);
            btnLoad.Text = "Load";
            btnLoad.Top = 500;
            btnLoad.Left = LeftPadding * 4;
            btnLoad.Width = 70;
            btnLoad.Click += btnLoad_Click;

            btnCancel = new Button(manager);
            btnCancel.Init();
            tomShaneSidebar.Add(btnCancel);
            btnCancel.Text = "Cancel";
            btnCancel.Top = 500;
            btnCancel.Left = btnLoad.Left + btnLoad.Width + 50;
            btnCancel.Width = 70;
            btnCancel.Click += btnCancel_Click;
        }
        private AddComponentWindow(Sidebar sidebar, Control under, DetailedView view, bool addToGroup = true)
        {
            this.under = under;
            under.Visible = false;
            sidebar.master.Visible = false;
            this.addToGroup = addToGroup;

            Control par = sidebar.tbcViews.TabPages[0];
            UserInterface.GameInputDisabled = true;
            this.view = view;
            this.manager = sidebar.manager;
            this.sidebar = sidebar;
            neoSidebar = new NeoSidebar(manager);
            neoSidebar.Init();
            neoSidebar.Left = sidebar.master.Left;
            neoSidebar.Width = par.Width;
            neoSidebar.Top = 5;
            neoSidebar.Height = par.Height + 15;
            neoSidebar.BevelBorder = BevelBorder.All;
            neoSidebar.BevelColor = Color.Black;
            neoSidebar.Left = LeftPadding;
            neoSidebar.Text = "Add Component";
            neoSidebar.BackColor = new Color(30, 60, 30);
            manager.Add(neoSidebar);

            TitlePanel titlePanelAddComponent = new TitlePanel(sidebar, neoSidebar, "Add Component", true);
            titlePanelAddComponent.btnBack.Click += Close;
            HeightCounter += titlePanelAddComponent.Height;
            NewLabel("Add", 15, false);
            NewLabel("Name", 50, false);
            int left = 145;
            NewLabel("AO", left, false);
            NewLabel("AS", left + 20, false);
            NewLabel("DR", left + 40, false);

            btnAdd = new Button(manager);
            btnAdd.Init();
            btnAdd.Parent = neoSidebar;
            btnAdd.Width = 150;
            btnAdd.Top = neoSidebar.Height - btnAdd.Height * 2;
            btnAdd.Left = neoSidebar.Width / 2 - btnAdd.Width / 2;
            btnAdd.Text = "Add Components";
            btnAdd.Click += AddComponents;
        }
        public EditLinkWindow(Sidebar sidebar, Link link, string FieldName)
        {
            this.sidebar = sidebar;
            this.manager = sidebar.manager;
            neoSidebar = new NeoSidebar(manager);
            neoSidebar.Init();
            int tomtom = 5;
            neoSidebar.ClientArea.BackColor = UserInterface.TomDark;
            neoSidebar.BackColor = Color.Black;
            neoSidebar.BevelBorder = BevelBorder.All;
            Margins tomtomtomtom = new Margins(tomtom, tomtom, tomtom, tomtom);
            neoSidebar.ClientMargins = tomtomtomtom;

            neoSidebar.Left = sidebar.master.Left;
            neoSidebar.Width = sidebar.Width;
            neoSidebar.Top = 0;
            neoSidebar.Resizable = false;
            neoSidebar.Movable = false;
            neoSidebar.Height = OrbIt.ScreenHeight;
            neoSidebar.Text = "Edit";
            manager.Add(neoSidebar);

            int width = 120;
            int offset = neoSidebar.Width - width - 20;

            titlePanelEditNode = new TitlePanel(sidebar, neoSidebar, "Edit" + FieldName, true);
            titlePanelEditNode.btnBack.Click += (s, e) =>
            {
                sidebar.groupsView.UpdateGroups();
                manager.Remove(neoSidebar);
            };

            HeightCounter += titlePanelEditNode.Height;

            componentView = new ComponentView(sidebar, neoSidebar, 0, HeightCounter, ViewType.Link);
            componentView.Width = neoSidebar.Width - 20;
            componentView.insView.Height += componentView.insView.Height / 2;

            neoSidebar.Width += 100;
            neoSidebar.Width -= 100;

            componentView.SwitchLink(link);
        }
示例#7
0
		////////////////////////////////////////////////////////////////////////////

		#endregion

		#region //// Methods ///////////

		////////////////////////////////////////////////////////////////////////////
		private void InitControls()
		{
			sidebar = new SideBar(Manager);
			sidebar.Init();
			sidebar.StayOnBack = true;
			sidebar.Passive = true;
			sidebar.Width = 200;
			sidebar.Height = ClientHeight;
			sidebar.Anchor = Anchors.Left | Anchors.Top | Anchors.Bottom;

			Add(sidebar);

			InitRes();
			InitTasks();
			InitStats();
			InitSkins();
			InitConsole();
		}
        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();
        }
示例#9
0
        private void CreateGUI()
        {
            //Create Sidebar
            m_SideBar = new SideBar(Global.GUIManager);
            m_SideBar.Top = Global.EDITORSIDEBAR_TOP;
            m_SideBar.Left = Global.EDITORSIDEBAR_LEFT;
            m_SideBar.Width = Global.EDITORSIDEBAR_WIDTH;
            m_SideBar.Height = Global.EDITORSIDEBAR_HEIGHT;
            m_Panel.Add(m_SideBar);
            Global.GUIManager.Add(m_SideBar);

            //Create Sidebar Panel
            m_SideBarPanel = new SideBarPanel(Global.GUIManager);
            m_SideBarPanel.Top = Global.EDITORSIDEBARPANEL_TOP;
            m_SideBarPanel.Left = Global.EDITORSIDEBARPANEL_LEFT;
            m_SideBarPanel.Width = Global.EDITORSIDEBARPANEL_WIDTH;
            m_SideBarPanel.Height = Global.EDITORSIDEBARPANEL_HEIGHT;
            m_Panel.Add(m_SideBarPanel);
            Global.GUIManager.Add(m_SideBarPanel);

            //Create Editor Buttons
            m_Buttons = new Button[Global.EDITORBUTTON_MENU.Length];
            for (int i = 0; i < m_Buttons.Length; i++)
            {
                //Create buttons
                m_Buttons[i] = new Button(Global.GUIManager);
                m_Buttons[i].Text = Global.EDITORBUTTON_MENU[i];
                m_Buttons[i].Top = Global.EDITORBUTTON_TOP + (i * Global.EDITORBUTTON_SPACE);
                m_Buttons[i].Left = Global.EDITORBUTTON_LEFT;
                m_Buttons[i].Width = Global.EDITORBUTTON_WIDTH;
                m_Buttons[i].Init();

                //Add the buttons
                m_Panel.Add(m_Buttons[i]);
                Global.GUIManager.Add(m_Buttons[i]);

                //Set event handler
                m_Buttons[i].Click += EditorChoose;
            }

            //Create Menu Buttons
            m_MenuButtons = new Button[Global.EDITOR_MENU.Length];
            for (int i = 0; i < m_MenuButtons.Length; i++)
            {
                //Create buttons
                m_MenuButtons[i] = new Button(Global.GUIManager);
                m_MenuButtons[i].Text = Global.EDITOR_MENU[i];
                m_MenuButtons[i].Top = Global.EDITORMENU_TOP + (i * Global.EDITORMENU_SPACE);
                m_MenuButtons[i].Left = Global.EDITORMENU_LEFT;
                m_MenuButtons[i].Width = Global.EDITORMENU_WIDTH;
                m_MenuButtons[i].Init();

                //Add the buttons
                m_Panel.Add(m_MenuButtons[i]);
                Global.GUIManager.Add(m_MenuButtons[i]);

                //Set event handler
                m_MenuButtons[i].Click += MenuChoose;
            }

            //Create Help Window
            m_Window = new Window(Global.GUIManager);
            m_Window.Init();
            m_Window.CloseButtonVisible = false;
            m_Window.Movable = false;
            m_Window.StayOnBack = true;
            m_Window.Resizable = false;
            m_Window.Visible = false;

            m_Window.Text = "Editor Help";
            m_Window.Top = Global.EDITORWINDOW_TOP;
            m_Window.Left = Global.EDITORWINDOW_LEFT;
            m_Window.Width = Global.EDITORWINDOW_WIDTH;
            m_Window.Height = Global.EDITORWINDOW_HEIGHT;
            m_Panel.Add(m_Window);
            Global.GUIManager.Add(m_Window);

            //Create label in Help window
            m_Help = new Label(Global.GUIManager);
            m_Help.Init();
            m_Help.Parent = m_Window;
            m_Help.Text = Global.EDITOR_HELP;
            m_Help.Top = Global.EDITORHELP_TOP;
            m_Help.Left = Global.EDITORHELP_LEFT;
            m_Help.Width = Global.EDITORHELP_WIDTH;
            m_Help.Height = Global.EDITORHELP_HEIGHT;

            //Add it to the
            m_Panel.Add(m_Help);
            Global.GUIManager.Add(m_Help);
        }
示例#10
0
 private void CreateSideBar()
 {
     _sideBar = new SideBar(ControlManager.Manager) { StayOnBack = true, Passive = true, Width = 250, Height = ScreenHeight };
     _sideBar.Left = ScreenWidth - _sideBar.Width;
     _sideBar.Init();
     ControlManager.Add(_sideBar);
 }
示例#11
0
        /// <summary>
        /// Initializes UI elements
        /// </summary>
        private void InitControls()
        {
            //Map

            MapControl = new MapWindow(Manager);
            MapControl.Init();
            MapControl.SetPosition(201, 0);
            MapControl.Environment = Environment;
            MapControl.Renderer = Renderers[0];
            MapControl.SetSize(Height, Height);
            MapControl.Resizable = true;
            MapControl.Movable = true;
            Add(MapControl);

            //Left side bar

            SideBar = new SideBar(Manager);
            SideBar.Init();
            SideBar.StayOnBack = true;
            SideBar.Passive = true;
            SideBar.SetSize(200, Height);
            SideBar.Anchor = Anchors.Left | Anchors.Top | Anchors.Bottom;

            Add(SideBar);

            NewMapBtn = new Button(Manager);
            NewMapBtn.Init();
            NewMapBtn.Text = "New Map";
            NewMapBtn.SetPosition(25, 10);
            NewMapBtn.SetSize(150, 25);
            NewMapBtn.Anchor = Anchors.Top | Anchors.Left;
            NewMapBtn.Click += new EventHandler(NewMapBtn_Click);
            SideBar.Add(NewMapBtn);

            SelectMapBtn = new Button(Manager);
            SelectMapBtn.Init();
            SelectMapBtn.Text = "Select Map";
            SelectMapBtn.Click += new EventHandler(selectMapBtn_Click);
            SelectMapBtn.SetPosition(25, 40);
            SelectMapBtn.SetSize(150, 25);
            SelectMapBtn.Anchor = Anchors.Top | Anchors.Left;
            SideBar.Add(SelectMapBtn);

            DoOneStepBtn = new Button(Manager);
            DoOneStepBtn.Init();
            DoOneStepBtn.Text = "Do One Step";
            DoOneStepBtn.SetPosition(25, 90);
            DoOneStepBtn.SetSize(150, 25);
            DoOneStepBtn.Anchor = Anchors.Top | Anchors.Left;
            DoOneStepBtn.Click += new EventHandler(DoOneStepBtn_Click);
            SideBar.Add(DoOneStepBtn);

            DoOneRunBtn = new Button(Manager);
            DoOneRunBtn.Init();
            DoOneRunBtn.Text = "Do One Run";
            DoOneRunBtn.SetPosition(25, 120);
            DoOneRunBtn.SetSize(150, 25);
            DoOneRunBtn.Anchor = Anchors.Top | Anchors.Left;
            DoOneRunBtn.Click += new EventHandler(DoOneRunBtn_Click);
            SideBar.Add(DoOneRunBtn);

            NextRunBtn = new Button(Manager);
            NextRunBtn.Init();
            NextRunBtn.Text = "Next Run";
            NextRunBtn.SetPosition(25, 150);
            NextRunBtn.SetSize(150, 25);
            NextRunBtn.Anchor = Anchors.Top | Anchors.Left;
            NextRunBtn.Click += new EventHandler(NextRunBtn_Click);
            SideBar.Add(NextRunBtn);

            DoAllRunBtn = new Button(Manager);
            DoAllRunBtn.Init();
            DoAllRunBtn.Text = "Do All Run";
            DoAllRunBtn.SetPosition(25, 180);
            DoAllRunBtn.SetSize(150, 25);
            DoAllRunBtn.Anchor = Anchors.Top | Anchors.Left;
            DoAllRunBtn.Click += new EventHandler(DoAllRunBtn_Click);
            SideBar.Add(DoAllRunBtn);

            GrpBox = new GroupBox(Manager);
            GrpBox.Init();
            GrpBox.SetSize(SideBar.Width - 30, 135);
            GrpBox.SetPosition(5, 220);
            GrpBox.ClientWidth = 180;
            GrpBox.Text = "Display Options";
            GrpBox.TextColor = Color.Wheat;
            SideBar.Add(GrpBox);

            Label stepsLbl = new Label(Manager);
            stepsLbl.Init();
            stepsLbl.Text = "Steps:";
            stepsLbl.SetPosition(5, 25);
            GrpBox.Add(stepsLbl);

            StepsTxt = new TextBox(Manager);
            StepsTxt.Init();
            StepsTxt.Text = "100";
            StepsTxt.SetSize(100, 25);
            StepsTxt.SetPosition(5 + stepsLbl.Width, 20);
            StepsTxt.TextColor = Color.WhiteSmoke;
            StepsTxt.TextChanged += new EventHandler(TimeTxt_TextChanged);
            GrpBox.Add(StepsTxt);

            Label timeLbl = new Label(Manager);
            timeLbl.Init();
            timeLbl.Text = "Time:";
            timeLbl.SetPosition(5, 60);
            GrpBox.Add(timeLbl);

            TimeTxt = new TextBox(Manager);
            TimeTxt.Init();
            TimeTxt.Text = "20";
            TimeTxt.SetSize(100, 25);
            TimeTxt.SetPosition(5 + stepsLbl.Width, 55);
            TimeTxt.TextChanged += new EventHandler(TimeTxt_TextChanged);
            TimeTxt.TextColor = Color.WhiteSmoke;
            GrpBox.Add(TimeTxt);

            DisplayBtn = new Button(Manager);
            DisplayBtn.Init();
            DisplayBtn.Text = "Display";
            DisplayBtn.Click += new EventHandler(displayBtn_Click);
            DisplayBtn.SetSize(120, 25);
            DisplayBtn.SetPosition(50, 90);
            GrpBox.Add(DisplayBtn);

            Label rendererLbl = new Label(Manager);
            rendererLbl.Init();
            rendererLbl.Text = "Renderer:";
            rendererLbl.SetPosition(25, 360);
            Add(rendererLbl);

            RenderersComboBox = new ComboBox(Manager);
            RenderersComboBox.Init();
            RenderersComboBox.SetPosition(25, 385);
            RenderersComboBox.Width = 150;
            RenderersComboBox.TextColor = Color.Wheat;
            RenderersComboBox.Items.AddRange(Renderers);
            RenderersComboBox.ItemIndex = 0;
            RenderersComboBox.TextChanged += new EventHandler(RenderersComboBox_TextChanged);
            Add(RenderersComboBox);

            Button makeFullScreenBtn = new Button(Manager);
            makeFullScreenBtn.Init();
            makeFullScreenBtn.Text = "Fullscreen";
            makeFullScreenBtn.SetPosition(25, 475);
            makeFullScreenBtn.SetSize(150, 25);
            makeFullScreenBtn.Click += new EventHandler(makeFullScreenBtn_Click);
            makeFullScreenBtn.Anchor = Anchors.Top | Anchors.Left;
            SideBar.Add(makeFullScreenBtn);

            Button exitBtn = new Button(Manager);
            exitBtn.Init();
            exitBtn.Text = "Quit";
            exitBtn.SetPosition(25, 510);
            exitBtn.SetSize(150, 25);
            exitBtn.Click += new EventHandler(exitBtn_Click);
            exitBtn.Anchor = Anchors.Top | Anchors.Left;
            SideBar.Add(exitBtn);

            ExitDlg = new ExitDialog(Manager);
            ExitDlg.Init();
            ExitDlg.Closed += new WindowClosedEventHandler(ExitDlg_Closed);
            Manager.Add(ExitDlg);
            ExitDlg.Hide();

            //Right side bar
            SideBarRight = new SideBar(Manager);
            SideBarRight.Init();
            SideBarRight.StayOnBack = true;
            SideBarRight.Resizable = true;
            SideBarRight.ResizeEdge = Anchors.Left;
            SideBarRight.SetSize(200, Height);
            SideBarRight.SetPosition(Width - SideBarRight.Width, 0);
            SideBarRight.Anchor = Anchors.Right | Anchors.Top | Anchors.Bottom;
            Add(SideBarRight);

            GroupBox runParamsGrpBox = new GroupBox(Manager);
            runParamsGrpBox.Init();
            runParamsGrpBox.SetSize(SideBarRight.Width - 30, 155);
            runParamsGrpBox.SetPosition(5, 10);
            runParamsGrpBox.ClientWidth = 38;
            runParamsGrpBox.Text = "Run Statistics";
            runParamsGrpBox.TextColor = Color.Wheat;
            runParamsGrpBox.Anchor = Anchors.Left | Anchors.Right | Anchors.Top;
            SideBarRight.Add(runParamsGrpBox);

            Label runLbl1 = new Label(Manager);
            runLbl1.Init();
            runLbl1.Text = "Run:";
            runLbl1.SetPosition(10, 20);
            runLbl1.Width = 120;
            runParamsGrpBox.Add(runLbl1);

            Label runLbl2 = new Label(Manager);
            runLbl2.Init();
            runLbl2.Text = "0";
            runLbl2.SetPosition(runLbl1.Left + runLbl1.Width + 10, 20);
            runParamsGrpBox.Add(runLbl2);
            RunStatsLbls.Add(runLbl2);

            Label timeStepLbl1 = new Label(Manager);
            timeStepLbl1.Init();
            timeStepLbl1.Text = "Time step:";
            timeStepLbl1.SetPosition(10, 35);
            timeStepLbl1.Width = 120;
            runParamsGrpBox.Add(timeStepLbl1);

            Label timeStepLbl2 = new Label(Manager);
            timeStepLbl2.Init();
            timeStepLbl2.Text = "0";
            timeStepLbl2.SetPosition(timeStepLbl1.Left + timeStepLbl1.Width + 10, 35);
            runParamsGrpBox.Add(timeStepLbl2);
            RunStatsLbls.Add(timeStepLbl2);

            Label actionLbl1 = new Label(Manager);
            actionLbl1.Init();
            actionLbl1.Text = "Action:";
            actionLbl1.SetPosition(10, 60);
            actionLbl1.Width = 120;
            runParamsGrpBox.Add(actionLbl1);

            Label actionLbl2 = new Label(Manager);
            actionLbl2.Init();
            actionLbl2.Text = "0";
            actionLbl2.SetPosition(actionLbl1.Left + actionLbl1.Width + 10, 60);
            runParamsGrpBox.Add(actionLbl2);
            RunStatsLbls.Add(actionLbl2);

            Label dirtyOnMapLbl1 = new Label(Manager);
            dirtyOnMapLbl1.Init();
            dirtyOnMapLbl1.Text = "Dirty on map:";
            dirtyOnMapLbl1.SetPosition(10, 85);
            dirtyOnMapLbl1.Width = 120;
            runParamsGrpBox.Add(dirtyOnMapLbl1);

            Label dirtyOnMapLbl2 = new Label(Manager);
            dirtyOnMapLbl2.Init();
            dirtyOnMapLbl2.Text = "0";
            dirtyOnMapLbl2.SetPosition(dirtyOnMapLbl1.Left + dirtyOnMapLbl1.Width + 10, 85);
            runParamsGrpBox.Add(dirtyOnMapLbl2);
            RunStatsLbls.Add(dirtyOnMapLbl2);

            Label overAllDirtyLbl1 = new Label(Manager);
            overAllDirtyLbl1.Init();
            overAllDirtyLbl1.Text = "Overall dirty:";
            overAllDirtyLbl1.SetPosition(10, 100);
            overAllDirtyLbl1.Width = 120;
            runParamsGrpBox.Add(overAllDirtyLbl1);

            Label overAllDirtyLbl2 = new Label(Manager);
            overAllDirtyLbl2.Init();
            overAllDirtyLbl2.Text = "0";
            overAllDirtyLbl2.SetPosition(overAllDirtyLbl1.Left + overAllDirtyLbl1.Width + 10, 100);
            runParamsGrpBox.Add(overAllDirtyLbl2);
            RunStatsLbls.Add(overAllDirtyLbl2);

            Label cleanedDirtyLbl1 = new Label(Manager);
            cleanedDirtyLbl1.Init();
            cleanedDirtyLbl1.Text = "Cleaned dirty:";
            cleanedDirtyLbl1.SetPosition(10, 115);
            cleanedDirtyLbl1.Width = 120;
            runParamsGrpBox.Add(cleanedDirtyLbl1);

            Label cleanedDirtyLbl2 = new Label(Manager);
            cleanedDirtyLbl2.Init();
            cleanedDirtyLbl2.Text = "0";
            cleanedDirtyLbl2.SetPosition(cleanedDirtyLbl1.Left + cleanedDirtyLbl1.Width + 10, 115);
            runParamsGrpBox.Add(cleanedDirtyLbl2);
            RunStatsLbls.Add(cleanedDirtyLbl2);

            Label consumedEnergyLbl1 = new Label(Manager);
            consumedEnergyLbl1.Init();
            consumedEnergyLbl1.Text = "Consumed energy:";
            consumedEnergyLbl1.SetPosition(10, 130);
            consumedEnergyLbl1.Width = 120;
            runParamsGrpBox.Add(consumedEnergyLbl1);

            Label consumedEnergyLbl2 = new Label(Manager);
            consumedEnergyLbl2.Init();
            consumedEnergyLbl2.Text = "0";
            consumedEnergyLbl2.SetPosition(consumedEnergyLbl1.Left + consumedEnergyLbl1.Width + 10, 130);
            runParamsGrpBox.Add(consumedEnergyLbl2);
            RunStatsLbls.Add(consumedEnergyLbl2);
            ////
            GroupBox totalParamsGrpBox = new GroupBox(Manager);
            totalParamsGrpBox.Init();
            totalParamsGrpBox.SetSize(SideBarRight.Width - 30, 215);
            totalParamsGrpBox.SetPosition(5, runParamsGrpBox.Top + runParamsGrpBox.Height + 10);
            totalParamsGrpBox.ClientWidth = 38;
            totalParamsGrpBox.Text = "Total Statistics";
            totalParamsGrpBox.TextColor = Color.Wheat;
            totalParamsGrpBox.Anchor = Anchors.Left | Anchors.Right | Anchors.Top;
            SideBarRight.Add(totalParamsGrpBox);

            Label completedRunsLbl1 = new Label(Manager);
            completedRunsLbl1.Init();
            completedRunsLbl1.Text = "Completed Runs:";
            completedRunsLbl1.SetPosition(10, 20);
            completedRunsLbl1.Width = 120;
            totalParamsGrpBox.Add(completedRunsLbl1);

            Label completedRunsLbl2 = new Label(Manager);
            completedRunsLbl2.Init();
            completedRunsLbl2.Text = "0";
            completedRunsLbl2.SetPosition(completedRunsLbl1.Left + completedRunsLbl1.Width + 10, 20);
            totalParamsGrpBox.Add(completedRunsLbl2);
            TotalStatsLbls.Add(completedRunsLbl2);

            Label totalDirtyLbl1 = new Label(Manager);
            totalDirtyLbl1.Init();
            totalDirtyLbl1.Text = "Total dirty degree:";
            totalDirtyLbl1.SetPosition(10, 35);
            totalDirtyLbl1.Width = 120;
            totalParamsGrpBox.Add(totalDirtyLbl1);

            Label totalDirtyLbl2 = new Label(Manager);
            totalDirtyLbl2.Init();
            totalDirtyLbl2.Text = "0";
            totalDirtyLbl2.SetPosition(totalDirtyLbl1.Left + totalDirtyLbl1.Width + 10, 35);
            totalParamsGrpBox.Add(totalDirtyLbl2);
            TotalStatsLbls.Add(totalDirtyLbl2);

            Label totalCleanedLbl1 = new Label(Manager);
            totalCleanedLbl1.Init();
            totalCleanedLbl1.Text = "Total cleaned dirty:";
            totalCleanedLbl1.SetPosition(10, 60);
            totalCleanedLbl1.Width = 120;
            totalParamsGrpBox.Add(totalCleanedLbl1);

            Label totalCleanedLbl2 = new Label(Manager);
            totalCleanedLbl2.Init();
            totalCleanedLbl2.Text = "0";
            totalCleanedLbl2.SetPosition(totalCleanedLbl1.Left + totalCleanedLbl1.Width + 10, 60);
            totalParamsGrpBox.Add(totalCleanedLbl2);
            TotalStatsLbls.Add(totalCleanedLbl2);

            Label totalConsumedLbl1 = new Label(Manager);
            totalConsumedLbl1.Init();
            totalConsumedLbl1.Text = "Total consumed\nenergy:";
            totalConsumedLbl1.SetPosition(10, 85);
            totalConsumedLbl1.SetSize(120, 30);
            totalParamsGrpBox.Add(totalConsumedLbl1);

            Label totalConsumedLbl2 = new Label(Manager);
            totalConsumedLbl2.Init();
            totalConsumedLbl2.Text = "0";
            totalConsumedLbl2.SetPosition(totalConsumedLbl1.Left + totalConsumedLbl1.Width + 10, 85);
            totalParamsGrpBox.Add(totalConsumedLbl2);
            TotalStatsLbls.Add(totalConsumedLbl2);

            Label avarageDirtyLbl1 = new Label(Manager);
            avarageDirtyLbl1.Init();
            avarageDirtyLbl1.Text = "Average dirty\ndegree:";
            avarageDirtyLbl1.SetPosition(10, 115);
            avarageDirtyLbl1.SetSize(120, 30);
            totalParamsGrpBox.Add(avarageDirtyLbl1);

            Label avarageDirtyLbl2 = new Label(Manager);
            avarageDirtyLbl2.Init();
            avarageDirtyLbl2.Text = "0";
            avarageDirtyLbl2.SetPosition(avarageDirtyLbl1.Left + avarageDirtyLbl1.Width + 10, 115);
            totalParamsGrpBox.Add(avarageDirtyLbl2);
            TotalStatsLbls.Add(avarageDirtyLbl2);

            Label avarageCleanedLbl1 = new Label(Manager);
            avarageCleanedLbl1.Init();
            avarageCleanedLbl1.Text = "Average cleaned\ndirty:";
            avarageCleanedLbl1.SetPosition(10, 145);
            avarageCleanedLbl1.SetSize(120, 30);
            totalParamsGrpBox.Add(avarageCleanedLbl1);

            Label avarageCleanedLbl2 = new Label(Manager);
            avarageCleanedLbl2.Init();
            avarageCleanedLbl2.Text = "0";
            avarageCleanedLbl2.SetPosition(avarageCleanedLbl1.Left + avarageCleanedLbl1.Width + 10, 145);
            totalParamsGrpBox.Add(avarageCleanedLbl2);
            TotalStatsLbls.Add(avarageCleanedLbl2);

            Label avarageConsumedLbl1 = new Label(Manager);
            avarageConsumedLbl1.Init();
            avarageConsumedLbl1.Text = "Average consumed\nenergy:";
            avarageConsumedLbl1.SetPosition(10, 175);
            avarageConsumedLbl1.Width = 120;
            avarageConsumedLbl1.Height = 30;
            totalParamsGrpBox.Add(avarageConsumedLbl1);

            Label avarageConsumedLbl2 = new Label(Manager);
            avarageConsumedLbl2.Init();
            avarageConsumedLbl2.Text = "0";
            avarageConsumedLbl2.SetPosition(avarageConsumedLbl1.Left + avarageConsumedLbl1.Width + 10, 175);
            totalParamsGrpBox.Add(avarageConsumedLbl2);
            TotalStatsLbls.Add(avarageConsumedLbl2);
            /////
            //Select map

            OpenFileDialog = new Dialog(Manager);
            OpenFileDialog.Init();
            OpenFileDialog.Text = "Select map file";
            OpenFileDialog.Description.Visible = false;
            OpenFileDialog.Caption.Text = "";
            OpenFileDialog.Width = 600;
            OpenFileDialog.Resize += new ResizeEventHandler(OpenFileDialog_Resize);
            Manager.Add(OpenFileDialog);
            OpenFileDialog.Hide();

            FilesList = new ListBox(Manager);
            FilesList.Init();
            FilesList.Tag = System.Environment.CurrentDirectory;
            FilesList.SetPosition(0, 40);
            FilesList.ClientWidth = OpenFileDialog.Width - 15;
            FilesList.ClientHeight = OpenFileDialog.ClientHeight - 40;
            FilesList.TextColor = Color.Wheat;
            FilesList.DoubleClick += new EventHandler(FilesList_DoubleClick);
            GetFilesAndFolders();
            OpenFileDialog.Add(FilesList);

            LifeTimeLbl = new Label(Manager);
            LifeTimeLbl.Init();
            LifeTimeLbl.Text = "Life Time:";
            LifeTimeLbl.SetPosition(5, 10);
            OpenFileDialog.Add(LifeTimeLbl);

            LifeTimeTxt = new TextBox(Manager);
            LifeTimeTxt.Init();
            LifeTimeTxt.Text = "2000";
            LifeTimeTxt.SetSize(100, 25);
            LifeTimeTxt.SetPosition(5 + stepsLbl.Width, 5);
            LifeTimeTxt.TextColor = Color.WhiteSmoke;
            LifeTimeTxt.TextChanged += new EventHandler(TimeTxt_TextChanged);
            OpenFileDialog.Add(LifeTimeTxt);

            TestCaseLbl = new Label(Manager);
            TestCaseLbl.Init();
            TestCaseLbl.Text = "Test Case:";
            TestCaseLbl.SetPosition(LifeTimeTxt.Left + LifeTimeTxt.Width + 5, 10);
            OpenFileDialog.Add(TestCaseLbl);

            TestCaseTxt = new TextBox(Manager);
            TestCaseTxt.Init();
            TestCaseTxt.Text = "10";
            TestCaseTxt.SetSize(100, 25);
            TestCaseTxt.SetPosition(TestCaseLbl.Left + TestCaseLbl.Width + 5, 5);
            TestCaseTxt.TextColor = Color.WhiteSmoke;
            TestCaseTxt.TextChanged += new EventHandler(TimeTxt_TextChanged);
            OpenFileDialog.Add(TestCaseTxt);

            AgentLbl = new Label(Manager);
            AgentLbl.Init();
            AgentLbl.Text = "Agent:";
            AgentLbl.SetPosition(TestCaseTxt.Left + TestCaseTxt.Width + 5, 10);
            OpenFileDialog.Add(AgentLbl);

            AgentsComboBox = new ComboBox(Manager);
            AgentsComboBox.Init();
            AgentsComboBox.SetPosition(AgentLbl.Left + AgentLbl.Width - 10, 5);
            AgentsComboBox.Width = 150;
            AgentsComboBox.Height = 25;
            AgentsComboBox.TextColor = Color.Wheat;
            AgentsComboBox.Items.Add("RandomAgent");
            AgentsComboBox.Items.Add("ModelAgent");
            AgentsComboBox.Items.Add("ModelAgentNoIdle");
            AgentsComboBox.ItemIndex = 0;
            OpenFileDialog.Add(AgentsComboBox);

            NewGameDialog = new Dialog(Manager);
            NewGameDialog.Init();
            NewGameDialog.Text = "Start new tests";
            NewGameDialog.Description.Visible = false;
            NewGameDialog.BottomPanel.Visible = false;
            NewGameDialog.Caption.Text = "";
            NewGameDialog.Width = 600;
            NewGameDialog.Height = 130;
            NewGameDialog.TopPanel.Height = 100;
            Manager.Add(NewGameDialog);
            NewGameDialog.Hide();

            Button newGameOk = new Button(Manager);
            newGameOk.Init();
            newGameOk.SetPosition(20, 50);
            newGameOk.Text = "Confirm";
            newGameOk.Click += new EventHandler(newGameOk_Click);
            NewGameDialog.Add(newGameOk);

            EnableDisableMapControls(false);
        }
示例#12
0
        public void Init(Control parent, Manager manager)
        {
            switch (Type)
            {
                case "Container":
                    Container container = new Container(manager);
                    container.Init();

                    SetProperties(container, parent, manager);

                    container.AutoScroll = true;
                    break;
                case "ImageBox":
                    ImageBox box = new ImageBox(manager);
                    box.Init();

                    SetProperties(box, parent, manager);

                    box.SizeMode = ImageMode;

                    if (!string.IsNullOrEmpty(ImageAsset))
                        box.Image = manager.Content.Load<Texture2D>(ImageAsset);
                    else if (AtlasAsset != null)
                    {
                        if (AtlasAsset.Atlas == "IconProvider")
                            box.Image = IconProvider.GetByName(AtlasAsset.Name);
                        else
                            box.Image = Provider.GetAtlas(AtlasAsset.Atlas).GetTexture(AtlasAsset.Name);
                    }

                    if (!string.IsNullOrEmpty(Draw))
                        box.Draw += delegate(object sender, DrawEventArgs e)
                        {
                            if (EventFieldDraw == null)
                            {
                                Type classType = parent.GetType();
                                EventFieldDraw = classType.GetMethod(Draw);
                            }

                            if (EventFieldDraw == null)
                                throw new Exception("Could not find: " + Draw + " method");

                            EventFieldDraw.Invoke(parent, new object[] { sender, e });
                        };
                    break;
                case "Label":
                    Label label = new Label(manager);
                    label.Init();

                    SetProperties(label, parent, manager);

                    label.Text = Text.StartsWith("TXT_KEY_") ? Provider.Instance.Translate(Text) : Text;

                    break;
                case "GameMapBox":
                    GameMapBox mapBox = new GameMapBox(manager);
                    mapBox.Init();

                    SetProperties(mapBox, parent, manager);

                    break;
                case "SideBar":
                    SideBar sideBar = new SideBar(manager);
                    sideBar.Init();

                    SetProperties(sideBar, parent, manager);

                    if (!string.IsNullOrEmpty(Draw))
                        sideBar.Draw += delegate(object sender, DrawEventArgs e)
                        {
                            if (EventFieldDraw == null)
                            {
                                Type classType = parent.GetType();
                                EventFieldDraw = classType.GetMethod(Draw);
                            }

                            if (EventFieldDraw == null)
                                throw new Exception("Could not find: " + Draw + " method");

                            EventFieldDraw.Invoke(parent, new object[] { sender, e });
                        };

                    break;
                case "ContextMenu":
                    ContextMenu contextMenu = new ContextMenu(manager);
                    contextMenu.Init();

                    contextMenu.Name = Name;
                    contextMenu.Tag = this;
                    contextMenu.Passive = Passive;
                    contextMenu.Enabled = Enabled;

                    foreach (MenuItemEntry entry in Items)
                    {
                        MenuItem menuItem = new MenuItem(entry.Title);
                        menuItem.Enabled = entry.Enabled;

                        contextMenu.Items.Add(menuItem);
                    }

                    if (!string.IsNullOrEmpty(Parent))
                        contextMenu.Parent = parent.GetControl(Parent);
                    else
                        parent.Add(contextMenu);

                    break;

                case "ImageListBox":
                    ImageListBox listBox = new ImageListBox(manager);
                    listBox.Init();

                    SetProperties(listBox, parent, manager);

                    listBox.HideSelection = HideSelection;

                    if (!string.IsNullOrEmpty(ContextMenu))
                        listBox.ContextMenu = parent.GetControl(ContextMenu) as ContextMenu;

                    break;

                case "TechInfoButton":
                    TechInfoButton techInfo = new TechInfoButton(manager);
                    techInfo.Init();

                    SetProperties(techInfo, parent, manager);

                    if (!string.IsNullOrEmpty(TechName))
                        techInfo.Tech = Provider.GetTech(TechName);

                    break;
                case "PolicyButton":
                    PolicyButton policyButton = new PolicyButton(manager);
                    policyButton.Init();

                    SetProperties(policyButton, parent, manager);

                    if (!string.IsNullOrEmpty(PolicyName))
                        policyButton.Policy = Provider.GetPolicy(PolicyName);

                    break;
                case "PolicyTypeBox":
                    PolicyTypeBox policyTypeBox = new PolicyTypeBox(manager);
                    policyTypeBox.Init();

                    SetProperties(policyTypeBox, parent, manager);

                    if (!string.IsNullOrEmpty(PolicyTypeName))
                        policyTypeBox.PolicyType = Provider.GetPolicyType(PolicyTypeName);

                    if (!string.IsNullOrEmpty(ImageAsset))
                        policyTypeBox.Image = manager.Content.Load<Texture2D>(ImageAsset);
                    else if (AtlasAsset != null)
                    {
                        if (AtlasAsset.Atlas == "IconProvider")
                            policyTypeBox.Image = IconProvider.GetByName(AtlasAsset.Name);
                        else
                            policyTypeBox.Image = Provider.GetAtlas(AtlasAsset.Atlas).GetTexture(AtlasAsset.Name);
                    }

                    break;
                case "ImageButton":
                    ImageButton button = new ImageButton(manager);
                    button.Init();

                    ApplyStyle(button, manager);
                    SetProperties(button, parent, manager);
                    SetAnimation(button, manager);

                    button.Text = Text;
                    break;
                case "ProgressBar":
                    ProgressBar progress = new ProgressBar(manager);
                    progress.Init();

                    SetProperties(progress, parent, manager);
                    break;
                case "CheckBox":
                    CheckBox check = new CheckBox(manager);
                    check.Init();

                    SetProperties(check, parent, manager);

                    check.Text = Text;
                    break;
                case "Graph":
                    Graph graph = new Graph(manager);
                    graph.Init();

                    SetProperties(graph, parent, manager);

                    break;
                case "RankingRow":
                    RankingRow rank = new RankingRow(manager);
                    rank.Init();

                    SetProperties(rank, parent, manager);
                    break;
                case "Include":
                    List<ControlItem> children = manager.Content.Load<List<ControlItem>>(Import);

                    foreach (ControlItem item in children)
                        item.Init(parent, manager);
                    break;
                default:
                    throw new Exception("No handling for " + Type);
            }
        }
        public CreateGroupWindow(Sidebar sidebar)
        {
            this.sidebar = sidebar;
            this.manager = sidebar.manager;
            sidebar.CreatingGroup = true;
            //sidebar.ui.game.SwitchToTempRoom();
            //temproom = sidebar.ui.game.tempRoom;
            //tempgroup = g;// sidebar.ActiveGroup;//temproom.groups.generalGroups.childGroups.ElementAt(0).Value;

            neoSidebar = new NeoSidebar(manager);
            neoSidebar.Init();
            int tomtom = 5;
            neoSidebar.ClientArea.BackColor = UserInterface.TomDark;
            neoSidebar.BackColor = Color.Black;
            neoSidebar.BevelBorder = BevelBorder.All;
            Margins tomtomtomtom = new Margins(tomtom, tomtom, tomtom, tomtom);
            neoSidebar.ClientMargins = tomtomtomtom;

            neoSidebar.Left = sidebar.master.Left;
            neoSidebar.Width = sidebar.Width;
            neoSidebar.Top = 0;
            neoSidebar.Height = OrbIt.ScreenHeight;
            //poop.Text = "Create Group";
            //poop.Closed += delegate { UserInterface.GameInputDisabled = false; sidebar.CreatingGroup = false; sidebar.ui.game.SwitchToMainRoom(); sidebar.groupsView.createGroupWindow = null; };
            //window.ShowModal();
            manager.Add(neoSidebar);

            int width = 120;
            int offset = neoSidebar.Width - width - 20;

            TitlePanel titlePanelCreateGroup = new TitlePanel(sidebar, neoSidebar, "Create Group", true);
            titlePanelCreateGroup.btnBack.Click += (s, e) => Close();

            HeightCounter += titlePanelCreateGroup.Height;

            Label lblName = new Label(manager);
            lblName.Init();
            lblName.Parent = neoSidebar;
            lblName.Left = LeftPadding;
            lblName.Top = HeightCounter;
            lblName.Width = width;
            lblName.Text = "Group Name:";

            TextBox txtName = new TextBox(manager);
            txtName.Init();
            txtName.Parent = neoSidebar;
            txtName.Top = HeightCounter;
            txtName.Width = width;
            txtName.Left = offset;
            HeightCounter += txtName.Height + LeftPadding;

            Button btnRandomName = new Button(manager);
            btnRandomName.Init();
            btnRandomName.Parent = neoSidebar;
            btnRandomName.Top = HeightCounter;
            btnRandomName.Width = txtName.Width;
            btnRandomName.Left = offset;
            btnRandomName.Text = "Random Name";
            HeightCounter += txtName.Height + LeftPadding;
            btnRandomName.Click += (s, e) =>
            {
                txtName.Text = Utils.RandomName();
            };

            RadioButton rdEmpty = new RadioButton(manager);
            rdEmpty.Init();
            rdEmpty.Parent = neoSidebar;
            rdEmpty.Top = HeightCounter;
            rdEmpty.Left = LeftPadding;
            rdEmpty.Text = "Default";
            rdEmpty.Checked = true;
            HeightCounter += rdEmpty.Height + LeftPadding;

            RadioButton rdExisting = new RadioButton(manager);
            rdExisting.Init();
            rdExisting.Parent = neoSidebar;
            rdExisting.Top = HeightCounter;
            rdExisting.Left = LeftPadding;
            rdExisting.Text = "Existing";
            rdExisting.Checked = false;
            rdExisting.Width = width;

            ComboBox cbExisting = new ComboBox(manager);
            cbExisting.Init();
            cbExisting.Parent = neoSidebar;
            cbExisting.Top = HeightCounter;
            cbExisting.Width = width;
            cbExisting.Left = offset;
            foreach(Group gg in sidebar.game.room.groups.general.childGroups.Values)
            {
                cbExisting.Items.Add(gg);
            }
            cbExisting.ItemIndex = 0;
            cbExisting.Enabled = false;
            HeightCounter += cbExisting.Height + LeftPadding;

            RadioButton rdTemplate = new RadioButton(manager);
            rdTemplate.Init();
            rdTemplate.Parent = neoSidebar;
            rdTemplate.Top = HeightCounter;
            rdTemplate.Left = LeftPadding;
            rdTemplate.Text = "Template";
            rdTemplate.Checked = false;
            rdTemplate.Width = width;

            ComboBox cbTemplate = new ComboBox(manager);
            cbTemplate.Init();
            cbTemplate.Parent = neoSidebar;
            cbTemplate.Top = HeightCounter;
            cbTemplate.Width = width;
            cbTemplate.Left = offset;
            foreach (Node n in Assets.NodePresets)
            {
                cbTemplate.Items.Add(n);
            }
            if (Assets.NodePresets.Count > 0) cbTemplate.ItemIndex = 0;
            cbTemplate.Enabled = false;
            HeightCounter += cbTemplate.Height + LeftPadding;

            componentView = new ComponentView(sidebar, neoSidebar, 0, HeightCounter, ViewType.Group);
            componentView.Height = 150;
            componentView.Width = neoSidebar.Width - LeftPadding * 4;

            neoSidebar.Width += 100;
            neoSidebar.Width -= 100;
            tempgroup = new Group(sidebar.room, sidebar.room.defaultNode.CreateClone(sidebar.room), null, "tempgroup", false);

            SetGroup(sidebar.room.defaultNode);

            rdEmpty.Click += (s, e) =>
            {
                cbExisting.Enabled = false;
                cbTemplate.Enabled = false;
                SetGroup(sidebar.room.defaultNode);
            };
            rdExisting.Click += (s, e) =>
            {
                cbExisting.Enabled = true;
                cbTemplate.Enabled = false;
                ComboUpdate(cbExisting);
            };
            cbExisting.ItemIndexChanged += (s, e) =>
            {
                ComboUpdate(cbExisting);
            };
            rdTemplate.Click += (s, e) =>
            {
                cbExisting.Enabled = false;
                cbTemplate.Enabled = true;
                ComboUpdate(cbTemplate);
            };
            cbTemplate.ItemIndexChanged += (s, e) =>
            {
                ComboUpdate(cbTemplate);
            };

            btnCreateGroup = new Button(manager);
            btnCreateGroup.Init();
            btnCreateGroup.Parent = neoSidebar;
            btnCreateGroup.Top = componentView.bottomArea.Top + componentView.bottomArea.Height + LeftPadding * 2;
            btnCreateGroup.Text = "Create Group";
            btnCreateGroup.Width = width;
            btnCreateGroup.Left = neoSidebar.Width / 2 - btnCreateGroup.Width / 2;

            btnCreateGroup.Click += (s, e) =>
            {
                if (String.IsNullOrWhiteSpace(txtName.Text))
                    PopUp.Toast("Please enter a group name.");
                else if(sidebar.game.room.groups.general.childGroups.Keys.Contains(txtName.Text))
                    PopUp.Toast("Group already exists.");
                else{

                    OrbIt.game.room = sidebar.game.room;
                    Node newNode = tempgroup.defaultNode.CreateClone(sidebar.game.room);
                    newNode.body.color = ColorChanger.randomColorHue();
                    newNode.basicdraw.UpdateColor();
                    Group newGroup = new Group(sidebar.game.room, newNode, sidebar.game.room.groups.general, txtName.Text.Trim());
                    newNode.name = txtName.Text.Trim();
                    newNode.group = newGroup;
                    sidebar.groupsView.UpdateGroups();
                    foreach(DetailedItem item in sidebar.groupsView.viewItems)
                    {
                        if (item.obj == newGroup)
                        {
                            sidebar.groupsView.SelectItem(item);
                            break;
                        }
                    }
                    Close();
                }
            };
        }