コード例 #1
0
        private void getPicture(GMapMarker marker)
        {
            MarkerTag  tag       = (MarkerTag)marker.Tag;
            Bitmap     bitmap    = ColorTable.getBitmap("Red", tag.Size);
            GMapMarker newMarker = new GMarkerGoogle(marker.Position, bitmap);

            newMarker.LocalPosition = marker.LocalPosition;
            newMarker.Offset        = marker.Offset;
            selectedMarkersOverlay.Markers.Add(newMarker);
            gMap.Overlays.Add(selectedMarkersOverlay);
            GMapMarker[] selectedMarkers = selectedMarkersOverlay.Markers.ToArray <GMapMarker>();
            mOverlayDict.Add("selected", selectedMarkers);

            if (tag.Path != null)
            {
                try
                {
                    if (pictureBox.Image != null)
                    {
                        pictureBox.Image.Dispose();
                    }
                    lbPhoto.Text     = tag.PhotoName;
                    pictureBox.Image = Image.FromFile(tag.Path);
                }
                catch (FileNotFoundException ex)
                {
                    lbPhoto.Text = ex.Message;
                }
            }
            else
            {
                string       bucket = "central-waikato";
                string       url    = "https://centralwaikato2019.s3.ap-southeast-2.amazonaws.com/" + tag.PhotoName + ".jpg";
                var          buffer = new byte[1024 * 8]; // 8k buffer.
                MemoryStream data   = new MemoryStream();
                int          offset = 0;
                try
                {
                    var request   = (HttpWebRequest)WebRequest.Create(url);
                    var response  = request.GetResponse();
                    int bytesRead = 0;
                    using (var responseStream = response.GetResponseStream())
                    {
                        while ((bytesRead = responseStream.Read(buffer, 0, buffer.Length)) != 0)
                        {
                            data.Write(buffer, 0, bytesRead);
                            offset += bytesRead;
                        }
                    }
                    image = Image.FromStream(data);
                    data.Close();
                    lbPhoto.Text     = tag.ToString();
                    pictureBox.Image = image;
                }
                catch (WebException ex)
                {
                    lbPhoto.Text = ex.Message;
                }
            }
        }
コード例 #2
0
        private GMapMarker setToolTip(GMapMarker marker)
        {
            MarkerTag tag = (MarkerTag)marker.Tag;

            marker.ToolTipText        = '\n' + tag.ToString();
            marker.ToolTip.Fill       = Brushes.White;
            marker.ToolTip.Foreground = Brushes.Black;
            marker.ToolTip.Stroke     = Pens.Black;
            //marker.ToolTip.TextPadding = new Size(20, 20);
            marker.ToolTipMode = MarkerTooltipMode.OnMouseOver;
            return(marker);
        }