public AddComponentWindow(Sidebar sidebar, Control under, Link link, DetailedView view, bool addToGroup = true)
     : this(sidebar, under, view, addToGroup)
 {
     this.link = link;
     addCompView = new AddComponentView(sidebar, neoSidebar, LeftPadding, 80, sidebar.tbcViews.TabPages[0].Height - 260);
     addCompView.InitLink(link);
 }
        public AddComponentView(Sidebar sidebar, Control parent, int Left, int Top, int Height)
            : base(sidebar, parent, Left, Top, false)
        {
            this.Height = Height;
            base.Initialize();
            ItemCreator = Creator;
            ColorChangeOnSelect = false;
            Width = parent.Width - 15;
            sidebar.ui.detailedViews.Remove(this);

            lblCompName = new Label(manager);
            lblCompName.Init();
            lblCompName.Parent = parent;
            lblCompName.Width = 400;
            //lblCompName.Height = 250;
            lblCompName.Top = backPanel.Height + Top;
            lblCompName.Left = 10;
            lblCompName.Text = "";
            lblCompName.TextColor = UserInterface.TomShanePuke;

            lblDescription = new Label(manager);
            lblDescription.Init();
            lblDescription.Parent = parent;
            lblDescription.Width = 400;
            lblDescription.Top = lblCompName.Top + lblCompName.Height;//backPanel.Height + Top + 10;
            lblDescription.Left = 10;
            lblDescription.Height = 70;
            lblDescription.Text = "l";
        }
        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];
        }
 public EditNodeWindow(Sidebar sidebar, string Type, string Name, ViewType viewType)
     : this(sidebar, viewType)
 {
     titlePanelEditNode.lblTitle.Text = "Edit " + Type;
     lblName.Text = Type + " Name:";
     txtName.Text = Name;
 }
 public EditNodeWindow(Sidebar sidebar, Node node)
     : this(sidebar, ViewType.Node)
 {
     titlePanelEditNode.lblTitle.Text = "Edit Node";
     lblName.Text = "Node Name:";
     txtName.Text = node.name;
 }
 public EditNodeWindow(Sidebar sidebar, Group group)
     : this(sidebar, ViewType.Group)
 {
     titlePanelEditNode.lblTitle.Text = "Edit Group";
     lblName.Text = "Group Name:";
     txtName.Text = group.Name;
 }
        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 UserInterface()
        {
            sidebar = new Sidebar(this);

            zoomfactor = 0.9f;
            GameInputDisabled = false;
            IsPaused = false;
            this.keyManager = new KeyManager(this);
            SidebarActive = true;
        }
        public GamemodeWindow(Sidebar sidebar)
        {
            this.manager = sidebar.manager;
            this.sidebar = sidebar;

            window = new Window(manager);
            window.Init();
            window.Left = sidebar.master.Left;
            window.Width = sidebar.master.Width;
            window.Top = 0;
            window.Height = 600;
            window.Text = "Game Mode";
            manager.Add(window);

            TitlePanel titlePanel = new TitlePanel(sidebar, window, "Game Mode", true);
            titlePanel.btnBack.Click += (s, e) => window.Close();

            HeightCounter += titlePanel.topPanel.Height + LeftPadding * 2;

            lblMode = new Label(manager);
            lblMode.Init();
            lblMode.Parent = window;
            lblMode.Top = HeightCounter;
            lblMode.Left = LeftPadding;
            lblMode.Text = "Game Mode Options";
            lblMode.Width = 120;
            lblMode.TextColor = Color.Black;

            //cbMode = new ComboBox(manager);
            //cbMode.Init();
            //cbMode.Parent = window;
            //cbMode.Left = lblMode.Left + lblMode.Width;
            //cbMode.Top = HeightCounter;
            //cbMode.Width = 100;
            //
            //foreach (GameModes m in Enum.GetValues(typeof(GameModes)))
            //{
            //    cbMode.Items.Add(m);
            //}
            HeightCounter += lblMode.Height + LeftPadding * 3;

            insViewModes = new InspectorView(sidebar, window, LeftPadding, HeightCounter);
            insViewModes.Width -= 20;
            insViewModes.Height -= 100;
            HeightCounter += insViewModes.Height + LeftPadding * 3;
            insViewModes.SetRootObject(OrbIt.globalGameMode);

            //insViewGlobal = new InspectorView(sidebar, window, LeftPadding, HeightCounter);
            //insViewGlobal.Width -= 20;
            //insViewGlobal.Height -= 100;

            window.Refresh();
        }
        //public Group activeGroup = null;
        public InspectorArea(Sidebar sidebar, Control parent, int Left, int Top)
        {
            //get rid of these if not needed.
            this.game = sidebar.game;
            this.ui = sidebar.ui;
            this.sidebar = sidebar;
            this.manager = sidebar.manager;
            this.parent = parent;

            this.Left = Left;
            this.Top = Top;

            this.GenerateFields = true; //todo: set to true when usermode is set up (so you can see fields in debug)
            //this.ActiveInspectorParent = sidebar.ActiveInspectorParent;

            Initialize();
        }
        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);
        }
        public RoomPanel(Sidebar sidebar, Control parent, Room room, bool interactive, int Top = 0, int Padding = 5)
        {
            this.Padding = Padding;
            panel = new Panel(sidebar.manager);
            panel.Init();
            panel.Top = Top;
            panel.Left = Padding;
            panel.Width = room.worldWidth;
            panel.Height = room.worldHeight;

            //roomPanel.Left = (parent.Width - roomPanel.Width)/2;

            int col = 30;

            panel.Color = new Color(col, col, col);
            panel.BevelBorder = BevelBorder.All;
            panel.BevelStyle = BevelStyle.Flat;
            panel.BevelColor = Color.Black;

            parent.Add(panel);
            panel.ClientArea.Draw += (s, e) =>
            {

                e.Renderer.Draw(room.roomRenderTarget, e.Rectangle, Color.White);

            };

            refreshAction = refresh;

            parent.VisibleChanged += (s, e) => {
                if (parent.Visible)
                    OrbIt.OnUpdate += refreshAction;
                else
                    OrbIt.OnUpdate -= refreshAction;
            };

            panel.Click += (s, e) =>
            {
                Point innerpos = (e as MouseEventArgs).Position;
                //room.spawnNode(innerpos.X, innerpos.Y);
                Utils.notImplementedException();
            };
        }
        public PlayerView(Sidebar sidebar, Control parent, int Left, int Top)
            : base(sidebar, parent, Left, Top, false)
        {
            playerGroup = sidebar.room.groups.player;

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

            };

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

            base.Initialize();

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

            InitializePlayers();
        }
        public TitlePanel(Sidebar sidebar, Control parent, string Title, bool BackButton, int Top = 0, int Padding = 5)
        {
            this.Padding = Padding;
            topPanel = new Panel(sidebar.manager);
            topPanel.Init();
            topPanel.Parent = parent;
            topPanel.Left = Padding;
            topPanel.Top = Top + Padding;
            topPanel.Width = parent.Width - Padding * 3;
            if (parent is SideBar) topPanel.Width -= Padding * 1;
            int col = 30;
            topPanel.Color = new Color(col, col, col);
            topPanel.BevelBorder = BevelBorder.All;
            topPanel.BevelStyle = BevelStyle.Flat;
            topPanel.BevelColor = Color.Black;

            lblTitle = new Label(sidebar.manager);
            lblTitle.Init();
            lblTitle.Parent = topPanel;
            lblTitle.Top = Padding * 2;
            lblTitle.Width = 120;
            lblTitle.Left = parent.Width / 2 - lblTitle.Width / 4;
            //lblTitle.Text = Title;
            this.Title = Title;
            topPanel.Height = 24 + Padding * 3;

            if (!BackButton) return;
            btnBack = new Button(sidebar.manager);
            btnBack.Init();
            btnBack.Parent = topPanel;
            btnBack.Top = Padding;
            btnBack.Text = "Back";
            btnBack.Width = 40;
            btnBack.Left = Padding;
            //topPanel.Height = btnBack.Height + Padding * 3;
        }
        public OptionsWindow(Sidebar sidebar)
        {
            UserInterface.GameInputDisabled = true;
            this.manager = sidebar.manager;
            this.sidebar = sidebar;

            window = new Window(manager);
            window.Init();
            window.Left = sidebar.master.Left;
            window.Width = sidebar.master.Width;
            window.Top = 200;
            window.Height = 200;
            window.Width = 240;
            window.Text = "Options";
            window.Resizable = false;
            window.Movable = false;

            window.Closed += delegate { UserInterface.GameInputDisabled = false; };
            window.ShowModal();
            manager.Add(window);

            btnOk = new Button(manager);
            btnOk.Init();
            btnOk.Parent = window;
            btnOk.Left = LeftPadding;
            btnOk.Top = window.Height - (btnOk.Height * 3);
            btnOk.Text = "Ok";// +"\u2713";
            btnOk.Click += (s, e) => window.Close();

            //btnLoadLevel = new Button(manager);
            //btnLoadLevel.Init();
            //window.Add(btnLoadLevel);
            //btnLoadLevel.Width += 30;
            //btnLoadLevel.Left = window.Width - btnLoadLevel.Width - LeftPadding * 5;
            //btnLoadLevel.Text = "Load Level";
            //btnLoadLevel.Top = window.Height - (btnLoadLevel.Height * 3);
            //btnLoadLevel.Click += btnLoadLevel_Click;
            //
            //btnSaveLevel = new Button(manager);
            //btnSaveLevel.Init();
            //window.Add(btnSaveLevel);
            //btnSaveLevel.Width += 30;
            //btnSaveLevel.Left = window.Width - btnSaveLevel.Width - LeftPadding * 5;
            //btnSaveLevel.Text = "Save Level";
            //btnSaveLevel.Top = btnLoadLevel.Top - btnSaveLevel.Height - LeftPadding;
            //btnSaveLevel.Click += btnSaveLevel_Click;

            lblUserLevel = new Label(manager);
            lblUserLevel.Init();
            lblUserLevel.Parent = window;
            lblUserLevel.Left = LeftPadding;
            lblUserLevel.Top = HeightCounter;
            lblUserLevel.Text = "User Level";
            lblUserLevel.Width += 10;

            cbUserLevel = new ComboBox(manager);
            cbUserLevel.Init();
            cbUserLevel.Parent = window;
            cbUserLevel.Top = HeightCounter;
            cbUserLevel.Left = lblUserLevel.Width;
            cbUserLevel.Width = 150;
            HeightCounter += cbUserLevel.Height;
            cbUserLevel.TextColor = Color.Black;
            foreach(string ul in Enum.GetNames(typeof(UserLevel)))
            {
                cbUserLevel.Items.Add(ul);
            }
            cbUserLevel.ItemIndexChanged += (s, e) =>
            {
                sidebar.userLevel = (UserLevel)cbUserLevel.ItemIndex;

            };
            int count = 0;
            foreach(object s in cbUserLevel.Items)
            {
                if (s.ToString().Equals(sidebar.userLevel.ToString()))
                {
                    cbUserLevel.ItemIndex = count;
                }
                count++;
            }

            Label lblRes = new Label(manager);
            lblRes.Init();
            lblRes.Parent = window;
            lblRes.Left = LeftPadding;
            lblRes.Top = HeightCounter;
            lblRes.Text = "Resolution";
            lblRes.Width += 10;

            ComboBox cbResolutions = new ComboBox(manager);
            cbResolutions.Init();
            cbResolutions.Parent = window;
            cbResolutions.Top = HeightCounter;
            cbResolutions.Left = lblUserLevel.Width;
            cbResolutions.Width = 150;
            HeightCounter += cbResolutions.Height;
            cbUserLevel.TextColor = Color.Black;
            foreach (resolutions r in Enum.GetValues(typeof(resolutions)))
            {
                cbResolutions.Items.Add(r);
            }
            cbResolutions.ItemIndexChanged += (s, e) =>
            {
                OrbIt.game.setResolution((resolutions)cbResolutions.ItemIndex, OrbIt.game.Graphics.IsFullScreen);
                if (OrbIt.game.Graphics.IsFullScreen)
                    OrbIt.game.prefFullScreenResolution = (resolutions)cbResolutions.ItemIndex;
                else OrbIt.game.prefWindowedResolution = (resolutions)cbResolutions.ItemIndex;

            };

            CreateCheckBox("FullScreen", OrbIt.isFullScreen, (o, e) =>
            {
                if ((o as CheckBox).Checked) OrbIt.game.setResolution(resolutions.AutoFullScreen, true);
                else OrbIt.game.setResolution(resolutions.WXGA_1280x800, false);
            });
            CreateCheckBox("Hide Links", sidebar.ui.game.room.DrawLinks, (o, e) => sidebar.ui.game.room.DrawLinks = !(o as CheckBox).Checked);

            CreateCheckBox("Edit Selected Node", false, (o, e) => Utils.notImplementedException() );

            //CreateCheckBox("Edit Selected Node", sidebar.EditSelectedNode, (o, e) => sidebar.EditSelectedNode = (o as CheckBox).Checked);
        }
        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();
                }
            };
        }
        public GroupsView(Sidebar sidebar, Control parent, int Left, int Top, Group parentGroup)
            : base(sidebar, parent, Left, Top, false)
        {
            Height += 50;
            this.parentGroup = parentGroup;
            HeightCounter = Top + 45;
            lblGroupLabel = new Label(manager);
            lblGroupLabel.Init();
            lblGroupLabel.Parent = parent;
            lblGroupLabel.Left = LeftPadding;
            lblGroupLabel.Top = 10;// HeightCounter;
            lblGroupLabel.Width = sidebar.Width / 2;
            lblGroupLabel.Text = "";
            lblGroupLabel.TextColor = Color.Black;
            //HeightCounter += lblGroupLabel.Height + LeftPadding;

            ItemCreator += ItemCreatorDelegate;

            Initialize();

            btnCreateGroup = new Button(manager);
            btnCreateGroup.Init();
            btnCreateGroup.Parent = parent;
            btnCreateGroup.Top = HeightCounter;
            btnCreateGroup.Text = "Create Group";
            btnCreateGroup.Height = (int)(btnCreateGroup.Height * 1.5);
            btnCreateGroup.Width = (parent.Width - LeftPadding * 2) / 2;
            btnCreateGroup.Left = LeftPadding;//parent.Width / 2 - btnCreateGroup.Width / 2;
            btnCreateGroup.Click += (s, e) =>
            {
                createGroupWindow = new CreateGroupWindow(sidebar);
            };
            Margins m = btnCreateGroup.ClientMargins;
            btnCreateGroup.ClientMargins = new Margins(m.Left, 1, m.Right, 1);

            btnEmptyGroup = new Button(manager);
            btnEmptyGroup.Init();
            btnEmptyGroup.Parent = parent;
            btnEmptyGroup.Top = HeightCounter;
            btnEmptyGroup.Text = "Empty Group";
            btnEmptyGroup.Height = (int)(btnEmptyGroup.Height * 1.5);
            btnEmptyGroup.Width = btnCreateGroup.Width;
            btnEmptyGroup.Left = parent.Width - LeftPadding * 2 - btnEmptyGroup.Width;//parent.Width / 2 - btnCreateGroup.Width / 2;
            btnEmptyGroup.Click += (s, e) =>
            {
                sidebar.btnRemoveAllNodes_Click(null, null);
            };
            Margins m2 = btnEmptyGroup.ClientMargins;
            btnEmptyGroup.ClientMargins = new Margins(m2.Left, 1, m2.Right, 1);

            HeightCounter += btnCreateGroup.Height + LeftPadding;

            btnEmptyAll = new Button(manager);
            btnEmptyAll.Init();
            btnEmptyAll.Parent = parent;
            btnEmptyAll.Top = HeightCounter;
            btnEmptyAll.Text = "Empty All Groups";
            //btnEmptyAll.Height = (int)(btnEmptyGroup.Height * 1.5);
            btnEmptyAll.Width = parent.Width / 2;
            btnEmptyAll.Left = parent.Width / 2 - btnEmptyAll.Width / 2;//parent.Width / 2 - btnCreateGroup.Width / 2;
            btnEmptyAll.Click += (s, e) =>
            {
                EmptyAllGroups();
            };
        }
        public ComponentView(Sidebar sidebar, Control parent, int Left, int Top, ViewType viewType)
            : base(sidebar, parent, Left, Top, false)
        {
            this.parent = parent;
            lblComponents = new Label(manager);
            lblComponents.Init();
            lblComponents.Parent = parent;
            lblComponents.Text = "Components";
            lblComponents.Width = 150;
            lblComponents.Left = LeftPadding;
            lblComponents.TextColor = Color.Black;
            lblComponents.Top = HeightCounter;
            HeightCounter += lblComponents.Height + VertPadding;
            base.Initialize();

            btnAddComponent = new Button(manager);
            btnAddComponent.Init();
            btnAddComponent.Width = 150;
            btnAddComponent.Left = Left + LeftPadding + (Width - btnAddComponent.Width) / 2;
            btnAddComponent.Top = HeightCounter;

            btnAddComponent.Parent = parent;
            btnAddComponent.Text = "Add Component";
            btnAddComponent.Click += btnAddComponent_Click;
            HeightCounter += btnAddComponent.Height + VertPadding;

            bottomArea = new TabControl(manager);
            bottomArea.Init();
            bottomArea.Parent = parent;
            bottomArea.Left = 0;
            bottomArea.Top = HeightCounter;
            bottomArea.Width = sidebar.Width - 5;
            bottomArea.Height = 500;

            bottomArea.AddPage();
            bottomArea.TabPages[0].Text = "Edit";
            TabPage editTab = bottomArea.TabPages[0];
            editTab.Margins = new Margins(0, 0, 0, 0);

            lblCurrentComp = new Label(manager);
            lblCurrentComp.Init();
            lblCurrentComp.Parent = editTab;
            lblCurrentComp.Width = 150;
            lblCurrentComp.Top = 5;
            lblCurrentComp.Left = LeftPadding;
            lblCurrentComp.Text = "";
            lblCurrentComp.TextColor = Color.Black;

            insView = new InspectorView(sidebar, editTab, Left, lblComponents.Height + 10);
            insView.GroupSync = true;
            insView.Height = 140;
            OnItemEvent += OnEvent2;
            editTab.Margins = new Margins(0, 0, 0, 0);

            bottomArea.AddPage();
            bottomArea.TabPages[1].Text = "Preview";
            TabPage previewTab = bottomArea.TabPages[1];
            previewTab.Margins = new Margins(0, 0, 0, 0);
            bottomArea.Height = insView.Height + 140;

            this.viewType = viewType;
        }
 //method
 public InspectorInfo(IList<object> masterList, InspectorInfo parentItem, MethodInfo methodInfo)
 {
     this.membertype = member_type.method;
     this.methodInfo = methodInfo;
     this.whitespace = "|";
     if (parentItem != null) this.whitespace += parentItem.whitespace;
     this.obj = null;
     this.parentItem = parentItem;
     this.masterList = masterList;
     this.children = new List<InspectorInfo>();
     this.showValueToString = parentItem.showValueToString;
     CheckItemType();
     prefix = "" + ((char)164);
     //this.inspectorArea = parentItem.inspectorArea;
     this.sidebar = parentItem.sidebar;
 }
        //obj = null
        //a IEnumberable entry
        public InspectorInfo(IList<object> masterList, InspectorInfo parentItem, object obj)
        {
            this.whitespace = "|";
            if (parentItem != null) this.whitespace += parentItem.whitespace;
            this.parentItem = parentItem;
            this.obj = obj;
            this.masterList = masterList;
            this.fpinfo = null;
            this.children = new List<InspectorInfo>();
            //this.inspectorArea = parentItem.inspectorArea;
            this.sidebar = parentItem.sidebar;
            this.showValueToString = parentItem.showValueToString;
            Type t = parentItem.obj.GetType();

            if (t.GetInterfaces()
                .Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IEnumerable<>)))
            {
                //Console.WriteLine("IEnumerable : {0}", obj.GetType());
                membertype = member_type.collectionentry;
                CheckItemType();
                prefix = "" + ((char)164);
            }
            else
            {
                System.Console.WriteLine("Unexpected: InspectorInfo with no obj reference was not a collection entry");
                membertype = member_type.unimplemented;
            }
        }
 //obj = null
 //a dictionary entry
 public InspectorInfo(IList<object> masterList, InspectorInfo parentItem, object obj, object key)
 {
     this.whitespace = "|";
     if (parentItem != null) this.whitespace += parentItem.whitespace;
     this.parentItem = parentItem;
     this.obj = obj;
     this.masterList = masterList;
     this.fpinfo = null;
     this.children = new List<InspectorInfo>();
     //this.inspectorArea = parentItem.inspectorArea;
     this.sidebar = parentItem.sidebar;
     this.showValueToString = parentItem.showValueToString;
     Type t = parentItem.obj.GetType();
     if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Dictionary<,>))
     {
         membertype = member_type.dictentry;
         this.key = key;
         CheckItemType();
         prefix = "" + ((char)164);
         //System.Console.WriteLine(this);
         //children = GenerateList(obj, whitespace, this);
     }
     else
     {
         System.Console.WriteLine("Unexpected: InspectorInfo with no obj reference was not a dictionary entry");
         membertype = member_type.unimplemented;
     }
 }
 //root item
 public InspectorInfo(IList<object> masterList, object obj, Sidebar sidebar, bool showValueToString = false)
 {
     this.showValueToString = showValueToString;
     this.whitespace = "|";
     this.obj = obj;
     this.masterList = masterList;
     //this.fpinfo = new FPInfo(propertyInfo);
     this.membertype = member_type.none;
     this.children = new List<InspectorInfo>();
     //this.inspectorArea = insArea;
     this.sidebar = sidebar;
     CheckItemType();
     prefix = "" + ((char)164);
     //System.Console.WriteLine(obj);
     //children = GenerateList(obj, whitespace, this);
 }
 private void FieldOrPropertyInitilize(IList<object> masterList, InspectorInfo parentItem, object obj)
 {
     this.whitespace = "|";
     if (parentItem != null) this.whitespace += parentItem.whitespace;
     this.obj = obj;
     this.parentItem = parentItem;
     this.masterList = masterList;
     this.children = new List<InspectorInfo>();
     this.showValueToString = parentItem.showValueToString;
     CheckItemType();
     prefix = "" + ((char)164);
     //this.inspectorArea = parentItem.inspectorArea;
     this.sidebar = parentItem.sidebar;
 }
        public LinkGeneratorWindow(Manager manager, Sidebar sidebar)
        {
            OrbIt game = OrbIt.game;
            UserInterface.GameInputDisabled = true;

            this.manager = manager;
            this.sidebar = sidebar;
            window = new Window(manager);
            window.Init();
            window.Left = OrbIt.ui.sidebar.master.Left;
            window.Width = OrbIt.ui.sidebar.master.Width;
            window.Top = 200;
            window.Height = 200;
            window.Text = "Link Generator";
            window.Closed += delegate { UserInterface.GameInputDisabled = false; };
            window.ShowModal();
            manager.Add(window);

            //LinkGenerator.ExpandedHeight += 30;
            HeightCounter3 = 0;
            int left = 0;
            int middle = 100;

            lblGenerateLink = new Label(manager);
            lblGenerateLink.Init();
            lblGenerateLink.Left = left + middle / 2;
            lblGenerateLink.Top = HeightCounter3; HeightCounter3 += lblGenerateLink.Height;
            lblGenerateLink.Text = "Generate Link";
            lblGenerateLink.Width += 40;
            lblGenerateLink.Parent = window;

            lblLinkType = new Label(manager);
            lblLinkType.Init();
            lblLinkType.Left = left;
            lblLinkType.Text = "Link Type";
            lblLinkType.Parent = window;
            lblLinkType.Top = HeightCounter3; HeightCounter3 += lblLinkType.Height;

            cbLinkType = new ComboBox(manager);
            cbLinkType.Init();
            cbLinkType.Left = left;
            cbLinkType.Width += 100;
            cbLinkType.Parent = window;
            cbLinkType.MaxItems = 15;
            cbLinkType.Top = HeightCounter3; HeightCounter3 += cbLinkType.Height;
            //cbLinkType.Items.AddRange(new List<object>() { });
            Link.GetILinkableEnumVals(cbLinkType.Items);

            /*
            foreach (comp key in Enum.GetValues(typeof(comp)))
            {
                Type compType = Game1.compTypes[key];

                if (!typeof(ILinkable).IsAssignableFrom(compType)) continue;

                cbLinkType.Items.Add(key);

                /*
                MethodInfo mInfo = compType.GetMethod("AffectOther");
                if (mInfo != null
                    && mInfo.DeclaringType == compType)
                {
                    cbLinkType.Items.Add(key);
                }
                //
            }
            */

            lblLinkFormation = new Label(manager);
            lblLinkFormation.Init();
            lblLinkFormation.Left = left;
            lblLinkFormation.Text = "Formation";
            lblLinkFormation.Parent = window;
            lblLinkFormation.Top = HeightCounter3; HeightCounter3 += lblLinkFormation.Height;

            cbLinkFormation = new ComboBox(manager);
            cbLinkFormation.Init();
            cbLinkFormation.Left = left;
            cbLinkFormation.Width += 20;
            cbLinkFormation.Parent = window;
            cbLinkFormation.Top = HeightCounter3; HeightCounter3 += cbLinkFormation.Height;

            foreach (formationtype f in Enum.GetValues(typeof(formationtype)))
            {
                cbLinkFormation.Items.Add(f);
            }
            cbLinkFormation.ItemIndex = 0;

            chkEntangled = new CheckBox(manager);
            chkEntangled.Init();
            chkEntangled.Left = left;
            chkEntangled.Width += 20;
            chkEntangled.Text = "Entangled";
            chkEntangled.Parent = window;
            chkEntangled.Top = HeightCounter3; HeightCounter3 += chkEntangled.Height;

            HeightCounter3 = lblGenerateLink.Height;

            lblLinkPresets = new Label(manager);
            lblLinkPresets.Init();
            lblLinkPresets.Left = left + middle;
            lblLinkPresets.Text = "Preset";
            lblLinkPresets.Parent = window;
            lblLinkPresets.Top = lblLinkFormation.Top;

            cbLinkPresets = new ComboBox(manager);
            cbLinkPresets.Init();
            cbLinkPresets.Left = left + middle;
            //cbLinkPresets.Width += 20;
            cbLinkPresets.Parent = window;
            cbLinkPresets.Top = cbLinkFormation.Top;

            cbLinkPresets.Items.Add("Default");
            cbLinkPresets.ItemIndex = 0;

            btnAddToPalette = new Button(manager);
            btnAddToPalette.Init();
            btnAddToPalette.Left = left + middle;
            btnAddToPalette.Width = middle - 20;
            btnAddToPalette.Text = "Add to\nPalette";
            btnAddToPalette.Height = btnAddToPalette.Height * 2 - 10;
            btnAddToPalette.Parent = window;
            btnAddToPalette.Top = chkEntangled.Top + chkEntangled.Height;
            btnAddToPalette.Click += btnAddToPalette_Click;
        }
 public InspectorView(Sidebar sidebar, Control parent, int Left, int Top, bool Init = true, int? Height = null)
     : base(sidebar, parent, Left, Top, Init, Height)
 {
     //backPanel.Height = 120;
     Setup(ItemCreatorDelegate, OnEvent);
 }