public MovieIcon(MoreButton mButt, ActionButton aButt, string url, double left = 20, double top = 10, int Width = 200, int Height = 285) { this.mButt = mButt; this.aButt = aButt; Margin = new Thickness(left, top, 0, 0); icon = new Image(); icon.Width = Width; icon.Height = Height; icon.Source = new BitmapImage(new Uri(url)); icon.Stretch = Stretch.Fill; icon.Opacity = 0.5; HorizontalAlignment = HorizontalAlignment.Left; VerticalAlignment = VerticalAlignment.Top; MouseEnter += iconEnterAnim; MouseLeave += iconLeaveAnim; this.Children.Add(icon); this.Children.Add(mButt); this.Children.Add(aButt); }
private void drawIconsThread(WrapPanel panel, Action <object, RoutedEventArgs> action, string aButtCon, DataTable icons, int startpoint, int incrementBy) { Task.Factory.StartNew(() => { for (int i = startpoint; i < icons.Rows.Count; i += incrementBy) { int j = i; this.Dispatcher.BeginInvoke(new Action(() => { DataRow row = icons.Rows[j]; ActionButton aButt = new ActionButton(row[0].ToString(), aButtCon, action); MoreButton mButt = new MoreButton(row[1].ToString(), row[2].ToString()); Movie movie = new TMDbClient("7e8f60e325cd06e164799af1e317d7a7").GetMovieAsync(Convert.ToInt32(row[1]), "pl", MovieMethods.Credits).Result; MovieIcon icon = new MovieIcon(mButt, aButt, "https://image.tmdb.org/t/p/w500/" + movie.PosterPath); panel.Children.Add(icon); })); } }); }