public void ctxtDownloadContext_Cancel_Click(object sender, EventArgs e)
        {
            ListView lstDownloads = rcloneExplorer.myform.Controls.Find("lstDownloads", true)[0] as ListView;
            //find PID for current transfer
            string PID = lstDownloads.SelectedItems[0].SubItems[0].Text;
            //get filename
            string FN = lstDownloads.SelectedItems[0].SubItems[1].Text;
            //get progress of file (cant cancel 100%)
            string FP = lstDownloads.SelectedItems[0].SubItems[2].Text;

            //if the file process is 100%, it's done
            if (FP == "Done!" || FP == "100%" || !miscContainer.ProcessExists(Convert.ToInt32(PID)))
            {
                MessageBox.Show("ERR: Transfer already completed");
            }
            //file is not 100% and the process is still active
            else
            {
                //kill PID
                miscContainer.KillProcessAndChildren(Convert.ToInt32(PID));
                //if the file exists, delete it
                if (System.IO.File.Exists(FN))
                {
                    System.IO.File.Delete(FN);
                }
                //mark list entry as cancelled
                lstDownloads.SelectedItems[0].SubItems[0].Text = "Cancelled";
            }
        }
 private void menuStripFile_QuitKill_Click(object sender, EventArgs e)
 {
     //go through every rclone download process on record
     foreach (string[] entry in downloadsHandler.downloading)
     {
         //get process ID
         int PID = Convert.ToInt32(entry[0]);
         //check if the process is still active
         if (miscContainer.ProcessExists(PID))
         {
             //kill PID
             miscContainer.KillProcessAndChildren(PID);
         }
     }
     //close app
     Environment.Exit(0);
 }
Esempio n. 3
0
        public void transferTimer_Tick(object sender, EventArgs e)
        {
            ListView   lstDownloads = rcloneExplorer.myform.Controls.Find("lstDownloads", true)[0] as ListView;
            ListView   lstUploads   = rcloneExplorer.myform.Controls.Find("lstUploads", true)[0] as ListView;
            TabPage    tabDownloads = rcloneExplorer.myform.Controls.Find("tabDownloads", true)[0] as TabPage;
            TabPage    tabUploads   = rcloneExplorer.myform.Controls.Find("tabUploads", true)[0] as TabPage;
            TextBox    txtSyncLog   = rcloneExplorer.myform.Controls.Find("txtSyncLog", true)[0] as TextBox;
            TextBox    txtRawOut    = rcloneExplorer.myform.Controls.Find("txtRawOut", true)[0] as TextBox;
            NotifyIcon notifyIcon   = rcloneExplorer.notifyIconPub;

            if (!notifyIcon.Visible)
            {
                if (downloadsHandler.downloading.Count > 0)
                {
                    for (var i = 0; i < downloadsHandler.downloading.Count; i++)
                    {
                        {
                            //check downloadPId proces.exists to see if uploadis complete yet
                            int PID = Convert.ToInt32(downloadsHandler.downloading[i][0]);
                            if (miscContainer.ProcessExists(PID))
                            {
                                //download still in progress
                                lstDownloads.Items[i].SubItems[0].Text = downloadsHandler.downloading[i][0].ToString();
                                lstDownloads.Items[i].SubItems[2].Text = downloadsHandler.downloading[i][2];
                                lstDownloads.Items[i].SubItems[3].Text = downloadsHandler.downloading[i][3];
                            }
                            else
                            {
                                if (lstDownloads.Items[i].SubItems[2].Text != "Done!")
                                {
                                    //download complete (guessing! probs best to validate this)
                                    lstDownloads.Items[i].SubItems[2].Text = "100!";
                                }
                            }
                        }
                    }
                    if (tabDownloads.Text != "Downloads (" + lstDownloads.Items.Count + ")")
                    {
                        tabDownloads.Text = "Downloads (" + lstDownloads.Items.Count + ")";
                    }
                }
                if (uploadsHandler.uploading.Count > 0)
                {
                    for (var i = 0; i < uploadsHandler.uploading.Count; i++)
                    {
                        {
                            //store current iteration from list
                            string[] entry = uploadsHandler.uploading[i];
                            //entry filename
                            string uploadedFilename = entry[1];

                            //check downloadPId proces.exists to see if uploadis complete yet
                            int PID = Convert.ToInt32(uploadsHandler.uploading[i][0]);
                            if (miscContainer.ProcessExists(PID))
                            {
                                //upload still in progress
                                //upload list should be {PID, Name, Percent, Speed}
                                lstUploads.Items[i].SubItems[0].Text = uploadsHandler.uploading[i][0].ToString();
                                lstUploads.Items[i].SubItems[2].Text = uploadsHandler.uploading[i][2];
                                lstUploads.Items[i].SubItems[3].Text = uploadsHandler.uploading[i][3];
                            }
                            else
                            {
                                if (lstUploads.Items[i].SubItems[2].Text != "Done!")
                                {
                                    //upload complete (guessing! probs best to validate this)
                                    lstUploads.Items[i].SubItems[2].Text = "Done!";
                                    if (iniSettings.Read("refreshAutomatically") == "true")
                                    {
                                        exploreHandler.refreshlstExplorer();
                                    }
                                }
                            }
                        }
                    }
                    if (tabUploads.Text != "Uploads (" + lstUploads.Items.Count + ")")
                    {
                        tabUploads.Text = "Uploads (" + lstUploads.Items.Count + ")";
                    }
                }
                if (syncingHandler.syncingPID > 0)
                {
                    if (File.Exists("sync.log"))
                    {
                        using (var fs = new FileStream("sync.log", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                            using (var sr = new StreamReader(fs, Encoding.Default))
                            {
                                string tmp = sr.ReadToEnd();
                                txtSyncLog.AppendText(tmp.Replace("\n", Environment.NewLine));
                            }
                    }
                }
                if (rcloneExplorer.consoleEnabled)
                {
                    txtRawOut.AppendText(rcloneExplorer.rawOutputBuffer);
                    rcloneExplorer.rawOutputBuffer = "";
                }
            }
        }