/// <summary> /// ����ļ� /// </summary> /// <param name="url"></param> /// <param name="disk"></param> /// <param name="isCover"></param> /// <returns></returns> public static FileDown AddDownFile(string url, string disk) { url = url.Replace("\\", "/"); disk = disk.Replace("/", "\\"); foreach (FileDown r in FileDownList) { if (r.Url.Equals(url, StringComparison.CurrentCultureIgnoreCase)) { return null; } } FileDown file = new FileDown(); file.BeginTime = DateTime.MinValue; file.EndTime = DateTime.MinValue; file.ErrorMsg = ""; file.FileName = url.Substring(url.LastIndexOf("/")); file.FileSize = 0; file.Id = Guid.NewGuid().ToString(); file.SavePath = disk; file.Status = FileDown.FileDownStatus.Wait; file.Url = url; file.UseTime = new TimeSpan(); FileDownList.Add(file); return file; }
private void ShowFile(FileDown file) { ListViewItem item = new ListViewItem(); item.Text = file.FileName; item.SubItems.Add(FileDown.GetFileDownStatusName(file.Status)); item.SubItems.Add(UtilTool.FormatSize(file.FileSize)); item.SubItems.Add(file.Url); item.SubItems.Add(file.SavePath); item.SubItems.Add(file.GetMemo()); item.Tag = file.Id; item.ForeColor = GetItemColor(file.Status); this.listFileDown.Items.Add(item); ResetColumnWidth(); }
/// <summary> /// 获取颜色 /// </summary> /// <param name="status"></param> /// <returns></returns> private Color GetItemColor(FileDown.FileDownStatus status) { Color color = Color.Black; switch (status) { case FileDown.FileDownStatus.Wait: color = Color.Black; break; case FileDown.FileDownStatus.Doing: color = Color.Blue; break; case FileDown.FileDownStatus.Error: color = Color.Red; break; case FileDown.FileDownStatus.Finish: color = Color.Green; break; case FileDown.FileDownStatus.Exixted: color = Color.DarkOliveGreen; break; default: break; } return color; }