/****************************************************************************** * SunnyUI 开源控件库、工具类库、扩展类库、多页面开发框架。 * CopyRight (C) 2012-2022 ShenYongHua(沈永华). * QQ群:56829229 QQ:17612584 EMail:SunnyUI@QQ.Com * * 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继承,可放置于容器内 * 当前版本: V3.1 * 创建日期: 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 增加NeedReload,页面切换是否需要重载Load * 2022-04-02: V3.1.2 默认设置AutoScaleMode为None * 2022-04-26: V3.1.8 屏蔽一些属性 * 2022-05-11: V3.1.8 ShowTitle时,可调整Padding * 2022-06-11: V3.1.9 弹窗默认关闭半透明遮罩 * 2022-08-25: V3.2.3 重构多页面框架传值删除SetParam,FeedbackToFrame * 2022-08-25: V3.2.3 重构多页面框架传值:页面发送给框架 SendParamToFrame 函数 * 2022-08-25: V3.2.3 重构多页面框架传值:页面发送给框架 SendParamToPage 函数 * 2022-08-25: V3.2.3 重构多页面框架传值:接收框架、页面传值 ReceiveParams 事件 ******************************************************************************/ using System; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.Drawing.Design; using System.Windows.Forms; namespace Sunny.UI { [DefaultEvent("Initialize")] public partial class UIPage : Form, IStyleInterface, ISymbol, IZoomScale { 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; } public UIPage() { InitializeComponent(); TopLevel = false; if (this.Register()) SetStyle(UIStyles.Style); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); UpdateStyles(); if (!IsDesignMode) base.Dock = DockStyle.Fill; Version = UIGlobal.Version; SetDPIScale(); BackColor = UIStyles.Blue.PageBackColor; _rectColor = UIStyles.Blue.PageRectColor; ForeColor = UIStyles.Blue.PageForeColor; titleFillColor = UIStyles.Blue.PageTitleFillColor; titleForeColor = UIStyles.Blue.PageTitleForeColor; base.WindowState = FormWindowState.Normal; base.TopMost = false; base.FormBorderStyle = FormBorderStyle.None; base.AutoScroll = false; base.ShowIcon = false; base.ShowInTaskbar = false; base.StartPosition = FormStartPosition.Manual; base.SizeGripStyle = SizeGripStyle.Hide; } [Browsable(false)] public new IButtonControl AcceptButton { get => base.AcceptButton; set => base.AcceptButton = value; } [Browsable(false)] public new IButtonControl CancelButton { get => base.CancelButton; set => base.CancelButton = value; } [Browsable(false)] public new SizeGripStyle SizeGripStyle { get => base.SizeGripStyle; set => base.SizeGripStyle = SizeGripStyle.Hide; } [Browsable(false)] public new FormStartPosition StartPosition { get => base.StartPosition; set => base.StartPosition = FormStartPosition.Manual; } [Browsable(false)] public new bool AutoScroll { get => base.AutoScroll; set => base.AutoScroll = false; } [Browsable(false)] public new bool ShowIcon { get => base.ShowIcon; set => base.ShowIcon = false; } [Browsable(false)] public new bool ShowInTaskbar { get => base.ShowInTaskbar; set => base.ShowInTaskbar = false; } [Browsable(false)] public new bool IsMdiContainer { get => base.IsMdiContainer; set => base.IsMdiContainer = false; } //不显示FormBorderStyle属性 [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public new FormBorderStyle FormBorderStyle { get { return base.FormBorderStyle; } set { if (!Enum.IsDefined(typeof(FormBorderStyle), value)) throw new InvalidEnumArgumentException(nameof(value), (int)value, typeof(FormBorderStyle)); base.FormBorderStyle = FormBorderStyle.None; } } [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public new bool TopMost { get => base.TopMost; set => base.TopMost = false; } /// /// 不显示WindowState属性 /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public new FormWindowState WindowState { get { return base.WindowState; } set { base.WindowState = FormWindowState.Normal; } } public UIPage SetPageIndex(int pageIndex) { PageIndex = pageIndex; return this; } public UIPage SetPageGuid(Guid pageGuid) { PageGuid = pageGuid; return this; } public UIPage SetText(string text) { Text = text; return this; } /// /// 禁止控件跟随窗体缩放 /// [DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")] public bool ZoomScaleDisabled { get; set; } /// /// 控件缩放前在其容器里的位置 /// [Browsable(false)] public Rectangle ZoomScaleRect { get; set; } /// /// 设置控件缩放比例 /// /// 缩放比例 public virtual void SetZoomScale(float scale) { } [Browsable(false)] public bool IsScaled { get; private set; } public void SetDPIScale() { if (DesignMode) return; if (!IsScaled) { this.SetDPIScaleFont(); if (!UIDPIScale.DPIScaleIsOne()) { this.TitleFont = TitleFont.DPIScaleFont(); } foreach (Control control in this.GetAllDPIScaleControls()) { if (control is UIDataGridView dgv) { dgv.SetDPIScale(); } else { control.SetDPIScaleFont(); } } IsScaled = true; } } public void ResetDPIScale() { IsScaled = false; SetDPIScale(); } public void Render() { SetStyle(UIStyles.Style); } private int _symbolSize = 24; /// /// 字体图标大小 /// [DefaultValue(24)] [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)] [Description("字体图标"), Category("SunnyUI")] public int Symbol { get => _symbol; set { _symbol = value; SymbolChange(); Invalidate(); } } private Point symbolOffset = new Point(0, 0); /// /// 字体图标的偏移位置 /// [DefaultValue(typeof(Point), "0, 0")] [Description("字体图标的偏移位置"), Category("SunnyUI")] public Point SymbolOffset { get => symbolOffset; set { symbolOffset = value; Invalidate(); } } [DefaultValue(false), Description("在Frame框架中不被关闭"), Category("SunnyUI")] public bool AlwaysOpen { get; set; } protected virtual void SymbolChange() { } [Browsable(false)] public Point ParentLocation { get; set; } = new Point(0, 0); [DefaultValue(-1)] 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; /// /// 边框颜色 /// /// The color of the border style. [Description("边框颜色"), Category("SunnyUI")] public Color RectColor { get => _rectColor; set { _rectColor = value; AfterSetRectColor(value); _style = UIStyle.Custom; Invalidate(); } } protected bool IsDesignMode { get { var ReturnFlag = false; if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) ReturnFlag = true; else if (Process.GetCurrentProcess().ProcessName == "devenv") ReturnFlag = true; return ReturnFlag; } } [DefaultValue(ToolStripStatusLabelBorderSides.None)] [Description("边框显示位置"), Category("SunnyUI")] public ToolStripStatusLabelBorderSides RectSides { get => _rectSides; set { _rectSides = value; Invalidate(); } } /// /// Tag字符串 /// [DefaultValue(null)] [Description("获取或设置包含有关控件的数据的对象字符串"), Category("SunnyUI")] public string TagString { get; set; } public string Version { get; } /// /// 主题样式 /// [DefaultValue(UIStyle.Blue), Description("主题样式"), Category("SunnyUI")] public UIStyle Style { get => _style; set => SetStyle(value); } /// /// 自定义主题风格 /// [DefaultValue(false)] [Description("获取或设置可以自定义主题风格"), Category("SunnyUI")] public bool StyleCustomMode { get; set; } public event EventHandler Initialize; public event EventHandler Finalize; 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; } internal event OnUIPageChanged PageSelected; public virtual void Init() { Initialize?.Invoke(this, new EventArgs()); PageSelected?.Invoke(this, new UIPageEventArgs(this)); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); Init(); } private bool IsShown; protected override void OnShown(EventArgs e) { base.OnShown(e); if (AutoScaleMode == AutoScaleMode.Font) AutoScaleMode = AutoScaleMode.None; IsShown = true; } public void ReLoad() { if (IsShown) { if (NeedReload) OnLoad(EventArgs.Empty); else Init(); } } /// /// 字体颜色 /// [Description("页面切换是否需要重载Load"), Category("SunnyUI")] [DefaultValue(false)] public bool NeedReload { get; set; } public virtual void Final() { Finalize?.Invoke(this, new EventArgs()); foreach (var item in this.GetControls(true)) { item.HideFilterForm(); } } public void SetStyle(UIStyle style) { this.SuspendLayout(); UIStyleHelper.SetChildUIStyle(this, style); if (!style.IsCustom()) { SetStyleColor(style.Colors()); Invalidate(); } _style = style; UIStyleChanged?.Invoke(this, new EventArgs()); this.ResumeLayout(); } public event EventHandler UIStyleChanged; public virtual void SetStyleColor(UIBaseStyle uiColor) { BackColor = uiColor.PageBackColor; _rectColor = uiColor.PageRectColor; ForeColor = uiColor.PageForeColor; titleFillColor = uiColor.PageTitleFillColor; titleForeColor = uiColor.PageTitleForeColor; } 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); if (Width <= 0 || Height <= 0) return; if (AllowShowTitle) { e.Graphics.FillRectangle(TitleFillColor, 0, 0, Width, TitleHeight); } 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) { 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) { 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); /// /// 填充颜色,当值为背景色或透明色或空值则不填充 /// [Description("标题颜色"), Category("SunnyUI")] [DefaultValue(typeof(Color), "76, 76, 76")] public Color TitleFillColor { get => titleFillColor; set { titleFillColor = value; Invalidate(); } } private Color titleForeColor = Color.White; /// /// 字体颜色 /// [Description("字体颜色"), Category("SunnyUI")] [DefaultValue(typeof(Color), "White")] public Color TitleForeColor { get => titleForeColor; set { titleForeColor = value; Invalidate(); } } /// /// 标题字体 /// private Font titleFont = UIFontColor.Font(); /// /// 标题字体 /// [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(); } } 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, 19); Padding = new Padding(Padding.Left, ShowTitle ? Math.Max(titleHeight, Padding.Top) : 0, 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) { 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, Math.Max(titleHeight, Padding.Top), Padding.Right, Padding.Bottom); } } [Description("允许显示标题栏"), Category("SunnyUI"), DefaultValue(false)] public bool AllowShowTitle { get => ShowTitle; set => ShowTitle = value; } /// /// 是否显示窗体的标题栏 /// private bool showTitle; /// /// 是否显示窗体的标题栏 /// [Description("是否显示窗体的标题栏"), Category("WindowStyle"), DefaultValue(false)] public bool ShowTitle { get => showTitle; set { showTitle = value; Padding = new Padding(Padding.Left, value ? Math.Max(titleHeight, Padding.Top) : 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; /// /// 是否显示窗体的控制按钮 /// private bool controlBox; /// /// 是否显示窗体的控制按钮 /// [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; } internal event OnReceiveParams OnFrameDealPageParams; public bool SendParamToFrame(object value) { var args = new UIPageParamsArgs(this, null, value); OnFrameDealPageParams?.Invoke(this, args); return args.Handled; } public bool SendParamToPage(int pageIndex, object value) { UIPage page = Frame.GetPage(pageIndex); if (page == null) { throw new NullReferenceException("未能查找到页面的索引为: " + pageIndex); } var args = new UIPageParamsArgs(this, page, value); OnFrameDealPageParams?.Invoke(this, args); return args.Handled; } public bool SendParamToPage(Guid pageGuid, object value) { UIPage page = Frame.GetPage(pageGuid); if (page == null) { throw new NullReferenceException("未能查找到页面的索引为: " + pageGuid); } var args = new UIPageParamsArgs(this, page, value); OnFrameDealPageParams?.Invoke(this, args); return args.Handled; } internal void DealReceiveParams(UIPageParamsArgs e) { ReceiveParams?.Invoke(this, e); } public event OnReceiveParams ReceiveParams; #region 一些辅助窗口 /// /// 显示进度提示窗 /// /// 描述文字 /// 最大进度值 /// 显示进度条小数个数 public void ShowStatusForm(int maximum = 100, string desc = "系统正在处理中,请稍候...", int decimalCount = 1) { UIStatusFormService.ShowStatusForm(maximum, desc, decimalCount); } /// /// 隐藏进度提示窗 /// public void HideStatusForm() { UIStatusFormService.HideStatusForm(); } /// /// 设置进度提示窗步进值加1 /// public void StatusFormStepIt() { UIStatusFormService.StepIt(); } /// /// 设置进度提示窗描述文字 /// /// 描述文字 public void SetStatusFormDescription(string desc) { UIStatusFormService.SetDescription(desc); } /// /// 显示等待提示窗 /// /// 描述文字 public void ShowWaitForm(string desc = "系统正在处理中,请稍候...") { UIWaitFormService.ShowWaitForm(desc); } /// /// 隐藏等待提示窗 /// public void HideWaitForm() { UIWaitFormService.HideWaitForm(); } /// /// 设置等待提示窗描述文字 /// /// 描述文字 public void SetWaitFormDescription(string desc) { UIWaitFormService.SetDescription(desc); } /// /// 正确信息提示框 /// /// 信息 /// 显示遮罩层 public void ShowSuccessDialog(string msg, bool showMask = false) { UIMessageDialog.ShowMessageDialog(msg, UILocalize.SuccessTitle, false, UIStyle.Green, showMask, Frame?.TopMost ?? false); } /// /// 信息提示框 /// /// 信息 /// 显示遮罩层 public void ShowInfoDialog(string msg, bool showMask = false) { UIMessageDialog.ShowMessageDialog(msg, UILocalize.InfoTitle, false, UIStyle.Gray, showMask, Frame?.TopMost ?? false); } /// /// 警告信息提示框 /// /// 信息 /// 显示遮罩层 public void ShowWarningDialog(string msg, bool showMask = false) { UIMessageDialog.ShowMessageDialog(msg, UILocalize.WarningTitle, false, UIStyle.Orange, showMask, Frame?.TopMost ?? false); } /// /// 错误信息提示框 /// /// 信息 /// 显示遮罩层 public void ShowErrorDialog(string msg, bool showMask = false) { UIMessageDialog.ShowMessageDialog(msg, UILocalize.ErrorTitle, false, UIStyle.Red, showMask, Frame?.TopMost ?? false); } /// /// 确认信息提示框 /// /// 信息 /// 显示遮罩层 /// 结果 public bool ShowAskDialog(string msg, bool showMask = false) { return UIMessageDialog.ShowMessageDialog(msg, UILocalize.AskTitle, true, UIStyle.Blue, showMask, Frame?.TopMost ?? false); } /// /// 正确信息提示框 /// /// 标题 /// 信息 /// 主题 /// 显示遮罩层 public void ShowSuccessDialog(string title, string msg, UIStyle style = UIStyle.Green, bool showMask = false) { UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask, Frame?.TopMost ?? false); } /// /// 信息提示框 /// /// 标题 /// 信息 /// 主题 /// 显示遮罩层 public void ShowInfoDialog(string title, string msg, UIStyle style = UIStyle.Gray, bool showMask = false) { UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask, Frame?.TopMost ?? false); } /// /// 警告信息提示框 /// /// 标题 /// 信息 /// 主题 /// 显示遮罩层 public void ShowWarningDialog(string title, string msg, UIStyle style = UIStyle.Orange, bool showMask = false) { UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask, Frame?.TopMost ?? false); } /// /// 错误信息提示框 /// /// 标题 /// 信息 /// 主题 /// 显示遮罩层 public void ShowErrorDialog(string title, string msg, UIStyle style = UIStyle.Red, bool showMask = false) { UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask, Frame?.TopMost ?? false); } /// /// 确认信息提示框 /// /// 标题 /// 信息 /// 主题 /// 显示遮罩层 /// 结果 public bool ShowAskDialog(string title, string msg, UIStyle style = UIStyle.Blue, bool showMask = false) { return UIMessageDialog.ShowMessageDialog(msg, title, true, style, showMask, Frame?.TopMost ?? false); } /// /// 显示消息 /// /// 消息文本 /// 消息停留时长(ms)。默认1秒 /// 是否漂浮 public void ShowInfoTip(string text, int delay = 1000, bool floating = true) => UIMessageTip.Show(text, null, delay, floating); /// /// 显示成功消息 /// /// 消息文本 /// 消息停留时长(ms)。默认1秒 /// 是否漂浮 public void ShowSuccessTip(string text, int delay = 1000, bool floating = true) => UIMessageTip.ShowOk(text, delay, floating); /// /// 显示警告消息 /// /// 消息文本 /// 消息停留时长(ms)。默认1秒 /// 是否漂浮 public void ShowWarningTip(string text, int delay = 1000, bool floating = true) => UIMessageTip.ShowWarning(text, delay, floating); /// /// 显示出错消息 /// /// 消息文本 /// 消息停留时长(ms)。默认1秒 /// 是否漂浮 public void ShowErrorTip(string text, int delay = 1000, bool floating = true) => UIMessageTip.ShowError(text, delay, floating); /// /// 在指定控件附近显示消息 /// /// 控件或工具栏项 /// 消息文本 /// 消息停留时长(ms)。默认1秒 /// 是否漂浮 public void ShowInfoTip(Component controlOrItem, string text, int delay = 1000, bool floating = true) => UIMessageTip.Show(controlOrItem, text, null, delay, floating); /// /// 在指定控件附近显示良好消息 /// /// 控件或工具栏项 /// 消息文本 /// 消息停留时长(ms)。默认1秒 /// 是否漂浮 public void ShowSuccessTip(Component controlOrItem, string text, int delay = 1000, bool floating = true) => UIMessageTip.ShowOk(controlOrItem, text, delay, floating); /// /// 在指定控件附近显示出错消息 /// /// 控件或工具栏项 /// 消息文本 /// 消息停留时长(ms)。默认1秒 /// 是否漂浮 public void ShowErrorTip(Component controlOrItem, string text, int delay = 1000, bool floating = true) => UIMessageTip.ShowError(controlOrItem, text, delay, floating); /// /// 在指定控件附近显示警告消息 /// /// 控件或工具栏项 /// 消息文本 /// 消息停留时长(ms)。默认1秒 /// 是否漂浮 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) { UINotifierHelper.ShowNotifier(desc, UINotifierType.INFO, UILocalize.InfoTitle, isDialog, timeout); } public void ShowSuccessNotifier(string desc, bool isDialog = false, int timeout = 2000) { UINotifierHelper.ShowNotifier(desc, UINotifierType.OK, UILocalize.SuccessTitle, isDialog, timeout); } public void ShowWarningNotifier(string desc, bool isDialog = false, int timeout = 2000) { UINotifierHelper.ShowNotifier(desc, UINotifierType.WARNING, UILocalize.WarningTitle, isDialog, timeout); } public void ShowErrorNotifier(string desc, bool isDialog = false, int timeout = 2000) { 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); } #endregion 一些辅助窗口 } }