Exemplo n.º 1
0
        private void plotTrain()
        {
            this.Text      = DateTime.Now.ToString();
            timer1.Enabled = false;

            List <PointLatLng> positions = new List <PointLatLng>();
            List <int>         list      = selected();

            #region Read File Data

            if (list.Count > 0)
            {
                string query = "SELECT * FROM logs" +
                               " inner join devices on devices.id = logs.device_id" +
                               " WHERE device_id IN(" + String.Join(",", list.ToArray()) + ") " +
                               " GROUP BY device_id ORDER BY id DESC";
                DataTable dt = SqliteDal.getData(query);

                foreach (DataRow row in dt.Rows) // Loop over the rows.
                {
                    PointLatLng p = new PointLatLng
                    {
                        Lat = float.Parse(row["lat"].ToString()),
                        Lng = float.Parse(row["lng"].ToString())
                    };

                    Image markerImage = Image.FromFile(config.MyDirectory() + @"\marker\" + row["image"].ToString());


                    /* Bitmap bmp = new Bitmap(markerImage.Width, markerImage.Height);
                     * using (Graphics g = Graphics.FromImage(bmp))
                     * {
                     *   g.Clear(Color.SkyBlue);
                     *   g.InterpolationMode = InterpolationMode.NearestNeighbor;
                     *   g.PixelOffsetMode = PixelOffsetMode.None;
                     *   g.DrawImage(markerImage, Point.Empty);
                     * }
                     */

                    GMapMarkerImage marker = new GMapMarkerImage(p, markerImage);
                    objects.Markers.Add(marker);

                    // marker.ToolTipMode = MarkerTooltipMode.Always; enable tooltip
                    marker.ToolTipText = row["subscriber_name"].ToString();
                }
            }
            MainMap.Refresh();
            #endregion
            timer1.Enabled = true;
        }
Exemplo n.º 2
0
        private void plotTrain_old()
        {
            this.Text      = DateTime.Now.ToString();
            timer1.Enabled = false;

            List <PointLatLng> positions = new List <PointLatLng>();
            List <int>         list      = selected();

            #region Read File Data

            if (list.Count > 0)
            {
                string query = "SELECT * FROM logs" +
                               " inner join devices on devices.id = logs.device_id" +
                               " WHERE device_id IN(" + String.Join(",", list.ToArray()) + ") " +
                               " GROUP BY device_id ORDER BY id DESC";
                DataTable dt = SqliteDal.getData(query);

                foreach (DataRow row in dt.Rows) // Loop over the rows.
                {
                    PointLatLng p = new PointLatLng
                    {
                        Lat = float.Parse(row["lat"].ToString()),
                        Lng = float.Parse(row["lng"].ToString())
                    };
                    //positions.Add(p);
                    //GMapCustomImageMarker marker = new GMapCustomImageMarker(markerImage, p);
                    Image           markerImage = Image.FromFile(config.MyDirectory() + @"\marker\" + row["image"]);
                    GMapMarkerImage marker      = new GMapMarkerImage(p, markerImage);
                    objects.Markers.Add(marker);

                    //add marker
                }
            }

            /*TextReader file = new StreamReader(config.MyDirectory() + @"\data\data.csv");
             * string aLine;
             * while ((aLine = file.ReadLine()) != null)
             * {
             *  string[] pos = aLine.Split(',');
             *  PointLatLng p = new PointLatLng
             *  {
             *      Lat = float.Parse(pos[1]),
             *      Lng = float.Parse(pos[2])
             *  };
             *  //positions.Add(p);
             *  //GMarkerGoogle m = new GMarkerGoogle(p, GMarkerGoogleType.green);
             *  Image markerImage = Image.FromFile(config.MyDirectory() + @"\marker\train_red.png");
             *  //GMapCustomImageMarker marker = new GMapCustomImageMarker(markerImage, p);
             *  GMapMarkerImage marker = new GMapMarkerImage(p, markerImage);
             *  objects.Markers.Add(marker);
             *
             *  //add marker
             *
             *
             * }*/

            MainMap.Refresh();



            #endregion



            //Random rnd = new Random();
            //int index = rnd.Next(1, positions.Count); // creates a number between 1 and 12

            //GMarkerGoogle m = new GMarkerGoogle(positions[index], GMarkerGoogleType.orange);
            //objects.Markers.Add(m);
            timer1.Enabled = true;
        }