public static string PlotSubReddit(EntityData dimstyle, string pickedSubReddit) { string result = "OK"; try { DrawEntity.DrawBox(dimstyle.origin, dimstyle.cornerBase, "REDDIT.BORDER", 20); RedditSharp.Reddit reddit = new RedditSharp.Reddit(); var subreddit = reddit.GetSubreddit(pickedSubReddit); if (subreddit != null) { Tuple <double, double> widthHeight; int i = -1; double yTextLocation = dimstyle.origin.Y; double mtextActualHeight = 0; DrawEntity.DrawDim(dimstyle.origin, new Point3d(dimstyle.cornerBase.X, dimstyle.origin.Y, 0), "/r/" + pickedSubReddit, "REDDIT.HEADINGS", dimstyle.headingTxtSize, 1.025); foreach (var post in subreddit.Hot.Take(20)) { string postId = GeneratePostId(PostMarker.postmarker); yTextLocation -= (mtextActualHeight - (dimstyle.yLength * .025)); //adds 5% height padding Point2d headingLocation = new Point2d(dimstyle.origin.X, yTextLocation); widthHeight = DrawEntity.DrawText(headingLocation, dimstyle.headingTxtSize, dimstyle.textWidth, post.Title, "REDDIT.HEADINGS", 7); mtextActualHeight = widthHeight.Item2; Point2d subHeadingLocation = new Point2d(dimstyle.origin.X, yTextLocation - mtextActualHeight); string subHeading = string.Format("By:{0} | No. Of Comments: {1} | Submitted: {2} | NSFW: {3}", post.Author.ToString(), post.CommentCount.ToString(), post.Created.ToString(), post.NSFW ? "YES":"NO"); widthHeight = DrawEntity.DrawText(subHeadingLocation, dimstyle.subHeadingTxtSize, dimstyle.textWidth, subHeading, "REDDIT.SUBHEADINGS", 251); Point2d postIdLocation = new Point2d((dimstyle.origin.X + widthHeight.Item1) + ((dimstyle.cornerBase.X - dimstyle.origin.X) * 0.001), yTextLocation - mtextActualHeight); string postIdFormat = string.Format("[REDDITCAD POST ID: {0} ]", postId); DrawEntity.DrawText(postIdLocation, dimstyle.subHeadingTxtSize, dimstyle.textWidth, postIdFormat, "REDDIT.POSTID", 10); PostIds.AddPost(postId, post); i--; } } } catch (Exception e) { System.Windows.MessageBox.Show(e.Message); result = "FAILED"; } return(result); }