public override void AddedToContainer() { base.AddedToContainer(); CloseButtonOn = false; var builder = new FieldBuilder(); builder.BuildSessionStart(this); var nameField = builder.AddTextField("Name: "); nameField.Text = template.TemplateName; var genomeEditPanel = new GenomeEditPanel(); genomeEditPanel.Initialize(template.Genome); builder.AddDrawBoxAsField(genomeEditPanel, DrawBoxAlignment.GetFull()); builder.AddResizableButtonField("OK", delegate(object sender) { template.TemplateName = nameField.Text; Close(); }, FieldBuilder.ResizableButtonOrientation.Right); builder.BuildSessionEnd(); X = (Parent.Width / 2) - (Width / 2); Y = (Parent.Height / 2) - (Height / 2); CanResizeFormVertically = false; }
public static Func <bool> GUI_Edit(SingleSlotBox container, FitnessWorld world) { var builder = new FieldBuilder(); builder.BuildSessionStart(container); Panel panel = new Panel(); panel.Initialize(); builder.AddDrawBoxAsField(panel, DrawBoxAlignment.GetFull()); Func <bool> isReadyFunc = World.GUI_Edit(panel, world); var minFood = builder.AddIntegerField("Minimum Food: "); var minCreatures = builder.AddIntegerField("Minimum Creatures: "); builder.BuildSessionEnd(); container.IsClosing += delegate(object sender) { world.MinimumFood = (int)minFood.Value; world.MinimumCreatures = (int)minCreatures.Value; }; return(delegate() { return isReadyFunc(); }); }
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(); var builder = new FieldBuilder(); builder.BuildSessionStart(this); var templateNameTextField = builder.AddTextField("Template Name: "); templateNameTextField.Text = template.TemplateName; var panel = new Panel(); panel.Initialize(); builder.AddDrawBoxAsField(panel, DrawBoxAlignment.GetFull()); var guiMethod = template.Creature.GetType().GetMethod("GUI_Edit"); var isReadyFunc = (Func <bool>)guiMethod.Invoke(template.Creature, new object[] { panel }); panel.Width = builder.FieldWidth; Wrap(); var okButton = new ResizableButton(); okButton.Initialize(); AddDrawBox(okButton); okButton.Title = "OK"; okButton.FitToText(); okButton.X = builder.FieldWidth - okButton.Width; okButton.Y = Height + 5; okButton.Click += delegate(object sender) { if (isReadyFunc()) { template.TemplateName = templateNameTextField.Text; Close(); } else { AlertForm.ShowDialogue(Parent, null, "All fields have not been filled out."); } }; builder.BuildSessionEnd(); okButton.Alignment = DrawBoxAlignment.GetRightBottom(); X = (Parent.Width / 2) - (Width / 2); Y = (Parent.Height / 2) - (Height / 2); CanResizeFormVertically = true; }
public Panel AddTabPage(string name) { Panel panel = new Panel(); panel.Initialize(); AddTabPage(new TabPage(name, panel)); panel.Fill(); panel.Alignment = DrawBoxAlignment.GetFull(); return(panel); }
public override void AddedToContainer() { const int buttonMinSize = 50; selector = new FileSelector(); selector.Initialize(null, file); AddDrawBox(selector); selector.Width = 200; selector.Height = 100; cancelButton = new ResizableButton(); cancelButton.Initialize(null, file); AddDrawBox(cancelButton); cancelButton.Title = "Cancel"; cancelButton.FitToText(); cancelButton.Width = Math.Max(cancelButton.Width, buttonMinSize); cancelButton.X = 0; cancelButton.Y = selector.Height + 3; okButton = new ResizableButton(); okButton.Initialize(null, file); AddDrawBox(okButton); switch (OperationType) { case OperationTypes.Open: okButton.Title = "Open"; break; case OperationTypes.Save: okButton.Title = "Save"; break; case OperationTypes.Select: okButton.Title = "Select"; break; } okButton.FitToText(); okButton.Width = Math.Max(okButton.Width, buttonMinSize); okButton.X = selector.Width - cancelButton.Width; okButton.Y = selector.Height + 3; Wrap(); selector.Alignment = DrawBoxAlignment.GetFull(); okButton.Alignment = DrawBoxAlignment.GetRightBottom(); cancelButton.Alignment = DrawBoxAlignment.GetLeftBottom(); okButton.Click += new DefaultEvent(okButton_Click); cancelButton.Click += new DefaultEvent(cancelButton_Click); }
public override void AddedToContainer() { base.AddedToContainer(); CloseButtonOn = false; var builder = new FieldBuilder(); builder.BuildSessionStart(this); var templateNameTextField = builder.AddTextField("Template Name: "); templateNameTextField.Text = template.TemplateName; Panel panel = new Panel(); panel.Initialize(); builder.AddDrawBoxAsField(panel, DrawBoxAlignment.GetFull()); var isReadyFunc = (Func <bool>)template.World.GetType().InvokeMember("GUI_Edit", BindingFlags.Default | BindingFlags.InvokeMethod, null, null, new object[] { panel, template.World }); builder.AddResizableButtonField("OK", delegate(object sender) { if (isReadyFunc()) { template.TemplateName = templateNameTextField.Text; Close(); } else { AlertForm.ShowDialogue(Parent, null, "All fields have not been filled out."); } }, FieldBuilder.ResizableButtonOrientation.Left); builder.BuildSessionEnd(); X = (Parent.Width / 2) - (Width / 2); Y = (Parent.Height / 2) - (Height / 2); CanResizeFormVertically = false; }
public override void AddedToContainer() { leftSlot = AddNewSlot(); Panel leftPanel = new Panel(); leftPanel.Initialize(); PutDrawBoxInSlot(leftPanel, leftSlot); leftPanel.X = 0; leftPanel.Y = 0; leftPanel.Fill(); leftPanel.Alignment = DrawBoxAlignment.GetFull(); rightSlot = AddNewSlot(); Panel rightPanel = new Panel(); rightPanel.Initialize(); PutDrawBoxInSlot(rightPanel, rightSlot); rightPanel.X = 0; rightPanel.Y = 0; rightPanel.Fill(); rightPanel.Alignment = DrawBoxAlignment.GetFull(); }
public override void AddedToContainer() { topSlot = AddNewSlot(); Panel topPanel = new Panel(); topPanel.Initialize(); PutDrawBoxInSlot(topPanel, topSlot); topPanel.X = 0; topPanel.Y = 0; topPanel.Fill(); topPanel.Alignment = DrawBoxAlignment.GetFull(); bottomSlot = AddNewSlot(); Panel bottomPanel = new Panel(); bottomPanel.Initialize(); PutDrawBoxInSlot(bottomPanel, bottomSlot); bottomPanel.X = 0; bottomPanel.Y = 0; bottomPanel.Fill(); bottomPanel.Alignment = DrawBoxAlignment.GetFull(); }
public static Func <bool> GUI_Edit(SingleSlotBox container, FoodWorld world) { var builder = new FieldBuilder(); builder.BuildSessionStart(container); Panel panel = new Panel(); panel.Initialize(); builder.AddDrawBoxAsField(panel, DrawBoxAlignment.GetFull()); Func <bool> isReadyFunc = World.GUI_Edit(panel, world); var minFood = builder.AddIntegerField("Minimum Food: "); minFood.Value = world.MinimumFood; var foodSpawnRate = builder.AddIntegerField("Food Spawn-rate: "); foodSpawnRate.Value = world.FoodSpawnRate; builder.AddResizableButtonField("Edit Food", delegate(object sender) { EditEntityForm.ShowDialogue(container.Parent, world.FoodToClone); }, FieldBuilder.ResizableButtonOrientation.FillWidth); container.IsClosing += delegate(object sender) { world.MinimumFood = (int)minFood.Value; world.FoodSpawnRate = (int)foodSpawnRate.Value; }; builder.BuildSessionEnd(); return(delegate() { return isReadyFunc(); }); }
public override void AddedToContainer() { base.AddedToContainer(); CloseButtonOn = false; var builder = new FieldBuilder(); builder.BuildSessionStart(this); Panel panel = new Panel(); panel.Initialize(); builder.AddDrawBoxAsField(panel, DrawBoxAlignment.GetFull()); var guiMethod = ann.GetType().GetMethod("GUI_Edit"); var isReadyFunc = (Func <bool>)guiMethod.Invoke(ann, new object[] { panel }); builder.AddResizableButtonField("OK", delegate(object sender) { if (isReadyFunc()) { Close(); } else { AlertForm.ShowDialogue(Parent, null, "All fields have not been filled out."); } }, FieldBuilder.ResizableButtonOrientation.Left); builder.BuildSessionEnd(); X = (Parent.Width / 2) - (Width / 2); Y = (Parent.Height / 2) - (Height / 2); CanResizeFormVertically = false; }
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); }; }
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); }
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); }
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); }
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); }
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); }