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);
        }
        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;
        }
        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();
                }
            };
        }