Esempio n. 1
0
    private void transferClient_Disconnected(object sender, EventArgs e)
    {
        if (InvokeRequired)
        {
            Invoke(new EventHandler(transferClient_Disconnected), sender, e);
            return;
        }
        deregiserEvents();

        foreach (ListViewItem item in lstTransfers.Items)
        {
            TransferQueue queue = (TransferQueue)item.Tag;
            queue.Close();
        }
        lstTransfers.Items.Clear();
        progressOverall.Value = 0;
        //transferClient.Close();
        transferClient = null;

        setConnectionStatus("-");

        if (serverRunning)
        {
            listener.Start(int.Parse(txtServerPort.Text.Trim()));
            setConnectionStatus("Waiting...");
        }
        else
        {
            btnConnect.Text = "Connect";
        }
    }
Esempio n. 2
0
    void transferClient_Disconnected(object sender, EventArgs e)
    {
        if (InvokeRequired)
        {
            Invoke(new EventHandler(transferClient_Disconnected), sender, e);
            return;
        }


        deregisterEvents();

        //Close every transfer
        foreach (ListViewItem item in lstTransfers.Items)
        {
            TransferQueue queue = (TransferQueue)item.Tag;
            queue.Close();
        }

        //To clear list view
        lstTransfers.Items.Clear();
        progressOverall.Value = 0;

        //Set the client to null
        transferClient = null;

        //Set the connection status to nothing
        setConnectionStatus("-");

        //If the server is still running, wait for another connection
        if (serverRunning)
        {
            listener.Start(int.Parse(txtServerPort.Text.Trim()));
            //listener1.Start(int.Parse(txtServerPort.Text.Trim()));
            setConnectionStatus("Waiting...");

            //listener1.Start(int.Parse(txtServerPort.Text.Trim()));
        }
        else //If we connected then disconnected, set the text back to connect.
        {
            btnConnect.Text = "Connect";
        }
    }
Esempio n. 3
0
 public void infoConexao(bool conectado, string mensagem, TransferClient transferClient)
 {
     if (InvokeRequired)
     {
         Invoke(new InfoConexaoHandler(infoConexao), conectado, mensagem, transferClient);
         return;
     }
     if (!conectado)
     {
         if (cliente != null)
         {
             desregistrarEvento(cliente);
             cliente = null;
             iniciarCliente();
         }
         //if (servidor != null)
         //    desregistrarEvento(servidor);
         //Close every transfer
         foreach (ListViewItem item in lstTransfers.Items)
         {
             TransferQueue queue = (TransferQueue)item.Tag;
             queue.Close();
         }
         //Clear the listview
         lstTransfers.Items.Clear();
         progressOverall.Value = 0;
         if (transferClient != null)
         {
             listBox1.Items.Remove(transferClient);
         }
     }
     else
     {
         if (transferClient != null)
         {
             listBox1.Items.Add(transferClient);
         }
     }
     lbInfoConexao.Text = mensagem;
 }