public async Task RetrieveImage() { if (retrievingImage) { return; } retrievingImage = true; try { HttpHelper.TryGetImage(URL, out img); UpdatePreview(); ImageUpdated?.Invoke(this); retrievingImage = false; } catch { ImageScraper.TryGetImage(URL, (bmp) => { if (bmp == null) { return; } img = bmp; UpdatePreview(); ImageUpdated?.Invoke(this); retrievingImage = false; }); } }
/// <summary> /// Updates the userInfo with a stream. Does not upload to datastore /// </summary> /// <param name="data"></param> public void UpdateImage(Stream data) { image = new byte[data.Length]; data.Position = 0; data.Read(image, 0, (int)data.Length); data.Position = 0; ImageUpdated?.Invoke(userId); }
private void UpdateVisual() { using (var g = Graphics.FromImage(Image)) { g.Clear(_backColor); foreach (var cell in _cells) { g.DrawImage(cell.Image, new Point(cell.PosX * CellPixelWidth, cell.PosY * CellPixelHeight)); } } ImageUpdated?.Invoke(this, EventArgs.Empty); }
private void OnThumbnailClicked(object sender, RoutedEventArgs e) { var button = (ButtonBase)sender; if (button.FindName("Thumbnail") is Image image) { Banner.Source = image.Source; BannerTitle.Text = button.Tag.ToString(); BannerEnter.Begin(); ImageUpdated.Invoke(this, new ImageUpdatedEventArgs(Banner.Source)); } ScrollToCenterOfViewport(sender); }
public void LoadImages() { Banner.Source = new BitmapImage(new Uri(_photos[0].Url)); BannerTitle.Text = _photos[0].Title; ImageUpdated.Invoke(this, new ImageUpdatedEventArgs(Banner.Source)); // TODO 1.2: [ItemsRepeater] - Auto-select first photo when loaded. //Repeater.Loaded += async (s, e) => //{ // // ChangeView can be called only when the layout has completed, hence waiting in the Loaded event. // ImageList.ChangeView((Layout.ItemWidth + Layout.Spacing) * 500, null, null, true); // ScrollToCenterOfViewport(s); // // Auto-select first photo. // await Task.Delay(1200); // var first = Repeater.FindDescendants<RadioButton>().Where(r => r.Tag.Equals(_photos[0].Title)).FirstOrDefault(); // if (first != null) first.IsChecked = true; //}; }
private void NextAction() { try { _imageUpdateTimer.Stop(); if (_images == null || _images.Count == _currentIndex) { _logger.Info("Loading Images..."); _images = Task.Run(() => _insta.GetMedia()).GetAwaiter().GetResult(); _logger.Info($"Loaded {_images.Count} images"); _currentIndex = 0; } else { var image = _images[_currentIndex++]; _logger.Debug($"Displaying image {_currentIndex} of {_images.Count} (user: {image.User})"); Application.Current.Dispatcher.Invoke( () => { BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(image.Url, UriKind.Absolute); bitmap.EndInit(); ImageUpdated?.Invoke(this, new NewImageEvent(bitmap, image.User)); }); } } catch (Exception ex) { _logger.Error($"Error occured while trying to get or display images. {ex}"); } finally { _imageUpdateTimer.Start(); } }
public Image InspectImage(string id) { ImageUpdated?.Invoke(); return(null); }
public void NotifyImageUpdated() { ImageUpdated?.Invoke(); }
/// <summary> /// Pull the user's image from the datastore if it exists. /// </summary> /// <returns></returns> public async Task UpdateImage() { await TryGetUserImage(); ImageUpdated?.Invoke(userId); }
public void Update() { ImageUtils.PopulateMinMax(this); _tags[ImageHandlerTagKeys.Thumbnail] = ThumbnailGenerator.Generate(this); ImageUpdated?.Invoke(new ImageUpdatedEventData(false)); }
/// <summary> /// Accept selected/taken photo /// </summary> /// <returns>Task completed</returns> private async Task Accept() { ImageUpdated?.Invoke(this, _imagePath); await _pageService.PopAsync(); }
public void UpdateImage(byte[] fftData, int osVerticalScale, Color backgroundColor, Color foregroundColor) { ImageUpdated?.Invoke(this, new ImageUpdatedEventArgs(fftData, osVerticalScale, backgroundColor, foregroundColor)); }