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 UISwitch uisVisible; private UISwitch uisSelectable; private UILabel uiLabel1; private UITextBox uitbScaleMax; private UITextBox uitbScaleMin; private UIListBox uiListBoxLayer; private UILabel uiLabel2; public KongZhiTuCeng() : base() { this.ConditionPanelName = "图层控制"; InitializeComponent(); base.IsShowResultWindow = false; } protected override void OnLoad(EventArgs e) { foreach (Layer ly in ComsStatic.MapLayers) { uiListBoxLayer.Items.Add(new DoListItem(ly.Name, ly.Caption)); } } private void uiListBoxLayer_SelectedIndexChanged(object sender, EventArgs e) { DoListItem item = uiListBoxLayer.SelectedItem as DoListItem; Layer lyr = MapControl.Map.Layers.FindLayer(item.Key); if (lyr is null) return; 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) { DoListItem item = uiListBoxLayer.SelectedItem as DoListItem; Layer lyr = MapControl.Map.Layers.FindLayer(item.Key); 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.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.uiListBoxLayer = new Sunny.UI.UIListBox(); this.SuspendLayout(); // // 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(284, 130); 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.Size = new System.Drawing.Size(150, 29); this.uitbScaleMin.TabIndex = 6; this.uitbScaleMin.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; // // 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(284, 83); 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.Size = new System.Drawing.Size(150, 29); this.uitbScaleMax.TabIndex = 4; this.uitbScaleMax.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; // // uiLabel2 // this.uiLabel2.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiLabel2.Location = new System.Drawing.Point(163, 130); this.uiLabel2.Name = "uiLabel2"; this.uiLabel2.Size = new System.Drawing.Size(100, 23); 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(163, 89); this.uiLabel1.Name = "uiLabel1"; this.uiLabel1.Size = new System.Drawing.Size(100, 23); 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(302, 23); this.uisSelectable.MinimumSize = new System.Drawing.Size(1, 1); this.uisSelectable.Name = "uisSelectable"; this.uisSelectable.Size = new System.Drawing.Size(94, 29); this.uisSelectable.TabIndex = 2; this.uisSelectable.Text = "uiSwitch1"; // // uisVisible // this.uisVisible.ActiveText = "可见"; this.uisVisible.Font = new System.Drawing.Font("微软雅黑", 12F); this.uisVisible.InActiveText = "不可见"; this.uisVisible.Location = new System.Drawing.Point(167, 24); this.uisVisible.MinimumSize = new System.Drawing.Size(1, 1); this.uisVisible.Name = "uisVisible"; this.uisVisible.Size = new System.Drawing.Size(96, 29); this.uisVisible.TabIndex = 1; // // uiListBoxLayer // this.uiListBoxLayer.Dock = System.Windows.Forms.DockStyle.Left; this.uiListBoxLayer.FillColor = System.Drawing.Color.White; this.uiListBoxLayer.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiListBoxLayer.FormatString = ""; this.uiListBoxLayer.ItemSelectForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255))))); this.uiListBoxLayer.Location = new System.Drawing.Point(0, 0); this.uiListBoxLayer.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.uiListBoxLayer.MinimumSize = new System.Drawing.Size(1, 1); this.uiListBoxLayer.Name = "uiListBoxLayer"; this.uiListBoxLayer.Padding = new System.Windows.Forms.Padding(2); this.uiListBoxLayer.Size = new System.Drawing.Size(144, 315); this.uiListBoxLayer.TabIndex = 0; this.uiListBoxLayer.Text = "uiListBox1"; this.uiListBoxLayer.SelectedIndexChanged += new System.EventHandler(this.uiListBoxLayer_SelectedIndexChanged); // // KongZhiTuCeng // this.Controls.Add(this.uiListBoxLayer); this.Controls.Add(this.uitbScaleMin); this.Controls.Add(this.uitbScaleMax); this.Controls.Add(this.uiLabel2); this.Controls.Add(this.uisVisible); this.Controls.Add(this.uiLabel1); this.Controls.Add(this.uisSelectable); this.Name = "KongZhiTuCeng"; this.Size = new System.Drawing.Size(500, 315); this.ResumeLayout(false); } } }