BasicToolBar.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. using SuperMap.Mapping;
  2. using SuperMap.UI;
  3. using System;
  4. using System.IO;
  5. using System.Windows.Forms;
  6. namespace WWPipeLine.MapBasic.Conditions
  7. {
  8. public class BasicToolBar : ConditionPanel
  9. {
  10. /// <summary>
  11. /// 工具条关闭按钮
  12. /// </summary>
  13. private Sunny.UI.UISymbolButton uiSymbolButtonClose;
  14. private ToolStripSeparator toolStripSeparator1;
  15. /// <summary>
  16. /// 工具条ToolStrip对象
  17. /// </summary>
  18. private ToolStrip m_ToolStrip;
  19. /// <summary>
  20. /// 工具条ToolStrip对象
  21. /// </summary>
  22. protected ToolStrip ToolStrip { get => m_ToolStrip; }
  23. /// <summary>
  24. /// 释放资源时统一释放对应的MapOperInterface对象
  25. /// </summary>
  26. /// <param name="disposing"></param>
  27. protected override void Dispose(bool disposing)
  28. {
  29. base.Dispose(disposing);
  30. }
  31. /// <summary>
  32. /// 默认的漫游按钮
  33. /// </summary>
  34. private ToolStripButton toolStripButtonPan;
  35. /// <summary>
  36. /// 默认的选择按钮
  37. /// </summary>
  38. private ToolStripButton toolStripButtonSelect;
  39. /// <summary>
  40. /// 默认的清除按钮
  41. /// </summary>
  42. private ToolStripButton toolStripButtonClear;
  43. /// <summary>
  44. /// 默认的图层选择框
  45. /// </summary>
  46. public ToolStripComboBox toolStripComboBoxLayer;
  47. public bool IsShowToolStripComboBox = false;
  48. /// <summary>
  49. /// 构造函数
  50. /// </summary>
  51. protected BasicToolBar()
  52. {
  53. InitializeComponent();
  54. this.ParentChanged += BasicToolBar_ParentChanged;
  55. string img1 = Commons.Paths.ApplicationResourcesDir + "\\ToolBar\\漫游.png";
  56. string img2 = Commons.Paths.ApplicationResourcesDir + "\\ToolBar\\选择.png";
  57. string img3 = Commons.Paths.ApplicationResourcesDir + "\\ToolBar\\清除.png";
  58. if (System.IO.File.Exists(img1))
  59. this.toolStripButtonPan.Image = System.Drawing.Image.FromFile(img1);
  60. if (System.IO.File.Exists(img2))
  61. this.toolStripButtonSelect.Image = System.Drawing.Image.FromFile(img2);
  62. if (System.IO.File.Exists(img3))
  63. this.toolStripButtonClear.Image = System.Drawing.Image.FromFile(img3);
  64. this.toolStripButtonPan.Click += ToolStripButtonPan_Click;
  65. this.toolStripButtonSelect.Click += ToolStripButtonSelect_Click;
  66. this.toolStripButtonClear.Click += ToolStripButtonClear_Click;
  67. this.uiSymbolButtonClose.Click += UiSymbolButtonClose_Click;
  68. }
  69. protected override void OnLoad(EventArgs e)
  70. {
  71. if (IsShowToolStripComboBox)
  72. {
  73. this.toolStripComboBoxLayer.Visible = true;
  74. foreach (Layer lyr in ComsStatic.MapLayers)
  75. {
  76. toolStripComboBoxLayer.ComboBox.Items.Add(new DoListItem(lyr.Dataset.Name, lyr.Caption));
  77. }
  78. toolStripComboBoxLayer.ComboBox.SelectedIndex = 0;
  79. }
  80. }
  81. /// <summary>
  82. /// 关闭父窗口时关闭对应的结果窗口
  83. /// </summary>
  84. /// <param name="sender"></param>
  85. /// <param name="e"></param>
  86. private void BasicToolBar_ParentChanged(object sender, EventArgs e)
  87. {
  88. if (this.Parent == null)
  89. {
  90. if (this.m_ResultWindow != null)
  91. {
  92. this.m_ResultWindow.Close();
  93. }
  94. }
  95. }
  96. /// <summary>
  97. /// 点击关闭按钮关闭
  98. /// </summary>
  99. /// <param name="sender"></param>
  100. /// <param name="e"></param>
  101. private void UiSymbolButtonClose_Click(object sender, EventArgs e)
  102. {
  103. CloseToolBar();
  104. }
  105. protected void CloseToolBar()
  106. {
  107. this.Parent.Controls.Remove(this);
  108. AfterClose();
  109. this.m_ResultWindow?.Close();
  110. }
  111. /// <summary>
  112. /// 给当前ToolStrip增加“保存标注”按钮及其单击事件
  113. /// </summary>
  114. protected void Item_add_BiaoZhuSave()
  115. {
  116. var bzSave = new ToolStripButton()
  117. {
  118. DisplayStyle = ToolStripItemDisplayStyle.ImageAndText,
  119. Text = "保存标注",
  120. Name = "StartDraw",
  121. AutoToolTip = false
  122. };
  123. var img = Commons.Paths.ApplicationResourcesDir + "\\ToolBar\\保存标注.png";
  124. if (System.IO.File.Exists(img))
  125. bzSave.Image = System.Drawing.Image.FromFile(img);
  126. m_ToolStrip.Items.Add(bzSave);
  127. bzSave.Click += BzSave_Click;
  128. }
  129. private void BzSave_Click(object sender, EventArgs e)
  130. {
  131. Sunny.UI.UIMessageTip.ShowError("未实现功能");
  132. }
  133. private void ToolStripButtonSelect_Click(object sender, EventArgs e)
  134. {
  135. MapControl.Action = SuperMap.UI.Action.Pan;
  136. MapControl.Action = SuperMap.UI.Action.Select;
  137. }
  138. private void ToolStripButtonPan_Click(object sender, EventArgs e)
  139. {
  140. MapControl.Action = SuperMap.UI.Action.Pan;
  141. }
  142. private void ToolStripButtonClear_Click(object sender, EventArgs e)
  143. {
  144. MapControl.Map.TrackingLayer.Clear();
  145. MapControl.Action = SuperMap.UI.Action.Pan;
  146. MapControl.Map.Refresh();
  147. }
  148. private void InitializeComponent()
  149. {
  150. System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BasicToolBar));
  151. this.m_ToolStrip = new System.Windows.Forms.ToolStrip();
  152. this.toolStripButtonPan = new System.Windows.Forms.ToolStripButton();
  153. this.toolStripButtonSelect = new System.Windows.Forms.ToolStripButton();
  154. this.toolStripButtonClear = new System.Windows.Forms.ToolStripButton();
  155. this.toolStripComboBoxLayer = new System.Windows.Forms.ToolStripComboBox();
  156. this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
  157. this.uiSymbolButtonClose = new Sunny.UI.UISymbolButton();
  158. this.m_ToolStrip.SuspendLayout();
  159. this.SuspendLayout();
  160. //
  161. // m_ToolStrip
  162. //
  163. this.m_ToolStrip.Dock = System.Windows.Forms.DockStyle.Fill;
  164. this.m_ToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
  165. this.toolStripButtonPan,
  166. this.toolStripButtonSelect,
  167. this.toolStripButtonClear,
  168. this.toolStripComboBoxLayer,
  169. this.toolStripSeparator1});
  170. this.m_ToolStrip.Location = new System.Drawing.Point(0, 0);
  171. this.m_ToolStrip.Name = "m_ToolStrip";
  172. this.m_ToolStrip.Padding = new System.Windows.Forms.Padding(0);
  173. this.m_ToolStrip.Size = new System.Drawing.Size(591, 28);
  174. this.m_ToolStrip.TabIndex = 0;
  175. this.m_ToolStrip.Text = "toolStrip";
  176. //
  177. // toolStripButtonPan
  178. //
  179. this.toolStripButtonPan.AutoToolTip = false;
  180. this.toolStripButtonPan.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonPan.Image")));
  181. this.toolStripButtonPan.ImageTransparentColor = System.Drawing.Color.Magenta;
  182. this.toolStripButtonPan.Name = "toolStripButtonPan";
  183. this.toolStripButtonPan.Size = new System.Drawing.Size(52, 25);
  184. this.toolStripButtonPan.Text = "漫游";
  185. this.toolStripButtonPan.ToolTipText = "漫游";
  186. //
  187. // toolStripButtonSelect
  188. //
  189. this.toolStripButtonSelect.AutoToolTip = false;
  190. this.toolStripButtonSelect.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonSelect.Image")));
  191. this.toolStripButtonSelect.ImageTransparentColor = System.Drawing.Color.Magenta;
  192. this.toolStripButtonSelect.Name = "toolStripButtonSelect";
  193. this.toolStripButtonSelect.Size = new System.Drawing.Size(52, 25);
  194. this.toolStripButtonSelect.Text = "选择";
  195. //
  196. // toolStripButtonClear
  197. //
  198. this.toolStripButtonClear.AutoToolTip = false;
  199. this.toolStripButtonClear.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonClear.Image")));
  200. this.toolStripButtonClear.ImageTransparentColor = System.Drawing.Color.Magenta;
  201. this.toolStripButtonClear.Name = "toolStripButtonClear";
  202. this.toolStripButtonClear.Size = new System.Drawing.Size(52, 25);
  203. this.toolStripButtonClear.Text = "清除";
  204. //
  205. // toolStripComboBoxLayer
  206. //
  207. this.toolStripComboBoxLayer.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  208. this.toolStripComboBoxLayer.Name = "toolStripComboBoxLayer";
  209. this.toolStripComboBoxLayer.Size = new System.Drawing.Size(121, 28);
  210. this.toolStripComboBoxLayer.Visible = false;
  211. //
  212. // toolStripSeparator1
  213. //
  214. this.toolStripSeparator1.Name = "toolStripSeparator1";
  215. this.toolStripSeparator1.Size = new System.Drawing.Size(6, 28);
  216. //
  217. // uiSymbolButtonClose
  218. //
  219. this.uiSymbolButtonClose.Cursor = System.Windows.Forms.Cursors.Hand;
  220. this.uiSymbolButtonClose.Dock = System.Windows.Forms.DockStyle.Right;
  221. this.uiSymbolButtonClose.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
  222. this.uiSymbolButtonClose.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(158)))), ((int)(((byte)(160)))), ((int)(((byte)(165)))));
  223. this.uiSymbolButtonClose.FillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(121)))), ((int)(((byte)(123)))), ((int)(((byte)(129)))));
  224. this.uiSymbolButtonClose.FillSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(121)))), ((int)(((byte)(123)))), ((int)(((byte)(129)))));
  225. this.uiSymbolButtonClose.Font = new System.Drawing.Font("微软雅黑 Light", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  226. this.uiSymbolButtonClose.Location = new System.Drawing.Point(563, 0);
  227. this.uiSymbolButtonClose.Margin = new System.Windows.Forms.Padding(5);
  228. this.uiSymbolButtonClose.MinimumSize = new System.Drawing.Size(1, 1);
  229. this.uiSymbolButtonClose.Name = "uiSymbolButtonClose";
  230. this.uiSymbolButtonClose.Radius = 10;
  231. this.uiSymbolButtonClose.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
  232. this.uiSymbolButtonClose.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(158)))), ((int)(((byte)(160)))), ((int)(((byte)(165)))));
  233. this.uiSymbolButtonClose.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(121)))), ((int)(((byte)(123)))), ((int)(((byte)(129)))));
  234. this.uiSymbolButtonClose.RectSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(121)))), ((int)(((byte)(123)))), ((int)(((byte)(129)))));
  235. this.uiSymbolButtonClose.Size = new System.Drawing.Size(28, 28);
  236. this.uiSymbolButtonClose.Style = Sunny.UI.UIStyle.Gray;
  237. this.uiSymbolButtonClose.Symbol = 61453;
  238. this.uiSymbolButtonClose.SymbolSize = 16;
  239. this.uiSymbolButtonClose.TabIndex = 1;
  240. this.uiSymbolButtonClose.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  241. //
  242. // BasicToolBar
  243. //
  244. this.Controls.Add(this.uiSymbolButtonClose);
  245. this.Controls.Add(this.m_ToolStrip);
  246. this.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(244)))));
  247. this.Name = "BasicToolBar";
  248. this.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
  249. this.Size = new System.Drawing.Size(591, 28);
  250. this.Style = Sunny.UI.UIStyle.Gray;
  251. this.m_ToolStrip.ResumeLayout(false);
  252. this.m_ToolStrip.PerformLayout();
  253. this.ResumeLayout(false);
  254. this.PerformLayout();
  255. }
  256. }
  257. }