OutPicture.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using WWPipeLine.MapBasic.Conditions;
  11. using Sunny.UI;
  12. using WeifenLuo.WinFormsUI.Docking;
  13. using SuperMap.Mapping;
  14. using WWPipeLine.MapBasic;
  15. namespace WWPipeLine.MapTools.Conditions.ShuJuChuLi
  16. {
  17. public partial class OutPicture : ConditionPanel
  18. {
  19. private string fileName = string.Empty;
  20. public OutPicture()
  21. {
  22. this.ConditionPanelName = "地图导出图片";
  23. InitializeComponent();
  24. }
  25. protected override void OnLoad(EventArgs e)
  26. {
  27. }
  28. private void uiButton1_Click(object sender, EventArgs e)
  29. {
  30. SaveFileDialog sfd = new SaveFileDialog();
  31. sfd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  32. sfd.Title = "请选择要保存的文件路径";
  33. sfd.Filter = "所有文件|*.*";
  34. if (sfd.ShowDialog() == DialogResult.OK)
  35. {
  36. fileName = sfd.FileName;
  37. uiTextBox1.Text = fileName;
  38. }
  39. }
  40. public override object Do(DockPanel dockPanel = null)
  41. {
  42. this.IsShowResultWindow = false;
  43. if (string.IsNullOrEmpty(fileName))
  44. { UIMessageTip.ShowError("请选择要保存的文件路径"); return false; }
  45. //bool result = false;
  46. //if (uiRBjpg.Checked) { result = MapControl.Map.OutputMapToJPG(fileName); }
  47. //else if (uiRBbmp.Checked) { result = MapControl.Map.OutputMapToBMP(fileName); }
  48. //else if (uiRBpng.Checked) { result = MapControl.Map.OutputMapToPNG(fileName, false); }
  49. //else if (uiRBgif.Checked) { result = MapControl.Map.OutputMapToGIF(fileName, false); }
  50. //else { result = MapControl.Map.OutputMapToJPG(fileName); }
  51. //ComsStatic.ShowUIMessageTipOKorError(result, "地图导出图片");
  52. ImageType imgType = ImageType.JPG; ;
  53. if (uiRBjpg.Checked) { imgType = ImageType.JPG; }
  54. if (uiRBbmp.Checked) { imgType = ImageType.BMP; }
  55. if (uiRBpng.Checked) { imgType = ImageType.PNG; }
  56. if (uiRBgif.Checked) { imgType = ImageType.GIF; }
  57. if (uiRBtiff.Checked) { imgType = ImageType.TIFF; }
  58. bool result = MapControl.Map.OutputMapToFile(fileName, imgType, 96, MapControl.Map.ViewBounds, false);
  59. ComsStatic.ShowUIMessageTipOKorError(result, "地图导出图片");
  60. return true;
  61. }
  62. }
  63. }