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 SuperMap.UI; using SuperMap.Mapping; using WeifenLuo.WinFormsUI.Docking; using WWPipeLine.MapBasic.Conditions; using SuperMap.Data; namespace WWPipeLine.MapBasic { /// /// 二维场景MapEx /// public partial class MapEx : DockContent //DocWindowExtend { /// /// 二维场景MapEx /// public MapEx() { InitializeComponent(); this.TabText = "二维场景MapEx"; this.Tag = "MainControls"; this.AutoScaleMode = AutoScaleMode.Dpi; this.CloseButtonVisible = false; this.CloseButton = false; this.AllowEndUserDocking = false; this.DockAreas = DockAreas.Document; this.FormBorderStyle = FormBorderStyle.None; this.MaximizeBox = false; this.MinimizeBox = false; this.ControlBox = false; } private MapControl m_MapControl; public MapControl MapControl { get => m_MapControl; set => m_MapControl = value; } private MapControl m_EagleEyeControl; public MapControl MapControlOfEagleEye { get => m_EagleEyeControl; set => m_EagleEyeControl = value; } protected override void OnLoad(EventArgs e) { if (m_MapControl != null) return; if (m_EagleEyeControl != null) return; m_MapControl = new MapControlover { Dock = DockStyle.Fill }; m_MapControl.InteractionMode = InteractionMode.CustomKeyboard; m_MapControl.KeyDown += new KeyEventHandler(m_MapControl_KeyDown); m_MapControl.MarginPanEnabled = false; m_MapControl.IsActionPrior = false; m_MapControl.TrackMode = TrackMode.Track; this.Controls.Add(m_MapControl); LayersTreeEx layersTreeEx = new LayersTreeEx(m_MapControl); layersTreeEx.Show(ComsStatic.DockPanel, DockState.DockLeft); layersTreeEx.DockPanel.DockLeftPortion = 0.15; m_EagleEyeControl = new MapControl { Dock = DockStyle.Fill }; m_EagleEyeControl.MarginPanEnabled = false; m_EagleEyeControl.IsWaitCursorEnabled = false; m_EagleEyeControl.InteractionMode = InteractionMode.CustomAll; this.Controls.Add(m_EagleEyeControl); EagleEyeEx eagleEyeEx = new EagleEyeEx(m_EagleEyeControl); eagleEyeEx.Show(layersTreeEx.Pane, DockAlignment.Top, 0.3); } protected class MapControlover : MapControl { public MapControlover() { MapControlover.Cursors.Pan = MapControl.Cursors.Arrow;//System.Windows.Forms.Cursors.Arrow; } protected override void OnMouseWheel(MouseEventArgs e) { if (e.Delta > 0) this.Map.Zoom(1.2); if (e.Delta < 0) this.Map.Zoom(0.8); } protected override void OnMouseDown(MouseEventArgs e) { if (e.Button == MouseButtons.Right && this.Action == SuperMap.UI.Action.Pan) return; base.OnMouseDown(e); } } private void m_MapControl_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.A: m_MapControl.Action = SuperMap.UI.Action.Pan; break; case Keys.S: m_MapControl.Action = SuperMap.UI.Action.Select; break; case Keys.F5: m_MapControl.Map.Refresh(); break; default: break; } } public void RemoveAllToolBar() { foreach (Control control in this.Controls) { if (control is BasicToolBar) { (control as BasicToolBar).AfterClose(); this.Controls.Remove(control); break; } } } public void AddToolBar(BasicToolBar basicToolBar) { basicToolBar.Dock = DockStyle.Top; this.Controls.Add(basicToolBar); } } }