public MegaFileDownload(MegaApiClient megaClient, MegaDownload megaDownload, INode fileNode, string savePath) { SavePath = savePath; Node = fileNode; MegaClient = megaClient; var progressHandler = new Progress <double>(value => { ProgressPercent = value; }); progressHandler.ProgressChanged += new EventHandler <double>(ProgreessChanged); Progress = progressHandler as IProgress <double>; MegaDownload = megaDownload; }
private void downloadMega_button_Click(object sender, EventArgs e) { maximumDownloads = (int)maximumDownloads_numericUpDown.Value; checkedFiles = new List <CloudFile>(); checkedFilesSize = 0; GetCheckedFiles((((SortedTreeModel)newFilesTreeViewAdv.Model).InnerModel as TreeModel).Nodes[0]); DialogResult dialogResult = MessageBox.Show($"Got links for {checkedFiles.Count} files [{(int)(checkedFilesSize / 1000000)} MB] Continue?", "Result", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.No) { return; } Directory.CreateDirectory(MainForm.syncFolderPath + @"\New Files " + DateTime.Now.ToShortDateString()); ProgressBar[] usedProgressBars = new ProgressBar[maximumDownloads]; Label[] usedLabels = new Label[maximumDownloads + 1]; for (int i = 0; i < maximumDownloads; i++) { usedProgressBars[i] = progressBars[i]; usedLabels[i] = progressLabels[i]; } usedLabels[maximumDownloads] = progressLabels[progressLabels.Count - 1]; if (megaApiClient == null) { megaApiClient = new MegaApiClient(); megaApiClient.LoginAnonymous(); } megaDownload = new MegaDownload(megaApiClient, checkedFiles, usedProgressBars, usedLabels, overwriteMode_comboBox.SelectedIndex); megaDownload.Start(); stopDownload_button.Enabled = true; stopDownload_button.Visible = true; }