Esempio n. 1
0
 /// <summary>
 /// Add a new Transmission to the active transmission manager
 /// </summary>
 /// <param name="transmission"></param>
 public bool AddTransmission(FileTransmissionEvent transmission) {
     lock (Lock)
     {
         if(!activeTransmissions.Contains(transmission)) {
             transmission.TransmissionStatus += TransmissionFinished;
             activeTransmissions.Add(transmission);
             return true;
         }
     }
     return false;
 }
Esempio n. 2
0
 /// <summary>
 /// Add a new Transmission to the active transmission manager
 /// </summary>
 /// <param name="transmission"></param>
 public bool AddTransmission(FileTransmissionEvent transmission)
 {
     lock (Lock)
     {
         if (!activeTransmissions.Contains(transmission))
         {
             transmission.TransmissionStatus += TransmissionFinished;
             activeTransmissions.Add(transmission);
             return(true);
         }
     }
     return(false);
 }
Esempio n. 3
0
 /// <summary>
 /// If a transmission is reported as finished/aborted/failed, the transmission is removed from the collection
 /// </summary>
 /// <param name='sender'>
 /// The transmission event.
 /// </param>
 /// <param name='e'>
 /// The progress parameters of the transmission.
 /// </param>
 private void TransmissionFinished(object sender, TransmissionProgressEventArgs e)
 {
     if ((e.Aborted == true || e.Completed == true || e.FailedException != null))
     {
         lock (Lock)
         {
             FileTransmissionEvent transmission = sender as FileTransmissionEvent;
             if (transmission != null && activeTransmissions.Contains(transmission))
             {
                 activeTransmissions.Remove(transmission);
                 transmission.TransmissionStatus -= TransmissionFinished;
                 Logger.Debug("Transmission removed");
             }
         }
     }
 }
Esempio n. 4
0
        public TransmissionMenuItem(FileTransmissionEvent transmission) {

            Title = System.IO.Path.GetFileName(transmission.Path);

            Activated += delegate {
                NSWorkspace.SharedWorkspace.OpenFile (System.IO.Directory.GetParent(transmission.Path).FullName);
            };

            transmission.TransmissionStatus += delegate (object sender, TransmissionProgressEventArgs e){
                double? percent = e.Percent;
                long? bitsPerSecond = e.BitsPerSecond;
                if( percent != null && bitsPerSecond != null ) {
                    BeginInvokeOnMainThread(delegate {
                        Title = String.Format("{0} ({1:###.#}% {2})",
                            System.IO.Path.GetFileName(transmission.Path),
                            Math.Round((double)percent,1),
                            CmisSync.Lib.Utils.FormatBandwidth((long)bitsPerSecond));
                    });
                }
            };
        }