/// <summary> /// Return a content item if it is already loaded, otherwise load the content item syncronously. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="uri"></param> /// <param name="enque"></param> /// <returns></returns> public ContentItem Get <T>(string uri, bool enque = false) { ContentItem item; lock (_contentItems) { if (_contentItems.Contains(uri)) { return(_contentItems[uri]); } else { item = new ContentItem(uri, null); _contentItems.Add(item); } } item.loader = Loader <T>; if (enque) { _loadQueue.Enqueue(item); } else { item.LoadingStatus = LoadingStatus.Loading; item.loader(item); item.LoadingStatus = LoadingStatus.Loaded; } return(item); }
/// <summary> /// Refresh the collection and close the form /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void btnClose_Click(object sender, EventArgs e) { if (wasModified) { items.Clear(); for (int idx = 0; idx < lbContentItems.Items.Count; idx++) { items.Add((ContentItem)lbContentItems.Items[idx]); } } this.Close(); }