private void UpdateUI(object sender, EventArgs e) { try { lock (this) { this.DownloadList.ClearList(); TasklistItem listItem = null; FileInfo info = null; string dir = _channelManager.Channel.GetDirectory(); string file = null; foreach (ChannelItem channelItem in _channelManager.Channel.Items) { // Channel items that do not have a title have been removed by the user. if (channelItem.Title.Length > 0) { file = Path.Combine(dir, channelItem.Enclosure.GetFilename()); listItem = new TasklistItem(channelItem.Guid, channelItem.Description); listItem.Total = channelItem.Enclosure.Length; // Check if the user has already downloaded this file. if (File.Exists(file)) { info = new FileInfo(file); listItem.Completed = info.Length; //if (listItem.Total < listItem.Completed) // listItem.Total = listItem.Completed; } listItem.Description = this.GetProgressDescription(listItem); if (listItem.Completed == listItem.Total) listItem.State = TasklistItem.ItemState.Complete; else if (listItem.Completed > 0) listItem.State = TasklistItem.ItemState.Incomplete; this.DownloadList.AddItem(listItem); } } this.DownloadList.SelectedItem = 0; this.DownloadList.Invalidate(); } } catch (Exception ex) { OdeoApplication.TraceException("FrmChannel::UpdateUI", ex); } }
public void RemoveItem(TasklistItem item) { m_list.Remove(item); m_scrollDirty = true; }
private string GetProgressDescription(TasklistItem item) { string completed = ConvertFileSize(item.Completed); string total = ConvertFileSize(item.Total); return String.Format("{0} of {1}", completed, total); }
// // public methods // /// <summary> /// Add task item to list. /// </summary> public void AddItem(TasklistItem item) { // add item to list and mark as dirty, // will upate next time it needs to draw list m_list.Add(item); m_scrollDirty = true; }