BasicToolBar.cs 11 KB

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