/// <summary> /// Constructor /// </summary> /// <param name="move"> Move position</param> public MoveSelectedEventArgs(ChessBoard.MovePosS move) { Move = move; }
/// <summary> /// Deserialize from XML /// </summary> /// <param name="reader"> XML reader</param> void IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { ChessBoard.MovePosS movePos; bool bIsEmpty; m_listMovePos.Clear(); if (reader.MoveToContent() != XmlNodeType.Element || reader.LocalName != "MoveList") { throw new SerializationException("Unknown format"); } else { bIsEmpty = reader.IsEmptyElement; m_iPosInList = Int32.Parse(reader.GetAttribute("PositionInList")); if (bIsEmpty) { reader.Read(); } else { if (reader.ReadToDescendant("Move")) { while (reader.IsStartElement()) { movePos = new ChessBoard.MovePosS(); movePos.OriginalPiece = (ChessBoard.PieceE)Enum.Parse(typeof(ChessBoard.SerPieceE), reader.GetAttribute("OriginalPiece")); movePos.StartPos = (byte)Int32.Parse(reader.GetAttribute("StartingPosition")); movePos.EndPos = (byte)Int32.Parse(reader.GetAttribute("EndingPosition")); movePos.Type = (ChessBoard.MoveTypeE)Enum.Parse(typeof(ChessBoard.MoveTypeE), reader.GetAttribute("MoveType")); m_listMovePos.Add(movePos); reader.ReadStartElement("Move"); } } reader.ReadEndElement(); } } }
/// <summary> /// Convert a list of PGN positions into a moving positions /// </summary> /// <param name="eColorToPlay"> Color to play</param> /// <param name="arrRawMove"> Array of PGN moves</param> /// <param name="piMoveList"> Returned array of moving position</param> /// <param name="listMovePos"> Returned the list of move if not null</param> /// <param name="iSkip"> Skipped count</param> /// <param name="iTruncated"> Truncated count</param> private void CnvRawMoveToPosMove(ChessBoard.PlayerColorE eColorToPlay, List<string> arrRawMove, out int[] piMoveList, List<ChessBoard.MovePosS> listMovePos, ref int iSkip, ref int iTruncated) { List<int> arrMoveList; ChessBoard.MovePosS movePos; int iPos; movePos = new ChessBoard.MovePosS(); movePos.StartPos = 0; movePos.EndPos = 0; movePos.Type = ChessBoard.MoveTypeE.Normal; arrMoveList = new List<int>(256); try { foreach (string strMove in arrRawMove) { if (strMove == "1-0" || strMove == "0-1" || strMove == "1/2-1/2" || strMove == "*" || strMove[0] == '(') { break; } else if (strMove == "..") { iSkip++; break; } CnvRawMoveToPosMove(eColorToPlay, strMove, out iPos, ref iTruncated, ref movePos); if (iPos != -1) { arrMoveList.Add(iPos); if (listMovePos != null) { listMovePos.Add(movePos); } eColorToPlay = (eColorToPlay == ChessBoard.PlayerColorE.Black) ? ChessBoard.PlayerColorE.White : ChessBoard.PlayerColorE.Black; } else { break; } } } catch(PgnParserException ex) { ex.MoveList = arrMoveList.ToArray(); throw; } piMoveList = arrMoveList.ToArray(); }