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 void AddDrawBoxAsField(DrawBox drawBox, DrawBoxAlignment drawBoxAlignment) { container.AddDrawBox(drawBox); if (lastField.Count != 0) { drawBox.Y = Push.GetBottomSide(lastField.ToArray()) + VerticalMargin + extraVerticalMargin; } alignments.Add(drawBox, drawBoxAlignment); AddNewFieldList(); lastField.Add(drawBox); }
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() { Panel = new GridPanel(); Panel.Initialize(gridWidth, gridHeight); const int defaultRowWidth = 100; RowWidths = new int[gridWidth]; for (int n = 0; n < RowWidths.Length; n++) { RowWidths[n] = defaultRowWidth; } AddDrawBox(Panel); Panel.X = BorderMargin; Panel.Y = BorderMargin; Wrap(); Width += BorderMargin; Height += BorderMargin; Panel.Alignment = DrawBoxAlignment.GetEmpty(); CanResizeFormHorizontally = false; 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; var builder = new FieldBuilder(); builder.BuildSessionStart(this); var symmetricalBordersCheckBox = builder.AddCheckBoxField("Symmetrical Borders: "); symmetricalBordersCheckBox.Checked = sigmoid.SymmetricalBorders; builder.AddLabelField("P: "); var pMin = builder.AddDoubleField("Min: "); var pMax = builder.AddDoubleField("Max: "); var pVal = builder.AddDoubleField("Value: "); var pMutable = builder.AddCheckBoxField("IsMutable: "); builder.AddVerticalMargin(4); builder.AddLabelField("Output-Border: "); var o1Min = builder.AddDoubleField("Min: "); var o1Max = builder.AddDoubleField("Max: "); var o1Val = builder.AddDoubleField("Value: "); var o1Mutable = builder.AddCheckBoxField("IsMutable: "); var switchBox = new SwitchBox(); switchBox.Initialize(); builder.AddDrawBoxAsField(switchBox, DrawBoxAlignment.GetLeftRight()); var emptyPanel = new Panel(); emptyPanel.Initialize(); switchBox.AddDrawBox(emptyPanel, "symmetrical"); var panel = new Panel(); panel.Initialize(); var builder2 = new FieldBuilder(); builder2.BuildSessionStart(panel); builder2.AddLabelField("Output-Border 2: "); var o2Min = builder2.AddDoubleField("Min: "); var o2Max = builder2.AddDoubleField("Max: "); var o2Val = builder2.AddDoubleField("Value: "); var o2Mutable = builder2.AddCheckBoxField("IsMutable: "); builder2.BuildSessionEnd(); switchBox.AddDrawBox(panel, "non-symmetrical"); int largestHeight = 0; foreach (var p in switchBox.DrawBoxList) { if (p.Height > largestHeight) { largestHeight = panel.Height; } } switchBox.Width = builder.FieldWidth; switchBox.Height = largestHeight; if (sigmoid.GeneList.Count != 0) { var o1Gene = (DoubleGene)sigmoid.GeneList[0]; o1Min.Value = o1Gene.Min; o1Max.Value = o1Gene.Max; o1Val.Value = o1Gene.Value; o1Mutable.Checked = o1Gene.IsMutable; int n = 1; if (!sigmoid.SymmetricalBorders) { var o2Gene = (DoubleGene)sigmoid.GeneList[n++]; o2Min.Value = o2Gene.Min; o2Max.Value = o2Gene.Max; o2Val.Value = o2Gene.Value; o2Mutable.Checked = o2Gene.IsMutable; } var pGene = (DoubleGene)sigmoid.GeneList[n++]; pMin.Value = pGene.Min; pMax.Value = pGene.Max; pVal.Value = pGene.Value; pMutable.Checked = pGene.IsMutable; } if (sigmoid.SymmetricalBorders) { switchBox.SelectDrawBoxWithKey("symmetrical"); } else { switchBox.SelectDrawBoxWithKey("non-symmetrical"); } symmetricalBordersCheckBox.CheckedChanged += delegate(object sender, bool newValue) { if (newValue) { switchBox.SelectDrawBoxWithKey("symmetrical"); } else { switchBox.SelectDrawBoxWithKey("non-symmetrical"); } }; builder.AddResizableButtonField("OK", delegate(object sender) { Close(); }, FieldBuilder.ResizableButtonOrientation.Left); builder.BuildSessionEnd(); IsClosing += delegate(object sender) { geneList.Clear(); var _o1Gene = new DoubleGene(); _o1Gene.SetMinMaxValue(o1Min.Value, o1Max.Value, o1Val.Value); _o1Gene.IsMutable = o1Mutable.Checked; geneList.Add(_o1Gene); if (!symmetricalBordersCheckBox.Checked) { var _o2Gene = new DoubleGene(); _o2Gene.SetMinMaxValue(o2Min.Value, o2Max.Value, o2Val.Value); _o2Gene.IsMutable = pMutable.Checked; geneList.Add(_o2Gene); } var _pGene = new DoubleGene(); _pGene.SetMinMaxValue(pMin.Value, pMax.Value, pVal.Value); _pGene.IsMutable = pMutable.Checked; geneList.Add(_pGene); }; CanResizeFormVertically = false; X = (Parent.Width / 2) - (Width / 2); Y = (Parent.Height / 2) - (Height / 2); }
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); }
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); }