/// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="parentController">Controller for the window.</param>
        public WaitingLobby(UserClientController parentController)
        {
            InitializeComponent();

            _ParentController = parentController;


            // Set default values
            tbIP.Text             = "127.0.0.1";
            tbPort.Text           = "4263";
            tbName.Text           = "Player";
            cbColor.SelectedIndex = 0;

            btnRegister.Click += (o, ev) =>
            {
                _ParentController.RegisterAs(tbName.Text, (PlayerColor)cbColor.SelectedValue);
            };

            btnConnect.Click += (o, ev) =>
            {
                if (!int.TryParse(tbPort.Text, out int port))
                {
                    MessageBox.Show("Invalid number of port.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                _ParentController.ConnectToServer(tbIP.Text, port);
            };

            Closed += (o, ev) => parentController.WaitingLobbyWindowClosed();
        }
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="parentController">Controller for this window.</param>
        public GameBoard(UserClientController parentController)
        {
            InitializeComponent();

            _ParentController = parentController;

            Closed += (obj, ev) => _ParentController.GameBoardWindowClosed();
        }
예제 #3
0
 /// <summary>
 /// De-facto application entrypoint.
 /// </summary>
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     Controller = new UserClientController();
     Controller.Start();
 }