using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Reddit_03 { public partial class Form1 : Form { public static int QUERY_TITLE_LENGTH = 30; public Form1() { InitializeComponent(); Classes.ReadInputFiles(); foreach (Classes.Subreddit i in Classes.subs) { Subs_ComboBox.Items.Add(i.Name); } /* foreach (Classes.User i in Classes.users) { User_ComboBox.Items.Add(i.Name); } */ } public string Dashes() { StringBuilder result = new StringBuilder(); for (uint i = 0; i < 50; i++) result.Append("-"); return result.ToString(); } public void END_OF_OUTPUT() { System_Output.AppendText("\n\n***** END OF QUERY RESULTS *****\n"); } private void Query4_Click(object sender, EventArgs e) { if (Subs_ComboBox.SelectedIndex == -1) // That is: no selection has been made { System_Output.Text = "Please select a Subreddit to list Posts from."; return; } // else, we can begin working if (Subs_ComboBox.SelectedIndex == 0) // The user has selected the r/all subreddit { var AllPostsQuery = from N in Classes.subs from M in N.SubPosts where M.Score < 0 select M; System_Output.Text = ""; if (AllPostsQuery.Count() == 0) { System_Output.Text = "Wow, such empty!"; return; } foreach (Classes.Post i in AllPostsQuery) { System_Output.AppendText(i.ToString("ListBox") + "\n"); } END_OF_OUTPUT(); return; } var PrintPostsQuery = from N in Classes.subs where N.Name.CompareTo(Subs_ComboBox.SelectedItem.ToString()) == 0 from M in N.SubPosts where M.Score < 0 select M; System_Output.Text = ""; if (PrintPostsQuery.Count() == 0) { System_Output.Text = "Wow, such empty!"; return; } foreach (Classes.Post i in PrintPostsQuery) { System_Output.AppendText(i.ToString("ListBox") + "\n"); } /* foreach (Classes.Subreddit i in PrintPostsQuery) { foreach (Classes.Post j in i) { System_Output.AppendText(j.ToString("ListBox") + "\n"); } } */ END_OF_OUTPUT(); } } }