KongZhiTuCeng.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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 UISwitch uisVisible;
  15. private UISwitch uisSelectable;
  16. private UILabel uiLabel1;
  17. private UITextBox uitbScaleMax;
  18. private UITextBox uitbScaleMin;
  19. private UIListBox uiListBoxLayer;
  20. private UILabel uiLabel2;
  21. public KongZhiTuCeng() : base()
  22. {
  23. this.ConditionPanelName = "图层控制";
  24. InitializeComponent();
  25. base.IsShowResultWindow = false;
  26. }
  27. protected override void OnLoad(EventArgs e)
  28. {
  29. foreach (Layer ly in ComsStatic.MapLayers)
  30. {
  31. uiListBoxLayer.Items.Add(new DoListItem(ly.Name, ly.Caption));
  32. }
  33. }
  34. private void uiListBoxLayer_SelectedIndexChanged(object sender, EventArgs e)
  35. {
  36. DoListItem item = uiListBoxLayer.SelectedItem as DoListItem;
  37. Layer lyr = MapControl.Map.Layers.FindLayer(item.Key);
  38. if (lyr is null) return;
  39. uisVisible.Active = lyr.IsVisible;
  40. uisSelectable.Active = lyr.IsSelectable;
  41. uitbScaleMax.Text = lyr.MaxVisibleScale.ToString();
  42. uitbScaleMin.Text = lyr.MinVisibleScale.ToString();
  43. }
  44. public override object Do(DockPanel dockPanel = null)
  45. {
  46. DoListItem item = uiListBoxLayer.SelectedItem as DoListItem;
  47. Layer lyr = MapControl.Map.Layers.FindLayer(item.Key);
  48. if (lyr is null) { UIMessageTip.ShowError("未找到可编辑的图层!"); return false; }
  49. lyr.IsVisible = uisVisible.Active;
  50. lyr.IsSelectable = uisSelectable.Active;
  51. Double scaleMax = ComsStatic.StringToDouble(uitbScaleMax.Text);
  52. Double scaleMin = ComsStatic.StringToDouble(uitbScaleMin.Text);
  53. if (scaleMax != 0)
  54. lyr.MaxVisibleScale = 1.0 / scaleMax;
  55. if (scaleMin != 0)
  56. lyr.MinVisibleScale = 1.0 / scaleMin;
  57. //if (lyr.MaxVisibleScale >= lyr.MinVisibleScale)
  58. //{ UIMessageTip.ShowError("最大可见比例尺必须小于最小可见比例尺!"); return false; }
  59. return true;
  60. }
  61. private void InitializeComponent()
  62. {
  63. this.uitbScaleMin = new Sunny.UI.UITextBox();
  64. this.uitbScaleMax = new Sunny.UI.UITextBox();
  65. this.uiLabel2 = new Sunny.UI.UILabel();
  66. this.uiLabel1 = new Sunny.UI.UILabel();
  67. this.uisSelectable = new Sunny.UI.UISwitch();
  68. this.uisVisible = new Sunny.UI.UISwitch();
  69. this.uiListBoxLayer = new Sunny.UI.UIListBox();
  70. this.SuspendLayout();
  71. //
  72. // uitbScaleMin
  73. //
  74. this.uitbScaleMin.Cursor = System.Windows.Forms.Cursors.IBeam;
  75. this.uitbScaleMin.FillColor = System.Drawing.Color.White;
  76. this.uitbScaleMin.Font = new System.Drawing.Font("微软雅黑", 12F);
  77. this.uitbScaleMin.Location = new System.Drawing.Point(284, 130);
  78. this.uitbScaleMin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  79. this.uitbScaleMin.Maximum = 2147483647D;
  80. this.uitbScaleMin.Minimum = -2147483648D;
  81. this.uitbScaleMin.MinimumSize = new System.Drawing.Size(1, 1);
  82. this.uitbScaleMin.Name = "uitbScaleMin";
  83. this.uitbScaleMin.Size = new System.Drawing.Size(150, 29);
  84. this.uitbScaleMin.TabIndex = 6;
  85. this.uitbScaleMin.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
  86. //
  87. // uitbScaleMax
  88. //
  89. this.uitbScaleMax.Cursor = System.Windows.Forms.Cursors.IBeam;
  90. this.uitbScaleMax.FillColor = System.Drawing.Color.White;
  91. this.uitbScaleMax.Font = new System.Drawing.Font("微软雅黑", 12F);
  92. this.uitbScaleMax.Location = new System.Drawing.Point(284, 83);
  93. this.uitbScaleMax.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  94. this.uitbScaleMax.Maximum = 2147483647D;
  95. this.uitbScaleMax.Minimum = -2147483648D;
  96. this.uitbScaleMax.MinimumSize = new System.Drawing.Size(1, 1);
  97. this.uitbScaleMax.Name = "uitbScaleMax";
  98. this.uitbScaleMax.Size = new System.Drawing.Size(150, 29);
  99. this.uitbScaleMax.TabIndex = 4;
  100. this.uitbScaleMax.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
  101. //
  102. // uiLabel2
  103. //
  104. this.uiLabel2.Font = new System.Drawing.Font("微软雅黑", 12F);
  105. this.uiLabel2.Location = new System.Drawing.Point(163, 130);
  106. this.uiLabel2.Name = "uiLabel2";
  107. this.uiLabel2.Size = new System.Drawing.Size(100, 23);
  108. this.uiLabel2.TabIndex = 5;
  109. this.uiLabel2.Text = "最小比例尺";
  110. this.uiLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  111. //
  112. // uiLabel1
  113. //
  114. this.uiLabel1.Font = new System.Drawing.Font("微软雅黑", 12F);
  115. this.uiLabel1.Location = new System.Drawing.Point(163, 89);
  116. this.uiLabel1.Name = "uiLabel1";
  117. this.uiLabel1.Size = new System.Drawing.Size(100, 23);
  118. this.uiLabel1.TabIndex = 3;
  119. this.uiLabel1.Text = "最大比例尺";
  120. this.uiLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  121. //
  122. // uisSelectable
  123. //
  124. this.uisSelectable.ActiveText = "可选";
  125. this.uisSelectable.Font = new System.Drawing.Font("微软雅黑", 12F);
  126. this.uisSelectable.InActiveText = "不可选";
  127. this.uisSelectable.Location = new System.Drawing.Point(302, 23);
  128. this.uisSelectable.MinimumSize = new System.Drawing.Size(1, 1);
  129. this.uisSelectable.Name = "uisSelectable";
  130. this.uisSelectable.Size = new System.Drawing.Size(94, 29);
  131. this.uisSelectable.TabIndex = 2;
  132. this.uisSelectable.Text = "uiSwitch1";
  133. //
  134. // uisVisible
  135. //
  136. this.uisVisible.ActiveText = "可见";
  137. this.uisVisible.Font = new System.Drawing.Font("微软雅黑", 12F);
  138. this.uisVisible.InActiveText = "不可见";
  139. this.uisVisible.Location = new System.Drawing.Point(167, 24);
  140. this.uisVisible.MinimumSize = new System.Drawing.Size(1, 1);
  141. this.uisVisible.Name = "uisVisible";
  142. this.uisVisible.Size = new System.Drawing.Size(96, 29);
  143. this.uisVisible.TabIndex = 1;
  144. //
  145. // uiListBoxLayer
  146. //
  147. this.uiListBoxLayer.Dock = System.Windows.Forms.DockStyle.Left;
  148. this.uiListBoxLayer.FillColor = System.Drawing.Color.White;
  149. this.uiListBoxLayer.Font = new System.Drawing.Font("微软雅黑", 12F);
  150. this.uiListBoxLayer.FormatString = "";
  151. this.uiListBoxLayer.ItemSelectForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
  152. this.uiListBoxLayer.Location = new System.Drawing.Point(0, 0);
  153. this.uiListBoxLayer.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  154. this.uiListBoxLayer.MinimumSize = new System.Drawing.Size(1, 1);
  155. this.uiListBoxLayer.Name = "uiListBoxLayer";
  156. this.uiListBoxLayer.Padding = new System.Windows.Forms.Padding(2);
  157. this.uiListBoxLayer.Size = new System.Drawing.Size(144, 315);
  158. this.uiListBoxLayer.TabIndex = 0;
  159. this.uiListBoxLayer.Text = "uiListBox1";
  160. this.uiListBoxLayer.SelectedIndexChanged += new System.EventHandler(this.uiListBoxLayer_SelectedIndexChanged);
  161. //
  162. // KongZhiTuCeng
  163. //
  164. this.Controls.Add(this.uiListBoxLayer);
  165. this.Controls.Add(this.uitbScaleMin);
  166. this.Controls.Add(this.uitbScaleMax);
  167. this.Controls.Add(this.uiLabel2);
  168. this.Controls.Add(this.uisVisible);
  169. this.Controls.Add(this.uiLabel1);
  170. this.Controls.Add(this.uisSelectable);
  171. this.Name = "KongZhiTuCeng";
  172. this.Size = new System.Drawing.Size(500, 315);
  173. this.ResumeLayout(false);
  174. }
  175. }
  176. }