Esempio n. 1
0
        void loadControls()
        {
            //if (editPanel != null)
            //    editPanel.Close();

            //editPanel = new Panel();
            //editPanel.Initialize();
            //editPanel.Y = startY;

            //AddDrawBox(editPanel);

            //var builder = new FieldBuilder();
            //builder.BuildSessionStart(editPanel);

            //var painterPanel = new Panel();
            //painterPanel.Initialize();
            //builder.AddDrawBoxAsField(painterPanel, DrawBoxAlignment.GetLeftRightBottom());

            //var isReadyFunc = Result.GUI_Edit(painterPanel);



            //builder.BuildSessionEnd();

            Wrap();

            editPanel.Alignment = DrawBoxAlignment.GetLeftRightBottom();
        }
Esempio n. 2
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            columnListBox = new ColumnListBox();
            columnListBox.Initialize(4);
            AddDrawBox(columnListBox);
            columnListBox.SetIntOrStringSort(false, true, true, true);
            columnListBox.SetColumnName(0, "Name");
            columnListBox.SetColumnName(1, "GeneID");
            columnListBox.SetColumnName(2, "Bias");
            columnListBox.SetColumnName(3, "Connections");
            columnListBox.Width  = 200;
            columnListBox.Height = 200;

            columnListBox.ItemDoubleClicked += delegate(object sender, TakaGUI.DrawBoxes.ColumnListBox.ListBoxRow item, int index)
            {
                T neuron = null;
                foreach (var n in neuronList)
                {
                    if (n.ID == (uint)item.ExtraValues[0])
                    {
                        neuron = n;
                    }
                }

                if (neuron != null)
                {
                    EditNeuronForm.ShowDialogue(Parent, neuron, delegate(object _sender)
                    {
                        ReloadListBox();
                    });
                }
            };

            ReloadListBox();

            var okButton = new ResizableButton();

            okButton.Initialize();
            AddDrawBox(okButton);
            okButton.Title = "OK";
            okButton.FitToText();
            Push.ToTheBottomSideOf(okButton, columnListBox, 3, Push.VerticalAlign.Left);
            okButton.Width  = 200;
            okButton.Click += delegate(object sender)
            {
                Close();
            };

            Wrap();

            columnListBox.Alignment = DrawBoxAlignment.GetFull();
            okButton.Alignment      = DrawBoxAlignment.GetLeftRightBottom();

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            CloseButtonOn = false;

            columnListBox = new ColumnListBox();
            columnListBox.Initialize(1);
            AddDrawBox(columnListBox);
            columnListBox.SetIntOrStringSort(false);
            columnListBox.SetColumnName(0, "Name");
            columnListBox.Width  = 200;
            columnListBox.Height = 200;

            columnListBox.ItemDoubleClicked += delegate(object sender, ColumnListBox.ListBoxRow item, int index)
            {
                GenomeTemplate template = null;
                foreach (var g in EditorData.GenomeTemplates)
                {
                    if (g.TemplateName == (string)item.Values[0])
                    {
                        template = g;
                    }
                }

                string oldName = template.TemplateName;
                EditGenomeTemplateForm.ShowDialogue(Parent, template, delegate(object _sender)
                {
                    foreach (var g in EditorData.GenomeTemplates)
                    {
                        if (g.TemplateName == template.TemplateName && g != template)
                        {
                            AlertForm.ShowDialogue(Parent, null, "There is a template with that name already.");
                            template.TemplateName = oldName;
                        }
                    }

                    ReloadListBox();
                });
            };

            ReloadListBox();

            var createTemplateButton = new ResizableButton();

            createTemplateButton.Initialize();
            AddDrawBox(createTemplateButton);
            createTemplateButton.Title = "Create New Template";
            createTemplateButton.FitToText();
            Push.ToTheBottomSideOf(createTemplateButton, columnListBox, 3, Push.VerticalAlign.Left);
            createTemplateButton.Width  = 200;
            createTemplateButton.Click += delegate(object sender)
            {
                var newTemplate = new GenomeTemplate();
                newTemplate.Genome = new EvoSim.Genes.Genome();

                EditGenomeTemplateForm.ShowDialogue(Parent, newTemplate, delegate(object _sender)
                {
                    bool alreadyExists = false;
                    foreach (var g in EditorData.GenomeTemplates)
                    {
                        if (g.TemplateName == newTemplate.TemplateName)
                        {
                            AlertForm.ShowDialogue(Parent, null, "There is a template with that name already.");
                            alreadyExists = true;
                        }
                    }

                    if (!alreadyExists)
                    {
                        EditorData.GenomeTemplates.Add(newTemplate);
                    }

                    ReloadListBox();
                });
            };

            var deleteTemplateButton = new ResizableButton();

            deleteTemplateButton.Initialize();
            AddDrawBox(deleteTemplateButton);
            deleteTemplateButton.Title = "Delete Template";
            deleteTemplateButton.FitToText();
            Push.ToTheBottomSideOf(deleteTemplateButton, createTemplateButton, 3, Push.VerticalAlign.Left);
            deleteTemplateButton.Width  = 200;
            deleteTemplateButton.Click += delegate(object sender)
            {
                if (columnListBox.SelectedRow != null)
                {
                    var findName = (string)columnListBox.SelectedRow.Values[0];

                    foreach (var g in EditorData.GenomeTemplates)
                    {
                        if (g.TemplateName == findName)
                        {
                            EditorData.GenomeTemplates.Remove(g);
                            ReloadListBox();
                            break;
                        }
                    }
                }
            };

            var editTemplateButton = new ResizableButton();

            editTemplateButton.Initialize();
            AddDrawBox(editTemplateButton);
            editTemplateButton.Title = "Edit Template";
            editTemplateButton.FitToText();
            Push.ToTheBottomSideOf(editTemplateButton, deleteTemplateButton, 3, Push.VerticalAlign.Left);
            editTemplateButton.Width  = 200;
            editTemplateButton.Click += delegate(object sender)
            {
                if (columnListBox.SelectedRow == null)
                {
                    return;
                }

                GenomeTemplate template = null;
                foreach (var g in EditorData.GenomeTemplates)
                {
                    if (g.TemplateName == (string)columnListBox.SelectedRow.Values[0])
                    {
                        template = g;
                    }
                }

                string oldName = template.TemplateName;
                EditGenomeTemplateForm.ShowDialogue(Parent, template, delegate(object _sender)
                {
                    foreach (var g in EditorData.GenomeTemplates)
                    {
                        if (g.TemplateName == template.TemplateName && g != template)
                        {
                            AlertForm.ShowDialogue(Parent, null, "There is a template with that name already.");
                            template.TemplateName = oldName;
                        }
                    }

                    ReloadListBox();
                });
            };

            var okButton = new ResizableButton();

            okButton.Initialize();
            AddDrawBox(okButton);
            okButton.Title = "OK";
            okButton.FitToText();
            Push.ToTheBottomSideOf(okButton, editTemplateButton, 3, Push.VerticalAlign.Left);
            okButton.Width  = 200;
            okButton.Click += delegate(object sender)
            {
                EditorData.Save(Globals.EditorDataSaveDir);
                Close();
            };

            Wrap();

            columnListBox.Alignment        = DrawBoxAlignment.GetFull();
            createTemplateButton.Alignment = DrawBoxAlignment.GetLeftRightBottom();
            deleteTemplateButton.Alignment = DrawBoxAlignment.GetLeftRightBottom();
            editTemplateButton.Alignment   = DrawBoxAlignment.GetLeftRightBottom();
            okButton.Alignment             = DrawBoxAlignment.GetLeftRightBottom();

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }
Esempio n. 4
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            CloseButtonOn = false;

            columnListBox = new ColumnListBox();
            columnListBox.Initialize(1);
            AddDrawBox(columnListBox);
            columnListBox.SetIntOrStringSort(false);
            columnListBox.SetColumnName(0, "Name");
            columnListBox.Width  = 200;
            columnListBox.Height = 200;

            columnListBox.ItemDoubleClicked += delegate(object sender, ColumnListBox.ListBoxRow item, int index)
            {
                SpawnPoint spawnPoint = null;
                foreach (var sp in spawnPointList)
                {
                    if (sp.Name == (string)item.Values[0])
                    {
                        spawnPoint = sp;
                    }
                }

                string oldName = spawnPoint.Name;
                EditSpawnPointForm.ShowDialogue(Parent, spawnPoint, delegate(object _sender)
                {
                    foreach (var sp in spawnPointList)
                    {
                        if (sp.Name == spawnPoint.Name && spawnPoint != sp)
                        {
                            AlertForm.ShowDialogue(Parent, null, "There is a spawnpoint with that name already.");
                            spawnPoint.Name = oldName;
                        }
                    }

                    ReloadListBox();
                });
            };

            ReloadListBox();

            var createTemplateButton = new ResizableButton();

            createTemplateButton.Initialize();
            AddDrawBox(createTemplateButton);
            createTemplateButton.Title = "Create New Spawnpoint";
            createTemplateButton.FitToText();
            Push.ToTheBottomSideOf(createTemplateButton, columnListBox, 3, Push.VerticalAlign.Left);
            createTemplateButton.Width  = 200;
            createTemplateButton.Click += delegate(object sender)
            {
                var spawnPoint = new SpawnPoint(world);
                EditSpawnPointForm.ShowDialogue(Parent, spawnPoint, delegate(object _sender)
                {
                    bool alreadyExists = false;
                    foreach (var sp in spawnPointList)
                    {
                        if (sp.Name == spawnPoint.Name && spawnPoint != sp)
                        {
                            alreadyExists = true;
                        }
                    }

                    if (alreadyExists)
                    {
                        AlertForm.ShowDialogue(Parent, null, "There is a spawnpoint with that name already.");
                    }
                    else
                    {
                        spawnPointList.Add(spawnPoint);
                    }

                    ReloadListBox();
                });
            };

            var deleteTemplateButton = new ResizableButton();

            deleteTemplateButton.Initialize();
            AddDrawBox(deleteTemplateButton);
            deleteTemplateButton.Title = "Delete Spawnpoint";
            deleteTemplateButton.FitToText();
            Push.ToTheBottomSideOf(deleteTemplateButton, createTemplateButton, 3, Push.VerticalAlign.Left);
            deleteTemplateButton.Width  = 200;
            deleteTemplateButton.Click += delegate(object sender)
            {
                if (columnListBox.SelectedRow != null)
                {
                    var findName = (string)columnListBox.SelectedRow.Values[0];

                    foreach (var t in EditorData.EntityTemplates)
                    {
                        if (t.TemplateName == findName)
                        {
                            EditorData.EntityTemplates.Remove(t);
                            ReloadListBox();
                            break;
                        }
                    }
                }
            };

            var editTemplateButton = new ResizableButton();

            editTemplateButton.Initialize();
            AddDrawBox(editTemplateButton);
            editTemplateButton.Title = "Edit Spawnpoint";
            editTemplateButton.FitToText();
            Push.ToTheBottomSideOf(editTemplateButton, deleteTemplateButton, 3, Push.VerticalAlign.Left);
            editTemplateButton.Width  = 200;
            editTemplateButton.Click += delegate(object sender)
            {
                if (columnListBox.SelectedRow == null)
                {
                    return;
                }

                SpawnPoint spawnPoint = null;
                foreach (var sp in spawnPointList)
                {
                    if (sp.Name == (string)columnListBox.SelectedRow.Values[0])
                    {
                        spawnPoint = sp;
                    }
                }

                string oldName = spawnPoint.Name;
                EditSpawnPointForm.ShowDialogue(Parent, spawnPoint, delegate(object _sender)
                {
                    foreach (var sp in spawnPointList)
                    {
                        if (sp.Name == spawnPoint.Name && spawnPoint != sp)
                        {
                            AlertForm.ShowDialogue(Parent, null, "There is a spawnpoint with that name already.");
                            spawnPoint.Name = oldName;
                        }
                    }

                    ReloadListBox();
                });
            };

            var okButton = new ResizableButton();

            okButton.Initialize();
            AddDrawBox(okButton);
            okButton.Title = "OK";
            okButton.FitToText();
            Push.ToTheBottomSideOf(okButton, editTemplateButton, 3, Push.VerticalAlign.Left);
            okButton.Width  = 200;
            okButton.Click += delegate(object sender)
            {
                Close();
            };

            Wrap();

            columnListBox.Alignment        = DrawBoxAlignment.GetFull();
            createTemplateButton.Alignment = DrawBoxAlignment.GetLeftRightBottom();
            deleteTemplateButton.Alignment = DrawBoxAlignment.GetLeftRightBottom();
            editTemplateButton.Alignment   = DrawBoxAlignment.GetLeftRightBottom();
            okButton.Alignment             = DrawBoxAlignment.GetLeftRightBottom();

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);

            IsClosing += delegate(object sender)
            {
                EditorData.Save(Globals.EditorDataSaveDir);
            };
        }
Esempio n. 5
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            columnListBox = new ColumnListBox();
            columnListBox.Initialize(4);
            AddDrawBox(columnListBox);
            columnListBox.SetIntOrStringSort(true, true, false, true);
            columnListBox.SetColumnName(0, "ID");
            columnListBox.SetColumnName(1, "Target");
            columnListBox.SetColumnName(2, "IsOutputConnection");
            columnListBox.SetColumnName(3, "Weight");
            columnListBox.Width  = 200;
            columnListBox.Height = 200;

            columnListBox.ItemDoubleClicked += delegate(object sender, TakaGUI.DrawBoxes.ColumnListBox.ListBoxRow item, int index)
            {
                RMP_ConnectionGene connectionGene = null;
                foreach (var gene in connections)
                {
                    if (gene.ID == (uint)item.Values[0])
                    {
                        connectionGene = gene;
                    }
                }

                if (connectionGene != null)
                {
                    EditConnectionGeneForm.ShowDialogue(Parent, connectionGene, delegate(object _sender)
                    {
                        ReloadListBox();
                    });
                }
            };

            ReloadListBox();

            var label = new Label("Connections To Add: ");

            label.Initialize();
            AddDrawBox(label);
            Push.ToTheBottomSideOf(label, columnListBox, 5, Push.VerticalAlign.Left);

            var connectionsToAddIntegerField = new IntegerField();

            connectionsToAddIntegerField.Initialize();
            AddDrawBox(connectionsToAddIntegerField);
            Push.ToTheRightSideOf(connectionsToAddIntegerField, label, 3, Push.HorizontalAlign.Top);
            connectionsToAddIntegerField.Width = 200 - connectionsToAddIntegerField.X;

            var generateConnectionsButton = new ResizableButton();

            generateConnectionsButton.Initialize();
            AddDrawBox(generateConnectionsButton);
            generateConnectionsButton.Title = "Generate Connections";
            generateConnectionsButton.FitToText();
            Push.ToTheBottomSideOf(generateConnectionsButton, label, 5, Push.VerticalAlign.Left);
            generateConnectionsButton.Width  = 200;
            generateConnectionsButton.Click += delegate(object sender)
            {
                GenerateConnections((int)connectionsToAddIntegerField.Value);
                ReloadListBox();
            };

            var okButton = new ResizableButton();

            okButton.Initialize();
            AddDrawBox(okButton);
            okButton.Title = "OK";
            okButton.FitToText();
            Push.ToTheBottomSideOf(okButton, generateConnectionsButton, 3, Push.VerticalAlign.Left);
            okButton.Width  = 200;
            okButton.Click += delegate(object sender)
            {
                Close();
            };

            Wrap();

            columnListBox.Alignment = DrawBoxAlignment.GetFull();
            label.Alignment         = DrawBoxAlignment.GetLeftBottom();
            connectionsToAddIntegerField.Alignment = DrawBoxAlignment.GetLeftRightBottom();
            generateConnectionsButton.Alignment    = DrawBoxAlignment.GetLeftRightBottom();
            okButton.Alignment = DrawBoxAlignment.GetLeftRightBottom();

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }
Esempio n. 6
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            columnListBox = new ColumnListBox();
            columnListBox.Initialize(5);
            AddDrawBox(columnListBox);
            columnListBox.SetIntOrStringSort(true, false, true, true, true);
            columnListBox.SetColumnName(0, "Order");
            columnListBox.SetColumnName(1, "Name");
            columnListBox.SetColumnName(2, "ID");
            columnListBox.SetColumnName(3, "Bias");
            columnListBox.SetColumnName(4, "Connections");
            columnListBox.Width  = 200;
            columnListBox.Height = 200;

            columnListBox.ItemDoubleClicked += delegate(object sender, TakaGUI.DrawBoxes.ColumnListBox.ListBoxRow item, int index)
            {
                RMP_NeuronGene neuronGene = null;
                foreach (var gene in neuronList)
                {
                    if (gene.ID == (uint)item.Values[2])
                    {
                        neuronGene = gene;
                    }
                }

                if (neuronGene != null)
                {
                    EditNeuronGeneForm.ShowDialogue(Parent, neuronGene, delegate(object _sender)
                    {
                        ReloadListBox();
                    });
                }
            };

            ReloadListBox();

            var label = new Label("Neurons To Add: ");

            label.Initialize();
            AddDrawBox(label);
            Push.ToTheBottomSideOf(label, columnListBox, 5, Push.VerticalAlign.Left);

            var neuronsToAddIntegerField = new IntegerField();

            neuronsToAddIntegerField.Initialize();
            AddDrawBox(neuronsToAddIntegerField);
            Push.ToTheRightSideOf(neuronsToAddIntegerField, label, 3, Push.HorizontalAlign.Top);
            neuronsToAddIntegerField.Width = 200 - neuronsToAddIntegerField.X;

            var generateNeuronsButton = new ResizableButton();

            generateNeuronsButton.Initialize();
            AddDrawBox(generateNeuronsButton);
            generateNeuronsButton.Title = "Generate Neurons";
            generateNeuronsButton.FitToText();
            Push.ToTheBottomSideOf(generateNeuronsButton, label, 5, Push.VerticalAlign.Left);
            generateNeuronsButton.Width  = 200;
            generateNeuronsButton.Click += delegate(object sender)
            {
                GenerateNeurons((int)neuronsToAddIntegerField.Value, neuronList);
                ReloadListBox();
            };

            var deleteNeuronsButton = new ResizableButton();

            deleteNeuronsButton.Initialize();
            AddDrawBox(deleteNeuronsButton);
            deleteNeuronsButton.Title = "Delete Neurons";
            deleteNeuronsButton.FitToText();
            Push.ToTheBottomSideOf(deleteNeuronsButton, generateNeuronsButton, 5, Push.VerticalAlign.Left);
            deleteNeuronsButton.Width  = 200;
            deleteNeuronsButton.Click += delegate(object sender)
            {
                if (columnListBox.SelectedRowIndex == -1)
                {
                    return;
                }

                uint searchId = (uint)columnListBox.Values[columnListBox.SelectedRowIndex].Values[2];

                foreach (var gene in neuronList)
                {
                    if (gene.ID == searchId)
                    {
                        neuronList.Remove(gene);
                        break;
                    }
                }

                ReloadListBox();
            };

            var moveUpButton = new ResizableButton();

            moveUpButton.Initialize();
            AddDrawBox(moveUpButton);
            moveUpButton.Title = "Move Up";
            moveUpButton.FitToText();
            Push.ToTheBottomSideOf(moveUpButton, deleteNeuronsButton, 3, Push.VerticalAlign.Left);
            moveUpButton.Width  = 200;
            moveUpButton.Click += delegate(object sender)
            {
                if (columnListBox.SelectedRowIndex < 1)
                {
                    return;
                }

                int index = columnListBox.SelectedRowIndex;

                var selected = neuronList[index];
                var upper    = neuronList[index - 1];
                neuronList[index - 1] = selected;
                neuronList[index]     = upper;

                ReloadListBox();

                columnListBox.SelectedRowIndex = index - 1;
            };

            var moveDownButton = new ResizableButton();

            moveDownButton.Initialize();
            AddDrawBox(moveDownButton);
            moveDownButton.Title = "Move Down";
            moveDownButton.FitToText();
            Push.ToTheBottomSideOf(moveDownButton, moveUpButton, 3, Push.VerticalAlign.Left);
            moveDownButton.Width  = 200;
            moveDownButton.Click += delegate(object sender)
            {
                if (columnListBox.SelectedRowIndex == -1 ||
                    columnListBox.SelectedRowIndex == columnListBox.Values.Count - 1)
                {
                    return;
                }

                int index = columnListBox.SelectedRowIndex;

                var selected = neuronList[index];
                var lower    = neuronList[index + 1];
                neuronList[index + 1] = selected;
                neuronList[index]     = lower;

                ReloadListBox();

                columnListBox.SelectedRowIndex = index + 1;
            };

            var okButton = new ResizableButton();

            okButton.Initialize();
            AddDrawBox(okButton);
            okButton.Title = "OK";
            okButton.FitToText();
            Push.ToTheBottomSideOf(okButton, moveDownButton, 3, Push.VerticalAlign.Left);
            okButton.Width  = 200;
            okButton.Click += delegate(object sender)
            {
                Close();
            };

            Wrap();

            columnListBox.Alignment            = DrawBoxAlignment.GetFull();
            label.Alignment                    = DrawBoxAlignment.GetLeftBottom();
            neuronsToAddIntegerField.Alignment = DrawBoxAlignment.GetLeftRightBottom();
            generateNeuronsButton.Alignment    = DrawBoxAlignment.GetLeftRightBottom();
            deleteNeuronsButton.Alignment      = DrawBoxAlignment.GetLeftRightBottom();
            moveUpButton.Alignment             = DrawBoxAlignment.GetLeftRightBottom();
            moveDownButton.Alignment           = DrawBoxAlignment.GetLeftRightBottom();
            okButton.Alignment                 = DrawBoxAlignment.GetLeftRightBottom();

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }
Esempio n. 7
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            CloseButtonOn = false;

            columnListBox = new ColumnListBox();
            columnListBox.Initialize(7);
            AddDrawBox(columnListBox);
            columnListBox.SetIntOrStringSort(true, false, true, true, true, true, false);
            columnListBox.SetColumnName(0, "Order");
            columnListBox.SetColumnName(1, "Name");
            columnListBox.SetColumnName(2, "ID");
            columnListBox.SetColumnName(3, "Value");
            columnListBox.SetColumnName(4, "Min");
            columnListBox.SetColumnName(5, "Max");
            columnListBox.SetColumnName(6, "IsMutable");
            columnListBox.Width  = 200;
            columnListBox.Height = 200;

            columnListBox.ItemDoubleClicked += delegate(object sender, ColumnListBox.ListBoxRow item, int index)
            {
                int n = 0;
                foreach (var g in geneList)
                {
                    if (g.ID == (uint)item.Values[2])
                    {
                        break;
                    }
                    n++;
                }

                EditDoubleGeneForm.ShowDialogue(Parent, geneList[n], delegate(object _sender)
                {
                    geneList[n] = ((EditDoubleGeneForm)_sender).Result;
                    ReloadListBox();
                });
            };

            ReloadListBox();

            var moveUpButton = new ResizableButton();

            moveUpButton.Initialize();
            AddDrawBox(moveUpButton);
            moveUpButton.Title = "Move Up";
            moveUpButton.FitToText();
            Push.ToTheBottomSideOf(moveUpButton, columnListBox, 3, Push.VerticalAlign.Left);
            moveUpButton.Width  = 200;
            moveUpButton.Click += delegate(object sender)
            {
                if (columnListBox.SelectedRowIndex < 1)
                {
                    return;
                }

                int index = columnListBox.SelectedRowIndex;

                var selected = geneList[index];
                var upper    = geneList[index - 1];
                geneList[index - 1] = selected;
                geneList[index]     = upper;

                ReloadListBox();

                columnListBox.SelectedRowIndex = index - 1;
            };

            var moveDownButton = new ResizableButton();

            moveDownButton.Initialize();
            AddDrawBox(moveDownButton);
            moveDownButton.Title = "Move Down";
            moveDownButton.FitToText();
            Push.ToTheBottomSideOf(moveDownButton, moveUpButton, 3, Push.VerticalAlign.Left);
            moveDownButton.Width  = 200;
            moveDownButton.Click += delegate(object sender)
            {
                if (columnListBox.SelectedRowIndex == -1 ||
                    columnListBox.SelectedRowIndex == columnListBox.Values.Count - 1)
                {
                    return;
                }

                int index = columnListBox.SelectedRowIndex;

                var selected = geneList[index];
                var lower    = geneList[index + 1];
                geneList[index + 1] = selected;
                geneList[index]     = lower;

                ReloadListBox();

                columnListBox.SelectedRowIndex = index + 1;
            };

            var createGeneButton = new ResizableButton();

            createGeneButton.Initialize();
            AddDrawBox(createGeneButton);
            createGeneButton.Title = "Create New Gene";
            createGeneButton.FitToText();
            Push.ToTheBottomSideOf(createGeneButton, moveDownButton, 3, Push.VerticalAlign.Left);
            createGeneButton.Width  = 200;
            createGeneButton.Click += delegate(object sender)
            {
                var dGene = new DoubleGene();
                dGene.SetMinMaxValue(0, 1, 0);
                dGene.IsMutable = true;

                EditDoubleGeneForm.ShowDialogue(Parent, dGene, delegate(object _sender)
                {
                    geneList.Add(((EditDoubleGeneForm)_sender).Result);
                    ReloadListBox();
                });
            };

            var deleteGeneButton = new ResizableButton();

            deleteGeneButton.Initialize();
            AddDrawBox(deleteGeneButton);
            deleteGeneButton.Title = "Delete Gene";
            deleteGeneButton.FitToText();
            Push.ToTheBottomSideOf(deleteGeneButton, createGeneButton, 3, Push.VerticalAlign.Left);
            deleteGeneButton.Width  = 200;
            deleteGeneButton.Click += delegate(object sender)
            {
                if (columnListBox.SelectedRow != null)
                {
                    var findID = (uint)columnListBox.SelectedRow.Values[2];

                    int n = 0;
                    foreach (var g in geneList)
                    {
                        if (g.ID == findID)
                        {
                            geneList.RemoveAt(n);
                            ReloadListBox();
                            break;
                        }
                        n++;
                    }
                }
            };

            var okButton = new ResizableButton();

            okButton.Initialize();
            AddDrawBox(okButton);
            okButton.Title = "OK";
            okButton.FitToText();
            Push.ToTheBottomSideOf(okButton, deleteGeneButton, 3, Push.VerticalAlign.Left);
            okButton.Width  = 200;
            okButton.Click += delegate(object sender)
            {
                Close();
            };

            Wrap();

            columnListBox.Alignment    = DrawBoxAlignment.GetFull();
            moveUpButton.Alignment     = DrawBoxAlignment.GetLeftRightBottom();
            moveDownButton.Alignment   = DrawBoxAlignment.GetLeftRightBottom();
            createGeneButton.Alignment = DrawBoxAlignment.GetLeftRightBottom();
            deleteGeneButton.Alignment = DrawBoxAlignment.GetLeftRightBottom();
            okButton.Alignment         = DrawBoxAlignment.GetLeftRightBottom();

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }
Esempio n. 8
0
        protected virtual ColumnListBox GUI_Edit_AddColumnListBox(SingleSlotBox container)
        {
            var columnListBox = new ColumnListBox();

            columnListBox.Initialize(2);
            container.AddDrawBox(columnListBox);
            columnListBox.SetIntOrStringSort(false, false);
            columnListBox.SetColumnName(0, "Name");
            columnListBox.SetColumnName(1, "Value");
            columnListBox.Width  = 200;
            columnListBox.Height = 200;

            GUI_Edit_SetColumnListBox(columnListBox);

            columnListBox.ItemDoubleClicked += delegate(object sender, ColumnListBox.ListBoxRow item, int index)
            {
                var valType = columnListBox.SelectedRow.Values[1].GetType();

                if (valType.IsEquivalentTo(typeof(int)))
                {
                    EditIntForm.ShowDialogue(container.Parent, (int)columnListBox.SelectedRow.Values[1], delegate(object _sender)
                    {
                        columnListBox.SelectedRow.Values[1] = ((EditIntForm)_sender).Result;
                    });
                }
                else if (valType.IsEquivalentTo(typeof(byte)))
                {
                    EditByteForm.ShowDialogue(container.Parent, (byte)columnListBox.SelectedRow.Values[1], delegate(object _sender)
                    {
                        columnListBox.SelectedRow.Values[1] = ((EditByteForm)_sender).Result;
                    });
                }
                else if (valType.IsEquivalentTo(typeof(double)))
                {
                    EditDoubleForm.ShowDialogue(container.Parent, (double)columnListBox.SelectedRow.Values[1], delegate(object _sender)
                    {
                        columnListBox.SelectedRow.Values[1] = ((EditDoubleForm)_sender).Result;
                    });
                }
                else if (valType.IsEquivalentTo(typeof(bool)))
                {
                    EditBoolForm.ShowDialogue(container.Parent, (bool)columnListBox.SelectedRow.Values[1], delegate(object _sender)
                    {
                        columnListBox.SelectedRow.Values[1] = ((EditBoolForm)_sender).Result;
                    });
                }
            };

            var editFieldButton = new ResizableButton();

            editFieldButton.Initialize();
            container.AddDrawBox(editFieldButton);
            editFieldButton.Title = "Edit Field";
            editFieldButton.FitToText();
            Push.ToTheBottomSideOf(editFieldButton, columnListBox, 3, Push.VerticalAlign.Left);
            editFieldButton.Width  = 200;
            editFieldButton.Click += delegate(object sender)
            {
                var valType = columnListBox.SelectedRow.Values[1].GetType();

                if (valType.IsEquivalentTo(typeof(int)))
                {
                    EditIntForm.ShowDialogue(container.Parent, (int)columnListBox.SelectedRow.Values[1], delegate(object _sender)
                    {
                        columnListBox.SelectedRow.Values[1] = ((EditIntForm)_sender).Result;
                    });
                }
                else if (valType.IsEquivalentTo(typeof(byte)))
                {
                    EditByteForm.ShowDialogue(container.Parent, (byte)columnListBox.SelectedRow.Values[1], delegate(object _sender)
                    {
                        columnListBox.SelectedRow.Values[1] = ((EditByteForm)_sender).Result;
                    });
                }
                else if (valType.IsEquivalentTo(typeof(double)))
                {
                    EditDoubleForm.ShowDialogue(container.Parent, (double)columnListBox.SelectedRow.Values[1], delegate(object _sender)
                    {
                        columnListBox.SelectedRow.Values[1] = ((EditDoubleForm)_sender).Result;
                    });
                }
                else if (valType.IsEquivalentTo(typeof(bool)))
                {
                    EditBoolForm.ShowDialogue(container.Parent, (bool)columnListBox.SelectedRow.Values[1], delegate(object _sender)
                    {
                        columnListBox.SelectedRow.Values[1] = ((EditBoolForm)_sender).Result;
                    });
                }
            };

            container.Wrap();

            columnListBox.Alignment   = DrawBoxAlignment.GetFull();
            editFieldButton.Alignment = DrawBoxAlignment.GetLeftRightBottom();

            container.IsClosing += delegate(object sender)
            {
                GUI_Edit_SetValues(columnListBox);
            };

            return(columnListBox);
        }