/// <summary> /// Copy values back to this object from a cached object /// </summary> /// <param name="origianl"></param> public void Restore(MediaView cachedObject) { this.caption = cachedObject.caption; this.description = cachedObject.description; this.id = cachedObject.id; this.title = cachedObject.title; this.myUrl = cachedObject.myUrl; this.fileName = cachedObject.fileName; this.updated = cachedObject.updated; }
public MediaView(MediaView original) { this.id = original.id; this.title = original.title; this.caption = original.caption; this.description = original.description; this.updated = original.updated; this.myUrl = original.myUrl; this.fileName = original.fileName; }
/// <summary> /// Load data to the UI /// </summary> /// <param name="mediaArray"></param> private void LoadData(media[] mediaArray) { DataList.Clear(); foreach (media theMedia in mediaArray) { MediaView mediaView = new MediaView(theMedia); WebClient wc = new WebClient(); wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted); wc.OpenReadAsync(new Uri(mediaView.myUrl), mediaView); DataList.Add(mediaView); } }
private void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { MediaView mediaView = e.UserState as MediaView; mediaView.ImageStream = e.Result; }
/// <summary> /// 'Cancel' button is clicked /// </summary> public void CancelEdit() { Restore(cache); cache = null; }
/// <summary> /// 'Edit' button is clicked /// Due to binding, all UI changed will be mapped to the object, so we need make a copy of object before edit in case user wants to cancel the editing /// </summary> public void BeginEdit() { cache = new MediaView(this); }