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. if (System.IO.File.Exists(img1))
  62. this.toolStripButtonPan.Image = System.Drawing.Image.FromFile(img1);
  63. if (System.IO.File.Exists(img2))
  64. this.toolStripButtonSelect.Image = System.Drawing.Image.FromFile(img2);
  65. if (System.IO.File.Exists(img3))
  66. this.toolStripButtonClear.Image = System.Drawing.Image.FromFile(img3);
  67. this.toolStripButtonPan.Click += ToolStripButtonPan_Click;
  68. this.toolStripButtonSelect.Click += ToolStripButtonSelect_Click;
  69. this.toolStripButtonClear.Click += ToolStripButtonClear_Click;
  70. this.uiSymbolButtonClose.Click += UiSymbolButtonClose_Click;
  71. }
  72. protected override void OnLoad(EventArgs e)
  73. {
  74. if (IsShowToolStripComboBox)
  75. {
  76. this.toolStripComboBoxLayer.Visible = true;
  77. toolStripComboBoxLayer.ComboBox.ValueMember = "LayerDatasetName";
  78. toolStripComboBoxLayer.ComboBox.DisplayMember = "LayerCaption";
  79. toolStripComboBoxLayer.ComboBox.DataSource = ComsStatic.getLayers();
  80. }
  81. }
  82. /// <summary>
  83. /// 关闭父窗口时关闭对应的结果窗口
  84. /// </summary>
  85. /// <param name="sender"></param>
  86. /// <param name="e"></param>
  87. private void BasicToolBar_ParentChanged(object sender, EventArgs e)
  88. {
  89. if (this.Parent == null)
  90. {
  91. if (this.m_ResultWindow != null)
  92. {
  93. this.m_ResultWindow.Close();
  94. }
  95. }
  96. }
  97. /// <summary>
  98. /// 点击关闭按钮关闭
  99. /// </summary>
  100. /// <param name="sender"></param>
  101. /// <param name="e"></param>
  102. private void UiSymbolButtonClose_Click(object sender, EventArgs e)
  103. {
  104. CloseToolBar();
  105. }
  106. protected void CloseToolBar()
  107. {
  108. this.Parent.Controls.Remove(this);
  109. AfterClose();
  110. this.m_ResultWindow?.Close();
  111. }
  112. /// <summary>
  113. /// 给当前ToolStrip增加“保存标注”按钮及其单击事件
  114. /// </summary>
  115. protected void Item_add_BiaoZhuSave()
  116. {
  117. var bzSave = new ToolStripButton()
  118. {
  119. DisplayStyle = ToolStripItemDisplayStyle.ImageAndText,
  120. Text = "保存标注",
  121. Name = "StartDraw",
  122. AutoToolTip = false
  123. };
  124. var img = Commons.Paths.ApplicationResourcesDir + "\\ToolBar\\保存标注.png";
  125. if (System.IO.File.Exists(img))
  126. bzSave.Image = System.Drawing.Image.FromFile(img);
  127. m_ToolStrip.Items.Add(bzSave);
  128. bzSave.Click += BzSave_Click;
  129. }
  130. private void BzSave_Click(object sender, EventArgs e)
  131. {
  132. Sunny.UI.UIMessageTip.ShowError("未实现功能");
  133. }
  134. private void ToolStripButtonSelect_Click(object sender, EventArgs e)
  135. {
  136. MapControl.Action = SuperMap.UI.Action.Pan;
  137. MapControl.Action = SuperMap.UI.Action.Select;
  138. }
  139. private void ToolStripButtonPan_Click(object sender, EventArgs e)
  140. {
  141. MapControl.Action = SuperMap.UI.Action.Pan;
  142. }
  143. private void ToolStripButtonClear_Click(object sender, EventArgs e)
  144. {
  145. MapControl.Map.TrackingLayer.Clear();
  146. MapControl.Action = SuperMap.UI.Action.Pan;
  147. MapControl.Map.Refresh();
  148. }
  149. private void InitializeComponent()
  150. {
  151. System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BasicToolBar));
  152. this.m_ToolStrip = new System.Windows.Forms.ToolStrip();
  153. this.toolStripButtonPan = new System.Windows.Forms.ToolStripButton();
  154. this.toolStripButtonSelect = new System.Windows.Forms.ToolStripButton();
  155. this.toolStripButtonClear = new System.Windows.Forms.ToolStripButton();
  156. this.toolStripLB = new System.Windows.Forms.ToolStripLabel();
  157. this.toolStripComboBoxLayer = new System.Windows.Forms.ToolStripComboBox();
  158. this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
  159. this.uiSymbolButtonClose = new Sunny.UI.UISymbolButton();
  160. this.m_ToolStrip.SuspendLayout();
  161. this.SuspendLayout();
  162. //
  163. // m_ToolStrip
  164. //
  165. this.m_ToolStrip.Dock = System.Windows.Forms.DockStyle.Fill;
  166. this.m_ToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
  167. this.toolStripButtonPan,
  168. this.toolStripButtonSelect,
  169. this.toolStripButtonClear,
  170. this.toolStripLB,
  171. this.toolStripComboBoxLayer,
  172. this.toolStripSeparator1});
  173. this.m_ToolStrip.Location = new System.Drawing.Point(0, 0);
  174. this.m_ToolStrip.Name = "m_ToolStrip";
  175. this.m_ToolStrip.Padding = new System.Windows.Forms.Padding(0);
  176. this.m_ToolStrip.Size = new System.Drawing.Size(591, 28);
  177. this.m_ToolStrip.TabIndex = 0;
  178. this.m_ToolStrip.Text = "toolStrip";
  179. //
  180. // toolStripButtonPan
  181. //
  182. this.toolStripButtonPan.AutoToolTip = false;
  183. this.toolStripButtonPan.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonPan.Image")));
  184. this.toolStripButtonPan.ImageTransparentColor = System.Drawing.Color.Magenta;
  185. this.toolStripButtonPan.Name = "toolStripButtonPan";
  186. this.toolStripButtonPan.Size = new System.Drawing.Size(52, 25);
  187. this.toolStripButtonPan.Text = "漫游";
  188. this.toolStripButtonPan.ToolTipText = "漫游";
  189. //
  190. // toolStripButtonSelect
  191. //
  192. this.toolStripButtonSelect.AutoToolTip = false;
  193. this.toolStripButtonSelect.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonSelect.Image")));
  194. this.toolStripButtonSelect.ImageTransparentColor = System.Drawing.Color.Magenta;
  195. this.toolStripButtonSelect.Name = "toolStripButtonSelect";
  196. this.toolStripButtonSelect.Size = new System.Drawing.Size(52, 25);
  197. this.toolStripButtonSelect.Text = "选择";
  198. //
  199. // toolStripButtonClear
  200. //
  201. this.toolStripButtonClear.AutoToolTip = false;
  202. this.toolStripButtonClear.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonClear.Image")));
  203. this.toolStripButtonClear.ImageTransparentColor = System.Drawing.Color.Magenta;
  204. this.toolStripButtonClear.Name = "toolStripButtonClear";
  205. this.toolStripButtonClear.Size = new System.Drawing.Size(52, 25);
  206. this.toolStripButtonClear.Text = "清除";
  207. //
  208. // toolStripLB
  209. //
  210. this.toolStripLB.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
  211. this.toolStripLB.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
  212. this.toolStripLB.Name = "toolStripLB";
  213. this.toolStripLB.Size = new System.Drawing.Size(24, 25);
  214. this.toolStripLB.Text = " ";
  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. }