Example #1
0
        private void UpdateMap()
        {
            if (!mapInit)
            {
                InitMap();
            }

            gMapControl1.Overlays.Clear();
            GMapOverlay markersOverlay = new GMapOverlay("markers");

            this.gMapControl1.Overlays.Add(markersOverlay);

            IEnumerable <DbTweet> tws = core.GetGeolocatedTweets(10);

            foreach (DbTweet tw in tws)
            {
                try
                {
                    Console.Out.WriteLine(">>> MAP: " + tw.Coord.Item1 + ", " + tw.Coord.Item2);
                    //gMapControl1.Visible = false;
                    GMarkerGoogle marker = null;

                    if (tw.Coord != null)
                    {
                        marker              = new GMarkerGoogle(new PointLatLng(tw.Coord.Item1, tw.Coord.Item2), new Bitmap(core.GetTopicImage(0, core.GetDbTopicFromId(tw.About[0]))));
                        marker.ToolTip      = new GMapToolTip(marker);
                        marker.ToolTip.Font = new Font(FontFamily.GenericSansSerif, 8);
                        marker.ToolTipText  = tw.Author + "\nPos: " + tw.PosValue + " - Neg: " + tw.NegValue + "\n\n";
                        String twText = tw.Text;
                        while (twText.Length > 40)
                        {
                            marker.Tag += twText.Substring(0, 40) + "\n";
                            twText      = twText.Substring(40);
                        }
                        marker.Tag += twText;
                        //marker.Offset = new Point(10, 10);
                    }

                    markersOverlay.Markers.Add(marker);
                }
                catch (Exception e)
                {
                    Console.Out.WriteLine("Problema al agregar marker: " + e.Message + "\n" + e.StackTrace);
                }
            }

            this.gMapControl1.Overlays.Add(markersOverlay);
            //gMapControl1.Visible = true;
            gMapControl1.Update();
        }
Example #2
0
        private void ShowTweets()
        {
            this.pictureBox1.Image = Core.GetTopicImage(2, About);

            List <DbTweet> TweetList = TweetSet.ToList();

            if (Selection != SelectionWordRelated) // No se muestran los tweets relacionados con una palabra, sino los que cumplen con cierta característica.
            {
                if (Selection == SelectionFav)
                {
                    TweetList = TweetList.Where(x => x.RT > 1).ToList();
                    TweetList.Sort((x, y) => { return(-x.RT.CompareTo(y.RT)); });
                    if (TweetList.Count > 5)
                    {
                        TweetList.RemoveRange(5, TweetList.Count - 5);
                    }
                }
                if (Selection == SelectionPos)
                {
                    TweetList = TweetList.Where(x => x.PosValue > 0).ToList();
                    TweetList.Sort((x, y) => { return(-x.PosValue.CompareTo(y.PosValue)); });
                    if (TweetList.Count > 5)
                    {
                        TweetList.RemoveRange(5, TweetList.Count - 5);
                    }
                }
                if (Selection == SelectionNeg)
                {
                    TweetList = TweetList.Where(x => x.NegValue > 0).ToList();
                    TweetList.Sort((x, y) => { return(-x.NegValue.CompareTo(y.NegValue)); });
                    if (TweetList.Count > 5)
                    {
                        TweetList.RemoveRange(5, TweetList.Count - 5);
                    }
                }
                if (Selection == SelectionAmb)
                {
                    TweetList = TweetList.Where(x => x.PosValue > 0 && x.NegValue > 0).ToList();
                    TweetList.Sort((x, y) => { return(-(x.PosValue + x.NegValue).CompareTo(y.PosValue + y.NegValue)); });
                    if (TweetList.Count > 5)
                    {
                        TweetList.RemoveRange(5, TweetList.Count - 5);
                    }
                }
            }

            //tableLayoutPanel.RowStyles[0].Height = 24;

            foreach (DbTweet tw in TweetList)
            {
                RichTextBox toAdd = new RichTextBox()
                {
                    Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular), Width = 400, Height = 80, Padding = new Padding(3)
                };

                toAdd.Enabled   = false;
                toAdd.ForeColor = Color.FromArgb(50, 50, 50);
                toAdd.Text      = tw.Text;
                foreach (String w in tw.Terms)
                {
                    Color c = Color.FromArgb(255, 0, 0, 128);
                    if (Core.GetDbTopicFromAlias(w) != null)
                    {
                        c = Color.FromArgb(255, 255, 0, 255);

                        toAdd.Find(w);
                        toAdd.SelectionColor = c;
                        toAdd.SelectionFont  = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
                    }
                    else if (Core.words.ContainsKey(w))
                    {
                        if (Core.words[w] == 1)
                        {
                            c = Color.FromArgb(255, 0, 128, 0);
                        }
                        else if (Core.words[w] == -1)
                        {
                            c = Color.FromArgb(255, 128, 0, 0);
                        }
                        else if (Core.words[w] == 2)
                        {
                            c = Color.FromArgb(255, 128, 128, 255);
                        }
                        else
                        {
                            c = Color.FromArgb(255, 0, 0, 128);
                        }

                        toAdd.Find(w, RichTextBoxFinds.WholeWord);
                        toAdd.SelectionColor = c;
                    }
                }

                tableLayoutPanel.RowCount++;
                tableLayoutPanel.Controls.Add(new Label()
                {
                    Text = tw.Author, Padding = new Padding(3)
                }, 0, tableLayoutPanel.RowCount - 1);
                tableLayoutPanel.Controls.Add(toAdd, 1, tableLayoutPanel.RowCount - 1);
                //tableLayoutPanel.Controls.Add(new Label() { Text = tw.RT + "", Padding = new Padding(3) }, 2, tableLayoutPanel.RowCount - 1);

                tableLayoutPanel.Height += toAdd.Height;
            }

            tableLayoutPanel.Update();
        }