private void listBox1_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index < 0) { return; } string name = listBox1.Items[e.Index].ToString(); CEngine eng = FormChess.engineList.GetEngine(name); bool selected = (e.State & DrawItemState.Selected) == DrawItemState.Selected; Brush b = Brushes.Black; if (selected) { e = new DrawItemEventArgs(e.Graphics, e.Font, e.Bounds, e.Index, e.State ^ DrawItemState.Selected, CBoard.colorMessage, CBoard.colorChartD); b = Brushes.White; } else if (!eng.FileExists()) { e = new DrawItemEventArgs(e.Graphics, e.Font, e.Bounds, e.Index, e.State, Color.White, CBoard.colorRed); b = Brushes.White; } else if (eng.tournament > 0) { e = new DrawItemEventArgs(e.Graphics, e.Font, e.Bounds, e.Index, e.State, Color.Black, CBoard.colorMessage); } e.DrawBackground(); e.Graphics.DrawString(name, e.Font, b, e.Bounds, StringFormat.GenericDefault); e.DrawFocusRectangle(); }
public void AutoUpdate() { foreach (string fn in CData.fileEngineUci) { string name = Path.GetFileNameWithoutExtension(fn); string file = $@"Uci\{fn}"; CEngine engine = GetEngineByFile(file); if (engine == null) { engine = GetEngine(name); if (engine == null) { engine = new CEngine(name); engine.protocol = CProtocol.uci; list.Add(engine); } engine.file = file; engine.SaveToIni(); } } foreach (string fn in CData.fileEngineWb) { string name = Path.GetFileNameWithoutExtension(fn); string file = $@"Winboard\{fn}"; CEngine engine = GetEngineByFile(file); if (engine == null) { engine = GetEngine(name); if (engine == null) { engine = new CEngine(name); engine.protocol = CProtocol.winboard; list.Add(engine); } engine.file = file; engine.SaveToIni(); } } for (int n = list.Count - 1; n >= 0; n--) { CEngine e = list[n]; if (e.IsAuto() && !e.FileExists()) { DeleteEngine(e.name); } } }
void SelectEngine() { optionList.list.Clear(); Uciok(); tbEngineName.Text = engine.name; tbParameters.Text = engine.parameters; cbFileList.Text = engine.GetFile(); cbProtocol.Text = CData.ProtocolToStr(engine.protocol); cbModeStandard.Checked = engine.modeStandard; nudElo.Value = Convert.ToInt32(engine.elo); nudTournament.Value = engine.tournament; if ((engine.protocol == CProtocol.uci) && engine.FileExists()) { if (process.SetProgram($@"{AppDomain.CurrentDomain.BaseDirectory}Engines\{engine.file}", engine.parameters) > 0) { process.WriteLine("uci"); } } }