KongZhiTuCeng.cs 10 KB

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