NetAutoGUI.Windows/WinFormMessageBoxController.cs
(完整代码) 1KBusing System.Runtime.Versioning;
using System.Windows.Forms;
using Vanara.PInvoke;
namespace NetAutoGUI.Windows
{
[SupportedOSPlatform("windows")]
internal class WinFormMessageBoxController : IMessageBoxController
{
public void Alert(string text, string title = " ")
{
User32.MessageBox(HWND.NULL, text, title, User32.MB_FLAGS.MB_ICONINFORMATION | User32.MB_FLAGS.MB_OK);
}
public bool Confirm(string text, string title = " ")
{
var result = User32.MessageBox(HWND.NULL, text, title, User32.MB_FLAGS.MB_ICONQUESTION | User32.MB_FLAGS.MB_OKCANCEL);
return result == User32.MB_RESULT.IDOK;
}
public string? Password(string title = "", string? okText = null, string? cancelText = null)
{
return ShowInputForm(title, okText, cancelText, FormInputType.Password);
}
public string? Prompt(string title = "", string? okText = null, string? cancelText = null)
{
return ShowInputForm(title, okText, cancelText, FormInputType.Plain);
}
private static string? ShowInputForm(string title, string? okText, string? cancelText, FormInputType inputType)
{
using FormInput form = new FormInput();
form.InputType = inputType;
form.Text = title;
if (!string.IsNullOrEmpty(okText))
{
form.OKText = okText;
}
if (!string.IsNullOrEmpty(cancelText))
{
form.CancelText = cancelText;
}
if (form.ShowDialog() == DialogResult.OK)
{
return form.Value;
}
else
{
return null;
}
}
public bool YesNoBox(string text, string title = " ")
{
var result = User32.MessageBox(HWND.NULL, text, title, User32.MB_FLAGS.MB_ICONQUESTION | User32.MB_FLAGS.MB_YESNO);
return result == User32.MB_RESULT.IDYES;
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。