private void Connect_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            KulamiPeer peer = IncomingChallengesListBox.SelectedPeer();

            if (peer == null)
            {
                return;
            }

            peer.SendResponse(true);
            StartGame(peer,
                      BoardSetup.GetBoard(peer.IncomingRequest.BoardNum),
                      !peer.IncomingRequest.ChallengerGoesFirst);
        }
        private void peer_update(KulamiPeer peer)
        {
            Dispatcher.Invoke(() =>
            {
                if (string.IsNullOrEmpty(peer.Name) || !peer.InLobby)
                {
                    PlayersListBox.RemovePeer(peer, null);
                    IncomingChallengesListBox.RemovePeer(peer, IncomingChallengesCanvas);
                    OutgoingChallengesListBox.RemovePeer(peer, OutgoingChallengesCanvas);
                    return;
                }

                PlayersListBox.AddOrUpdatePeer(peer);
                IncomingChallengesListBox.UpdatePeer(peer);
                OutgoingChallengesListBox.UpdatePeer(peer);
            });
        }
        private void on_game_request(object sender, NetGameRequestEventArgs e)
        {
            KulamiPeer peer = sender as KulamiPeer;

            if (peer == null)
            {
                return;
            }

            Dispatcher.Invoke(() =>
            {
                IncomingChallengesCanvas.show();

                // Don't add them if they've already challenged us
                if (!IncomingChallengesListBox.Contains(peer))
                {
                    IncomingChallengesListBox.AddPeer(peer);
                }
            });
        }
        private void on_peer_connect_change(object sender, NetConnectionEventArgs e)
        {
            KulamiPeer peer = sender as KulamiPeer;

            if (peer == null)
            {
                return;
            }

            if (e.Connected)
            {
                return;
            }

            Dispatcher.Invoke(() =>
            {
                PlayersListBox.RemovePeer(peer, null);
                IncomingChallengesListBox.RemovePeer(peer, IncomingChallengesCanvas);
                OutgoingChallengesListBox.RemovePeer(peer, OutgoingChallengesCanvas);
            });
        }
        private void on_game_response(object sender, NetGameResponseEventArgs e)
        {
            KulamiPeer peer = sender as KulamiPeer;

            if (peer == null)
            {
                return;
            }

            if (e.ChallengeAccpeted)
            {
                StartGame(peer, BoardSetup.GetBoard(e.BoardNum), e.ChallengerGoesFirst);
            }
            else
            {
                Dispatcher.Invoke(() =>
                {
                    IncomingChallengesListBox.RemovePeer(peer, IncomingChallengesCanvas);
                });
            }
        }