//aggiorno la progress bar del file in ricezione
 private void UpdateReceivingProgressBar(string id, int percentage)
 {
     try
     {
         Application.Current.Dispatcher.Invoke(new Action(() =>
         {
             foreach (ReceivingFile r in FilesToReceive)
             {
                 if (String.Compare(r.Guid, id) == 0)
                 {
                     r.Value = percentage;
                     if (r.Value == 100)
                     {
                         r.File_state = Constants.FILE_STATE.COMPLETED;
                         r.Pic        = new BitmapImage(new Uri(App.currentDirectoryResources + "/check.ico"));
                         TriggerBalloon?.Invoke(r.Filename, r.Name, 0);
                         break;
                     }
                 }
             }
         }));
     }
     catch (Exception e)
     {
         Console.WriteLine("Update Progress Bar RECEIVER");
         var st = new StackTrace(e, 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);
     }
 }
 //file annullato da parte del sender => aggiorno la lista dei file in ricezione
 private void File_cancel(string id, Constants.NOTIFICATION_STATE state)
 {
     Application.Current.Dispatcher.Invoke(new Action(() =>
     {
         foreach (ReceivingFile r in FilesToReceive)
         {
             if (String.Compare(r.Guid, id) == 0)
             {
                 r.File_state = Constants.FILE_STATE.CANCELED;
                 r.Pic        = new BitmapImage(new Uri(App.currentDirectoryResources + "/cross.ico"));
                 TriggerBalloon?.Invoke(r.Filename, r.Name, state);
                 break;
             }
         }
     }));
 }
 //aggiorno la progress bar del file in invio
 private void UpdateProgressBar(string filename, Socket sock, int percentage, string remainingTime)
 {
     try
     {
         Application.Current.Dispatcher.Invoke(new Action(() =>
         {
             foreach (SendingFile sf in FilesToSend)
             {
                 if (sf.Sock == sock)
                 {
                     if (!String.IsNullOrEmpty(remainingTime))
                     {
                         if (String.Compare(sf.RemainingTime, remainingTime) != 0)
                         {
                             sf.RemainingTime = remainingTime;
                         }
                     }
                     sf.Value      = percentage;
                     sf.File_state = Constants.FILE_STATE.PROGRESS;
                     if (sf.Value == 100)
                     {
                         sf.File_state = Constants.FILE_STATE.COMPLETED;
                         sf.Pic        = new BitmapImage(new Uri(App.currentDirectoryResources + "/check.ico"));
                         if (WindowState != WindowState.Normal || tabControl.SelectedIndex != 1)
                         {
                             TriggerBalloon?.Invoke(sf.FileName, sf.Name, Constants.NOTIFICATION_STATE.SENT); //1
                         }
                     }
                     break;
                 }
             }
         }));
     }
     catch (Exception e)
     {
         Console.WriteLine("Update Progress Bar SENDER");
         var st = new StackTrace(e, 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);
     }
 }