} //end m_PictureBoxGraph_Resize private void DrawGraph() { m_graphics.Clear(m_Options.Background); float[] rf = m_recv_all_q.ToArray(); float[] sf = m_send_all_q.ToArray(); for (int i = 0; i < m_bmp.Width && i < rf.Length; i++) { float recv2 = rf[rf.Length - (1 + i)]; float send2 = sf[sf.Length - (1 + i)]; recv2 /= linespeed; send2 /= linespeed; float maxr = recv2; float minr = send2; Pen maxp = m_penDown; if (recv2 < send2) { maxp = m_penUp; maxr = send2; minr = recv2; } //end if //Pen s = both; int max = (int)(m_bmp.Height - (maxr * m_bmp.Height / (1 + m_Options.Overflow))); int min = (int)(m_bmp.Height - (minr * m_bmp.Height / (1 + m_Options.Overflow))); if (max < 0) { max = 0; } if (min < 0) { min = 0; } int pos = m_bmp.Width - i - 1; m_graphics.DrawLine(maxp, pos, min, pos, max); m_graphics.DrawLine(m_penBoth, pos, m_bmp.Height, pos, min); } //end for m_PictureBoxGraph.Image = m_bmp; } //end DrawGraph
public void Process(string chunk, ProcessorResult result) { var comments = JSON.Deserialize <Comment[]>(chunk); // We'll use this queue to keep track of all the phrases in our comments var lastWords = new FixedSizeQueue <string>(_queueSize); foreach (var comment in comments) { if (!CommunityWhitelist.Values.Contains(comment.subreddit.ToUpper())) { continue; } var body = Regex.Replace(comment.body, @"[.!?,_]", " "); var tokens = body.Split((string[])null, StringSplitOptions.RemoveEmptyEntries) .ToList() .Select(token => token.ToUpper()); result.WordCountBySub.TryAdd(comment.subreddit, new Dictionary <string, long>()); foreach (var token in tokens) { lastWords.Enqueue(token); for (var i = 0; i < lastWords.Count; i++) { var words = lastWords.ToArray().Take(i + 1); // Join our phrase together var phrase = string.Join(" ", words); result.WordCountBySub[comment.subreddit].TryAdd(phrase, 0); result.WordCountBySub[comment.subreddit][phrase] += 1; } } // After we're done with a comment, clear out the queue lastWords.Clear(); } }