private void btnOK_Click(object sender, EventArgs e) { DownloadClicked?.Invoke(_comAlbumUrl.Text); }
public StreamView(RpanData data, string currentSearchTerm) { rpanData = data; #region UI elements Background = new SolidColorBrush(Color.FromRgb(24, 24, 24)); Height = 80; Margin = new Thickness(10, 5, 10, 0); MouseEnter += StreamView_MouseEnter; MouseLeave += StreamView_MouseLeave; Image img = new Image { Width = 70, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(5) }; StackPanel info = new StackPanel { Margin = new Thickness(70, 5, 90, 5) }; WrapPanel userAndViews = new WrapPanel { Margin = new Thickness(0, 0, 0, -5) }; TextBlock username = new TextBlock { Text = "u/" + data.post.authorInfo.name, Foreground = new SolidColorBrush(Color.FromRgb(0, 200, 255)), Height = 18, Margin = new Thickness(0, 0, 5, 0), }; TextBlock viewers = new TextBlock { Text = data.continuous_watchers + " viewers - " + data.unique_watchers + " unique watchers", Foreground = new SolidColorBrush(Color.FromRgb(200, 200, 200)), Height = 18 }; TextBlock title = new TextBlock { FontFamily = new FontFamily("Segoe UI"), Text = System.Globalization.CultureInfo.InvariantCulture.TextInfo.ToTitleCase(data.post.title.ToLowerInvariant()), Foreground = new SolidColorBrush(Colors.White), Height = 25, Margin = new Thickness(0, 0, 0, -5), FontSize = 17, //FontWeight = FontWeights.Bold, }; WrapPanel buttons = new WrapPanel(); TextBlock messages = new TextBlock { Text = Math.Floor(double.Parse(data.post.commentCount)) + " chat messages", Foreground = new SolidColorBrush(Color.FromRgb(200, 200, 200)), Height = 18 }; openRpan.Visibility = Visibility.Hidden; openRpanMedia.Visibility = Visibility.Hidden; download.Visibility = Visibility.Hidden; openRpan.Click += (s, a) => { Process.Start("https://reddit.com" + data.share_link); }; openRpanMedia.Click += (s, a) => { Process.Start("https://reddit.com" + data.post.permalink); }; download.Click += (s, a) => { DownloadClicked?.Invoke(this, data); }; StackPanel votes = new StackPanel { Width = 80, HorizontalAlignment = HorizontalAlignment.Right, }; TextBlock netVotes = new TextBlock { Foreground = new SolidColorBrush(Color.FromRgb(255, 90, 0)), Text = (data.upvotes - data.downvotes).ToString(), FontWeight = FontWeights.Bold, FontSize = 24, TextAlignment = TextAlignment.Center, Margin = new Thickness(0, 10, 0, -5) }; TextBlock upvotes = new TextBlock { Foreground = new SolidColorBrush(Color.FromRgb(255, 90, 0)), Text = data.upvotes.ToString(), FontSize = 14, TextAlignment = TextAlignment.Center, Margin = new Thickness(0, 0, 0, -3) }; TextBlock downvotes = new TextBlock { Foreground = new SolidColorBrush(Color.FromRgb(0, 90, 255)), Text = data.downvotes.ToString(), FontSize = 14, TextAlignment = TextAlignment.Center }; #endregion if (data.downvotes > data.upvotes) { netVotes.Foreground = new SolidColorBrush(Color.FromRgb(0, 90, 255)); } BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(data.stream.thumbnail, UriKind.Absolute); bitmap.EndInit(); img.Source = bitmap; userAndViews.Children.Add(username); userAndViews.Children.Add(messages); buttons.Children.Add(openRpan); buttons.Children.Add(openRpanMedia); buttons.Children.Add(download); info.Children.Add(userAndViews); info.Children.Add(title); info.Children.Add(viewers); info.Children.Add(buttons); votes.Children.Add(netVotes); votes.Children.Add(upvotes); votes.Children.Add(downvotes); Children.Add(img); Children.Add(info); Children.Add(votes); if (!string.IsNullOrWhiteSpace(currentSearchTerm)) { lastSearchTerm = currentSearchTerm; checkSearchTerm(currentSearchTerm); } }