private void Picture_Click(object sender, EventArgs e) { if (sender is Label2) { Label2 lab = (Label2)sender; string video = lab.GetUrl(); VideoForm vf = new VideoForm(video); vf.Show(); } else { // int max = Screen.PrimaryScreen.WorkingArea.Height - 25; PictureBox pb = (PictureBox)sender; System.Drawing.Image img = pb.Image; PictureForm pf = new PictureForm(img); pf.Height = Sheight < img.Height ? (int)Sheight + 15 : img.Height; pf.Width = img.Width + 20; pf.Show(); } }
public void DoSearch(String term, string selected = null) { if (term == "" && !SearchAll.Checked) { return; } ClearPanel(BigPanel); mainDict = new Dictionary <string, List <String> >(); NameId = new Dictionary <string, List <int> >(); Dictionary <string, List <string> > TimeStamp = new Dictionary <string, List <string> >(); int index = 0; foreach (var msg in o1["messages"]) { if (msg.ToString().Contains("content") || SearchAll.Checked || msg["share"] != null) { String content = msg.ToString().Contains("content") ? msg["content"].ToString() : "!!Click to view media!!"; if (msg["share"] != null) { if (msg["share"]["link"] != null) { content = msg["share"]["link"].ToString(); } } String pattern = @"\b" + term.ToLower() + @"\b"; if (System.Text.RegularExpressions.Regex.IsMatch(content.ToLower(), pattern)) { String name = msg["sender_name"].ToString(); double timeMs = Convert.ToDouble(msg["timestamp_ms"].ToString()); string timeStr = TimespampConverter(timeMs).ToString(); if (!mainDict.ContainsKey(name)) { mainDict.Add(name, new List <String>()); NameId.Add(name, new List <int>()); TimeStamp.Add(name, new List <string>()); } mainDict[name].Add(content); NameId[name].Add(index); TimeStamp[name].Add(timeStr); } } index++; } if (selected == null) { foreach (RadioButton btn in ButtonPanel.Controls) { if (btn.Checked) { selected = btn.Text; } } } if (mainDict.Count == 0) { NowReadingLab.Text = "No one has said " + term; NowReadingLab.Visible = true; return; } if ((selected != null && selected != "None") && !mainDict.ContainsKey(selected)) { NowReadingLab.Text = selected + " has never said " + term; NowReadingLab.Visible = true; return; } if (selected == null || selected == "None") { NowReadingLab.Visible = false; List <string> sorted = GetOrder(mainDict); foreach (string name in sorted) { Label temp = new Label { Text = name + " said " + term + " " + mainDict[name].Count + " times", AutoSize = true, Font = new System.Drawing.Font(Font.Name, 10) }; temp.Click += new EventHandler(Label_Click); BigPanel.Controls.Add(temp); BigPanel.Controls.Add(new Label()); } } else { string firstname = selected.Substring(0, selected.IndexOf(' ')); NowReadingLab.Text = "Now reading messages from " + firstname; NowReadingLab.Visible = true; for (int i = 0; i < mainDict[selected].Count; i++) { string msg = mainDict[selected][i]; Label2 temp = new Label2(); temp.Set(NameId[selected][i]); temp.SetDate(TimeStamp[selected][i]); temp.Text = msg; temp.AutoSize = true; temp.Font = new System.Drawing.Font(temp.Font.Name, 10); temp.DoubleClick += new EventHandler(ContextMsg_Click); BigPanel.Controls.Add(temp); if (ShowDatesCheck.Checked) { Label2 timeLab = new Label2(); timeLab.AutoSize = true; timeLab.Text = TimeStamp[selected][i]; timeLab.ForeColor = System.Drawing.Color.Aquamarine; BigPanel.Controls.Add(timeLab); } BigPanel.Controls.Add(new Label()); } } }
public void ContextMsg_Click(object sender, EventArgs e) { NowReadingLab.Text = "Now reading context messages"; Label2 LabMsg = (Label2)sender; String term = LabMsg.Text; ClearPanel(BigPanel); List <String[]> msgList = new List <String[]>(); int index = LabMsg.GetId(); Label scrollTarget = null; int orgIndex = index; if (index - 15 < 0) { index = 15; } else if (index + 15 > o1["messages"].Count() - 1) { index = o1["messages"].Count() - 16; } for (int i = index + 15; i >= index - 15; i--) { var msgObj = o1["messages"][i]; string name = msgObj["sender_name"].ToString(); Label timeLab = new Label(); double time = Convert.ToDouble(msgObj["timestamp_ms"].ToString()); timeLab.AutoSize = true; timeLab.Text = TimespampConverter(time).ToString(); timeLab.ForeColor = System.Drawing.Color.Aquamarine; if (msgObj.ToString().Contains("content")) { string msg = msgObj["content"].ToString(); Label tempName = new Label() { Text = name + ":", AutoSize = true, Font = new System.Drawing.Font(Font.Name, 10) }; tempName.Font = new Font(tempName.Font, FontStyle.Bold); Label2 tempMsg = new Label2 { Text = msg, AutoSize = true, Font = new System.Drawing.Font(Font.Name, 10) }; tempMsg.Set(i); string Date = TimespampConverter(Convert.ToDouble(msgObj["timestamp_ms"].ToString())).ToString(); tempMsg.SetDate(Date); tempMsg.DoubleClick += new EventHandler(ContextMsg_Click); if (i == orgIndex) { tempName.ForeColor = System.Drawing.Color.Red; tempMsg.ForeColor = System.Drawing.Color.Red; scrollTarget = tempMsg; } BigPanel.Controls.Add(tempName); BigPanel.Controls.Add(tempMsg); if (ShowDatesCheck.Checked) { BigPanel.Controls.Add(timeLab); } BigPanel.Controls.Add(new Label()); } else if (msgObj.ToString().Contains("photos") || msgObj.ToString().Contains("gifs")) { Label tempName = new Label() { Text = name + ":", AutoSize = true, Font = new System.Drawing.Font(Font.Name, 10) }; string url = msgObj.ToString().Contains("photos") ? path + msgObj["photos"][0]["uri"].ToString() : path + msgObj["gifs"][0]["uri"].ToString(); System.Drawing.Image img = System.Drawing.Image.FromFile(url); PictureBox pb = new PictureBox() { Image = img, Width = img.Width / 3, Height = img.Height / 3, SizeMode = PictureBoxSizeMode.Zoom, Tag = timeLab.Text }; pb.DoubleClick += new EventHandler(Picture_Click); BigPanel.Controls.Add(tempName); BigPanel.Controls.Add(pb); if (ShowDatesCheck.Checked) { BigPanel.Controls.Add(timeLab); } BigPanel.Controls.Add(new Label()); } else if (msgObj.ToString().Contains("videos")) { Label tempName = new Label() { Text = name + ":", AutoSize = true, Font = new System.Drawing.Font(Font.Name, 10) }; string uri = path + msgObj["videos"][0]["uri"].ToString(); Label2 textDisp = new Label2() { Text = "Click here to play media" + ":", AutoSize = true, Font = new System.Drawing.Font(Font.Name, 10) }; textDisp.Font = new Font(textBox1.Font, FontStyle.Bold); textDisp.SetUrl(uri); textDisp.DoubleClick += new EventHandler(Picture_Click); BigPanel.Controls.Add(tempName); BigPanel.Controls.Add(textDisp); if (ShowDatesCheck.Checked) { BigPanel.Controls.Add(timeLab); } BigPanel.Controls.Add(new Label()); } } BigPanel.ScrollControlIntoView(scrollTarget); }