KongZhiTuCeng.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. using SuperMap.Data;
  2. using System;
  3. using System.Collections.Generic;
  4. using WeifenLuo.WinFormsUI.Docking;
  5. using WWPipeLine.MapBasic.Conditions;
  6. using WWPipeLine.MapBasic;
  7. using System.Windows.Forms;
  8. using Sunny.UI;
  9. using SuperMap.Mapping;
  10. namespace WWPipeLine.MapTools.Conditions.XiTongGuanLi
  11. {
  12. public class KongZhiTuCeng : ConditionPanel
  13. {
  14. private UITreeView uitvLayers;
  15. private UIMarkLabel uimlbName;
  16. private UISwitch uisVisible;
  17. private UISwitch uisSelectable;
  18. private UILabel uiLabel1;
  19. private UITextBox uitbScaleMax;
  20. private UITextBox uitbScaleMin;
  21. private UILabel uiLabel2;
  22. private SplitContainer splitContainer1;
  23. public KongZhiTuCeng() : base()
  24. {
  25. this.ConditionPanelName = "图层控制";
  26. InitializeComponent();
  27. base.IsShowResultWindow = false;
  28. }
  29. protected override void OnLoad(EventArgs e)
  30. {
  31. TreeNode root = new TreeNode() { Text = "全部图层", Name = "All" };
  32. TreeNode node;
  33. foreach (Layer ly in MapControl.Map.Layers)
  34. {
  35. if (!ly.Caption.Contains("供水")) continue;
  36. node = new TreeNode() { Text = ly.Caption, Name = ly.Name };
  37. root.Nodes.Add(node);
  38. }
  39. uitvLayers.Nodes.Add(root); uitvLayers.ExpandAll();
  40. }
  41. private void uitvLayers_AfterSelect(object sender, TreeViewEventArgs e)
  42. {
  43. if (uitvLayers.SelectedNode.Name != "All")
  44. {
  45. Layer lyr = MapControl.Map.Layers.FindLayer(uitvLayers.SelectedNode.Name);
  46. if (lyr is null) return;
  47. uimlbName.Text = "图层名称:" + uitvLayers.SelectedNode.Text;
  48. uisVisible.Active = lyr.IsVisible;
  49. uisSelectable.Active = lyr.IsSelectable;
  50. uitbScaleMax.Text = lyr.MaxVisibleScale.ToString();
  51. uitbScaleMin.Text = lyr.MinVisibleScale.ToString();
  52. }
  53. }
  54. public override object Do(DockPanel dockPanel = null)
  55. {
  56. if (uitvLayers.SelectedNode.Name != "All")
  57. {
  58. Layer lyr = MapControl.Map.Layers.FindLayer(uitvLayers.SelectedNode.Name);
  59. if (lyr is null) { UIMessageTip.ShowError("未找到可编辑的图层!"); return false; }
  60. lyr.IsVisible = uisVisible.Active;
  61. lyr.IsSelectable = uisSelectable.Active;
  62. Double scaleMax = ComsStatic.StringToDouble(uitbScaleMax.Text);
  63. Double scaleMin = ComsStatic.StringToDouble(uitbScaleMin.Text);
  64. if (scaleMax != 0)
  65. lyr.MaxVisibleScale = 1.0 / scaleMax;
  66. if (scaleMin != 0)
  67. lyr.MinVisibleScale = 1.0 / scaleMin;
  68. //if (lyr.MaxVisibleScale >= lyr.MinVisibleScale)
  69. //{ UIMessageTip.ShowError("最大可见比例尺必须小于最小可见比例尺!"); return false; }
  70. }
  71. return true;
  72. }
  73. private void InitializeComponent()
  74. {
  75. this.splitContainer1 = new System.Windows.Forms.SplitContainer();
  76. this.uitvLayers = new Sunny.UI.UITreeView();
  77. this.uitbScaleMin = new Sunny.UI.UITextBox();
  78. this.uitbScaleMax = new Sunny.UI.UITextBox();
  79. this.uiLabel2 = new Sunny.UI.UILabel();
  80. this.uiLabel1 = new Sunny.UI.UILabel();
  81. this.uisSelectable = new Sunny.UI.UISwitch();
  82. this.uisVisible = new Sunny.UI.UISwitch();
  83. this.uimlbName = new Sunny.UI.UIMarkLabel();
  84. ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
  85. this.splitContainer1.Panel1.SuspendLayout();
  86. this.splitContainer1.Panel2.SuspendLayout();
  87. this.splitContainer1.SuspendLayout();
  88. this.SuspendLayout();
  89. //
  90. // splitContainer1
  91. //
  92. this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
  93. this.splitContainer1.Location = new System.Drawing.Point(0, 0);
  94. this.splitContainer1.Name = "splitContainer1";
  95. //
  96. // splitContainer1.Panel1
  97. //
  98. this.splitContainer1.Panel1.Controls.Add(this.uitvLayers);
  99. //
  100. // splitContainer1.Panel2
  101. //
  102. this.splitContainer1.Panel2.Controls.Add(this.uitbScaleMin);
  103. this.splitContainer1.Panel2.Controls.Add(this.uitbScaleMax);
  104. this.splitContainer1.Panel2.Controls.Add(this.uiLabel2);
  105. this.splitContainer1.Panel2.Controls.Add(this.uiLabel1);
  106. this.splitContainer1.Panel2.Controls.Add(this.uisSelectable);
  107. this.splitContainer1.Panel2.Controls.Add(this.uisVisible);
  108. this.splitContainer1.Panel2.Controls.Add(this.uimlbName);
  109. this.splitContainer1.Size = new System.Drawing.Size(520, 345);
  110. this.splitContainer1.SplitterDistance = 164;
  111. this.splitContainer1.TabIndex = 0;
  112. //
  113. // uitvLayers
  114. //
  115. this.uitvLayers.Dock = System.Windows.Forms.DockStyle.Fill;
  116. this.uitvLayers.FillColor = System.Drawing.Color.White;
  117. this.uitvLayers.Font = new System.Drawing.Font("微软雅黑", 12F);
  118. this.uitvLayers.Location = new System.Drawing.Point(0, 0);
  119. this.uitvLayers.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  120. this.uitvLayers.MinimumSize = new System.Drawing.Size(1, 1);
  121. this.uitvLayers.Name = "uitvLayers";
  122. this.uitvLayers.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
  123. this.uitvLayers.SelectedNode = null;
  124. this.uitvLayers.ShowLines = true;
  125. this.uitvLayers.Size = new System.Drawing.Size(164, 345);
  126. this.uitvLayers.Style = Sunny.UI.UIStyle.Gray;
  127. this.uitvLayers.TabIndex = 0;
  128. this.uitvLayers.Text = null;
  129. this.uitvLayers.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
  130. this.uitvLayers.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.uitvLayers_AfterSelect);
  131. //
  132. // uitbScaleMin
  133. //
  134. this.uitbScaleMin.Cursor = System.Windows.Forms.Cursors.IBeam;
  135. this.uitbScaleMin.FillColor = System.Drawing.Color.White;
  136. this.uitbScaleMin.Font = new System.Drawing.Font("微软雅黑", 12F);
  137. this.uitbScaleMin.Location = new System.Drawing.Point(124, 161);
  138. this.uitbScaleMin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  139. this.uitbScaleMin.Maximum = 2147483647D;
  140. this.uitbScaleMin.Minimum = -2147483648D;
  141. this.uitbScaleMin.MinimumSize = new System.Drawing.Size(1, 1);
  142. this.uitbScaleMin.Name = "uitbScaleMin";
  143. this.uitbScaleMin.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
  144. this.uitbScaleMin.Size = new System.Drawing.Size(150, 29);
  145. this.uitbScaleMin.Style = Sunny.UI.UIStyle.Gray;
  146. this.uitbScaleMin.TabIndex = 6;
  147. this.uitbScaleMin.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
  148. this.uitbScaleMin.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.uitbScaleMax_KeyPress);
  149. //
  150. // uitbScaleMax
  151. //
  152. this.uitbScaleMax.Cursor = System.Windows.Forms.Cursors.IBeam;
  153. this.uitbScaleMax.FillColor = System.Drawing.Color.White;
  154. this.uitbScaleMax.Font = new System.Drawing.Font("微软雅黑", 12F);
  155. this.uitbScaleMax.Location = new System.Drawing.Point(124, 114);
  156. this.uitbScaleMax.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  157. this.uitbScaleMax.Maximum = 2147483647D;
  158. this.uitbScaleMax.Minimum = -2147483648D;
  159. this.uitbScaleMax.MinimumSize = new System.Drawing.Size(1, 1);
  160. this.uitbScaleMax.Name = "uitbScaleMax";
  161. this.uitbScaleMax.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
  162. this.uitbScaleMax.Size = new System.Drawing.Size(150, 29);
  163. this.uitbScaleMax.Style = Sunny.UI.UIStyle.Gray;
  164. this.uitbScaleMax.TabIndex = 4;
  165. this.uitbScaleMax.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
  166. this.uitbScaleMax.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.uitbScaleMax_KeyPress);
  167. //
  168. // uiLabel2
  169. //
  170. this.uiLabel2.Font = new System.Drawing.Font("微软雅黑", 12F);
  171. this.uiLabel2.Location = new System.Drawing.Point(3, 161);
  172. this.uiLabel2.Name = "uiLabel2";
  173. this.uiLabel2.Size = new System.Drawing.Size(100, 23);
  174. this.uiLabel2.Style = Sunny.UI.UIStyle.Custom;
  175. this.uiLabel2.TabIndex = 5;
  176. this.uiLabel2.Text = "最小比例尺";
  177. this.uiLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  178. //
  179. // uiLabel1
  180. //
  181. this.uiLabel1.Font = new System.Drawing.Font("微软雅黑", 12F);
  182. this.uiLabel1.Location = new System.Drawing.Point(3, 120);
  183. this.uiLabel1.Name = "uiLabel1";
  184. this.uiLabel1.Size = new System.Drawing.Size(100, 23);
  185. this.uiLabel1.Style = Sunny.UI.UIStyle.Custom;
  186. this.uiLabel1.TabIndex = 3;
  187. this.uiLabel1.Text = "最大比例尺";
  188. this.uiLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  189. //
  190. // uisSelectable
  191. //
  192. this.uisSelectable.ActiveText = "可选";
  193. this.uisSelectable.Font = new System.Drawing.Font("微软雅黑", 12F);
  194. this.uisSelectable.InActiveText = "不可选";
  195. this.uisSelectable.Location = new System.Drawing.Point(172, 54);
  196. this.uisSelectable.MinimumSize = new System.Drawing.Size(1, 1);
  197. this.uisSelectable.Name = "uisSelectable";
  198. this.uisSelectable.Size = new System.Drawing.Size(140, 29);
  199. this.uisSelectable.TabIndex = 2;
  200. this.uisSelectable.Text = "uiSwitch1";
  201. //
  202. // uisVisible
  203. //
  204. this.uisVisible.ActiveColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
  205. this.uisVisible.ActiveText = "可见";
  206. this.uisVisible.Font = new System.Drawing.Font("微软雅黑", 12F);
  207. this.uisVisible.InActiveText = "不可见";
  208. this.uisVisible.Location = new System.Drawing.Point(37, 55);
  209. this.uisVisible.MinimumSize = new System.Drawing.Size(1, 1);
  210. this.uisVisible.Name = "uisVisible";
  211. this.uisVisible.Size = new System.Drawing.Size(115, 29);
  212. this.uisVisible.Style = Sunny.UI.UIStyle.Gray;
  213. this.uisVisible.TabIndex = 1;
  214. //
  215. // uimlbName
  216. //
  217. this.uimlbName.Font = new System.Drawing.Font("微软雅黑", 12F);
  218. this.uimlbName.Location = new System.Drawing.Point(13, 14);
  219. this.uimlbName.MarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
  220. this.uimlbName.Name = "uimlbName";
  221. this.uimlbName.Padding = new System.Windows.Forms.Padding(5, 0, 0, 0);
  222. this.uimlbName.Size = new System.Drawing.Size(327, 23);
  223. this.uimlbName.Style = Sunny.UI.UIStyle.Custom;
  224. this.uimlbName.TabIndex = 0;
  225. this.uimlbName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  226. //
  227. // KongZhiTuCeng
  228. //
  229. this.Controls.Add(this.splitContainer1);
  230. this.Name = "KongZhiTuCeng";
  231. this.Size = new System.Drawing.Size(520, 345);
  232. this.splitContainer1.Panel1.ResumeLayout(false);
  233. this.splitContainer1.Panel2.ResumeLayout(false);
  234. ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
  235. this.splitContainer1.ResumeLayout(false);
  236. this.ResumeLayout(false);
  237. }
  238. private void uitbScaleMax_KeyPress(object sender, KeyPressEventArgs e)
  239. {
  240. if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar < 96 || e.KeyChar > 105) && (e.KeyChar != 46) && (e.KeyChar != 8))
  241. e.Handled = true;
  242. }
  243. }
  244. }