Ejemplo n.º 1
0
        /// <summary>
        /// Disconnects the client and closes this window.  Opens a new starting window.
        /// </summary>
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            model.disconnect();

            new MainWindow(model.hostname, model.name).Show();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Ask the user if they want to exit before exiting, and if so disconnects
        /// the user and opens a new MainWindow if the user wants to play again.
        ///
        /// If the other player disconnected, or if the game is over, the
        /// "Are you sure you want to exit?" message is skipped.
        /// </summary>
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);
            if (!disconnected)
            {
                MessageBoxResult result = MessageBox.Show("Are you sure you want to exit? ", "Exiting", MessageBoxButton.YesNo);
                if (result != MessageBoxResult.Yes)
                {
                    e.Cancel = true;
                    return;
                }
            }

            if (!gameOver)
            {
                model.disconnect();
                disconnected = true;
                new MainWindow(model.hostname, model.name).Show();
            }
        }
Ejemplo n.º 3
0
        public void TestTerminated()
        {
            // Create two clients.
            BoggleClientModel client1 = new BoggleClientModel();
            BoggleClientModel client2 = new BoggleClientModel();

            // Connect the clients.
            client1.Connect("localhost", 2000, "Harry");
            client2.Connect("localhost", 2000, "Hermione");
            Thread.Sleep(100);

            client1.disconnect();
            Thread.Sleep(100);

            Assert.AreEqual("TERMINATED", client2.msgString);
        }