2020-05-11 21:11:29 +08:00
|
|
|
|
using System;
|
2021-04-26 22:09:06 +08:00
|
|
|
|
using System.Collections.Generic;
|
2020-05-11 21:11:29 +08:00
|
|
|
|
|
|
|
|
|
namespace Sunny.UI.Demo.Forms
|
|
|
|
|
{
|
2021-08-16 23:05:32 +08:00
|
|
|
|
public partial class FEditor : UIPage
|
2020-05-11 21:11:29 +08:00
|
|
|
|
{
|
|
|
|
|
public FEditor()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnEdit_Click(object sender, System.EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Person person = new Person();
|
|
|
|
|
person.Name = "SunnyUI";
|
|
|
|
|
person.Sex = Sex.Male;
|
|
|
|
|
person.Age = 18;
|
|
|
|
|
person.Department = "研发部";
|
|
|
|
|
person.Birthday = new DateTime(2002, 1, 1);
|
|
|
|
|
|
|
|
|
|
FEdit frm = new FEdit();
|
|
|
|
|
frm.Person = person;
|
|
|
|
|
frm.ShowDialog();
|
|
|
|
|
if (frm.IsOK)
|
|
|
|
|
{
|
|
|
|
|
this.ShowSuccessDialog(frm.Person.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
frm.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
FEdit frm = new FEdit();
|
|
|
|
|
frm.ShowDialog();
|
|
|
|
|
if (frm.IsOK)
|
|
|
|
|
{
|
|
|
|
|
this.ShowSuccessDialog(frm.Person.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
frm.Dispose();
|
|
|
|
|
}
|
2020-12-28 23:18:33 +08:00
|
|
|
|
|
|
|
|
|
private void uiSymbolButton1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2021-04-26 22:09:06 +08:00
|
|
|
|
List<FCombobox.Info> infoList = new List<FCombobox.Info>();
|
|
|
|
|
FCombobox.Info info1 = new FCombobox.Info() { Id = "1", Name = "张三" };
|
|
|
|
|
FCombobox.Info info2 = new FCombobox.Info() { Id = "2", Name = "李四" };
|
|
|
|
|
FCombobox.Info info3 = new FCombobox.Info() { Id = "3", Name = "王五" };
|
|
|
|
|
infoList.Add(info1);
|
|
|
|
|
infoList.Add(info2);
|
|
|
|
|
infoList.Add(info3);
|
|
|
|
|
|
|
|
|
|
string[] sex = new[] { "男", "女" };
|
|
|
|
|
|
2020-12-28 23:18:33 +08:00
|
|
|
|
UIEditOption option = new UIEditOption();
|
|
|
|
|
option.AutoLabelWidth = true;
|
|
|
|
|
option.Text = "增加";
|
2021-05-20 13:16:48 +08:00
|
|
|
|
option.AddText("Name", "姓名", null, true);
|
2021-05-19 14:03:36 +08:00
|
|
|
|
option.AddInteger("Age", "年龄", 16);
|
2020-12-28 23:18:33 +08:00
|
|
|
|
option.AddDate("Birthday", "生日", DateTime.Now);
|
2021-04-26 22:09:06 +08:00
|
|
|
|
option.AddCombobox("Sex", "性别", sex, 1, true, true);
|
|
|
|
|
option.AddCombobox("Info", "关联", infoList, "Name", "Id", "2");
|
2021-04-26 22:21:05 +08:00
|
|
|
|
option.AddSwitch("Switch", "选择", false);
|
2020-12-28 23:18:33 +08:00
|
|
|
|
|
|
|
|
|
UIEditForm frm = new UIEditForm(option);
|
2021-05-19 14:03:36 +08:00
|
|
|
|
frm.CheckedData += Frm_CheckedData;
|
2020-12-28 23:18:33 +08:00
|
|
|
|
frm.ShowDialog();
|
|
|
|
|
|
|
|
|
|
if (frm.IsOK)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("姓名: " + frm["Name"]);
|
|
|
|
|
Console.WriteLine("年龄: " + frm["Age"]);
|
|
|
|
|
Console.WriteLine("生日: " + frm["Birthday"]);
|
2021-04-26 22:09:06 +08:00
|
|
|
|
Console.WriteLine("性别: " + sex[(int)frm["Sex"]]);
|
|
|
|
|
Console.WriteLine("关联: " + frm["Info"]);
|
2021-04-26 22:21:05 +08:00
|
|
|
|
Console.WriteLine("选择: " + frm["Switch"]);
|
2020-12-28 23:18:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
frm.Dispose();
|
|
|
|
|
}
|
2021-05-19 14:03:36 +08:00
|
|
|
|
|
|
|
|
|
private bool Frm_CheckedData(object sender, UIEditForm.EditFormEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Form["Age"].ToString().ToInt() < 18 || e.Form["Age"].ToString().ToInt() > 60)
|
|
|
|
|
{
|
|
|
|
|
e.Form.SetEditorFocus("Age");
|
|
|
|
|
ShowWarningTip("年龄范围为18到60岁");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2020-05-11 21:11:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Person
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
public int Age { get; set; }
|
|
|
|
|
|
|
|
|
|
public Sex Sex { get; set; }
|
|
|
|
|
|
|
|
|
|
public string Department { get; set; }
|
|
|
|
|
|
|
|
|
|
public DateTime Birthday { get; set; }
|
|
|
|
|
|
|
|
|
|
public string Address { get; set; }
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return Name + ", " + Age + ", " + Department;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum Sex
|
|
|
|
|
{
|
|
|
|
|
Male,
|
|
|
|
|
Female
|
|
|
|
|
}
|
|
|
|
|
}
|