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