private void evoEngine_OnGenerationCompleted(int generation, int iteration, EResultGeneration resultGeneration) { this.InvokeEx( () => { slblEvent.Text = "On Generation Completed"; slblGenIter.Text = String.Format("GEN:{0} ITER:{1}", generation, iteration); drawPrograms(); } ); }
private void evoEngine_OnGenerationCompleted(int generation, int iteration, EResultGeneration resultGeneration) { this.InvokeEx( () => { if (cbOneEvent.Checked) { btnPause_Click(null, null); } lblGen.Text = generation.ToString(); lblIter.Text = iteration.ToString(); slblResultGeneration.Text = resultGeneration.ToShortString(); drawResultGeneration(resultGeneration); updateHistory(); //addReportMessage(String.Format("evoEngine_OnGenerationCompleted G:{0} I:{1}", generation, iteration)); } ); }
private void drawResultGeneration(EResultGeneration resultGeneration) { if (_evoEngine == null) { return; } Color colorGrid = SystemColors.Control; Brush brushBot = Brushes.Navy; Font fontBot = new Font(FontFamily.GenericSansSerif, 8.0F, FontStyle.Regular); Brush brushFont = Brushes.Red; Font fontBotH = new Font(FontFamily.GenericSansSerif, 10.0F, FontStyle.Regular); Brush brushFontH = Brushes.White; Font fontBotG = new Font(FontFamily.GenericSansSerif, 10.0F, FontStyle.Bold); Brush brushFontG = Brushes.Yellow; Graphics g = _pbResultGenerationBufferGraphics.Graphics; g.Clear(colorGrid); int sizeX = 48; int sizeY = 80; int padding = 24; for (int i = 0; i < resultGeneration.resultBots.Count; i++) { EResultGenerationBot resultBot = resultGeneration.resultBots[i]; int px = 3 + i * (sizeX + padding); int py = 3; if (i < ESetting.BOT_COUNT_MIN) { Brush bTrace = new SolidBrush(ESetting.TRACE_COLOR[i]); Rectangle rTrace = new Rectangle(px - 3, py - 3, sizeX + 6, sizeY + 6); g.FillRectangle(bTrace, rTrace); } Rectangle r = new Rectangle(px + 1, py + 1, sizeX - 2, sizeY - 2); g.FillRectangle(brushBot, r); g.DrawString(resultBot.generation.ToString(), fontBotG, brushFontG, px + 8, py + 8); g.DrawString(resultBot.health.ToString(), fontBotH, brushFontH, px + 16, py + 56); //g.DrawString("" + resultBot.program.index + " (" + resultBot.program.botCount + ")", fontBot, brushFont, px + 4, py + 32); g.DrawString(resultBot.checkSum, fontBot, brushFont, px + 4, py + 32); } //_pbResultGenerationBufferGraphics.Render(); _pbResultGenerationBufferGraphics.Render(pbResultGeneration.CreateGraphics()); return; }