Exemple #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Client received 2. </summary>
        ///
        /// <remarks>   Jakob, 15/09/2018. </remarks>
        ///
        /// <param name="sender2">  The second sender. </param>
        /// <param name="data2">    The second data. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        void client_Received2(Client2 sender2, byte[] data2)
        {
            equation = new Values2(Convert.ToInt32(txtFirstNumber.Text), Convert.ToInt32(txtSecondNumber.Text), cboxOperator.Text, Convert.ToInt32(txtAnswer.Text));
            binaryTree2();

            Invoke((MethodInvoker) delegate
            {
                if (txtAnswer.Text == Encoding.Default.GetString(data2))
                {
                    MessageBox.Show("You were correct");
                    btnSend.Enabled = true;
                }
                else if (txtAnswer.Text != Encoding.Default.GetString(data2))
                {
                    int num;
                    bool answer = int.TryParse(txtAnswer.Text, out num);
                    valueNode.AddValuesNode(new LinkListNode(num));
                    LinkedListNodes();
                    MessageBox.Show("You were incorrect");
                }
            });

            btnSend.Enabled      = true;
            txtFirstNumber.Text  = "";
            cboxOperator.Text    = "";
            txtSecondNumber.Text = "";
            txtAnswer.Text       = "";
        }
Exemple #2
0
        void listener_SocketAccepted(System.Net.Sockets.Socket f)
        {
            Client2 client = new Client2(f);

            client.Received     += new Client2.ClientReceivedHandler2(client_Received2);
            client.Disconnected += Client_Disconnected;

            Invoke((MethodInvoker) delegate
            {
                ListViewItem i = new ListViewItem();
                i.Text         = client.EndPoint.ToString();
                i.Tag          = client;
            });
        }
Exemple #3
0
        void client_Received2(Client2 sender2, byte[] data2)
        {
            Invoke((MethodInvoker) delegate
            {
                if (txtAnswer.Text == Encoding.Default.GetString(data2))
                {
                    MessageBox.Show("You were correct");
                    txtFirstNumber.Text  = "";
                    cboxOperator.Text    = "";
                    txtSecondNumber.Text = "";
                    txtAnswer.Text       = "";
                    btnSend.Enabled      = true;
                }
                else if (txtAnswer.Text != Encoding.Default.GetString(data2))
                {
                    Values numberValues = new Values(Convert.ToUInt16(txtFirstNumber.Text),
                                                     Convert.ToUInt16(txtSecondNumber.Text), cboxOperator.Text, Convert.ToUInt16(txtAnswer.Text), false);

                    //add to list to be displayed
                    values.Add(numberValues);

                    //create new node and add to nodelist
                    LinkListNode node = new LinkListNode(numberValues);
                    valueNode.AddValuesNode(node);

                    StringBuilder sb = new StringBuilder();
                    if (txtRichLinkedList.Text == "")
                    {
                        sb.Append("Head <-> ");
                        sb.Append(valueNode.getCurrentNode().NodeToString());
                    }
                    else
                    {
                        sb.Append(txtRichLinkedList.Text);
                        sb.Append(" <-> ");
                        sb.Append(valueNode.getCurrentNode().NodeToString());
                    }

                    txtRichLinkedList.Text = sb.ToString();
                    MessageBox.Show("You were incorrect");

                    txtFirstNumber.Text  = "";
                    cboxOperator.Text    = "";
                    txtSecondNumber.Text = "";
                    txtAnswer.Text       = "";
                    btnSend.Enabled      = true;
                }
            });
        }
Exemple #4
0
 private void Client_Disconnected(Client2 sender2)
 {
     /* Invoke((MethodInvoker)delegate
      * {
      *   for (int i = 0; i < lstClients.Items.Count; i++)
      *   {
      *       Client client = lstClients.Items[i].Tag as Client;
      *       if (client.ID == sender.ID)
      *       {
      *           lstClients.Items.RemoveAt(i);
      *           break;
      *       }
      *   }
      * }); */
 }
Exemple #5
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Client disconnected. </summary>
        ///
        /// <remarks>   Jakob, 15/09/2018. </remarks>
        ///
        /// <param name="sender2">  The second sender. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        private void Client_Disconnected(Client2 sender2)
        {
        }