using SuperMap.Data; using System; using System.Collections.Generic; using WeifenLuo.WinFormsUI.Docking; using WWPipeLine.MapBasic.Conditions; using WWPipeLine.MapBasic; using System.Windows.Forms; using Sunny.UI; using SuperMap.Mapping; namespace WWPipeLine.MapTools.Conditions.XiTongGuanLi { public class KongZhiTuCeng : ConditionPanel { private UITreeView uitvLayers; private UIMarkLabel uimlbName; private UISwitch uisVisible; private UISwitch uisSelectable; private UILabel uiLabel1; private UITextBox uitbScaleMax; private UITextBox uitbScaleMin; private UILabel uiLabel2; private SplitContainer splitContainer1; public KongZhiTuCeng() : base() { this.ConditionPanelName = "图层控制"; InitializeComponent(); base.IsShowResultWindow = false; } protected override void OnLoad(EventArgs e) { TreeNode root = new TreeNode() { Text = "全部图层", Name = "All" }; TreeNode node; foreach (Layer ly in MapControl.Map.Layers) { if (!ly.Caption.Contains("供水")) continue; node = new TreeNode() { Text = ly.Caption, Name = ly.Name }; root.Nodes.Add(node); } uitvLayers.Nodes.Add(root); uitvLayers.ExpandAll(); } private void uitvLayers_AfterSelect(object sender, TreeViewEventArgs e) { if (uitvLayers.SelectedNode.Name != "All") { Layer lyr = MapControl.Map.Layers.FindLayer(uitvLayers.SelectedNode.Name); if (lyr is null) return; uimlbName.Text = "图层名称:" + uitvLayers.SelectedNode.Text; uisVisible.Active = lyr.IsVisible; uisSelectable.Active = lyr.IsSelectable; uitbScaleMax.Text = lyr.MaxVisibleScale.ToString(); uitbScaleMin.Text = lyr.MinVisibleScale.ToString(); } } public override object Do(DockPanel dockPanel = null) { if (uitvLayers.SelectedNode.Name != "All") { Layer lyr = MapControl.Map.Layers.FindLayer(uitvLayers.SelectedNode.Name); if (lyr is null) { UIMessageTip.ShowError("未找到可编辑的图层!"); return false; } lyr.IsVisible = uisVisible.Active; lyr.IsSelectable = uisSelectable.Active; Double scaleMax = ComsStatic.StringToDouble(uitbScaleMax.Text); Double scaleMin = ComsStatic.StringToDouble(uitbScaleMin.Text); if (scaleMax != 0) lyr.MaxVisibleScale = 1.0 / scaleMax; if (scaleMin != 0) lyr.MinVisibleScale = 1.0 / scaleMin; //if (lyr.MaxVisibleScale >= lyr.MinVisibleScale) //{ UIMessageTip.ShowError("最大可见比例尺必须小于最小可见比例尺!"); return false; } } return true; } private void InitializeComponent() { this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.uitvLayers = new Sunny.UI.UITreeView(); this.uitbScaleMin = new Sunny.UI.UITextBox(); this.uitbScaleMax = new Sunny.UI.UITextBox(); this.uiLabel2 = new Sunny.UI.UILabel(); this.uiLabel1 = new Sunny.UI.UILabel(); this.uisSelectable = new Sunny.UI.UISwitch(); this.uisVisible = new Sunny.UI.UISwitch(); this.uimlbName = new Sunny.UI.UIMarkLabel(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); this.SuspendLayout(); // // splitContainer1 // this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer1.Location = new System.Drawing.Point(0, 0); this.splitContainer1.Name = "splitContainer1"; // // splitContainer1.Panel1 // this.splitContainer1.Panel1.Controls.Add(this.uitvLayers); // // splitContainer1.Panel2 // this.splitContainer1.Panel2.Controls.Add(this.uitbScaleMin); this.splitContainer1.Panel2.Controls.Add(this.uitbScaleMax); this.splitContainer1.Panel2.Controls.Add(this.uiLabel2); this.splitContainer1.Panel2.Controls.Add(this.uiLabel1); this.splitContainer1.Panel2.Controls.Add(this.uisSelectable); this.splitContainer1.Panel2.Controls.Add(this.uisVisible); this.splitContainer1.Panel2.Controls.Add(this.uimlbName); this.splitContainer1.Size = new System.Drawing.Size(520, 345); this.splitContainer1.SplitterDistance = 164; this.splitContainer1.TabIndex = 0; // // uitvLayers // this.uitvLayers.Dock = System.Windows.Forms.DockStyle.Fill; this.uitvLayers.FillColor = System.Drawing.Color.White; this.uitvLayers.Font = new System.Drawing.Font("微软雅黑", 12F); this.uitvLayers.Location = new System.Drawing.Point(0, 0); this.uitvLayers.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.uitvLayers.MinimumSize = new System.Drawing.Size(1, 1); this.uitvLayers.Name = "uitvLayers"; this.uitvLayers.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140))))); this.uitvLayers.SelectedNode = null; this.uitvLayers.ShowLines = true; this.uitvLayers.Size = new System.Drawing.Size(164, 345); this.uitvLayers.Style = Sunny.UI.UIStyle.Gray; this.uitvLayers.TabIndex = 0; this.uitvLayers.Text = null; this.uitvLayers.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter; this.uitvLayers.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.uitvLayers_AfterSelect); // // uitbScaleMin // this.uitbScaleMin.Cursor = System.Windows.Forms.Cursors.IBeam; this.uitbScaleMin.FillColor = System.Drawing.Color.White; this.uitbScaleMin.Font = new System.Drawing.Font("微软雅黑", 12F); this.uitbScaleMin.Location = new System.Drawing.Point(124, 161); this.uitbScaleMin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.uitbScaleMin.Maximum = 2147483647D; this.uitbScaleMin.Minimum = -2147483648D; this.uitbScaleMin.MinimumSize = new System.Drawing.Size(1, 1); this.uitbScaleMin.Name = "uitbScaleMin"; this.uitbScaleMin.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140))))); this.uitbScaleMin.Size = new System.Drawing.Size(150, 29); this.uitbScaleMin.Style = Sunny.UI.UIStyle.Gray; this.uitbScaleMin.TabIndex = 6; this.uitbScaleMin.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; this.uitbScaleMin.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.uitbScaleMax_KeyPress); // // uitbScaleMax // this.uitbScaleMax.Cursor = System.Windows.Forms.Cursors.IBeam; this.uitbScaleMax.FillColor = System.Drawing.Color.White; this.uitbScaleMax.Font = new System.Drawing.Font("微软雅黑", 12F); this.uitbScaleMax.Location = new System.Drawing.Point(124, 114); this.uitbScaleMax.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.uitbScaleMax.Maximum = 2147483647D; this.uitbScaleMax.Minimum = -2147483648D; this.uitbScaleMax.MinimumSize = new System.Drawing.Size(1, 1); this.uitbScaleMax.Name = "uitbScaleMax"; this.uitbScaleMax.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140))))); this.uitbScaleMax.Size = new System.Drawing.Size(150, 29); this.uitbScaleMax.Style = Sunny.UI.UIStyle.Gray; this.uitbScaleMax.TabIndex = 4; this.uitbScaleMax.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; this.uitbScaleMax.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.uitbScaleMax_KeyPress); // // uiLabel2 // this.uiLabel2.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiLabel2.Location = new System.Drawing.Point(3, 161); this.uiLabel2.Name = "uiLabel2"; this.uiLabel2.Size = new System.Drawing.Size(100, 23); this.uiLabel2.Style = Sunny.UI.UIStyle.Custom; this.uiLabel2.TabIndex = 5; this.uiLabel2.Text = "最小比例尺"; this.uiLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // uiLabel1 // this.uiLabel1.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiLabel1.Location = new System.Drawing.Point(3, 120); this.uiLabel1.Name = "uiLabel1"; this.uiLabel1.Size = new System.Drawing.Size(100, 23); this.uiLabel1.Style = Sunny.UI.UIStyle.Custom; this.uiLabel1.TabIndex = 3; this.uiLabel1.Text = "最大比例尺"; this.uiLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // uisSelectable // this.uisSelectable.ActiveText = "可选"; this.uisSelectable.Font = new System.Drawing.Font("微软雅黑", 12F); this.uisSelectable.InActiveText = "不可选"; this.uisSelectable.Location = new System.Drawing.Point(172, 54); this.uisSelectable.MinimumSize = new System.Drawing.Size(1, 1); this.uisSelectable.Name = "uisSelectable"; this.uisSelectable.Size = new System.Drawing.Size(140, 29); this.uisSelectable.TabIndex = 2; this.uisSelectable.Text = "uiSwitch1"; // // uisVisible // this.uisVisible.ActiveColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140))))); this.uisVisible.ActiveText = "可见"; this.uisVisible.Font = new System.Drawing.Font("微软雅黑", 12F); this.uisVisible.InActiveText = "不可见"; this.uisVisible.Location = new System.Drawing.Point(37, 55); this.uisVisible.MinimumSize = new System.Drawing.Size(1, 1); this.uisVisible.Name = "uisVisible"; this.uisVisible.Size = new System.Drawing.Size(115, 29); this.uisVisible.Style = Sunny.UI.UIStyle.Gray; this.uisVisible.TabIndex = 1; // // uimlbName // this.uimlbName.Font = new System.Drawing.Font("微软雅黑", 12F); this.uimlbName.Location = new System.Drawing.Point(13, 14); this.uimlbName.MarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140))))); this.uimlbName.Name = "uimlbName"; this.uimlbName.Padding = new System.Windows.Forms.Padding(5, 0, 0, 0); this.uimlbName.Size = new System.Drawing.Size(327, 23); this.uimlbName.Style = Sunny.UI.UIStyle.Custom; this.uimlbName.TabIndex = 0; this.uimlbName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // KongZhiTuCeng // this.Controls.Add(this.splitContainer1); this.Name = "KongZhiTuCeng"; this.Size = new System.Drawing.Size(520, 345); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); this.splitContainer1.ResumeLayout(false); this.ResumeLayout(false); } private void uitbScaleMax_KeyPress(object sender, KeyPressEventArgs e) { if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar < 96 || e.KeyChar > 105) && (e.KeyChar != 46) && (e.KeyChar != 8)) e.Handled = true; } } }