public void SendPlayersTurnDetails(string serverIP, PlayersTurnDetails iPlayersTurnDetails)
        {
            string messageText = Serialiser.SerializeToXml<PlayersTurnDetails>(iPlayersTurnDetails);

            NetworkMessage message = new NetworkMessage()
            {
                RecipientsIP = serverIP,
                MessagePacket = new NetworkMessagePacket()
                {
                    Command = eProtocol.PlayersTurnDetails,
                    MessageText = messageText
                }
            };

            AddMessageToQueue(message);
        }
		private void DisplayPlay(PlayersTurnDetails iPlayersTurnDetails)
		{
			if (iPlayersTurnDetails.PlayersIP != m_localNetwork.IpAddress)
			{
				foreach (TileControl tile in m_justPlayedTiles)
				{
					tile.TileStatus = eTileState.Played;
				}

				m_justPlayedTiles.Clear();

				foreach (TileDetails tileData in iPlayersTurnDetails.LettersPlayed)
				{
					AddTileToBoard(tileData);
				}

				m_firstWord = false;
			}

			if (OnDisplayPlays != null)
			{
				string message = string.Empty;

				foreach (UpWord playedWord in iPlayersTurnDetails.PlayedWords)
				{
					if (message.Length > 0)
					{
						message += ", ";
					}
					message += playedWord.Word;
				}
				message = "Scored " + iPlayersTurnDetails.Score.ToString() + 
						  " points from:" + (iPlayersTurnDetails.PlayedWords.Count > 1 ? "s " : " ") + message +
						  ".\r\n";

				Paragraph detail = new Windows.UI.Xaml.Documents.Paragraph();
				detail.Inlines.Add(new Windows.UI.Xaml.Documents.Run() { FontSize = 20, Text = message });

				Paragraph title = new Windows.UI.Xaml.Documents.Paragraph();
				title.Inlines.Add(new Windows.UI.Xaml.Documents.Run()
				{
					FontSize = 24,
					Text = iPlayersTurnDetails.PlayerName + " - Score: " + iPlayersTurnDetails.TotalScore.ToString()
				});

				m_currentGame.PlayDetails.Insert(0, detail);
				m_currentGame.PlayDetails.Insert(0, title);

				OnDisplayPlays(title, detail);
			}
		}
		void LocalNetwork_OnPlayersTurnDetailsReceived(string playersIpAddress, PlayersTurnDetails iPlayersTurnDetails)
		{
			DisplayPlay(iPlayersTurnDetails);

			if(GameSettings.Settings.IamGameCreator)
			{
				foreach (string playerIP in GameSettings.Settings.PlayersJoined.Keys)
				{
					// Remove the played letters from the players current letter store.
					if (GameSettings.Settings.PlayersJoined.ContainsKey(playerIP))
					{
						foreach (TileDetails tile in iPlayersTurnDetails.LettersPlayed)
						{
							GameSettings.Settings.PlayersJoined[playerIP].CurrentLetters.Letters.Remove(tile.Letter);
						}
					}

					if(playerIP != playersIpAddress)
					{
						m_localNetwork.SendPlayersTurnDetails(playerIP, iPlayersTurnDetails);
					}
					else if (iPlayersTurnDetails.LettersPlayed.Count < 7)
					{
						SendLetters(playersIpAddress, iPlayersTurnDetails.LettersPlayed.Count);
					}
				}
				GameSettings.SaveSettings();

				NextActivePlayer();
			}
		}
		public void SubmitWords()
		{
			if (TilesAreLayedCorrectly())
			{
				bool allWordsOk = true;
				List<UpWord> playedWords = GetPlayedWords();

				if (playedWords.Count == 0)
				{
					return;
				}

				foreach (UpWord playedWord in playedWords)
				{
					if (playedWord.Word.Length > 0)
					{
						if (!m_words.Contains(playedWord.Word))
						{
							ShowMessage("My dictionary does not contain the word '" + playedWord.Word + "'.");
							allWordsOk = false;
							break;
						}
					}
				}

				if (allWordsOk)
				{
					int replacementTiles = m_currentWordTiles.Count;
					PlayersTurnDetails iPlayersTurnDetails = new PlayersTurnDetails();
					iPlayersTurnDetails.PlayersIP = m_localNetwork.IpAddress;
					iPlayersTurnDetails.PlayerName = m_localNetwork.Username;
					iPlayersTurnDetails.PlayedWords = playedWords;

					foreach (UpWord playedWord in iPlayersTurnDetails.PlayedWords)
					{
						iPlayersTurnDetails.Score += playedWord.Score;
					}
					GameSettings.Settings.TotalScore += iPlayersTurnDetails.Score;
					GameSettings.SaveSettings();

					iPlayersTurnDetails.TotalScore += GameSettings.Settings.TotalScore;

					foreach (TileControl tile in m_justPlayedTiles)
					{
						tile.TileStatus = eTileState.Played;
					}

					m_justPlayedTiles.Clear();

					foreach (TileControl tile in m_currentWordTiles)
					{
						tile.TileStatus = eTileState.JustPlayed;
						tile.ManipulationMode = ManipulationModes.None;
						m_justPlayedTiles.Add(tile);
						m_playedTiles.Add(tile);
						m_boardTiles[tile.GridX, tile.GridY] = tile;

						iPlayersTurnDetails.LettersPlayed.Add(tile.TileData);
					}

					m_firstWord = false;
					m_currentWordTiles.Clear();

					DisplayPlay(iPlayersTurnDetails);

					if (GameSettings.Settings.IamGameCreator)
					{
						foreach (string playerIP in GameSettings.Settings.PlayersJoined.Keys)
						{
							m_localNetwork.SendPlayersTurnDetails(playerIP, iPlayersTurnDetails);
						}

						AddLettersToPanel(GetLetters(replacementTiles));
						NextActivePlayer();
					}
					else
					{
						m_localNetwork.SendPlayersTurnDetails(GameSettings.Settings.CreatorsIpAddress, iPlayersTurnDetails);
					}
				}
			}
		}