MapEx.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 SuperMap.UI;
  11. using SuperMap.Mapping;
  12. using WeifenLuo.WinFormsUI.Docking;
  13. using WWPipeLine.MapBasic.Conditions;
  14. using SuperMap.Data;
  15. namespace WWPipeLine.MapBasic
  16. {
  17. /// <summary>
  18. /// 二维场景MapEx
  19. /// </summary>
  20. public partial class MapEx : DockContent //DocWindowExtend
  21. {
  22. /// <summary>
  23. /// 二维场景MapEx
  24. /// </summary>
  25. public MapEx()
  26. {
  27. InitializeComponent();
  28. this.TabText = "二维场景MapEx";
  29. this.Tag = "MainControls";
  30. this.AutoScaleMode = AutoScaleMode.Dpi;
  31. this.CloseButtonVisible = false;
  32. this.CloseButton = false;
  33. this.AllowEndUserDocking = false;
  34. this.DockAreas = DockAreas.Document;
  35. this.FormBorderStyle = FormBorderStyle.None;
  36. this.MaximizeBox = false;
  37. this.MinimizeBox = false;
  38. this.ControlBox = false;
  39. }
  40. private MapControl m_MapControl;
  41. public MapControl MapControl { get => m_MapControl; set => m_MapControl = value; }
  42. private MapControl m_EagleEyeControl;
  43. public MapControl MapControlOfEagleEye { get => m_EagleEyeControl; set => m_EagleEyeControl = value; }
  44. protected override void OnLoad(EventArgs e)
  45. {
  46. if (m_MapControl != null) return;
  47. if (m_EagleEyeControl != null) return;
  48. m_MapControl = new MapControlover { Dock = DockStyle.Fill };
  49. m_MapControl.InteractionMode = InteractionMode.CustomKeyboard;
  50. m_MapControl.KeyDown += new KeyEventHandler(m_MapControl_KeyDown);
  51. m_MapControl.MarginPanEnabled = false;
  52. m_MapControl.IsActionPrior = false;
  53. m_MapControl.TrackMode = TrackMode.Track;
  54. this.Controls.Add(m_MapControl);
  55. LayersTreeEx layersTreeEx = new LayersTreeEx(m_MapControl);
  56. layersTreeEx.Show(ComsStatic.DockPanel, DockState.DockLeft);
  57. layersTreeEx.DockPanel.DockLeftPortion = 0.15;
  58. m_EagleEyeControl = new MapControl { Dock = DockStyle.Fill };
  59. m_EagleEyeControl.MarginPanEnabled = false;
  60. m_EagleEyeControl.IsWaitCursorEnabled = false;
  61. m_EagleEyeControl.InteractionMode = InteractionMode.CustomAll;
  62. this.Controls.Add(m_EagleEyeControl);
  63. EagleEyeEx eagleEyeEx = new EagleEyeEx(m_EagleEyeControl);
  64. eagleEyeEx.Show(layersTreeEx.Pane, DockAlignment.Top, 0.3);
  65. }
  66. protected class MapControlover : MapControl
  67. {
  68. public MapControlover()
  69. {
  70. MapControlover.Cursors.Pan = MapControl.Cursors.Arrow;//System.Windows.Forms.Cursors.Arrow;
  71. }
  72. protected override void OnMouseWheel(MouseEventArgs e)
  73. {
  74. if (e.Delta > 0)
  75. this.Map.Zoom(1.2);
  76. if (e.Delta < 0)
  77. this.Map.Zoom(0.8);
  78. }
  79. protected override void OnMouseDown(MouseEventArgs e)
  80. {
  81. if (e.Button == MouseButtons.Right && this.Action == SuperMap.UI.Action.Pan)
  82. return;
  83. base.OnMouseDown(e);
  84. }
  85. }
  86. private void m_MapControl_KeyDown(object sender, KeyEventArgs e)
  87. {
  88. switch (e.KeyCode)
  89. {
  90. case Keys.A: m_MapControl.Action = SuperMap.UI.Action.Pan; break;
  91. case Keys.S: m_MapControl.Action = SuperMap.UI.Action.Select; break;
  92. case Keys.F5: m_MapControl.Map.Refresh(); break;
  93. default: break;
  94. }
  95. }
  96. public void RemoveAllToolBar()
  97. {
  98. foreach (Control control in this.Controls)
  99. {
  100. if (control is BasicToolBar)
  101. {
  102. (control as BasicToolBar).AfterClose();
  103. this.Controls.Remove(control);
  104. break;
  105. }
  106. }
  107. }
  108. public void AddToolBar(BasicToolBar basicToolBar)
  109. {
  110. basicToolBar.Dock = DockStyle.Top;
  111. this.Controls.Add(basicToolBar);
  112. }
  113. }
  114. }