void getFileAttachmentImageValue_DoWork(object sender, DoWorkEventArgs e) { BackgroundTask task = e.Argument as BackgroundTask; ImageArgs imageProps = task.TaskArgs as ImageArgs; BitmapSource source = Item.Store.GetImageFileAttachment(Item, imageProps.PropName); if (source != null) { Attachments.Add(imageProps.PropName, new ImageAttachment { BitmapSource = source }); } }
void getImageValueTask_TaskCompleted(object TaskArgs, BackgroundTaskResult result) { ImageArgs imageArgs = TaskArgs as ImageArgs; if (imageArgs.PublicPropName != null) { StoreItem itemToNotify = imageArgs.ItemToNotify; if (itemToNotify == null) { itemToNotify = Item; } itemToNotify.NotifyPropertyChangedByName(imageArgs.PublicPropName); } }
void getActiveDirectoryImageValueTask_DoWork(object sender, DoWorkEventArgs e) { BackgroundTask task = e.Argument as BackgroundTask; ImageArgs imageProps = task.TaskArgs as ImageArgs; UserInformation userInfo = new UserInformation(); userInfo.InitializeWithAlias(imageProps.Alias); MemoryStream stream = userInfo.UserPicture; BitmapSource source = null; if (stream != null) { source = FileUtils.GetBitmapSourceFromStream(stream); } if (source != null) { ImageAttachment imageAttachment = new ImageAttachment { BitmapSource = source }; Attachments.Add(imageProps.PublicPropName, imageAttachment); } }