public MainForm() { InitializeComponent(); downloadList1.SelectionChange += new EventHandler(downloadList1_SelectionChange); downloadList1.UpdateUI(); speedLimit = (SpeedLimitExtension)App.Instance.GetExtensionByType(typeof(SpeedLimitExtension)); }
private void StartJobsIfNeeded() { if (!Active || DownloadManager.Instance.AddBatchCount > 0) { Debug.WriteLine("Leaving StartJobsIfNeeded"); return; } DateTime now = DateTime.Now; EnableMode em = matrix[now.DayOfWeek, now.Hour]; if (parameters.WorkOnlyOnSpecifiedTimes && em == EnableMode.Disabled) { RestoreIfNecessary(); return; } if (em == EnableMode.ActiveWithLimit) { SpeedLimitExtension limit = (SpeedLimitExtension)AppManager.Instance.Application.GetExtensionByType(typeof(SpeedLimitExtension)); if (limit.Parameters.MaxRate != parameters.MaxRateOnTime) { //limit.Parameters.Enabled = true; //limit.Parameters.MaxRate = parameters.MaxRateOnTime; limit.SetMaxRateTemp(parameters.MaxRateOnTime); needToRestore = true; } } else { RestoreIfNecessary(); } int maxJobs = parameters.MaxJobs; using (DownloadManager.Instance.LockDownloadList(false)) { int count = GetActiveJobsCount(); if (count < maxJobs) { for (int i = 0; (count < maxJobs) && i < DownloadManager.Instance.Downloads.Count; i++) { Downloader d = DownloadManager.Instance.Downloads[i]; if (d.State != DownloaderState.Ended && !d.IsWorking()) { DownloadManager.Instance.Downloads[i].Start(); count++; } } } } }
private void RestoreIfNecessary() { if (needToRestore) { SpeedLimitExtension limit = (SpeedLimitExtension)AppManager.Instance.Application.GetExtensionByType(typeof(SpeedLimitExtension)); limit.RestoreMaxRateFromParameters(); needToRestore = false; } }
public MainForm() { InitializeComponent(); this.Icon = App.Instance.Icon; UpdateWCFService(); //DownloaderService.SetDownloadList(downloadList1); Log.OnLogWrite += LogWrite; downloadList1.SelectionChange += new EventHandler(downloadList1_SelectionChange); downloadList1.UpdateUI(); speedLimit = (SpeedLimitExtension)App.Instance.GetExtensionByType(typeof(SpeedLimitExtension)); }