SunnyUI/SunnyUI.Demo/Forms/FDialogs.cs

272 lines
8.8 KiB
C#
Raw Normal View History

using System;
2020-05-11 21:11:29 +08:00
using System.Collections.Generic;
using System.Threading;
2020-05-11 21:11:29 +08:00
namespace Sunny.UI.Demo
{
2024-07-23 14:33:14 +08:00
public partial class FDialogs : UIPage, ITranslate
2020-05-11 21:11:29 +08:00
{
public FDialogs()
{
InitializeComponent();
}
2024-07-23 14:33:14 +08:00
public override void Init()
{
base.Init();
btnCH.PerformClick();
}
2024-06-11 23:07:17 +08:00
private void btnInfo_Click(object sender, EventArgs e)
{
2024-10-06 21:31:18 +08:00
this.ShowInfoDialog2(CodeTranslator.Current.Default);
this.ShowInfoDialog(CodeTranslator.Current.Default);
2024-06-11 23:07:17 +08:00
}
2020-05-11 21:11:29 +08:00
private void btnAsk_Click(object sender, EventArgs e)
{
2024-10-06 21:31:18 +08:00
if (this.ShowAskDialog2(CodeTranslator.Current.Confirm, true))
2020-05-11 21:11:29 +08:00
{
2024-10-06 21:31:18 +08:00
this.ShowSuccessTip(CodeTranslator.Current.PressedOK);
2020-05-11 21:11:29 +08:00
}
else
{
2024-10-06 21:31:18 +08:00
this.ShowErrorTip(CodeTranslator.Current.PressedCancel);
2020-05-11 21:11:29 +08:00
}
2024-10-06 21:31:18 +08:00
if (this.ShowAskDialog(CodeTranslator.Current.Confirm))
2024-06-11 23:07:17 +08:00
{
2024-10-06 21:31:18 +08:00
this.ShowSuccessTip(CodeTranslator.Current.PressedOK);
2024-06-11 23:07:17 +08:00
}
else
{
2024-10-06 21:31:18 +08:00
this.ShowErrorTip(CodeTranslator.Current.PressedCancel);
2024-06-11 23:07:17 +08:00
}
2020-05-11 21:11:29 +08:00
}
private void btnSuccess_Click(object sender, EventArgs e)
{
2024-10-06 21:31:18 +08:00
this.ShowSuccessDialog2(CodeTranslator.Current.Success, false, 3000);
this.ShowSuccessDialog(CodeTranslator.Current.Success, false, 3000);
2020-05-11 21:11:29 +08:00
}
private void btnWarn_Click(object sender, EventArgs e)
{
2024-10-06 21:31:18 +08:00
this.ShowWarningDialog2(CodeTranslator.Current.Warning);
this.ShowWarningDialog(CodeTranslator.Current.Warning);
2020-05-11 21:11:29 +08:00
}
private void btnError_Click(object sender, EventArgs e)
{
2024-10-06 21:31:18 +08:00
this.ShowErrorDialog2(CodeTranslator.Current.Error);
this.ShowErrorDialog(CodeTranslator.Current.Error);
2020-05-11 21:11:29 +08:00
}
private void btnStatus2_Click(object sender, EventArgs e)
{
2024-10-06 21:31:18 +08:00
this.ShowStatusForm(100, CodeTranslator.Current.Loading + "......", 0);
for (int i = 0; i < 88; i++)
2020-05-11 21:11:29 +08:00
{
SystemEx.Delay(50);
2024-10-06 21:31:18 +08:00
this.SetStatusFormDescription(CodeTranslator.Current.Loading + "(" + i + "%)......");
2023-10-16 17:26:23 +08:00
this.SetStatusFormStepIt();
2020-05-11 21:11:29 +08:00
}
2023-10-16 17:26:23 +08:00
this.HideStatusForm();
2020-05-11 21:11:29 +08:00
}
private void btnStringInput_Click(object sender, EventArgs e)
{
2024-10-06 21:31:18 +08:00
string value = CodeTranslator.Current.InputString;
if (this.ShowInputStringDialog(ref value, true, CodeTranslator.Current.InputString, true))
2020-05-11 21:11:29 +08:00
{
2024-05-02 23:04:38 +08:00
this.ShowInfoDialog(value);
2020-05-11 21:11:29 +08:00
}
}
private void btnIntInput_Click(object sender, EventArgs e)
{
int value = 0;
2024-05-02 23:04:38 +08:00
if (this.ShowInputIntegerDialog(ref value))
2020-05-11 21:11:29 +08:00
{
2024-05-02 23:04:38 +08:00
this.ShowInfoDialog(value.ToString());
2020-05-11 21:11:29 +08:00
}
}
private void btnDoubleInput_Click(object sender, EventArgs e)
{
double value = 0;
2024-05-02 23:04:38 +08:00
if (this.ShowInputDoubleDialog(ref value))
2020-05-11 21:11:29 +08:00
{
2024-05-02 23:04:38 +08:00
this.ShowInfoDialog(value.ToString("F2"));
2020-05-11 21:11:29 +08:00
}
}
private void btnPasswordInput_Click(object sender, EventArgs e)
{
string value = "";
2024-05-02 23:04:38 +08:00
if (this.ShowInputPasswordDialog(ref value))
2020-05-11 21:11:29 +08:00
{
2024-05-02 23:04:38 +08:00
this.ShowInfoDialog(value);
2020-05-11 21:11:29 +08:00
}
}
private void uiSymbolButton1_Click(object sender, EventArgs e)
{
List<string> items = new List<string>() { "0", "1", "2", "3", "4" };
int index = 2;
if (this.ShowSelectDialog(ref index, items))
{
2024-05-02 23:04:38 +08:00
this.ShowInfoDialog(index.ToString());
2020-05-11 21:11:29 +08:00
}
}
private void uiSymbolButton2_Click(object sender, EventArgs e)
{
2024-05-02 23:04:38 +08:00
this.ShowInfoNotifier("Info", InfoNotifierClick);
}
private void InfoNotifierClick(object sender, EventArgs e)
{
2024-10-06 21:31:18 +08:00
this.ShowInfoTip(CodeTranslator.Current.PressedNotifier);
2020-05-11 21:11:29 +08:00
}
private void uiSymbolButton6_Click(object sender, EventArgs e)
{
2024-05-02 23:04:38 +08:00
this.ShowSuccessNotifier("Success");
2020-05-11 21:11:29 +08:00
}
private void uiSymbolButton5_Click(object sender, EventArgs e)
{
2024-05-02 23:04:38 +08:00
this.ShowWarningNotifier("Warning");
2020-05-11 21:11:29 +08:00
}
private void uiSymbolButton4_Click(object sender, EventArgs e)
{
2024-05-02 23:04:38 +08:00
this.ShowErrorNotifier("Error");
2020-05-11 21:11:29 +08:00
}
private void uiSymbolButton9_Click(object sender, EventArgs e)
{
2024-10-06 21:31:18 +08:00
this.ShowSuccessTip(CodeTranslator.Current.Success);
}
private void uiSymbolButton8_Click(object sender, EventArgs e)
{
2024-10-06 21:31:18 +08:00
this.ShowWarningTip(CodeTranslator.Current.Warning);
}
private void uiSymbolButton7_Click(object sender, EventArgs e)
{
2024-10-06 21:31:18 +08:00
this.ShowErrorTip(CodeTranslator.Current.Error);
}
2020-06-20 21:00:15 +08:00
private void uiSymbolButton10_Click(object sender, EventArgs e)
{
FLogin frm = new FLogin();
frm.ShowDialog();
if (frm.IsLogin)
{
2024-10-06 21:31:18 +08:00
UIMessageTip.ShowOk(CodeTranslator.Current.LoginSuccess);
2020-06-20 21:00:15 +08:00
}
frm.Dispose();
}
private void uiSymbolButton3_Click(object sender, EventArgs e)
{
2021-08-01 10:57:52 +08:00
UILoginForm frm = new UILoginForm
{
ShowInTaskbar = true,
Text = "Login",
Title = "SunnyUI.Net Login Form",
SubText = Version
};
2020-06-20 21:00:15 +08:00
frm.OnLogin += Frm_OnLogin;
frm.LoginImage = UILoginForm.UILoginImage.Login2;
frm.ShowDialog();
if (frm.IsLogin)
{
2024-10-06 21:31:18 +08:00
UIMessageTip.ShowOk(CodeTranslator.Current.LoginSuccess);
2020-06-20 21:00:15 +08:00
}
frm.Dispose();
}
private bool Frm_OnLogin(string userName, string password)
{
return userName == "admin" && password == "admin";
}
private void uiSymbolButton11_Click(object sender, EventArgs e)
{
2024-10-06 21:31:18 +08:00
this.ShowWaitForm(CodeTranslator.Current.Prepare);
2022-03-25 18:08:35 +08:00
Thread.Sleep(1000);
2024-10-06 21:31:18 +08:00
this.SetWaitFormDescription(UIStyles.CurrentResources.SystemProcessing + "20%");
2022-03-25 18:08:35 +08:00
Thread.Sleep(1000);
2024-10-06 21:31:18 +08:00
this.SetWaitFormDescription(UIStyles.CurrentResources.SystemProcessing + "40%");
2022-03-25 18:08:35 +08:00
Thread.Sleep(1000);
2024-10-06 21:31:18 +08:00
this.SetWaitFormDescription(UIStyles.CurrentResources.SystemProcessing + "60%");
2022-03-25 18:08:35 +08:00
Thread.Sleep(1000);
2024-10-06 21:31:18 +08:00
this.SetWaitFormDescription(UIStyles.CurrentResources.SystemProcessing + "80%");
2022-03-25 18:08:35 +08:00
Thread.Sleep(1000);
2024-10-06 21:31:18 +08:00
this.SetWaitFormDescription(UIStyles.CurrentResources.SystemProcessing + "100%");
2023-10-16 17:26:23 +08:00
this.HideWaitForm();
}
private void uiSymbolButton13_Click(object sender, EventArgs e)
{
string dir = "";
2024-10-06 21:31:18 +08:00
if (DirEx.SelectDirEx(CodeTranslator.Current.OpenDir, ref dir))
{
UIMessageTip.ShowOk(dir);
}
}
private void uiSymbolButton12_Click(object sender, EventArgs e)
{
2023-10-16 17:26:23 +08:00
this.ShowProcessForm(200);
Thread.Sleep(2000);
2023-10-16 17:26:23 +08:00
this.HideProcessForm();
}
2024-07-23 14:33:14 +08:00
private void btnCH_Click(object sender, EventArgs e)
{
2024-10-06 21:31:18 +08:00
UIStyles.CultureInfo = CultureInfos.zh_CN;
2024-07-23 14:33:14 +08:00
}
private void btnEN_Click(object sender, EventArgs e)
{
2024-10-06 21:31:18 +08:00
UIStyles.CultureInfo = CultureInfos.en_US;
2024-07-23 14:33:14 +08:00
}
2024-10-06 21:31:18 +08:00
/// <summary>
/// 重载多语翻译
/// </summary>
public override void Translate()
2024-07-23 14:33:14 +08:00
{
2024-10-06 21:31:18 +08:00
//必须保留
base.Translate();
//读取翻译代码中的多语资源
CodeTranslator.Load(this);
}
2024-07-23 14:33:14 +08:00
2024-10-06 21:31:18 +08:00
private class CodeTranslator : IniCodeTranslator<CodeTranslator>
{
public string Default { get; set; } = "默认信息提示框";
public string Confirm { get; set; } = "确认信息提示框";
public string PressedOK { get; set; } = "您点击了确定按钮";
public string PressedCancel { get; set; } = "您点击了取消按钮";
public string Success { get; set; } = "正确信息提示框";
public string Warning { get; set; } = "警告信息提示框";
public string Error { get; set; } = "错误信息提示框";
public string Loading { get; set; } = "数据加载中";
public string InputString { get; set; } = "请输入字符串";
public string PressedNotifier { get; set; } = "嗨,你点击了右下角的弹窗消息";
public string LoginSuccess { get; set; } = "登录成功";
public string Prepare { get; set; } = "准备开始";
public string OpenDir { get; set; } = "打开文件夹";
2024-07-23 14:33:14 +08:00
}
2020-05-11 21:11:29 +08:00
}
}