Exemple #1
0
        private void OnButtonDelete(object sender)
        {
            Gtk.Application.Invoke(delegate {
                FileProgressObject obj = sender as FileProgressObject;
                obj.Delete            -= new BlankEventHandler(OnButtonDelete);

                FileReceiver fileReceiver = null;
                lock (progressObjects) {
                    foreach (FileReceiver fileRecv in progressObjects.Keys)
                    {
                        if (progressObjects[fileRecv] == obj)
                        {
                            fileReceiver = fileRecv;
                            break;
                        }
                    }

                    if (obj.Finished != true)
                    {
                        fileReceiver.Abort();
                    }

                    progressObjects.Remove(fileReceiver);
                    vbox.Remove(obj);
                }
            });
        }
Exemple #2
0
        // ============================================
        // PRIVATE (Methods) Event Handlers
        // ============================================
        private void OnAdded(object sender)
        {
            Gtk.Application.Invoke(delegate {
                FileReceiver fileRecv = sender as FileReceiver;

                FileProgressObject obj = new FileProgressObject();
                obj.Delete            += new BlankEventHandler(OnButtonDelete);

                // Setup Image
                string ext = FileUtils.GetExtension(fileRecv.MyDiskName);
                obj.Image  = StockIcons.GetFileIconPixbuf(TextUtils.UpFirstChar(ext));

                // Set Transfer Info
                SetTransferInfo(obj, fileRecv);

                // Set Info
                UserInfo userInfo = fileRecv.Peer.Info as UserInfo;
                obj.SetName(fileRecv.Name, userInfo.Name);

                // Add Update
                progressObjects.Add(fileRecv, obj);
                vbox.PackStart(obj, false, false, 2);
                obj.ShowAll();
            });
        }
Exemple #3
0
 // ============================================
 // PRIVATE Methods
 // ============================================
 private void SetTransferInfo(FileProgressObject obj, FileSender fs)
 {
     if (obj == null)
     {
         return;
     }
     obj.SetTransferInfo(fs.SendedSize, fs.Size, fs.SendedPercent);
 }
Exemple #4
0
 // ============================================
 // PRIVATE Methods
 // ============================================
 private void SetTransferInfo(FileProgressObject obj, FileReceiver fr)
 {
     if (obj != null)
     {
         int percent = fr.ReceivedPercent;
         if (percent < 0)
         {
             percent = 0;
         }
         obj.SetTransferInfo(fr.SavedSize, fr.Size, percent);
     }
 }
Exemple #5
0
 private void OnFinished(object sender)
 {
     Gtk.Application.Invoke(delegate {
         try {
             FileReceiver fileRecv   = sender as FileReceiver;
             FileProgressObject obj  = (FileProgressObject)progressObjects[fileRecv];
             obj.ProgressBar.Visible = false;
             obj.Info     = "<b>(Finished)</b>";
             obj.Finished = true;
         } catch (Exception e) {
             Debug.Log("Download Viewer Finished: {0}", e.Message);
         }
     });
 }
Exemple #6
0
 private void OnAborted(object sender)
 {
     Gtk.Application.Invoke(delegate {
         try {
             FileReceiver fileRecv  = sender as FileReceiver;
             FileProgressObject obj = (FileProgressObject)progressObjects[fileRecv];
             SetTransferInfo(obj, fileRecv);
             obj.Info    += " <b>ABORTED</b>";
             obj.Finished = true;
         } catch (Exception e) {
             Debug.Log("Download Viewer Abort: {0}", e.Message);
         }
     });
 }
Exemple #7
0
 private void OnReceivedPart(object sender)
 {
     Gtk.Application.Invoke(delegate {
         try {
             FileReceiver fileRecv  = sender as FileReceiver;
             FileProgressObject obj = (FileProgressObject)progressObjects[fileRecv];
             if (obj == null)
             {
                 OnAdded(sender);
                 obj = (FileProgressObject)progressObjects[fileRecv];
             }
             else if (obj.Finished == true)
             {
                 return;
             }
             SetTransferInfo(obj, fileRecv);
         } catch (Exception e) {
             Debug.Log("Download Viewer Received Part: {0}", e.Message);
         }
     });
 }
Exemple #8
0
        // ============================================
        // PUBLIC Methods
        // ============================================
        /// Remove Finished or Aborted
        public void Clear()
        {
            lock (progressObjects) {
                Hashtable rm = new Hashtable();
                foreach (FileReceiver fileRecv in progressObjects.Keys)
                {
                    FileProgressObject obj = (FileProgressObject)progressObjects[fileRecv];
                    if (obj.Finished == true)
                    {
                        rm.Add(fileRecv, obj);
                    }
                }

                foreach (FileReceiver fileRecv in rm.Keys)
                {
                    progressObjects.Remove(fileRecv);
                    vbox.Remove((FileProgressObject)rm[fileRecv]);
                }
                rm.Clear();
                rm = null;
            }
        }
Exemple #9
0
        // ============================================
        // PUBLIC Methods
        // ============================================
        /// Remove Finished or Aborted
        public void Clear()
        {
            lock (progressObjects) {
                Hashtable rm = new Hashtable();
                foreach (FileSender fileSender in progressObjects.Keys)
                {
                    FileProgressObject obj = (FileProgressObject)progressObjects[fileSender];
                    if (obj.Finished == true)
                    {
                        obj.Delete -= new BlankEventHandler(OnButtonDelete);
                        rm.Add(fileSender, obj);
                    }
                }

                foreach (FileSender fileSender in rm.Keys)
                {
                    progressObjects.Remove(fileSender);
                    vbox.Remove((FileProgressObject)rm[fileSender]);
                }
                rm.Clear();
                rm = null;
            }
        }
 // ============================================
 // PRIVATE Methods
 // ============================================
 private void SetTransferInfo(FileProgressObject obj, FileReceiver fr)
 {
     if (obj != null) {
         int percent = fr.ReceivedPercent;
         if (percent < 0) percent = 0;
         obj.SetTransferInfo(fr.SavedSize, fr.Size, percent);
     }
 }
        // ============================================
        // PRIVATE (Methods) Event Handlers
        // ============================================
        private void OnAdded(object sender)
        {
            Gtk.Application.Invoke(delegate {
            FileReceiver fileRecv = sender as FileReceiver;

            FileProgressObject obj = new FileProgressObject();
            obj.Delete += new BlankEventHandler(OnButtonDelete);

            // Setup Image
            string ext = FileUtils.GetExtension(fileRecv.MyDiskName);
            obj.Image = StockIcons.GetFileIconPixbuf(TextUtils.UpFirstChar(ext));

            // Set Transfer Info
            SetTransferInfo(obj, fileRecv);

            // Set Info
            UserInfo userInfo = fileRecv.Peer.Info as UserInfo;
            obj.SetName(fileRecv.Name, userInfo.Name);

            // Add Update
            progressObjects.Add(fileRecv, obj);
            vbox.PackStart(obj, false, false, 2);
            obj.ShowAll();
            });
        }
 // ============================================
 // PRIVATE Methods
 // ============================================
 private void SetTransferInfo(FileProgressObject obj, FileSender fs)
 {
     if (obj == null) return;
     obj.SetTransferInfo(fs.SendedSize, fs.Size, fs.SendedPercent);
 }