Beispiel #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         using (SaveFileDialog saveFileDialog = new SaveFileDialog())
         {
             DateTime now = DateTime.Now;
             saveFileDialog.Filter   = "PNG (*.png)|*.png";
             saveFileDialog.FileName = string.Format("Map{0}{1:00}{2:00}.{3:00}{4:00}{5:00}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);
             Image image = gMap.ToImage();
             if (image == null)
             {
                 return;
             }
             using (image)
             {
                 if (saveFileDialog.ShowDialog(this) != DialogResult.OK)
                 {
                     return;
                 }
                 image.Save(saveFileDialog.FileName);
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #2
0
        public void SaveSnapshot(string fileName)
        {
            Image tmpImage = fMapControl.ToImage();

            if (tmpImage != null)
            {
                using (tmpImage) {
                    tmpImage.Save(fileName);
                }
            }
        }
        public static void SaveMap(GMapControl map)
        {
            try
            {
                using (SaveFileDialog dialog = new SaveFileDialog())
                {
                    dialog.Filter   = "PNG (*.png)|*.png";
                    dialog.FileName = "GMap.NET image";
                    Image image = map.ToImage();
                    if (image != null)
                    {
                        using (image)
                        {
                            if (dialog.ShowDialog() == DialogResult.OK)
                            {
                                //Заносим в переменную имя файла введенное
                                //в диалоговом окне.
                                string fileName = dialog.FileName;


                                if (!fileName.EndsWith(".png",
                                                       StringComparison.OrdinalIgnoreCase))
                                {
                                    fileName += ".png";
                                }

                                image.Save(fileName);


                                MessageBox.Show("Карта успешно сохранена в директории: "
                                                + Environment.NewLine
                                                + dialog.FileName, "GMap.NET",
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Asterisk);
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Ошибка при сохранении карты: "
                                + Environment.NewLine
                                + exception.Message,
                                "GMap.NET",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Hand);
            }
        }
Beispiel #4
0
 /// <summary>
 /// 地图快照
 /// </summary>
 /// <returns>图片</returns>
 public System.Drawing.Image Snapshot()
 {
     return(mapControl.ToImage());
 }