SunnyUI/SunnyUI/Frames/UIPage.cs

959 lines
31 KiB
C#
Raw Normal View History

2020-05-11 21:11:29 +08:00
/******************************************************************************
* SunnyUI
2022-01-02 12:32:50 +08:00
* CopyRight (C) 2012-2022 ShenYongHua().
2021-02-20 15:45:47 +08:00
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
2020-05-11 21:11:29 +08:00
*
* Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI
*
* SunnyUI.dll can be used for free under the GPL-3.0 license.
* If you use this code, please keep this note.
* 使
******************************************************************************
* : UIPage.cs
* : Form继承
2022-01-05 21:57:47 +08:00
* : V3.1
2020-05-11 21:11:29 +08:00
* : 2020-01-01
*
* 2020-01-01: V2.2.0
* 2021-05-21: V3.0.4 Init事件调用
* 2021-06-20: V3.0.4 UITitlePage
* 2021-07-18: V3.0.5 OnLoad在加载时重复加载两次的问题Final函数退
* 2021-08-17: V3.0.6 TitleFont属性
* 2021-08-24: V3.0.6 OnLoad在加载时重复加载两次的问题
* 2021-12-01: V3.0.9 FeedBack和SetParam函数
* 2021-12-30: V3.0.9 NeedReloadLoad
2020-05-11 21:11:29 +08:00
******************************************************************************/
using System;
using System.ComponentModel;
2020-06-05 22:42:48 +08:00
using System.Diagnostics;
2020-05-11 21:11:29 +08:00
using System.Drawing;
using System.Drawing.Design;
2020-05-11 21:11:29 +08:00
using System.Windows.Forms;
namespace Sunny.UI
{
[DefaultEvent("Initialize")]
2021-07-15 13:54:31 +08:00
public partial class UIPage : Form, IStyleInterface, ISymbol
2020-05-11 21:11:29 +08:00
{
2020-06-05 22:42:48 +08:00
public readonly Guid Guid = Guid.NewGuid();
private Color _rectColor = UIColor.Blue;
private ToolStripStatusLabelBorderSides _rectSides = ToolStripStatusLabelBorderSides.None;
protected UIStyle _style = UIStyle.Blue;
[Browsable(false)]
public IFrame Frame
{
get; set;
}
2020-05-11 21:11:29 +08:00
public UIPage()
{
InitializeComponent();
2020-06-05 22:42:48 +08:00
TopLevel = false;
if (this.Register()) SetStyle(UIStyles.Style);
2020-05-11 21:11:29 +08:00
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
UpdateStyles();
2020-06-05 22:42:48 +08:00
if (!IsDesignMode) base.Dock = DockStyle.Fill;
2020-05-11 21:11:29 +08:00
Version = UIGlobal.Version;
SetDPIScale();
BackColor = UIStyles.Blue.PageBackColor;
_rectColor = UIStyles.Blue.PageRectColor;
ForeColor = UIStyles.Blue.PageForeColor;
titleFillColor = UIStyles.Blue.PageTitleFillColor;
titleForeColor = UIStyles.Blue.PageTitleForeColor;
}
2021-10-20 22:38:37 +08:00
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()
{
if (!IsScaled)
{
this.SetDPIScaleFont();
2022-03-29 18:26:37 +08:00
if (!UIDPIScale.DPIScaleIsOne())
2021-11-17 23:46:56 +08:00
{
2022-03-29 23:55:38 +08:00
this.TitleFont = TitleFont.DPIScaleFont();
2021-11-17 23:46:56 +08:00
}
foreach (Control control in this.GetAllDPIScaleControls())
{
if (control is UIDataGridView dgv)
{
dgv.SetDPIScale();
}
else
{
control.SetDPIScaleFont();
}
}
IsScaled = true;
}
2020-05-11 21:11:29 +08:00
}
public void ReSetDPIScale()
{
IsScaled = false;
SetDPIScale();
}
public void Render()
{
SetStyle(UIStyles.Style);
}
private int _symbolSize = 24;
[DefaultValue(24)]
2021-03-22 21:31:14 +08:00
[Description("字体图标大小"), Category("SunnyUI")]
public int SymbolSize
{
get => _symbolSize;
set
{
_symbolSize = Math.Max(value, 16);
_symbolSize = Math.Min(value, 128);
SymbolChange();
Invalidate();
}
}
private int _symbol;
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Editor("Sunny.UI.UIImagePropertyEditor, " + AssemblyRefEx.SystemDesign, typeof(UITypeEditor))]
[DefaultValue(0)]
2021-03-22 21:31:14 +08:00
[Description("字体图标"), Category("SunnyUI")]
public int Symbol
{
get => _symbol;
set
{
_symbol = value;
SymbolChange();
Invalidate();
}
}
2021-07-15 13:54:31 +08:00
private Point symbolOffset = new Point(0, 0);
[DefaultValue(typeof(Point), "0, 0")]
[Description("字体图标的偏移位置"), Category("SunnyUI")]
public Point SymbolOffset
{
get => symbolOffset;
set
{
symbolOffset = value;
Invalidate();
}
}
2021-03-22 21:31:14 +08:00
[DefaultValue(false), Description("在Frame框架中不被关闭"), Category("SunnyUI")]
public bool AlwaysOpen
{
get; set;
}
2020-06-27 16:53:32 +08:00
protected virtual void SymbolChange()
{
}
2021-03-22 21:31:14 +08:00
[Browsable(false)]
public Point ParentLocation { get; set; } = new Point(0, 0);
2020-05-11 21:11:29 +08:00
[DefaultValue(-1)]
2020-06-05 22:42:48 +08:00
public int PageIndex { get; set; } = -1;
[Browsable(false)]
public Guid PageGuid { get; set; } = Guid.Empty;
[Browsable(false), DefaultValue(null)]
public TabPage TabPage { get; set; } = null;
2020-06-05 22:42:48 +08:00
/// <summary>
/// 边框颜色
/// </summary>
/// <value>The color of the border style.</value>
2021-03-22 21:31:14 +08:00
[Description("边框颜色"), Category("SunnyUI")]
2020-06-05 22:42:48 +08:00
public Color RectColor
{
get => _rectColor;
set
{
_rectColor = value;
AfterSetRectColor(value);
_style = UIStyle.Custom;
Invalidate();
}
}
protected bool IsDesignMode
2020-05-11 21:11:29 +08:00
{
2020-06-05 22:42:48 +08:00
get
2020-05-11 21:11:29 +08:00
{
2020-06-05 22:42:48 +08:00
var ReturnFlag = false;
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
ReturnFlag = true;
else if (Process.GetCurrentProcess().ProcessName == "devenv")
ReturnFlag = true;
return ReturnFlag;
2020-05-11 21:11:29 +08:00
}
2020-06-05 22:42:48 +08:00
}
[DefaultValue(ToolStripStatusLabelBorderSides.None)]
2021-03-22 21:31:14 +08:00
[Description("边框显示位置"), Category("SunnyUI")]
2020-06-05 22:42:48 +08:00
public ToolStripStatusLabelBorderSides RectSides
{
get => _rectSides;
set
{
_rectSides = value;
Invalidate();
}
}
/// <summary>
/// Tag字符串
/// </summary>
[DefaultValue(null)]
[Description("获取或设置包含有关控件的数据的对象字符串"), Category("SunnyUI")]
public string TagString
{
get; set;
}
2020-06-05 22:42:48 +08:00
public string Version
{
get;
}
2020-06-05 22:42:48 +08:00
/// <summary>
/// 主题样式
/// </summary>
[DefaultValue(UIStyle.Blue), Description("主题样式"), Category("SunnyUI")]
2020-06-05 22:42:48 +08:00
public UIStyle Style
{
get => _style;
set => SetStyle(value);
}
/// <summary>
/// 自定义主题风格
/// </summary>
[DefaultValue(false)]
[Description("获取或设置可以自定义主题风格"), Category("SunnyUI")]
public bool StyleCustomMode
{
get; set;
}
public event EventHandler Initialize;
2021-11-17 23:46:56 +08:00
public event EventHandler Finalize;
2020-06-05 22:42:48 +08:00
2020-05-11 21:11:29 +08:00
protected override void OnControlAdded(ControlEventArgs e)
{
base.OnControlAdded(e);
if (e.Control is IStyleInterface ctrl)
{
if (!ctrl.StyleCustomMode) ctrl.Style = Style;
}
UIStyleHelper.SetRawControlStyle(e, Style);
if (AllowShowTitle && !AllowAddControlOnTitle && e.Control.Top < TitleHeight)
{
e.Control.Top = Padding.Top;
}
}
[DefaultValue(false)]
[Description("允许在标题栏放置控件"), Category("SunnyUI")]
public bool AllowAddControlOnTitle
{
get; set;
2020-05-11 21:11:29 +08:00
}
public virtual void Init()
{
Initialize?.Invoke(this, new EventArgs());
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Init();
}
private bool IsShown;
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
IsShown = true;
}
public void ReLoad()
{
if (IsShown)
{
if (NeedReload)
OnLoad(EventArgs.Empty);
else
Init();
}
}
/// <summary>
/// 字体颜色
/// </summary>
[Description("页面切换是否需要重载Load"), Category("SunnyUI")]
[DefaultValue(false)]
public bool NeedReload { get; set; }
2020-05-11 21:11:29 +08:00
public virtual void Final()
{
Finalize?.Invoke(this, new EventArgs());
2020-05-11 21:11:29 +08:00
}
public void SetStyle(UIStyle style)
{
this.SuspendLayout();
UIStyleHelper.SetChildUIStyle(this, style);
2020-05-11 21:11:29 +08:00
if (!style.IsCustom())
{
SetStyleColor(style.Colors());
Invalidate();
}
2020-05-11 21:11:29 +08:00
_style = style;
UIStyleChanged?.Invoke(this, new EventArgs());
this.ResumeLayout();
2020-05-11 21:11:29 +08:00
}
public event EventHandler UIStyleChanged;
2020-05-11 21:11:29 +08:00
public virtual void SetStyleColor(UIBaseStyle uiColor)
{
BackColor = uiColor.PageBackColor;
_rectColor = uiColor.PageRectColor;
ForeColor = uiColor.PageForeColor;
titleFillColor = uiColor.PageTitleFillColor;
titleForeColor = uiColor.PageTitleForeColor;
2020-05-11 21:11:29 +08:00
}
protected virtual void AfterSetFillColor(Color color)
{
}
protected virtual void AfterSetRectColor(Color color)
{
}
protected virtual void AfterSetForeColor(Color color)
{
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
2020-06-05 22:42:48 +08:00
if (Width <= 0 || Height <= 0) return;
2020-05-11 21:11:29 +08:00
if (AllowShowTitle)
{
e.Graphics.FillRectangle(TitleFillColor, 0, 0, Width, TitleHeight);
}
2020-05-11 21:11:29 +08:00
if (RectSides != ToolStripStatusLabelBorderSides.None)
{
if (RectSides.GetValue(ToolStripStatusLabelBorderSides.Left))
e.Graphics.DrawLine(RectColor, 0, 0, 0, Height - 1);
if (RectSides.GetValue(ToolStripStatusLabelBorderSides.Top))
e.Graphics.DrawLine(RectColor, 0, 0, Width - 1, 0);
if (RectSides.GetValue(ToolStripStatusLabelBorderSides.Right))
e.Graphics.DrawLine(RectColor, Width - 1, 0, Width - 1, Height - 1);
if (RectSides.GetValue(ToolStripStatusLabelBorderSides.Bottom))
e.Graphics.DrawLine(RectColor, 0, Height - 1, Width - 1, Height - 1);
}
if (!AllowShowTitle) return;
if (Symbol > 0)
{
2021-07-15 13:54:31 +08:00
e.Graphics.DrawFontImage(Symbol, SymbolSize, TitleForeColor, new Rectangle(ImageInterval, 0, SymbolSize, TitleHeight), SymbolOffset.X, SymbolOffset.Y);
}
SizeF sf = e.Graphics.MeasureString(Text, TitleFont);
e.Graphics.DrawString(Text, TitleFont, TitleForeColor,
Symbol > 0 ? ImageInterval * 2 + SymbolSize : ImageInterval, (TitleHeight - sf.Height) / 2);
e.Graphics.SetHighQuality();
if (ControlBox)
{
if (InControlBox)
{
e.Graphics.FillRectangle(UIColor.Red, ControlBoxRect);
}
e.Graphics.DrawLine(Color.White,
ControlBoxRect.Left + ControlBoxRect.Width / 2 - 5,
ControlBoxRect.Top + ControlBoxRect.Height / 2 - 5,
ControlBoxRect.Left + ControlBoxRect.Width / 2 + 5,
ControlBoxRect.Top + ControlBoxRect.Height / 2 + 5);
e.Graphics.DrawLine(Color.White,
ControlBoxRect.Left + ControlBoxRect.Width / 2 - 5,
ControlBoxRect.Top + ControlBoxRect.Height / 2 + 5,
ControlBoxRect.Left + ControlBoxRect.Width / 2 + 5,
ControlBoxRect.Top + ControlBoxRect.Height / 2 - 5);
}
}
protected override void OnMouseClick(MouseEventArgs e)
{
2021-07-26 11:45:06 +08:00
base.OnMouseClick(e);
if (FormBorderStyle == FormBorderStyle.None && ShowTitle)
{
if (InControlBox)
{
InControlBox = false;
Close();
AfterClose();
}
}
}
private void AfterClose()
{
Console.WriteLine("Close");
}
private Color titleFillColor = Color.FromArgb(76, 76, 76);
/// <summary>
/// 填充颜色,当值为背景色或透明色或空值则不填充
/// </summary>
[Description("标题颜色"), Category("SunnyUI")]
[DefaultValue(typeof(Color), "76, 76, 76")]
public Color TitleFillColor
{
get => titleFillColor;
set
{
titleFillColor = value;
Invalidate();
}
}
private Color titleForeColor = Color.White;
/// <summary>
/// 字体颜色
/// </summary>
[Description("字体颜色"), Category("SunnyUI")]
[DefaultValue(typeof(Color), "White")]
public Color TitleForeColor
{
get => titleForeColor;
set
{
titleForeColor = value;
Invalidate();
}
}
/// <summary>
/// 标题字体
/// </summary>
private Font titleFont = UIFontColor.Font();
/// <summary>
/// 标题字体
/// </summary>
[Description("标题字体"), Category("SunnyUI")]
[DefaultValue(typeof(Font), "微软雅黑, 12pt")]
public Font TitleFont
{
get => titleFont;
set
{
titleFont = value;
Invalidate();
}
}
private int imageInterval = 6;
public int ImageInterval
{
get => imageInterval;
set
{
imageInterval = Math.Max(2, value);
Invalidate();
}
2020-05-11 21:11:29 +08:00
}
protected override void OnBackColorChanged(EventArgs e)
{
base.OnBackColorChanged(e);
AfterSetFillColor(BackColor);
_style = UIStyle.Custom;
}
protected override void OnForeColorChanged(EventArgs e)
{
base.OnForeColorChanged(e);
AfterSetForeColor(ForeColor);
_style = UIStyle.Custom;
}
private int titleHeight = 35;
[Description("面板高度"), Category("SunnyUI")]
[DefaultValue(35)]
public int TitleHeight
{
get => titleHeight;
set
{
titleHeight = Math.Max(value, 31);
Padding = new Padding(Padding.Left, titleHeight, Padding.Right, Padding.Bottom);
CalcSystemBoxPos();
Invalidate();
}
}
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
CalcSystemBoxPos();
}
private bool InControlBox;
protected override void OnMouseMove(MouseEventArgs e)
{
2021-07-26 11:45:06 +08:00
base.OnMouseMove(e);
if (ShowTitle && ControlBox)
{
bool inControlBox = e.Location.InRect(ControlBoxRect);
if (inControlBox != InControlBox)
{
InControlBox = inControlBox;
Invalidate();
}
}
}
protected override void OnPaddingChanged(EventArgs e)
{
base.OnPaddingChanged(e);
if (AllowShowTitle)
{
Padding = new Padding(Padding.Left, titleHeight, Padding.Right, Padding.Bottom);
}
}
[Description("允许显示标题栏"), Category("SunnyUI"), DefaultValue(false)]
public bool AllowShowTitle
{
get => ShowTitle;
set => ShowTitle = value;
}
/// <summary>
/// 是否显示窗体的标题栏
/// </summary>
private bool showTitle;
/// <summary>
/// 是否显示窗体的标题栏
/// </summary>
[Description("是否显示窗体的标题栏"), Category("WindowStyle"), DefaultValue(false)]
public bool ShowTitle
{
get => showTitle;
set
{
showTitle = value;
Padding = new Padding(Padding.Left, value ? titleHeight : 0, Padding.Right, Padding.Bottom);
Invalidate();
}
}
protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
Invalidate();
}
private void CalcSystemBoxPos()
{
ControlBoxRect = new Rectangle(Width - 6 - 28, titleHeight / 2 - 14, 28, 28);
}
private Rectangle ControlBoxRect;
/// <summary>
/// 是否显示窗体的控制按钮
/// </summary>
2021-06-20 23:28:59 +08:00
private bool controlBox;
/// <summary>
/// 是否显示窗体的控制按钮
/// </summary>
[Description("是否显示窗体的控制按钮"), Category("WindowStyle"), DefaultValue(false)]
public new bool ControlBox
{
get => controlBox;
set
{
controlBox = value;
CalcSystemBoxPos();
Invalidate();
}
}
[Browsable(false)]
public new bool MinimizeBox
{
get; set;
}
[Browsable(false)]
public new bool MaximizeBox
{
get; set;
}
public void FeedbackToFrame(params object[] objects)
{
Frame?.FeedbackFormPage(PageIndex, objects);
}
public virtual bool SetParam(int fromPageIndex, params object[] objects)
{
return false;
}
public virtual bool SetParam(Guid fromPageGuid, params object[] objects)
{
return false;
}
#region
/// <summary>
/// 显示进度提示窗
/// </summary>
/// <param name="desc">描述文字</param>
/// <param name="maximum">最大进度值</param>
/// <param name="decimalCount">显示进度条小数个数</param>
public void ShowStatusForm(int maximum = 100, string desc = "系统正在处理中,请稍候...", int decimalCount = 1)
{
UIStatusFormService.ShowStatusForm(maximum, desc, decimalCount);
}
/// <summary>
/// 隐藏进度提示窗
/// </summary>
public void HideStatusForm()
{
UIStatusFormService.HideStatusForm();
}
/// <summary>
/// 设置进度提示窗步进值加1
/// </summary>
public void StatusFormStepIt()
{
UIStatusFormService.StepIt();
}
/// <summary>
/// 设置进度提示窗描述文字
/// </summary>
/// <param name="desc">描述文字</param>
public void SetStatusFormDescription(string desc)
{
UIStatusFormService.SetDescription(desc);
}
/// <summary>
/// 显示等待提示窗
/// </summary>
/// <param name="desc">描述文字</param>
public void ShowWaitForm(string desc = "系统正在处理中,请稍候...")
{
UIWaitFormService.ShowWaitForm(desc);
}
/// <summary>
/// 隐藏等待提示窗
/// </summary>
public void HideWaitForm()
{
UIWaitFormService.HideWaitForm();
}
/// <summary>
/// 设置等待提示窗描述文字
/// </summary>
/// <param name="desc">描述文字</param>
public void SetWaitFormDescription(string desc)
{
UIWaitFormService.SetDescription(desc);
}
/// <summary>
/// 正确信息提示框
/// </summary>
/// <param name="msg">信息</param>
/// <param name="showMask">显示遮罩层</param>
public void ShowSuccessDialog(string msg, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, UILocalize.SuccessTitle, false, UIStyle.Green, showMask, Frame?.TopMost ?? false);
}
/// <summary>
/// 信息提示框
/// </summary>
/// <param name="msg">信息</param>
/// <param name="showMask">显示遮罩层</param>
public void ShowInfoDialog(string msg, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, UILocalize.InfoTitle, false, UIStyle.Gray, showMask, Frame?.TopMost ?? false);
}
/// <summary>
/// 警告信息提示框
/// </summary>
/// <param name="msg">信息</param>
/// <param name="showMask">显示遮罩层</param>
public void ShowWarningDialog(string msg, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, UILocalize.WarningTitle, false, UIStyle.Orange, showMask, Frame?.TopMost ?? false);
}
/// <summary>
/// 错误信息提示框
/// </summary>
/// <param name="msg">信息</param>
/// <param name="showMask">显示遮罩层</param>
public void ShowErrorDialog(string msg, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, UILocalize.ErrorTitle, false, UIStyle.Red, showMask, Frame?.TopMost ?? false);
}
/// <summary>
/// 确认信息提示框
/// </summary>
/// <param name="msg">信息</param>
/// <param name="showMask">显示遮罩层</param>
/// <returns>结果</returns>
public bool ShowAskDialog(string msg, bool showMask = true)
{
return UIMessageDialog.ShowMessageDialog(msg, UILocalize.AskTitle, true, UIStyle.Blue, showMask, Frame?.TopMost ?? false);
}
/// <summary>
/// 正确信息提示框
/// </summary>
/// <param name="title">标题</param>
/// <param name="msg">信息</param>
/// <param name="style">主题</param>
/// <param name="showMask">显示遮罩层</param>
public void ShowSuccessDialog(string title, string msg, UIStyle style = UIStyle.Green, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask, Frame?.TopMost ?? false);
}
/// <summary>
/// 信息提示框
/// </summary>
/// <param name="title">标题</param>
/// <param name="msg">信息</param>
/// <param name="style">主题</param>
/// <param name="showMask">显示遮罩层</param>
public void ShowInfoDialog(string title, string msg, UIStyle style = UIStyle.Gray, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask, Frame?.TopMost ?? false);
}
/// <summary>
/// 警告信息提示框
/// </summary>
/// <param name="title">标题</param>
/// <param name="msg">信息</param>
/// <param name="style">主题</param>
/// <param name="showMask">显示遮罩层</param>
public void ShowWarningDialog(string title, string msg, UIStyle style = UIStyle.Orange, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask, Frame?.TopMost ?? false);
}
/// <summary>
/// 错误信息提示框
/// </summary>
/// <param name="title">标题</param>
/// <param name="msg">信息</param>
/// <param name="style">主题</param>
/// <param name="showMask">显示遮罩层</param>
public void ShowErrorDialog(string title, string msg, UIStyle style = UIStyle.Red, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask, Frame?.TopMost ?? false);
}
/// <summary>
/// 确认信息提示框
/// </summary>
/// <param name="title">标题</param>
/// <param name="msg">信息</param>
/// <param name="style">主题</param>
/// <param name="showMask">显示遮罩层</param>
/// <returns>结果</returns>
public bool ShowAskDialog(string title, string msg, UIStyle style = UIStyle.Blue, bool showMask = true)
{
return UIMessageDialog.ShowMessageDialog(msg, title, true, style, showMask, Frame?.TopMost ?? false);
}
/// <summary>
/// 显示消息
/// </summary>
/// <param name="text">消息文本</param>
/// <param name="delay">消息停留时长(ms)。默认1秒</param>
/// <param name="floating">是否漂浮</param>
public void ShowInfoTip(string text, int delay = 1000, bool floating = true)
=> UIMessageTip.Show(text, null, delay, floating);
/// <summary>
/// 显示成功消息
/// </summary>
/// <param name="text">消息文本</param>
/// <param name="delay">消息停留时长(ms)。默认1秒</param>
/// <param name="floating">是否漂浮</param>
public void ShowSuccessTip(string text, int delay = 1000, bool floating = true)
=> UIMessageTip.ShowOk(text, delay, floating);
/// <summary>
/// 显示警告消息
/// </summary>
/// <param name="text">消息文本</param>
/// <param name="delay">消息停留时长(ms)。默认1秒</param>
/// <param name="floating">是否漂浮</param>
public void ShowWarningTip(string text, int delay = 1000, bool floating = true)
=> UIMessageTip.ShowWarning(text, delay, floating);
/// <summary>
/// 显示出错消息
/// </summary>
/// <param name="text">消息文本</param>
/// <param name="delay">消息停留时长(ms)。默认1秒</param>
/// <param name="floating">是否漂浮</param>
public void ShowErrorTip(string text, int delay = 1000, bool floating = true)
=> UIMessageTip.ShowError(text, delay, floating);
/// <summary>
/// 在指定控件附近显示消息
/// </summary>
/// <param name="controlOrItem">控件或工具栏项</param>
/// <param name="text">消息文本</param>
/// <param name="delay">消息停留时长(ms)。默认1秒</param>
/// <param name="floating">是否漂浮</param>
public void ShowInfoTip(Component controlOrItem, string text, int delay = 1000, bool floating = true)
=> UIMessageTip.Show(controlOrItem, text, null, delay, floating);
/// <summary>
/// 在指定控件附近显示良好消息
/// </summary>
/// <param name="controlOrItem">控件或工具栏项</param>
/// <param name="text">消息文本</param>
/// <param name="delay">消息停留时长(ms)。默认1秒</param>
/// <param name="floating">是否漂浮</param>
public void ShowSuccessTip(Component controlOrItem, string text, int delay = 1000, bool floating = true)
=> UIMessageTip.ShowOk(controlOrItem, text, delay, floating);
/// <summary>
/// 在指定控件附近显示出错消息
/// </summary>
/// <param name="controlOrItem">控件或工具栏项</param>
/// <param name="text">消息文本</param>
/// <param name="delay">消息停留时长(ms)。默认1秒</param>
/// <param name="floating">是否漂浮</param>
public void ShowErrorTip(Component controlOrItem, string text, int delay = 1000, bool floating = true)
=> UIMessageTip.ShowError(controlOrItem, text, delay, floating);
/// <summary>
/// 在指定控件附近显示警告消息
/// </summary>
/// <param name="controlOrItem">控件或工具栏项</param>
/// <param name="text">消息文本</param>
/// <param name="delay">消息停留时长(ms)。默认1秒</param>
/// <param name="floating">是否漂浮</param>
public void ShowWarningTip(Component controlOrItem, string text, int delay = 1000, bool floating = true)
=> UIMessageTip.ShowWarning(controlOrItem, text, delay, floating, false);
public void ShowInfoNotifier(string desc, bool isDialog = false, int timeout = 2000)
{
2021-07-15 13:54:31 +08:00
UINotifierHelper.ShowNotifier(desc, UINotifierType.INFO, UILocalize.InfoTitle, isDialog, timeout);
}
public void ShowSuccessNotifier(string desc, bool isDialog = false, int timeout = 2000)
{
2021-07-15 13:54:31 +08:00
UINotifierHelper.ShowNotifier(desc, UINotifierType.OK, UILocalize.SuccessTitle, isDialog, timeout);
}
public void ShowWarningNotifier(string desc, bool isDialog = false, int timeout = 2000)
{
2021-07-15 13:54:31 +08:00
UINotifierHelper.ShowNotifier(desc, UINotifierType.WARNING, UILocalize.WarningTitle, isDialog, timeout);
}
public void ShowErrorNotifier(string desc, bool isDialog = false, int timeout = 2000)
{
2021-07-15 13:54:31 +08:00
UINotifierHelper.ShowNotifier(desc, UINotifierType.ERROR, UILocalize.ErrorTitle, isDialog, timeout);
}
public void ShowInfoNotifier(string desc, EventHandler clickEvent, int timeout = 2000)
{
UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.INFO, UILocalize.InfoTitle, timeout);
}
public void ShowSuccessNotifier(string desc, EventHandler clickEvent, int timeout = 2000)
{
UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.OK, UILocalize.SuccessTitle, timeout);
}
public void ShowWarningNotifier(string desc, EventHandler clickEvent, int timeout = 2000)
{
UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.WARNING, UILocalize.WarningTitle, timeout);
}
public void ShowErrorNotifier(string desc, EventHandler clickEvent, int timeout = 2000)
{
UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.ERROR, UILocalize.ErrorTitle, timeout);
}
2021-11-17 23:46:56 +08:00
#endregion
2020-05-11 21:11:29 +08:00
}
}