public void StepParsed(IPgnReader iParser) { if (iParser.State == Enums.PGNReaderState.Number) { _lastNumber = iParser.Value; } else if (iParser.State == Enums.PGNReaderState.White) { _tmpStep = new Step(); _tmpStep.Number = int.Parse(_lastNumber); _tmpStep.GameSide = Enums.GameSide.White; _tmpStep.Parse(iParser.Value); _tmpStepTree.Items.Add(_tmpStep); } else if (iParser.State == Enums.PGNReaderState.Black) { if (string.IsNullOrEmpty(iParser.Value)) { return; } _tmpStep = new Step(); _tmpStep.Number = int.Parse(_lastNumber); _tmpStep.GameSide = Enums.GameSide.Black; _tmpStep.Parse(iParser.Value); _tmpStepTree.Items.Add(_tmpStep); } }
public void EnterVariation(IPgnReader iParser) { _states.Push(_lastNumber); if (_tmpStep != null) { _tmpStep.Parent = (IChessItem)_tmpStepTree; _tmpStepTree = _tmpStep; if (_tmpStepTree.Items == null) { _tmpStepTree.Items = new Variation(); } //_tmpStepTree.Items.Add(_tmpStep); _tmpStep = null; } else { IStepTree tmpTree = null; int i = 1; while (!(_tmpStepTree.Items[_tmpStepTree.Items.Count - i] is IStepTree)) { i++; } tmpTree = (IStepTree)_tmpStepTree.Items[_tmpStepTree.Items.Count - i]; tmpTree.Parent = (IChessItem)_tmpStepTree; _tmpStepTree = tmpTree; } if (_tmpStepTree.Items == null) { _tmpStepTree.Items = new Steps(); } }
public void ExitVariation(IPgnReader iParser) { if (iParser.State != Enums.PGNReaderState.Number) { StepParsed(iParser); } _tmpStepTree = (IStepTree)_tmpStepTree.Parent; _lastNumber = (string)_states.Pop(); }
public void TagParsed(IPgnReader iParser) { try { ((Record)_tmpStepTree).Tags.Add(iParser.Tag, iParser.Value); } catch (RecordException e) { throw e; } }
public void NagParsed(IPgnReader iParser) { if (_tmpStep != null) { _tmpStepTree.Items.Add(_tmpStep); _tmpStep = null; } Nag nag = new Nag(iParser.Value); _tmpStepTree.Items.Add(nag); }
public void Finished(IPgnReader iParser) { _states = new Stack(); }
public void Starting(IPgnReader iParser) { }
public void ExitHeader(IPgnReader iParser) { }
public void NewGame(IPgnReader iParser) { _states = new Stack(); _tmpStepTree = new Record(); _ChessRecords.Add((Record)_tmpStepTree); }
public void EndMarker(IPgnReader iParser) { GameResult end = GameResult.Parse(iParser.Value); _tmpStepTree.Items.Add(end); }
public void CommentParsed(IPgnReader iParser) { _tmpComment = Annotation.Parse(iParser.Value); _tmpStepTree.Items.Add(_tmpComment); }