//context menu sui file in invio (cancella un file inviato correttamente)
        private void Sending_files_menu_delete_click(object sender, RoutedEventArgs e)
        {
            if (sendingFiles.SelectedIndex == -1)
            {
                return;
            }
            SendingFile sf = sendingFiles.SelectedItem as SendingFile;

            if (sf.File_state == Constants.FILE_STATE.PROGRESS || sf.File_state == Constants.FILE_STATE.ACCEPTANCE || sf.File_state == Constants.FILE_STATE.PREPARATION)
            {
                this.ShowMessageAsync("Ops", "Non puoi cancellare un file in invio.\nPremi annulla per fermarlo.");
            }
            else
            {
                FilesToSend.Remove(sf);
            }
        }
        //click a seguito della cancellazione di un file in invio
        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            Button      b  = sender as Button;
            SendingFile sf = b.DataContext as SendingFile;

            try
            {
                if (sf.Sock.Connected)
                {
                    sf.Sock.Shutdown(SocketShutdown.Both);
                }
            }
            catch (ObjectDisposedException o)
            {
                Console.WriteLine("main");
                var st = new StackTrace(o, true);
                // Get the top stack frame
                var frame = st.GetFrame(st.FrameCount - 1);
                // Get the line number from the stack frame
                var line = frame.GetFileLineNumber();
                Console.WriteLine("Error at line {0} ", line);
            }
            catch (Exception ex)
            {
                Console.WriteLine("MainWindwos");
                var st = new StackTrace(ex, true);
                // Get the top stack frame
                var frame = st.GetFrame(st.FrameCount - 1);
                // Get the line number from the stack frame
                var line = frame.GetFileLineNumber();
                Console.WriteLine("Error at line {0} ", line);
            }
            finally
            {
                sf.File_state = Constants.FILE_STATE.CANCELED;
                sf.Pic        = new BitmapImage(new Uri(App.currentDirectoryResources + "/cross.ico"));
            }
        }