Exemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                ASCIIEncoding enc = new ASCIIEncoding();
                byte[]        msg = new byte[1500];
                msg = enc.GetBytes(TypingBox.Text);

                m_sckt.Send(msg);
                MessagesSentReceived.Items.Add("You: " + TypingBox.Text);
                MessagesSentReceived.SelectedIndex += 1;
                TypingBox.Clear();
                TypingBox.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 2
0
        private void StartButton_Click(object sender, RoutedEventArgs e)
        {
            // make game element visible
            ((Button)sender).Visibility = Visibility.Hidden;
            TypingBox.Visibility        = Visibility.Visible;
            TimerBlock.Visibility       = Visibility.Visible;
            LifeCount.Visibility        = Visibility.Visible;

            // initialise the content
            TimerBlock.Text = GameController.Instance.Counter + "s";
            LifeCount.Text  = "Life: " + GameController.Instance.Life;
            TypingBox.Focus();

            // assign the delegate to call in each tick
            dispatcherTimer.Tick    += dispatcherTimer_Tick;
            dispatcherTimer.Interval = TimeSpan.FromSeconds(1);
            dispatcherTimer.Start();

            // start to throw the first word
            GameController.Instance.DropWord(WordCanvas);
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                m_endPointLocal = new IPEndPoint(IPAddress.Parse(YourIP.Text), Convert.ToInt32(YourPort.Text));
                m_sckt.Bind(m_endPointLocal);

                m_endPointRemote = new IPEndPoint(IPAddress.Parse(TheirIP.Text), Convert.ToInt32(TheirPort.Text));
                m_sckt.Connect(m_endPointRemote);

                byte[] buffer = new byte[1500];
                m_sckt.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref m_endPointRemote, new AsyncCallback(MessageCallBack), buffer);

                ConnectButton.Text    = "Connected";
                ConnectButton.Enabled = false;
                SendButton.Enabled    = true;
                TypingBox.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 4
0
 private void btnSend_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     RealTimeChat.SendMessage(TypingBox.Text);
     TypingBox.Clear();
 }