From 46f88867a2d3561a701535bcc6c41d0f76634b52 Mon Sep 17 00:00:00 2001 From: cloudflight <cloudflight@126.com> Date: 星期一, 05 八月 2024 15:19:07 +0800 Subject: [PATCH] 添加示例 --- WinFrmUI/Yw.WinFrmUI.Hydro.Q3d.Core/MapView/Base/IBaseViewModel.cs | 139 +-------------------------------------------- 1 files changed, 5 insertions(+), 134 deletions(-) diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.Q3d.Core/MapView/Base/IBaseViewModel.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.Q3d.Core/MapView/Base/IBaseViewModel.cs index a77cd22..34f028d 100644 --- a/WinFrmUI/Yw.WinFrmUI.Hydro.Q3d.Core/MapView/Base/IBaseViewModel.cs +++ b/WinFrmUI/Yw.WinFrmUI.Hydro.Q3d.Core/MapView/Base/IBaseViewModel.cs @@ -8,9 +8,9 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -using static Hydro.MapView.MapViewEnum; +using static Yw.WinFrmUI.Q3D.MapViewEnum; -namespace Hydro.MapView +namespace Yw.WinFrmUI.Q3D { public interface IBaseViewModel { @@ -74,7 +74,7 @@ [Description("鏍囬珮")] [DisplayName("鏍囬珮")] [Browsable(true)] - float Elev { get; set; } + float Z { get; set; } [Category("鍏朵粬鍙傛暟")] [Description("瀵硅薄鐨勭瓑绾�")] @@ -105,7 +105,7 @@ string IDType { get; }// => Type.ToString()+"\t"+ ID; MapObjectType GetTypeString(); - TagList Tags { get; set; } + //TagList Tags { get; set; } //string TagsString { get; set; } @@ -150,136 +150,7 @@ } } - public class MyEditor : UITypeEditor - { - public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) - { - return UITypeEditorEditStyle.Modal; - } + - public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) - { - List<string> tags = value as List<string>; - // Create and show dialog - TagEditorForm form = new TagEditorForm(tags); - //form寮瑰嚭鏃讹紝浣嶇疆鍦ㄩ紶鏍囦綅缃� - form.StartPosition = FormStartPosition.Manual; - form.Location =new Point( Cursor.Position.X-form.Width+10,Cursor.Position.Y-10); - - //if (form.ShowDialog() == DialogResult.OK) - //{ - - //} - form.ShowDialog(); - return form.Tags; - //return base.EditValue(context, provider, value); - } - } - - public class TagEditorForm : Form - { - public List<string> Tags { get; set; } - - private ListBox listBox; - private TextBox tb_text; - - public TagEditorForm(List<string> tags) - { - Tags = tags; - - - // Initialize ListBox - listBox = new ListBox(); - listBox.DataSource = Tags; - listBox.Dock = DockStyle.Fill; - this.Controls.Add(listBox); - - // Add buttons for add, remove, update operations - tb_text = new TextBox(); - tb_text.Dock = DockStyle.Top; - - this.Controls.Add(tb_text); - Button addButton = new Button(); - addButton.Dock = DockStyle.Bottom; - addButton.Text = "娣诲姞"; - addButton.Click += AddButton_Click; - this.Controls.Add(addButton); - - Button removeButton = new Button(); - removeButton.Dock = DockStyle.Bottom; - removeButton.Text = "鍒犻櫎"; - removeButton.Click += RemoveButton_Click; - this.Controls.Add(removeButton); - - Button updateButton = new Button(); - updateButton.Dock = DockStyle.Bottom; - updateButton.Text = "鏇存柊"; - updateButton.Click += UpdateButton_Click; - this.Controls.Add(updateButton); - - Panel panel = new Panel(); - updateButton.Dock = DockStyle.Bottom; - this.Controls.Add(panel); - - Button btn_ok = new Button(); - btn_ok.Dock=DockStyle.Left; - btn_ok.Click+=(o,e) => { this.DialogResult = DialogResult.OK; }; - btn_ok.Text = "纭畾"; - panel.Controls.Add(btn_ok); - - Button btn_cancel = new Button(); - btn_cancel.Dock = DockStyle.Right; - btn_ok.Click += (o, e) => { this.DialogResult = DialogResult.Cancel; }; - btn_cancel.Text = "鍙栨秷"; - panel.Controls.Add(btn_cancel); - - listBox.SelectedIndexChanged += (o,e) => - { - if (listBox.SelectedItem!=null) - tb_text.Text= listBox.SelectedItem.ToString(); - }; - this.Icon =Icon.ExtractAssociatedIcon(Application.ExecutablePath); - } - - private void AddButton_Click(object sender, EventArgs e) - { - - // 鍦╨istBox涓寜tb_text鐨勫唴瀹癸紝娣诲姞鏂扮殑tag - if (tb_text.Text != null && tb_text.Text != "") - { - if (Tags == null) - Tags = new List<string>(); - Tags.Add(tb_text.Text); - listBox.DataSource = null; - listBox.DataSource = Tags; - } - - } - - private void RemoveButton_Click(object sender, EventArgs e) - { - //鍒犻櫎listBox涓�変腑鐨則ag - if (listBox.SelectedItem != null) - { - - Tags.Remove(listBox.SelectedItem.ToString()); - listBox.DataSource = null; - listBox.DataSource = Tags; - } - // Remove tag - } - - private void UpdateButton_Click(object sender, EventArgs e) - { - // 鍦╨istBox涓寜tb_text鐨勫唴瀹癸紝鏇存柊tag锛屼絾鏄笉鏀瑰彉椤哄簭 - if (listBox.SelectedItem != null) - { - - Tags[listBox.SelectedIndex] = tb_text.Text; - listBox.DataSource = null; - listBox.DataSource = Tags; - } - } - } } -- Gitblit v1.9.3