示例#1
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);
        }
示例#2
0
文件: Entity.cs 项目: lukastk/EvoSim
 protected virtual void GUI_Edit_SetColumnListBox(ColumnListBox listBox)
 {
     listBox.AddRow("PositionX", Position.X);
     listBox.AddRow("PositionY", Position.Y);
     listBox.AddRow("Rotation", Rotation);
     listBox.AddRow("EntityColorR", EntityColor.R);
     listBox.AddRow("EntityColorG", EntityColor.G);
     listBox.AddRow("EntityColorB", EntityColor.B);
     listBox.AddRow("Radius", Radius);
     listBox.AddRow("Age", Age);
 }
示例#3
0
        private void DialogOKButton_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < ColumnListBox.Items.Count; i++)
            {
                ColumnDefinition colDef = (ColumnDefinition)ColumnListBox.Items[i];
                colDef.Visble = ColumnListBox.GetItemChecked(i);
                colDef.Order  = i;
            }

            columnDefList.Sort();
        }
示例#4
0
        protected override void GUI_Edit_SetValues(ColumnListBox listBox)
        {
            base.GUI_Edit_SetValues(listBox);

            Dictionary <string, object> values = new Dictionary <string, object>();

            foreach (var row in listBox.Values)
            {
                values.Add((string)row.Values[0], row.Values[1]);
            }

            EnergyStorage = (double)values["EnergyStorage"];
        }
示例#5
0
        private void ShowColumnList()
        {
            ColumnListBox.Items.Clear();

            columnDefList.Sort();

            foreach (ColumnDefinition colDef in columnDefList)
            {
                ColumnListBox.Items.Add(colDef);

                int index = ColumnListBox.Items.IndexOf(colDef);
                ColumnListBox.SetItemChecked(index, colDef.Visble);
            }
        }
示例#6
0
        private void GenerateForeignButton_Click(object sender, EventArgs e)
        {
            string table1  = TablesList1.GetItemText(TablesList1.SelectedItem);
            string table2  = TablesList2.GetItemText(TablesList2.SelectedItem);
            string column1 = ColumnListBox.GetItemText(ColumnListBox.SelectedItem);
            string column2 = ColumnListBox2.GetItemText(ColumnListBox2.SelectedItem);

            saveFileDialog1.Filter           = "Text file (*.txt)|*.txt|All files (*.*)|*.*|Structured Query Language file (*.sql)|*.sql";
            saveFileDialog1.FilterIndex      = 2;
            saveFileDialog1.RestoreDirectory = true;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                System.IO.File.AppendAllText(saveFileDialog1.FileName, Environment.NewLine + Environment.NewLine + "if not exists(select 1 from sysobjects where name='" + table2 +
                                             ")' \n alter table " + table1 + " add constraint " + table2 + " foreign key (" + column1 + ") references " + column2);
            }
        }
示例#7
0
        public ColumnListBox AddColumnListBox(string labelText, int width, int height, int columns)
        {
            if (labelText != null)
            {
                AddLabelField(labelText);
            }

            var listBox = new ColumnListBox();

            listBox.Initialize(columns);
            AddDrawBoxAsField(listBox, new DrawBoxAlignment(AlignTop, AlignBottom, true, true));
            listBox.Width  = width;
            listBox.Height = height;

            return(listBox);
        }
示例#8
0
        protected override void GUI_Edit_SetValues(ColumnListBox listBox)
        {
            base.GUI_Edit_SetValues(listBox);

            Dictionary <string, object> values = new Dictionary <string, object>();

            foreach (var row in listBox.Values)
            {
                values.Add((string)row.Values[0], row.Values[1]);
            }

            EyeNeuronsAmount = (int)values["EyeNeuronsAmount"];
            EyeSpan          = (double)values["EyeSpan"];
            ViewDistance     = (int)values["ViewDistance"];
            Speed            = (double)values["Speed"];
            RotationSpeed    = (double)values["RotationSpeed"];
            energy.Min       = (double)values["EnergyMin"];
            energy.Max       = (double)values["EnergyMax"];
            energy.Value     = (double)values["EnergyValue"];

            CanSeeCreatures = (bool)values["CanSeeCreatures"];

            EnergyLossByTick     = (double)values["EnergyLossByTick"];
            EnergyLossByRotation = (double)values["EnergyLossByRotation"];
            EnergyLossByMove     = (double)values["EnergyLossByMove"];
            EnergyLossByEating   = (double)values["EnergyLossByEating"];
            EnergyLossByMating   = (double)values["EnergyLossByMating"];
            EatingBiteSize       = (double)values["EatingBiteSize"];

            CyclesNeededForMating       = (int)values["CyclesNeededForMating"];
            MatingCooldown              = (int)values["MatingCooldown"];
            AttackingCooldownCyclesLeft = (int)values["AttackingCooldownCyclesLeft"];
            AttackingCooldown           = (int)values["AttackingCooldown"];
            AttackMultiplier            = (double)values["AttackMultiplier"];

            MaxAge = (int)values["MaxAge"];

            LoseEnergy       = (bool)values["LoseEnergy"];
            IsThinking       = (bool)values["IsThinking"];
            DisableMating    = (bool)values["DisableMating"];
            DisableAttacking = (bool)values["DisableAttacking"];

            AlwaysMate = (bool)values["AlwaysMate"];
            AlwaysEat  = (bool)values["AlwaysEat"];
        }
示例#9
0
        protected override void GUI_Edit_SetColumnListBox(ColumnListBox listBox)
        {
            base.GUI_Edit_SetColumnListBox(listBox);

            listBox.AddRow("EyeNeuronsAmount", EyeNeuronsAmount);
            listBox.AddRow("EyeSpan", EyeSpan);
            listBox.AddRow("ViewDistance", ViewDistance);
            listBox.AddRow("Speed", Speed);
            listBox.AddRow("RotationSpeed", RotationSpeed);
            listBox.AddRow("EnergyMin", Energy.Min);
            listBox.AddRow("EnergyMax", Energy.Max);
            listBox.AddRow("EnergyValue", Energy.Value);

            listBox.AddRow("CanSeeCreatures", CanSeeCreatures);

            listBox.AddRow("EnergyLossByTick", EnergyLossByTick);
            listBox.AddRow("EnergyLossByRotation", EnergyLossByRotation);
            listBox.AddRow("EnergyLossByMove", EnergyLossByMove);
            listBox.AddRow("EnergyLossByEating", EnergyLossByEating);
            listBox.AddRow("EnergyLossByMating", EnergyLossByMating);
            listBox.AddRow("EatingBiteSize", EatingBiteSize);

            listBox.AddRow("CyclesNeededForMating", CyclesNeededForMating);
            listBox.AddRow("MatingCooldown", MatingCooldown);
            listBox.AddRow("AttackingCooldownCyclesLeft", AttackingCooldownCyclesLeft);
            listBox.AddRow("AttackingCooldown", AttackingCooldown);
            listBox.AddRow("AttackMultiplier", AttackMultiplier);

            listBox.AddRow("MaxAge", MaxAge);

            //listBox.AddRow("PixelsRotatedLeft", PixelsRotatedLeft);
            //listBox.AddRow("PixelsRotatedRight", PixelsRotatedRight);
            //listBox.AddRow("PixelsMovedForwards", PixelsMovedForwards);
            //listBox.AddRow("PixelsMovedBackwards", PixelsMovedBackwards);
            //listBox.AddRow("TimesHaveEaten", TimesHaveEaten);
            //listBox.AddRow("TimesMated", TimesMated);

            listBox.AddRow("LoseEnergy", LoseEnergy);
            listBox.AddRow("IsThinking", IsThinking);
            listBox.AddRow("DisableMating", DisableMating);
            listBox.AddRow("DisableAttacking", DisableAttacking);

            listBox.AddRow("AlwaysMate", AlwaysMate);
            listBox.AddRow("AlwaysEat", AlwaysEat);
        }
示例#10
0
文件: Entity.cs 项目: lukastk/EvoSim
        protected virtual void GUI_Edit_SetValues(ColumnListBox listBox)
        {
            Dictionary <string, object> values = new Dictionary <string, object>();

            foreach (var row in listBox.Values)
            {
                values.Add((string)row.Values[0], row.Values[1]);
            }

            Position = new EntityPosition((double)values["PositionX"], (double)values["PositionY"]);
            Rotation = (double)values["Rotation"];
            var entityColor = new Color();

            entityColor.R = (byte)values["EntityColorR"];
            entityColor.G = (byte)values["EntityColorG"];
            entityColor.B = (byte)values["EntityColorB"];
            EntityColor   = entityColor;
            Radius        = (int)values["Radius"];
            Age           = (int)values["Age"];
        }
示例#11
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);
            };
        }
示例#12
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);
        }
示例#13
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);
        }
示例#14
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            var builder = new FieldBuilder();

            builder.BuildSessionStart(this);

            var painterTypesComboBox = builder.AddComboBoxField("Painter-type: ");
            var painterTypes         = Globals.GetAllTypesDeriving(typeof(IEntityPainter), Assembly.GetExecutingAssembly());

            painterTypesComboBox.Items.AddRange(painterTypes.Select(s => s.Name));

            painterTypesComboBox.SelectedItemChanged += delegate(object sender, int newItemIndex, int oldItemIndex)
            {
                if (painterTypesComboBox.Index == -1)
                {
                    return;
                }

                Result = (IEntityPainter)Activator.CreateInstance(painterTypes[painterTypesComboBox.Index]);

                //loadControls();
            };

            builder.AlignTop    = true;
            builder.AlignBottom = true;
            entitiesToDraw      = builder.AddColumnListBox("Entity-types to draw:", 200, 2);
            entitiesToDraw.SetColumnName(0, "Type-name");
            entitiesToDraw.SetColumnName(1, "State");
            entitiesToDraw.SetIntOrStringSort(false, false);

            builder.AlignTop    = false;
            builder.AlignBottom = true;

            var entityTypesComboBox = builder.AddComboBoxField("Entity-type: ");
            var entityTypes         = Globals.GetAllTypesDeriving(typeof(IEntity), Assembly.GetExecutingAssembly(), true);

            entityTypesComboBox.Items.AddRange(entityTypes.Select(s => s.Name));

            var addEntityButton = builder.AddResizableButtonField("Add Entity", delegate(object sender)
            {
                if (entityTypesComboBox.Index == -1)
                {
                    return;
                }

                Result.EntityTypeList.Add(entityTypes[entityTypesComboBox.Index]);
                reloadList();
            }, FieldBuilder.ResizableButtonOrientation.FillWidth);

            var okButton = builder.AddResizableButtonField("OK", delegate(object sender)
            {
                Close();
            }, FieldBuilder.ResizableButtonOrientation.Right);

            builder.BuildSessionEnd();

            startY = Height;

            painterTypesComboBox.Index = 0;

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

            CanResizeFormVertically = true;
        }
示例#15
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);
        }
示例#16
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            var builder = new FieldBuilder();

            builder.BuildSessionStart(this);

            var nameField = builder.AddTextField("Name: ");

            nameField.Text = spawnPoint.Name;

            var posX = builder.AddDoubleField("Position X: ");

            posX.Value = spawnPoint.SpawnArea.X;

            var posY = builder.AddDoubleField("Position Y: ");

            posY.Value = spawnPoint.SpawnArea.Y;

            var width = builder.AddIntegerField("Width: ");

            width.Value = spawnPoint.SpawnArea.Width;

            var height = builder.AddIntegerField("Height: ");

            height.Value = spawnPoint.SpawnArea.Height;

            var timeInterval = builder.AddDoubleField("Time Interval: ");

            timeInterval.Value = spawnPoint.TimeInterval;

            reloadValues = delegate()
            {
                nameField.Text     = spawnPoint.Name;
                posX.Value         = spawnPoint.SpawnArea.X;
                posY.Value         = spawnPoint.SpawnArea.Y;
                width.Value        = spawnPoint.SpawnArea.Width;
                height.Value       = spawnPoint.SpawnArea.Height;
                timeInterval.Value = spawnPoint.TimeInterval;
            };

            reloadValues();

            Action setValues = delegate()
            {
                spawnPoint.Name = nameField.Text;

                spawnPoint.SpawnArea.X      = (int)posX.Value;
                spawnPoint.SpawnArea.Y      = (int)posY.Value;
                spawnPoint.SpawnArea.Width  = (int)width.Value;
                spawnPoint.SpawnArea.Height = (int)height.Value;

                spawnPoint.SetTimeInterval(timeInterval.Value);
            };

            builder.AddVerticalMargin(5);

            builder.AddResizableButtonField("Set Spawn-Area with mouse", delegate(object sender)
            {
                setValues();

                Parent.DialoguesAreHidden = true;

                Globals.Editor.Mode = Editor.Modes.SetPeremiter;
                Globals.Editor.Set_SendPeremiterFunction(sendPeremiter);
            }, FieldBuilder.ResizableButtonOrientation.FillWidth);

            builder.AlignTop    = true;
            builder.AlignBottom = true;

            spawnEntitiesList = builder.AddColumnListBox("Spawn-entities", 300, 2);
            spawnEntitiesList.SetIntOrStringSort(false, true);
            spawnEntitiesList.SetColumnName(0, "Entity-Type");
            spawnEntitiesList.SetColumnName(1, "Amount");

            builder.AlignTop    = false;
            builder.AlignBottom = true;

            builder.AddResizableButtonField("Add Entity", delegate(object sender)
            {
                AddSpawnEntityForm.ShowDialogue(Parent, spawnPoint, delegate(object _sender)
                {
                    reloadList();
                });
            }, FieldBuilder.ResizableButtonOrientation.Right);

            builder.AddResizableButtonField("Remove Entity", delegate(object sender)
            {
                if (spawnEntitiesList.SelectedRowIndex == -1)
                {
                    return;
                }

                spawnPoint.SpawnClones.Remove((IEntity)spawnEntitiesList.Values[spawnEntitiesList.SelectedRowIndex].ExtraValues[0]);
                reloadValues();
            }, FieldBuilder.ResizableButtonOrientation.Right);

            builder.AddResizableButtonField("OK", delegate(object sender)
            {
                setValues();
                Close();
            }, FieldBuilder.ResizableButtonOrientation.Right);

            builder.BuildSessionEnd();

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

            CanResizeFormVertically = false;
        }
示例#17
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            leftPanel = new Panel();
            leftPanel.Initialize();
            AddDrawBox(leftPanel);

            rightPanel = new Panel();
            rightPanel.Initialize();
            AddDrawBox(rightPanel);

            var builder = new FieldBuilder();

            builder.BuildSessionStart(leftPanel);

            entitiesWithPainters = builder.AddColumnListBox("Entities being drawn:", 400, 2);
            entitiesWithPainters.SetColumnName(0, "Entity-Type");
            entitiesWithPainters.SetColumnName(1, "Painter-Type");

            builder.BuildSessionEnd();

            builder.BuildSessionStart(rightPanel);

            entityPainters = builder.AddColumnListBox("Entity-painters:", 400, 1);
            entityPainters.SetColumnName(0, "Painter-Type");

            builder.AddResizableButtonField("Add Painter", delegate(object sender)
            {
                AddEntityPainterForm.ShowDialogue(Parent, simulation, delegate(object _sender)
                {
                    var form = (AddEntityPainterForm)_sender;

                    form.Result.Initialize(DrawBox.DefaultSkinFile);
                    simulation.EntityPainters.Add(form.Result);

                    reloadEntitiesWithPaintersList();
                    reloadPainterList();
                });
            }, FieldBuilder.ResizableButtonOrientation.FillWidth);

            builder.AddResizableButtonField("Remove Painter", delegate(object sender)
            {
                if (entityPainters.SelectedRow != null)
                {
                    simulation.EntityPainters.Remove((IEntityPainter)entityPainters.SelectedRow.ExtraValues[0]);
                    reloadEntitiesWithPaintersList();
                    reloadPainterList();
                }
            }, FieldBuilder.ResizableButtonOrientation.FillWidth);

            builder.BuildSessionEnd();

            leftPanel.Width  = Math.Max(leftPanel.Width, rightPanel.Width);
            leftPanel.Height = Math.Max(leftPanel.Height, rightPanel.Height);

            rightPanel.X      = leftPanel.Width + panelMargin;
            rightPanel.Width  = Math.Max(leftPanel.Width, rightPanel.Width);
            rightPanel.Height = Math.Max(leftPanel.Height, rightPanel.Height);

            Wrap();

            reloadEntitiesWithPaintersList();
            reloadPainterList();

            leftPanel.Alignment  = DrawBoxAlignment.GetTopBottom();
            rightPanel.Alignment = DrawBoxAlignment.GetTopBottom();

            SizeChanged += new SizeChangedEvent(EntityDrawingOptionsForm_SizeChanged);

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }
示例#18
0
        protected override void GUI_Edit_SetColumnListBox(ColumnListBox listBox)
        {
            base.GUI_Edit_SetColumnListBox(listBox);

            listBox.AddRow("EnergyStorage", EnergyStorage);
        }
示例#19
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)
            {
                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);
        }
示例#20
0
文件: Entity.cs 项目: lukastk/EvoSim
        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);
        }