123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- using Sunny.UI;
- using SuperMap.Data;
- using SuperMap.Mapping;
- using SuperMap.UI;
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- using WeifenLuo.WinFormsUI.Docking;
- using WWPipeLine.MapBasic;
- using WWPipeLine.MapBasic.Conditions;
- namespace WWPipeLine.MapTools.Conditions.EditGuanWang
- {
- public class ShuXingXiuGai : ConditionPanel
- {
- private Recordset _recordset = null;
- public ShuXingXiuGai() : base()
- {
- this.ConditionPanelName = "修改属性";
- this.SetSize(500, 800);
- InitializeComponent();
- }
- protected override void OnLoad(EventArgs e)
- {
- MapControl.GeometrySelected += MapControl_GeometrySelected;
- }
- private void MapControl_GeometrySelected(object sender, GeometrySelectedEventArgs e)
- {
- this.Controls.Clear();
- Selection[] _selection = MapControl.Map.FindSelection(true);
- if (_selection.Length != 1 || _selection[0].Count != 1)
- {
- Sunny.UI.UIMessageTip.ShowError("仅可以选择一个图层中的一个元素进行修改操作", 2000); return;
- }
- _recordset = _selection[0].ToRecordset();
- FieldInfos infos = _recordset.GetFieldInfos();
- foreach (FieldInfo info in infos)
- {
- //不显示的字段
- string HideTag = ",SmID,SmX,SmY,SmLibTileID,SmLength,SmTopoError,SmUserID,SmGeometry,OBJECTID,WTH,TFH,DMT,TSDH,SSBH,ROTATEANGLE,ENABLED,ANCILLARYROLE,X,Y,SHAPE_Length,ANCILLARYROLE,tzbm,zcbh,qdms,zdms,CQBH,LRRQ,".ToLower();
- if (HideTag.Contains("," + info.Name.ToLower() + ",") || info.IsSystemField) continue;
- UILabel labName = new UILabel()
- {
- Name = info.Name,
- Text = info.Caption,
- TextAlign = ContentAlignment.BottomCenter,
- Location = new System.Drawing.Point(20, 20 + this.Controls.Count * 18),
- Style = UIStyle.Gray,
- Width = 100
- };
- this.Controls.Add(labName);
- //显示但是不允许更改的字段
- string EnableTag = ",FLDM,BSM,QSDH,ZDDH,CD,".ToLower();
- string shuzi = ",Double,Single,Int32,Int16,Int64,";
- bool isEnable = EnableTag.Contains("," + info.Name.ToLower() + ",") ? true : false;
- if (info.Type == FieldType.DateTime)
- {
- UIDatePicker con = new UIDatePicker();
- con.DateFormat = "yyyy-MM-dd";
- string infoValue = _recordset.GetFieldValue(info.Name)?.ToString();
- con.Text = infoValue;
- setControl(con, info, isEnable); continue;
- }
- else
- {
- UITextBox con = new UITextBox();
- string infoValue = _recordset.GetFieldValue(info.Name)?.ToString();
- con.Text = infoValue;
- con.MaxLength = info.MaxLength;
- if (shuzi.Contains("," + info.Type.ToString() + ","))
- con.KeyPress += uitb_KeyPress;
- setControl(con, info, isEnable); continue;
- }
- void setControl(UIPanel control, FieldInfo fieldInfo, bool _isEnable)
- {
- control.Tag = fieldInfo.Name;
- if (fieldInfo.IsSystemField || _isEnable)
- { control.Name = "SM_tbValue"; control.Enabled = false; }
- else
- control.Name = "tbValue";
- control.Location = new System.Drawing.Point(140, this.Controls.Count * 18);
- control.Width = 250;
- control.Style = UIStyle.Gray;
- this.Controls.Add(control);
- }
- }
- }
- private void uitb_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;
- }
- public override object Do(DockPanel dockPanel = null)
- {
- this.IsShowResultWindow = false;
- if (_recordset is null || _recordset.RecordCount != 1)
- {
- Sunny.UI.UIMessageTip.ShowError("仅可以选择一个图层中的一个元素进行修改操作"); return false;
- }
- _recordset.Edit();
- foreach (Control tb in this.Controls.Find("tbValue", true))
- {
- _recordset.SetFieldValue(tb.Tag.ToString(), tb.Text);
- }
- ComsStatic.ShowUIMessageTipOKorError(_recordset.Update(),"属性修改");
- return null;
- }
- public override void AfterClose()
- {
- MapControl.GeometrySelected -= MapControl_GeometrySelected;
- ComsStatic.RecordsetDispose(_recordset);
- base.AfterClose();
- }
- private void InitializeComponent()
- {
- this.SuspendLayout();
- //
- // ShuXingXiuGai
- //
- this.AutoScroll = true;
- this.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(244)))));
- this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 20);
- this.Name = "ShuXingXiuGai";
- this.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
- this.Size = new System.Drawing.Size(413, 321);
- this.Style = Sunny.UI.UIStyle.Gray;
- this.ResumeLayout(false);
- }
- }
- }
|