* UIEditForm: 代码生成增加文件选择和文件夹选择功能
This commit is contained in:
parent
12359d1bb4
commit
cfa40a5381
@ -25,6 +25,7 @@
|
|||||||
* 2023-04-23: V3.3.5 代码生成增加,Double类型增加小数点位数
|
* 2023-04-23: V3.3.5 代码生成增加,Double类型增加小数点位数
|
||||||
* 2023-07-27: V3.4.1 默认提示弹窗TopMost为true
|
* 2023-07-27: V3.4.1 默认提示弹窗TopMost为true
|
||||||
* 2023-10-31: V3.5.2 代码生成增加ComboDataGridView类型
|
* 2023-10-31: V3.5.2 代码生成增加ComboDataGridView类型
|
||||||
|
* 2024-08-02: V3.6.8 代码生成增加文件选择和文件夹选择功能
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -94,6 +95,31 @@ namespace Sunny.UI
|
|||||||
edit.EnterAsTab = true;
|
edit.EnterAsTab = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (info.EditType == EditType.FileSelect)
|
||||||
|
{
|
||||||
|
ctrl = new UITextBox();
|
||||||
|
var edit = (UITextBox)ctrl;
|
||||||
|
edit.ShowButton = true;
|
||||||
|
edit.ButtonSymbol = 261788;
|
||||||
|
edit.ButtonSymbolSize = 22;
|
||||||
|
edit.ButtonSymbolOffset = new Point(1, 1);
|
||||||
|
edit.Text = info.Value?.ToString();
|
||||||
|
edit.EnterAsTab = true;
|
||||||
|
edit.ButtonClick += Edit_FileButtonClick;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.EditType == EditType.DirSelect)
|
||||||
|
{
|
||||||
|
ctrl = new UITextBox();
|
||||||
|
var edit = (UITextBox)ctrl;
|
||||||
|
edit.ShowButton = true;
|
||||||
|
edit.ButtonSymbol = 61717;
|
||||||
|
edit.ButtonSymbolOffset = new Point(2, 0);
|
||||||
|
edit.Text = info.Value?.ToString();
|
||||||
|
edit.EnterAsTab = true;
|
||||||
|
edit.ButtonClick += Dir_FileButtonClick;
|
||||||
|
}
|
||||||
|
|
||||||
if (info.EditType == EditType.Password)
|
if (info.EditType == EditType.Password)
|
||||||
{
|
{
|
||||||
ctrl = new UITextBox();
|
ctrl = new UITextBox();
|
||||||
@ -271,6 +297,28 @@ namespace Sunny.UI
|
|||||||
btnOK.ShowFocusLine = btnCancel.ShowFocusLine = true;
|
btnOK.ShowFocusLine = btnCancel.ShowFocusLine = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Edit_FileButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UITextBox edit = (UITextBox)sender;
|
||||||
|
string filename = edit.Text;
|
||||||
|
var info = Option.Dictionary[edit.Name.Replace("Edit_", "")];
|
||||||
|
if (FileEx.OpenDialog(ref filename, info.DisplayMember, info.ValueMember))
|
||||||
|
{
|
||||||
|
edit.Text = filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Dir_FileButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UITextBox edit = (UITextBox)sender;
|
||||||
|
string dirname = edit.Text;
|
||||||
|
var info = Option.Dictionary[edit.Name.Replace("Edit_", "")];
|
||||||
|
if (DirEx.SelectDirEx(info.DisplayMember, ref dirname))
|
||||||
|
{
|
||||||
|
edit.Text = dirname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void Edit_SelectIndexChange(object sender, int index)
|
private void Edit_SelectIndexChange(object sender, int index)
|
||||||
{
|
{
|
||||||
UIComboDataGridView edit = (UIComboDataGridView)sender;
|
UIComboDataGridView edit = (UIComboDataGridView)sender;
|
||||||
@ -395,7 +443,8 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
foreach (var info in Option.Infos)
|
foreach (var info in Option.Infos)
|
||||||
{
|
{
|
||||||
if (info.EditType == EditType.Text || info.EditType == EditType.Password)
|
if (info.EditType == EditType.Text || info.EditType == EditType.Password ||
|
||||||
|
info.EditType == EditType.FileSelect || info.EditType == EditType.DirSelect)
|
||||||
{
|
{
|
||||||
UITextBox edit = this.GetControl<UITextBox>("Edit_" + info.DataPropertyName);
|
UITextBox edit = this.GetControl<UITextBox>("Edit_" + info.DataPropertyName);
|
||||||
if (edit == null) continue;
|
if (edit == null) continue;
|
||||||
|
@ -40,7 +40,9 @@ namespace Sunny.UI
|
|||||||
Switch,
|
Switch,
|
||||||
ComboTreeView,
|
ComboTreeView,
|
||||||
ComboCheckedListBox,
|
ComboCheckedListBox,
|
||||||
ComboDataGridView
|
ComboDataGridView,
|
||||||
|
FileSelect,
|
||||||
|
DirSelect
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ComboCheckedListBoxItem
|
public class ComboCheckedListBoxItem
|
||||||
@ -118,6 +120,47 @@ namespace Sunny.UI
|
|||||||
Dictionary.TryAdd(info.DataPropertyName, info);
|
Dictionary.TryAdd(info.DataPropertyName, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddFileSelect(string dataPropertyName, string text, string filename, bool checkEmpty, string filter = "", string defaultExt = "", bool enabled = true)
|
||||||
|
{
|
||||||
|
if (Dictionary.ContainsKey(dataPropertyName))
|
||||||
|
throw new DuplicateNameException(dataPropertyName + ": 已经存在");
|
||||||
|
|
||||||
|
EditInfo info = new EditInfo()
|
||||||
|
{
|
||||||
|
DataPropertyName = dataPropertyName,
|
||||||
|
EditType = EditType.FileSelect,
|
||||||
|
Text = text,
|
||||||
|
Value = filename,
|
||||||
|
CheckEmpty = checkEmpty,
|
||||||
|
Enabled = enabled,
|
||||||
|
DisplayMember = filter,
|
||||||
|
ValueMember = defaultExt
|
||||||
|
};
|
||||||
|
|
||||||
|
Infos.Add(info);
|
||||||
|
Dictionary.TryAdd(info.DataPropertyName, info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddDirSelect(string dataPropertyName, string text, string dirname, bool checkEmpty, string desc = "请选择文件夹", bool enabled = true)
|
||||||
|
{
|
||||||
|
if (Dictionary.ContainsKey(dataPropertyName))
|
||||||
|
throw new DuplicateNameException(dataPropertyName + ": 已经存在");
|
||||||
|
|
||||||
|
EditInfo info = new EditInfo()
|
||||||
|
{
|
||||||
|
DataPropertyName = dataPropertyName,
|
||||||
|
EditType = EditType.DirSelect,
|
||||||
|
Text = text,
|
||||||
|
Value = dirname,
|
||||||
|
CheckEmpty = checkEmpty,
|
||||||
|
Enabled = enabled,
|
||||||
|
DisplayMember = desc,
|
||||||
|
};
|
||||||
|
|
||||||
|
Infos.Add(info);
|
||||||
|
Dictionary.TryAdd(info.DataPropertyName, info);
|
||||||
|
}
|
||||||
|
|
||||||
public void AddPassword(string dataPropertyName, string text, string value, bool checkEmpty, bool enabled = true)
|
public void AddPassword(string dataPropertyName, string text, string value, bool checkEmpty, bool enabled = true)
|
||||||
{
|
{
|
||||||
if (Dictionary.ContainsKey(dataPropertyName))
|
if (Dictionary.ContainsKey(dataPropertyName))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user