12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using WWPipeLine.MapBasic.Conditions;
- using Sunny.UI;
- using WeifenLuo.WinFormsUI.Docking;
- using SuperMap.Mapping;
- using WWPipeLine.MapBasic;
- using SuperMap.Data;
- namespace WWPipeLine.MapTools.Conditions.ShuJuChuLi
- {
- public partial class OutPicturecj : ConditionPanel
- {
- private string fileName = string.Empty;
- private GeoRegion m_geo = null;
- public OutPicturecj()
- {
- this.ConditionPanelName = "裁剪地图导出图片";
- InitializeComponent();
- }
- protected override void OnLoad(EventArgs e)
- {
- }
- private void uiButton1_Click(object sender, EventArgs e)
- {
- SaveFileDialog sfd = new SaveFileDialog();
- sfd.InitialDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory);
- sfd.Title = "请选择要保存的文件路径";
- sfd.Filter = "所有文件|*.*";
- if (sfd.ShowDialog() == DialogResult.OK)
- {
- fileName = sfd.FileName;
- uiTextBox1.Text = fileName;
- }
- }
- public override object Do(DockPanel dockPanel = null)
- {
- this.IsShowResultWindow = false;
- if (string.IsNullOrEmpty(fileName))
- { UIMessageTip.ShowError("请选择要保存的文件路径"); return false; }
- ImageType imgType = ImageType.JPG; ;
- if (uiRBjpg.Checked) { imgType = ImageType.JPG; }
- if (uiRBbmp.Checked) { imgType = ImageType.BMP; }
- if (uiRBpng.Checked) { imgType = ImageType.PNG; }
- bool result = MapControl.Map.OutputMapToFile(fileName, imgType, 96, MapControl.Map.ViewBounds, false);
- ComsStatic.ShowUIMessageTipOKorError(result, "地图导出图片");
- return true;
- }
- private void uiButton2_Click(object sender, EventArgs e)
- {
- MapControl.Action = SuperMap.UI.Action.CreatePolygon;
- MapControl.Tracked += MapControl_Tracked;
- }
- private void uiButton3_Click(object sender, EventArgs e)
- {
- MapControl.Action = SuperMap.UI.Action.Pan;
- MapControl.Map.TrackingLayer.Clear();
- MapControl.Map.RefreshEx(MapControl.Map.ViewBounds);
- }
- private void MapControl_Tracked(object sender, SuperMap.UI.TrackedEventArgs e)
- {
- if (e.Geometry is null) return;
- m_geo = e.Geometry.Clone() as GeoRegion;
- if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("区域绘制失败"); return; }
- m_geo.Style = ComsStatic.geoStyle_Red_1mm_OpaqueRate;
- MapControl.Map.TrackingLayer.Clear();
- MapControl.Map.TrackingLayer.Add(m_geo, "GeoRectangle");
- MapControl.Map.IsClipRegionEnabled = true;
- MapControl.Map.ClipRegion = m_geo;
- MapControl.Map.Refresh();
- }
- public override void AfterClose()
- {
- MapControl.Map.IsClipRegionEnabled = false;
- MapControl.Tracked -= MapControl_Tracked;
- base.AfterClose();
- }
- }
- }
|