diff --git a/Bin/SunnyUI.Demo.exe b/Bin/SunnyUI.Demo.exe
index 83285803..b35afb7b 100644
Binary files a/Bin/SunnyUI.Demo.exe and b/Bin/SunnyUI.Demo.exe differ
diff --git a/Bin/SunnyUI.dll b/Bin/SunnyUI.dll
index 386cd104..50f49da1 100644
Binary files a/Bin/SunnyUI.dll and b/Bin/SunnyUI.dll differ
diff --git a/SunnyUI.Demo/Forms/FDialogs.cs b/SunnyUI.Demo/Forms/FDialogs.cs
index 4b38275b..764771e6 100644
--- a/SunnyUI.Demo/Forms/FDialogs.cs
+++ b/SunnyUI.Demo/Forms/FDialogs.cs
@@ -13,34 +13,34 @@ namespace Sunny.UI.Demo
private void btnAsk_Click(object sender, EventArgs e)
{
- if (this.ShowAskDialog("确认信息提示框"))
+ if (ShowAskDialog("确认信息提示框"))
{
- this.ShowSuccessTip("您点击了确定按钮");
+ ShowSuccessTip("您点击了确定按钮");
}
else
{
- this.ShowErrorTip("您点击了取消按钮");
+ ShowErrorTip("您点击了取消按钮");
}
}
private void btnAuto_Click(object sender, EventArgs e)
{
- this.ShowInfoDialog("跟随界面主题风格信息提示框", Style);
+ UIMessageDialog.ShowMessageDialog("跟随界面主题风格信息提示框", UILocalize.InfoTitle, false, Style);
}
private void btnSuccess_Click(object sender, EventArgs e)
{
- this.ShowSuccessDialog("正确信息提示框");
+ ShowSuccessDialog("正确信息提示框");
}
private void btnWarn_Click(object sender, EventArgs e)
{
- this.ShowWarningDialog("警告信息提示框");
+ ShowWarningDialog("警告信息提示框");
}
private void btnError_Click(object sender, EventArgs e)
{
- this.ShowErrorDialog("错误信息提示框");
+ ShowErrorDialog("错误信息提示框");
}
private void btnStatus2_Click(object sender, EventArgs e)
@@ -58,8 +58,7 @@ namespace Sunny.UI.Demo
private void btnInfo_Click(object sender, EventArgs e)
{
- this.ShowInfoDialog("默认信息提示框");
- UIMessageDialog.ShowMessageDialog("默认信息提示框", "提示", false, UIStyle.Blue, true);
+ ShowInfoDialog("默认信息提示框");
}
private void btnStringInput_Click(object sender, EventArgs e)
@@ -67,7 +66,7 @@ namespace Sunny.UI.Demo
string value = "请输入字符串";
if (this.InputStringDialog(ref value))
{
- this.ShowInfoDialog(value);
+ ShowInfoDialog(value);
}
}
@@ -76,7 +75,7 @@ namespace Sunny.UI.Demo
int value = 0;
if (this.InputIntegerDialog(ref value))
{
- this.ShowInfoDialog(value.ToString());
+ ShowInfoDialog(value.ToString());
}
}
@@ -85,7 +84,7 @@ namespace Sunny.UI.Demo
double value = 0;
if (this.InputDoubleDialog(ref value))
{
- this.ShowInfoDialog(value.ToString("F2"));
+ ShowInfoDialog(value.ToString("F2"));
}
}
@@ -94,7 +93,7 @@ namespace Sunny.UI.Demo
string value = "";
if (this.InputPasswordDialog(ref value))
{
- this.ShowInfoDialog(value);
+ ShowInfoDialog(value);
}
}
@@ -104,28 +103,28 @@ namespace Sunny.UI.Demo
int index = 2;
if (this.ShowSelectDialog(ref index, items))
{
- this.ShowInfoDialog(index.ToString());
+ ShowInfoDialog(index.ToString());
}
}
private void uiSymbolButton2_Click(object sender, EventArgs e)
{
- this.ShowInfoNotifier("Info");
+ ShowInfoNotifier("Info");
}
private void uiSymbolButton6_Click(object sender, EventArgs e)
{
- this.ShowSuccessNotifier("Success");
+ ShowSuccessNotifier("Success");
}
private void uiSymbolButton5_Click(object sender, EventArgs e)
{
- this.ShowWarningNotifier("Warning");
+ ShowWarningNotifier("Warning");
}
private void uiSymbolButton4_Click(object sender, EventArgs e)
{
- this.ShowErrorNotifier("Error");
+ ShowErrorNotifier("Error");
}
private void btnCH_Click(object sender, EventArgs e)
@@ -140,17 +139,17 @@ namespace Sunny.UI.Demo
private void uiSymbolButton9_Click(object sender, EventArgs e)
{
- UIMessageTip.ShowOk("轻便消息提示框 - 成功");
+ ShowSuccessTip("轻便消息提示框 - 成功");
}
private void uiSymbolButton8_Click(object sender, EventArgs e)
{
- UIMessageTip.ShowWarning("轻便消息提示框 - 警告", 1000, true);
+ ShowWarningTip("轻便消息提示框 - 警告");
}
private void uiSymbolButton7_Click(object sender, EventArgs e)
{
- UIMessageTip.ShowError("轻便消息提示框 - 错误");
+ ShowErrorTip("轻便消息提示框 - 错误");
}
private void uiSymbolButton10_Click(object sender, EventArgs e)
diff --git a/SunnyUI/Controls/DropItem/UIDropControl.cs b/SunnyUI/Controls/DropItem/UIDropControl.cs
index ca1fceee..a9bd1cf1 100644
--- a/SunnyUI/Controls/DropItem/UIDropControl.cs
+++ b/SunnyUI/Controls/DropItem/UIDropControl.cs
@@ -25,7 +25,6 @@ using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
-using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Sunny.UI
@@ -386,8 +385,7 @@ namespace Sunny.UI
{
private string watermark;
- [DllImport("user32.dll", CharSet = CharSet.Auto)]
- private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, string lParam);
+
[DefaultValue(null)]
public string Watermark
@@ -396,7 +394,7 @@ namespace Sunny.UI
set
{
watermark = value;
- SendMessage(Handle, 0x1501, (int)IntPtr.Zero, value);
+ Win32.User.SendMessage(Handle, 0x1501, (int)IntPtr.Zero, value);
}
}
}
diff --git a/SunnyUI/Controls/UIEdit.cs b/SunnyUI/Controls/UIEdit.cs
index 9d8c1438..175c30af 100644
--- a/SunnyUI/Controls/UIEdit.cs
+++ b/SunnyUI/Controls/UIEdit.cs
@@ -21,7 +21,6 @@
using System;
using System.ComponentModel;
-using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Sunny.UI
@@ -57,13 +56,10 @@ namespace Sunny.UI
set
{
watermark = value;
- SendMessage(Handle, 0x1501, (int)IntPtr.Zero, value);
+ Win32.User.SendMessage(Handle, 0x1501, (int)IntPtr.Zero, value);
}
}
- [DllImport("user32.dll", CharSet = CharSet.Auto)]
- private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, string lParam);
-
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyData == Keys.Enter || e.KeyData == Keys.Down)
diff --git a/SunnyUI/Controls/UINavMenu.cs b/SunnyUI/Controls/UINavMenu.cs
index 55903812..4776c318 100644
--- a/SunnyUI/Controls/UINavMenu.cs
+++ b/SunnyUI/Controls/UINavMenu.cs
@@ -24,7 +24,6 @@ using System;
using System.Collections.Concurrent;
using System.ComponentModel;
using System.Drawing;
-using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Sunny.UI
@@ -157,8 +156,7 @@ namespace Sunny.UI
///
const int TVM_SETEXTENDEDSTYLE = 0x112C;
const int TVS_EX_DOUBLEBUFFER = 0x0004;
- [DllImport("user32.dll", CharSet = CharSet.Auto)]
- private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
+
private void UpdateExtendedStyles()
{
int Style = 0;
@@ -167,7 +165,7 @@ namespace Sunny.UI
Style |= TVS_EX_DOUBLEBUFFER;
if (Style != 0)
- SendMessage(Handle, TVM_SETEXTENDEDSTYLE, new IntPtr(TVS_EX_DOUBLEBUFFER), new IntPtr(Style));
+ Win32.User.SendMessage(Handle, TVM_SETEXTENDEDSTYLE, new IntPtr(TVS_EX_DOUBLEBUFFER), new IntPtr(Style));
}
protected override void OnHandleCreated(EventArgs e)
diff --git a/SunnyUI/Controls/UITabControl.cs b/SunnyUI/Controls/UITabControl.cs
index af312351..029ef3dc 100644
--- a/SunnyUI/Controls/UITabControl.cs
+++ b/SunnyUI/Controls/UITabControl.cs
@@ -21,6 +21,7 @@
* 2020-08-12: V2.2.7 标题垂直居中
******************************************************************************/
+using Sunny.UI.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -741,11 +742,11 @@ namespace Sunny.UI
{
if (SystemInformation.MouseButtonsSwapped)
{
- return (NativeMethods.GetKeyState(NativeMethods.VK_RBUTTON) < 0);
+ return (Win32.User.GetKeyState(Win32.User.VK_RBUTTON) < 0);
}
else
{
- return (NativeMethods.GetKeyState(NativeMethods.VK_LBUTTON) < 0);
+ return (Win32.User.GetKeyState(Win32.User.VK_LBUTTON) < 0);
}
}
@@ -779,11 +780,11 @@ namespace Sunny.UI
clipRect = new Rectangle(UpDownButtonLocation, UpDownButtonSize);
NativeMethods.MoveWindow(Handle, UpDownButtonLocation.X, UpDownButtonLocation.Y, clipRect.Width, clipRect.Height);
- NativeMethods.PAINTSTRUCT ps = new NativeMethods.PAINTSTRUCT();
+ PAINTSTRUCT ps = new PAINTSTRUCT();
_bPainting = true;
- NativeMethods.BeginPaint(m.HWnd, ref ps);
+ Win32.User.BeginPaint(m.HWnd, ref ps);
DrawUpDownButton();
- NativeMethods.EndPaint(m.HWnd, ref ps);
+ Win32.User.EndPaint(m.HWnd, ref ps);
_bPainting = false;
m.Result = NativeMethods.TRUE;
}
@@ -814,27 +815,8 @@ namespace Sunny.UI
{
public const int WM_PAINT = 0xF;
- public const int VK_LBUTTON = 0x1;
- public const int VK_RBUTTON = 0x2;
public static readonly IntPtr TRUE = new IntPtr(1);
- [StructLayout(LayoutKind.Sequential)]
- public struct PAINTSTRUCT
- {
- internal IntPtr hdc;
- internal int fErase;
- internal RECT rcPaint;
- internal int fRestore;
- internal int fIncUpdate;
- internal int Reserved1;
- internal int Reserved2;
- internal int Reserved3;
- internal int Reserved4;
- internal int Reserved5;
- internal int Reserved6;
- internal int Reserved7;
- internal int Reserved8;
- }
[StructLayout(LayoutKind.Sequential)]
public struct RECT
@@ -860,16 +842,6 @@ namespace Sunny.UI
string lpszClass,
string lpszWindow);
- [DllImport("user32.dll")]
- public static extern IntPtr BeginPaint(IntPtr hWnd, ref PAINTSTRUCT ps);
-
- [DllImport("user32.dll")]
- [return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool EndPaint(IntPtr hWnd, ref PAINTSTRUCT ps);
-
- [DllImport("user32.dll")]
- public static extern short GetKeyState(int nVirtKey);
-
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetCursorPos(ref Point lpPoint);
diff --git a/SunnyUI/Forms/UIForm.cs b/SunnyUI/Forms/UIForm.cs
index adc96b61..987a413b 100644
--- a/SunnyUI/Forms/UIForm.cs
+++ b/SunnyUI/Forms/UIForm.cs
@@ -28,7 +28,6 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
-using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Sunny.UI
@@ -76,67 +75,6 @@ namespace Sunny.UI
SetStyle(UIStyles.Style);
}
- ///
- /// 显示进度提示窗
- ///
- /// 描述文字
- /// 最大进度值
- public void ShowStatusForm(int maximum = 100, string desc = "系统正在处理中,请稍候...")
- {
- UIStatusFormService.ShowStatusForm(maximum, desc);
- }
-
- ///
- /// 隐藏进度提示窗
- ///
- 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);
- }
-
protected override void OnBackColorChanged(EventArgs e)
{
base.OnBackColorChanged(e);
@@ -415,30 +353,6 @@ namespace Sunny.UI
}
}
- [DllImport("gdi32.dll")]
- public static extern int CreateRoundRectRgn(int x1, int y1, int x2, int y2, int x3, int y3);
-
- [DllImport("user32.dll")]
- public static extern int SetWindowRgn(IntPtr wnd, int hRgn, Boolean bRedraw);
-
- [DllImport("gdi32.dll", EntryPoint = "DeleteObject", CharSet = CharSet.Ansi)]
- public static extern int DeleteObject(int hObject);
-
- ///
- /// 设置窗体的圆角矩形
- ///
- /// 需要设置的窗体
- /// 圆角矩形的半径
- public static void SetFormRoundRectRegion(Form form, int rgnRadius)
- {
- if (form != null && form.FormBorderStyle == FormBorderStyle.None)
- {
- int region = CreateRoundRectRgn(0, 0, form.Width + 1, form.Height + 1, rgnRadius, rgnRadius);
- SetWindowRgn(form.Handle, region, true);
- DeleteObject(region);
- }
- }
-
protected bool IsDesignMode
{
get
@@ -542,7 +456,7 @@ namespace Sunny.UI
Height = ShowFullScreen ? screen.Bounds.Height : screen.WorkingArea.Height;
Left = screen.Bounds.Left;
Top = screen.Bounds.Top;
- SetFormRoundRectRegion(this, 0);
+ GDIEx.SetFormRoundRectRegion(this, 0);
WindowState = FormWindowState.Maximized;
}
else if (WindowState == FormWindowState.Maximized)
@@ -558,7 +472,7 @@ namespace Sunny.UI
if (location.X == 0 && location.Y == 0) location = center;
Location = location;
- SetFormRoundRectRegion(this, ShowRadius ? 5 : 0);
+ GDIEx.SetFormRoundRectRegion(this, ShowRadius ? 5 : 0);
WindowState = FormWindowState.Normal;
}
@@ -1094,33 +1008,14 @@ namespace Sunny.UI
}
}
- [DllImport("dwmapi.dll")]
- private static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);
-
- [DllImport("dwmapi.dll")]
- private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
-
- [DllImport("dwmapi.dll")]
- private static extern int DwmIsCompositionEnabled(ref int pfEnabled);
-
private bool m_aeroEnabled;
- private const int CS_DROPSHADOW = 0x00020000;
- private const int WM_NCPAINT = 0x0085;
-
- private struct MARGINS
- {
- public int leftWidth;
- public int rightWidth;
- public int topHeight;
- public int bottomHeight;
- }
private bool CheckAeroEnabled()
{
if (Environment.OSVersion.Version.Major >= 6)
{
int enabled = 0;
- DwmIsCompositionEnabled(ref enabled);
+ Win32.Dwm.DwmIsCompositionEnabled(ref enabled);
return enabled == 1;
}
@@ -1200,19 +1095,13 @@ namespace Sunny.UI
return base.ProcessCmdKey(ref msg, keyData); //其他键按默认处理
}
- [DllImport("user32.dll")]
- private static extern bool ReleaseCapture();
-
- [DllImport("user32.dll")]
- private static extern bool SendMessage(IntPtr handle, int wMsg, int wParam, int lParam);
-
///
/// 通过Windows的API控制窗体的拖动
///
public static void MousePressMove(IntPtr handle)
{
- ReleaseCapture();
- SendMessage(handle, 0x0112, 0xF010 + 0x0002, 0);
+ Win32.User.ReleaseCapture();
+ Win32.User.SendMessage(handle, Win32.User.WM_SYSCOMMAND, Win32.User.SC_MOVE + Win32.User.HTCAPTION, 0);
}
///
@@ -1264,11 +1153,11 @@ namespace Sunny.UI
if (WindowState == FormWindowState.Maximized)
{
- SetFormRoundRectRegion(this, 0);
+ GDIEx.SetFormRoundRectRegion(this, 0);
}
else
{
- SetFormRoundRectRegion(this, ShowRadius ? 5 : 0);
+ GDIEx.SetFormRoundRectRegion(this, ShowRadius ? 5 : 0);
}
Invalidate();
@@ -1309,16 +1198,14 @@ namespace Sunny.UI
CreateParams cp = base.CreateParams;
if (!m_aeroEnabled)
{
- cp.ClassStyle |= CS_DROPSHADOW;
+ cp.ClassStyle |= Win32.User.CS_DROPSHADOW;
}
- //---
if (FormBorderStyle == FormBorderStyle.None)
{
// 当边框样式为FormBorderStyle.None时
// 点击窗体任务栏图标,可以进行最小化
- const int WS_MINIMIZEBOX = 0x00020000;
- cp.Style = cp.Style | WS_MINIMIZEBOX;
+ cp.Style = cp.Style | Win32.User.WS_MINIMIZEBOX;
return cp;
}
@@ -1351,20 +1238,11 @@ namespace Sunny.UI
#region 拉拽调整窗体大小
- private const int WM_LEFT = 10;
- private const int WM_RIGHT = 11;
- private const int WM_TOP = 12;
- private const int WM_TOPLEFT = 13;
- private const int WM_TOPRIGHT = 14;
- private const int WM_BOTTOM = 15;
- private const int WM_BOTTOMLEFT = 0x10;
- private const int WM_BOTTOMRIGHT = 17;
-
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
- if (m.Msg == 0x0084 && ShowDragStretch && WindowState == FormWindowState.Normal)
+ if (m.Msg == Win32.User.WM_NCHITTEST && ShowDragStretch && WindowState == FormWindowState.Normal)
{
Point vPoint = new Point((int)m.LParam & 0xFFFF, (int)m.LParam >> 16 & 0xFFFF);
vPoint = PointToClient(vPoint);
@@ -1372,34 +1250,34 @@ namespace Sunny.UI
if (vPoint.X <= dragSize)
{
if (vPoint.Y <= dragSize)
- m.Result = (IntPtr)WM_TOPLEFT;
+ m.Result = (IntPtr)Win32.User.HTTOPLEFT;
else if (vPoint.Y >= ClientSize.Height - dragSize)
- m.Result = (IntPtr)WM_BOTTOMLEFT;
- else m.Result = (IntPtr)WM_LEFT;
+ m.Result = (IntPtr)Win32.User.HTBOTTOMLEFT;
+ else m.Result = (IntPtr)Win32.User.HTLEFT;
}
else if (vPoint.X >= ClientSize.Width - dragSize)
{
if (vPoint.Y <= dragSize)
- m.Result = (IntPtr)WM_TOPRIGHT;
+ m.Result = (IntPtr)Win32.User.HTTOPRIGHT;
else if (vPoint.Y >= ClientSize.Height - dragSize)
- m.Result = (IntPtr)WM_BOTTOMRIGHT;
- else m.Result = (IntPtr)WM_RIGHT;
+ m.Result = (IntPtr)Win32.User.HTBOTTOMRIGHT;
+ else m.Result = (IntPtr)Win32.User.HTRIGHT;
}
else if (vPoint.Y <= dragSize)
{
- m.Result = (IntPtr)WM_TOP;
+ m.Result = (IntPtr)Win32.User.HTTOP;
}
else if (vPoint.Y >= ClientSize.Height - dragSize)
{
- m.Result = (IntPtr)WM_BOTTOM;
+ m.Result = (IntPtr)Win32.User.HTBOTTOM;
}
}
- if (m.Msg == WM_NCPAINT && ShowShadow && m_aeroEnabled)
+ if (m.Msg == Win32.User.WM_NCPAINT && ShowShadow && m_aeroEnabled)
{
var v = 2;
- DwmSetWindowAttribute(Handle, 2, ref v, 4);
- MARGINS margins = new MARGINS()
+ Win32.Dwm.DwmSetWindowAttribute(Handle, 2, ref v, 4);
+ Win32.Dwm.MARGINS margins = new Win32.Dwm.MARGINS()
{
bottomHeight = 0,
leftWidth = 0,
@@ -1407,10 +1285,282 @@ namespace Sunny.UI
topHeight = 1
};
- DwmExtendFrameIntoClientArea(Handle, ref margins);
+ Win32.Dwm.DwmExtendFrameIntoClientArea(Handle, ref margins);
}
}
#endregion 拉拽调整窗体大小
+
+ #region 一些辅助窗口
+ ///
+ /// 显示进度提示窗
+ ///
+ /// 描述文字
+ /// 最大进度值
+ public void ShowStatusForm(int maximum = 100, string desc = "系统正在处理中,请稍候...")
+ {
+ UIStatusFormService.ShowStatusForm(maximum, desc);
+ }
+
+ ///
+ /// 隐藏进度提示窗
+ ///
+ 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 = true)
+ {
+ UIMessageDialog.ShowMessageDialog(msg, UILocalize.SuccessTitle, false, UIStyle.Green, showMask);
+ }
+
+ ///
+ /// 信息提示框
+ ///
+ /// 信息
+ /// 显示遮罩层
+ public void ShowInfoDialog(string msg, bool showMask = true)
+ {
+ UIMessageDialog.ShowMessageDialog(msg, UILocalize.InfoTitle, false, UIStyle.Gray, showMask);
+ }
+
+ ///
+ /// 警告信息提示框
+ ///
+ /// 信息
+ /// 显示遮罩层
+ public void ShowWarningDialog(string msg, bool showMask = true)
+ {
+ UIMessageDialog.ShowMessageDialog(msg, UILocalize.WarningTitle, false, UIStyle.Orange, showMask);
+ }
+
+ ///
+ /// 错误信息提示框
+ ///
+ /// 信息
+ /// 显示遮罩层
+ public void ShowErrorDialog(string msg, bool showMask = true)
+ {
+ UIMessageDialog.ShowMessageDialog(msg, UILocalize.ErrorTitle, false, UIStyle.Red, showMask);
+ }
+
+ ///
+ /// 确认信息提示框
+ ///
+ /// 信息
+ /// 显示遮罩层
+ /// 结果
+ public bool ShowAskDialog(string msg, bool showMask = true)
+ {
+ return UIMessageDialog.ShowMessageDialog(msg, UILocalize.AskTitle, true, UIStyle.Blue, showMask);
+ }
+
+ ///
+ /// 正确信息提示框
+ ///
+ /// 标题
+ /// 信息
+ /// 主题
+ /// 显示遮罩层
+ public void ShowSuccessDialog(string title, string msg, UIStyle style = UIStyle.Green, bool showMask = true)
+ {
+ UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask);
+ }
+
+ ///
+ /// 信息提示框
+ ///
+ /// 标题
+ /// 信息
+ /// 主题
+ /// 显示遮罩层
+ public void ShowInfoDialog(string title, string msg, UIStyle style = UIStyle.Gray, bool showMask = true)
+ {
+ UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask);
+ }
+
+ ///
+ /// 警告信息提示框
+ ///
+ /// 标题
+ /// 信息
+ /// 主题
+ /// 显示遮罩层
+ public void ShowWarningDialog(string title, string msg, UIStyle style = UIStyle.Orange, bool showMask = true)
+ {
+ UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask);
+ }
+
+ ///
+ /// 错误信息提示框
+ ///
+ /// 标题
+ /// 信息
+ /// 主题
+ /// 显示遮罩层
+ public void ShowErrorDialog(string title, string msg, UIStyle style = UIStyle.Red, bool showMask = true)
+ {
+ UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask);
+ }
+
+ ///
+ /// 确认信息提示框
+ ///
+ /// 标题
+ /// 信息
+ /// 主题
+ /// 显示遮罩层
+ /// 结果
+ public bool ShowAskDialog(string title, string msg, UIStyle style = UIStyle.Blue, bool showMask = true)
+ {
+ return UIMessageDialog.ShowMessageDialog(msg, title, true, style, showMask);
+ }
+
+ ///
+ /// 显示消息
+ ///
+ /// 消息文本
+ /// 消息停留时长(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, false, timeout);
+ }
+
+ public void ShowSuccessNotifier(string desc, bool isDialog = false, int timeout = 2000)
+ {
+ UINotifierHelper.ShowNotifier(desc, UINotifierType.OK, UILocalize.SuccessTitle, false, timeout);
+ }
+
+ public void ShowWarningNotifier(string desc, bool isDialog = false, int timeout = 2000)
+ {
+ UINotifierHelper.ShowNotifier(desc, UINotifierType.WARNING, UILocalize.WarningTitle, false, timeout);
+ }
+
+ public void ShowErrorNotifier(string desc, bool isDialog = false, int timeout = 2000)
+ {
+ UINotifierHelper.ShowNotifier(desc, UINotifierType.ERROR, UILocalize.ErrorTitle, false, timeout);
+ }
+
+ #endregion
}
}
\ No newline at end of file
diff --git a/SunnyUI/Forms/UIFormHelper.cs b/SunnyUI/Forms/UIFormHelper.cs
index 112272ee..453e9539 100644
--- a/SunnyUI/Forms/UIFormHelper.cs
+++ b/SunnyUI/Forms/UIFormHelper.cs
@@ -21,7 +21,6 @@
******************************************************************************/
using System.Collections;
-using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
@@ -29,110 +28,6 @@ namespace Sunny.UI
{
public static class UIMessageDialog
{
- ///
- /// 正确信息提示框
- ///
- /// 窗体
- /// 信息
- /// 主题
- public static void ShowSuccessDialog(this Form form, string msg, UIStyle style = UIStyle.Green)
- {
- ShowMessageDialog(msg, UILocalize.SuccessTitle, false, style);
- }
-
- ///
- /// 信息提示框
- ///
- /// 窗体
- /// 信息
- /// 主题
- public static void ShowInfoDialog(this Form form, string msg, UIStyle style = UIStyle.Gray)
- {
- ShowMessageDialog(msg, UILocalize.InfoTitle, false, style);
- }
-
- ///
- /// 警告信息提示框
- ///
- /// 窗体
- /// 信息
- /// 主题
- public static void ShowWarningDialog(this Form form, string msg, UIStyle style = UIStyle.Orange)
- {
- ShowMessageDialog(msg, UILocalize.WarningTitle, false, style);
- }
-
- ///
- /// 错误信息提示框
- ///
- /// 窗体
- /// 信息
- /// 主题
- public static void ShowErrorDialog(this Form form, string msg, UIStyle style = UIStyle.Red)
- {
- ShowMessageDialog(msg, UILocalize.ErrorTitle, false, style);
- }
-
- ///
- /// 确认信息提示框
- ///
- /// 窗体
- /// 信息
- ///
- /// 结果
- public static bool ShowAskDialog(this Form form, string msg, UIStyle style = UIStyle.Blue)
- {
- return ShowMessageDialog(msg, UILocalize.AskTitle, true, style);
- }
-
- ///
- /// 正确信息提示框
- ///
- /// 窗体
- /// 标题
- /// 信息
- /// 主题
- public static void ShowSuccessDialog(this Form form, string title, string msg, UIStyle style = UIStyle.Green)
- {
- ShowMessageDialog(msg, title, false, style);
- }
-
- ///
- /// 信息提示框
- ///
- /// 窗体
- /// 标题
- /// 信息
- /// 主题
- public static void ShowInfoDialog(this Form form, string title, string msg, UIStyle style = UIStyle.Gray)
- {
- ShowMessageDialog(msg, title, false, style);
- }
-
- ///
- /// 警告信息提示框
- ///
- /// 窗体
- /// 标题
- /// 信息
- /// 主题
- public static void ShowWarningDialog(this Form form, string title, string msg, UIStyle style = UIStyle.Orange)
- {
- ShowMessageDialog(msg, title, false, style);
- }
-
- ///
- /// 错误信息提示框
- ///
- /// 窗体
- /// 标题
- /// 信息
- /// 主题
- public static void ShowErrorDialog(this Form form, string title, string msg, UIStyle style = UIStyle.Red)
- {
- ShowMessageDialog(msg, title, false, style);
- }
-
///
/// 确认信息提示框
///
@@ -144,19 +39,22 @@ namespace Sunny.UI
/// 结果
public static bool ShowMessageDialog(string message, string title, bool showCancelButton, UIStyle style, bool showMask = true)
{
- Form back = null;
+ Point pt = SystemEx.GetCursorPos();
+ Rectangle screen = Screen.GetBounds(pt);
+
+ Form mask = null;
if (showMask)
{
- int backBorder = 200;
- back = new Form(); // Create the fade background
- back.FormBorderStyle = FormBorderStyle.None;
- back.BackColor = Color.FromArgb(0, 0, 0);
- back.Opacity = 0.5;
- back.ShowInTaskbar = false;
- back.Location = new Point(-backBorder, -backBorder);
- back.Size = new Size(Screen.PrimaryScreen.WorkingArea.Width + backBorder, Screen.PrimaryScreen.WorkingArea.Height + backBorder);
- back.Show();
- back.TopMost = true;
+ mask = new Form();
+ mask.FormBorderStyle = FormBorderStyle.None;
+ mask.BackColor = Color.FromArgb(0, 0, 0);
+ mask.Opacity = 0.5;
+ mask.ShowInTaskbar = false;
+ mask.StartPosition = FormStartPosition.Manual;
+ mask.Bounds = screen;
+ mask.Show();
+ mask.TopMost = true;
+ Application.DoEvents();
}
UIMessageForm frm = new UIMessageForm();
@@ -168,46 +66,46 @@ namespace Sunny.UI
bool isOk = frm.IsOK;
frm.Dispose();
- back?.Close();
+ mask?.Close();
return isOk;
}
}
public static class UIMessageBox
{
- public static void Show(string text)
+ public static void Show(string text, bool showMask = true)
{
- Show(text, UILocalize.InfoTitle);
+ Show(text, UILocalize.InfoTitle, UIStyle.Blue, UIMessageBoxButtons.OK, showMask);
}
- public static void ShowInfo(string text)
+ public static void ShowInfo(string text, bool showMask = true)
{
- Show(text, UILocalize.InfoTitle, UIStyle.Gray);
+ Show(text, UILocalize.InfoTitle, UIStyle.Gray, UIMessageBoxButtons.OK, showMask);
}
- public static void ShowSuccess(string text)
+ public static void ShowSuccess(string text, bool showMask = true)
{
- Show(text, UILocalize.SuccessTitle, UIStyle.Green);
+ Show(text, UILocalize.SuccessTitle, UIStyle.Green, UIMessageBoxButtons.OK, showMask);
}
- public static void ShowWarning(string text)
+ public static void ShowWarning(string text, bool showMask = true)
{
- Show(text, UILocalize.WarningTitle, UIStyle.Orange);
+ Show(text, UILocalize.WarningTitle, UIStyle.Orange, UIMessageBoxButtons.OK, showMask);
}
- public static void ShowError(string text)
+ public static void ShowError(string text, bool showMask = true)
{
- Show(text, UILocalize.ErrorTitle, UIStyle.Red);
+ Show(text, UILocalize.ErrorTitle, UIStyle.Red, UIMessageBoxButtons.OK, showMask);
}
- public static bool ShowAsk(string text)
+ public static bool ShowAsk(string text, bool showMask = true)
{
- return Show(text, UILocalize.AskTitle, UIStyle.Blue, UIMessageBoxButtons.OKCancel);
+ return Show(text, UILocalize.AskTitle, UIStyle.Blue, UIMessageBoxButtons.OKCancel, showMask);
}
- public static bool Show(string text, string caption, UIStyle style = UIStyle.Blue, UIMessageBoxButtons buttons = UIMessageBoxButtons.OK, bool topMost = false)
+ public static bool Show(string text, string caption, UIStyle style = UIStyle.Blue, UIMessageBoxButtons buttons = UIMessageBoxButtons.OK, bool showMask = true)
{
- return UIMessageDialog.ShowMessageDialog(text, caption, buttons == UIMessageBoxButtons.OKCancel, style, topMost);
+ return UIMessageDialog.ShowMessageDialog(text, caption, buttons == UIMessageBoxButtons.OKCancel, style, showMask);
}
}
@@ -497,138 +395,9 @@ namespace Sunny.UI
public static class UINotifierHelper
{
- private static void ShowNotifier(string desc, UINotifierType type = UINotifierType.INFO, string title = "Notifier", bool isDialog = false, int timeout = 0, Form inApp = null)
+ public static void ShowNotifier(string desc, UINotifierType type = UINotifierType.INFO, string title = "Notifier", bool isDialog = false, int timeout = 0, Form inApp = null)
{
UINotifier.Show(desc, type, title, isDialog, timeout, inApp);
}
-
- public static void ShowInfoNotifier(this Form form, string desc, bool isDialog = false, int timeout = 2000)
- {
- ShowNotifier(desc, UINotifierType.INFO, UILocalize.InfoTitle, false, timeout);
- }
-
- public static void ShowSuccessNotifier(this Form form, string desc, bool isDialog = false, int timeout = 3000)
- {
- ShowNotifier(desc, UINotifierType.OK, UILocalize.SuccessTitle, false, timeout);
- }
-
- public static void ShowWarningNotifier(this Form form, string desc, bool isDialog = false, int timeout = 0)
- {
- ShowNotifier(desc, UINotifierType.WARNING, UILocalize.WarningTitle, false, timeout);
- }
-
- public static void ShowErrorNotifier(this Form form, string desc, bool isDialog = false, int timeout = 0)
- {
- ShowNotifier(desc, UINotifierType.ERROR, UILocalize.ErrorTitle, false, timeout);
- }
- }
-
- public static class UIMessageTipHelper
- {
- ///
- /// 显示消息
- ///
- /// 窗体
- /// 消息文本
- /// 消息样式。不指定则使用默认样式
- /// 消息停留时长(ms)。为负时使用全局时长
- /// 是否漂浮,不指定则使用全局设置
- /// 消息窗显示位置。不指定则智能判定,当由工具栏项(ToolStripItem)弹出时,请指定该参数或使用接收控件的重载
- /// 是否以point参数为中心进行呈现。为false则是在其附近呈现
- public static void ShowInfoTip(this Form form, string text, TipStyle style = null, int delay = -1, bool? floating = null,
- Point? point = null, bool centerByPoint = false)
- => UIMessageTip.Show(text, style, delay, floating, point, centerByPoint);
-
- ///
- /// 在指定控件附近显示消息
- ///
- /// 窗体
- /// 控件或工具栏项
- /// 消息文本
- /// 消息样式。不指定则使用默认样式
- /// 消息停留时长(ms)。为负时使用全局时长
- /// 是否漂浮,不指定则使用全局设置
- /// 是否在控件中央显示,不指定则自动判断
- public static void ShowInfoTip(this Form form, Component controlOrItem, string text, TipStyle style = null, int delay = -1,
- bool? floating = null, bool? centerInControl = null)
- => UIMessageTip.Show(controlOrItem, text, style, delay, floating, centerInControl);
-
- ///
- /// 在指定控件附近显示出错消息
- ///
- /// 窗体
- /// 控件或工具栏项
- /// 消息文本
- /// 消息停留时长(ms)。默认1秒,若要使用全局时长请设为-1
- /// 是否漂浮。默认不漂浮。若要使用全局设置请设为null
- /// 是否在控件中央显示,不指定则自动判断
- public static void ShowErrorTip(this Form form, Component controlOrItem, string text = null, int delay = 1000,
- bool? floating = null, bool? centerInControl = null)
- => UIMessageTip.ShowError(controlOrItem, text, delay, floating, centerInControl);
-
- ///
- /// 显示出错消息
- ///
- /// 窗体
- /// 消息文本
- /// 消息停留时长(ms)。默认1秒,若要使用全局时长请设为-1
- /// 是否漂浮。默认不漂浮。若要使用全局设置请设为null
- /// 消息窗显示位置。不指定则智能判定,当由工具栏项(ToolStripItem)弹出时,请指定该参数或使用接收控件的重载
- /// 是否以point参数为中心进行呈现。为false则是在其附近呈现
- public static void ShowErrorTip(this Form form, string text = null, int delay = 1000, bool? floating = null, Point? point = null,
- bool centerByPoint = false)
- => UIMessageTip.ShowError(text, delay, floating, point, centerByPoint);
-
- ///
- /// 在指定控件附近显示良好消息
- ///
- /// 窗体
- /// 控件或工具栏项
- /// 消息文本
- /// 消息停留时长(ms)。为负时使用全局时长
- /// 是否漂浮,不指定则使用全局设置
- /// 是否在控件中央显示,不指定则自动判断
- public static void ShowSuccessTip(this Form form, Component controlOrItem, string text = null, int delay = -1, bool? floating = null,
- bool? centerInControl = null)
- => UIMessageTip.ShowOk(controlOrItem, text, delay, floating, centerInControl);
-
- ///
- /// 显示良好消息
- ///
- /// 窗体
- /// 消息文本
- /// 消息停留时长(ms)。为负时使用全局时长
- /// 是否漂浮,不指定则使用全局设置
- /// 消息窗显示位置。不指定则智能判定,当由工具栏项(ToolStripItem)弹出时,请指定该参数或使用接收控件的重载
- /// 是否以point参数为中心进行呈现。为false则是在其附近呈现
- public static void ShowSuccessTip(this Form form, string text = null, int delay = -1, bool? floating = null, Point? point = null,
- bool centerByPoint = false)
- => UIMessageTip.ShowOk(text, delay, floating, point, centerByPoint);
-
- ///
- /// 在指定控件附近显示警告消息
- ///
- /// 窗体
- /// 控件或工具栏项
- /// 消息文本
- /// 消息停留时长(ms)。默认1秒,若要使用全局时长请设为-1
- /// 是否漂浮。默认不漂浮。若要使用全局设置请设为null
- /// 是否在控件中央显示,不指定则自动判断
- public static void ShowWarningTip(this Form form, Component controlOrItem, string text = null, int delay = 1000,
- bool? floating = null, bool? centerInControl = null)
- => UIMessageTip.ShowWarning(controlOrItem, text, delay, floating, centerInControl);
-
- ///
- /// 显示警告消息
- ///
- /// 窗体
- /// 消息文本
- /// 消息停留时长(ms)。默认1秒,若要使用全局时长请设为-1
- /// 是否漂浮。默认不漂浮。若要使用全局设置请设为null
- /// 消息窗显示位置。不指定则智能判定,当由工具栏项(ToolStripItem)弹出时,请指定该参数或使用接收控件的重载
- /// 是否以point参数为中心进行呈现。为false则是在其附近呈现
- public static void ShowWarningTip(this Form form, string text = null, int delay = 1000, bool? floating = null, Point? point = null,
- bool centerByPoint = false)
- => UIMessageTip.ShowWarning(text, delay, floating, point, centerByPoint);
}
}
\ No newline at end of file
diff --git a/SunnyUI/Pages/UIPage.cs b/SunnyUI/Pages/UIPage.cs
index 1275016b..4a53360d 100644
--- a/SunnyUI/Pages/UIPage.cs
+++ b/SunnyUI/Pages/UIPage.cs
@@ -184,67 +184,6 @@ namespace Sunny.UI
public event EventHandler Initialize;
- ///
- /// 显示进度提示窗
- ///
- /// 描述文字
- /// 最大进度值
- public void ShowStatusForm(int maximum = 100, string desc = "系统正在处理中,请稍候...")
- {
- UIStatusFormService.ShowStatusForm(maximum, desc);
- }
-
- ///
- /// 隐藏进度提示窗
- ///
- 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);
- }
-
protected override void OnControlAdded(ControlEventArgs e)
{
base.OnControlAdded(e);
@@ -350,14 +289,276 @@ namespace Sunny.UI
//SetStyle(UIStyles.Style);
}
- // protected override CreateParams CreateParams
- // {
- // get
- // {
- // CreateParams cp = base.CreateParams;
- // cp.ExStyle |= 0x02000000;
- // return cp;
- // }
- // }
+ #region 一些辅助窗口
+ ///
+ /// 显示进度提示窗
+ ///
+ /// 描述文字
+ /// 最大进度值
+ public void ShowStatusForm(int maximum = 100, string desc = "系统正在处理中,请稍候...")
+ {
+ UIStatusFormService.ShowStatusForm(maximum, desc);
+ }
+
+ ///
+ /// 隐藏进度提示窗
+ ///
+ 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 = true)
+ {
+ UIMessageDialog.ShowMessageDialog(msg, UILocalize.SuccessTitle, false, UIStyle.Green, showMask);
+ }
+
+ ///
+ /// 信息提示框
+ ///
+ /// 信息
+ /// 显示遮罩层
+ public void ShowInfoDialog(string msg, bool showMask = true)
+ {
+ UIMessageDialog.ShowMessageDialog(msg, UILocalize.InfoTitle, false, UIStyle.Gray, showMask);
+ }
+
+ ///
+ /// 警告信息提示框
+ ///
+ /// 信息
+ /// 显示遮罩层
+ public void ShowWarningDialog(string msg, bool showMask = true)
+ {
+ UIMessageDialog.ShowMessageDialog(msg, UILocalize.WarningTitle, false, UIStyle.Orange, showMask);
+ }
+
+ ///
+ /// 错误信息提示框
+ ///
+ /// 信息
+ /// 显示遮罩层
+ public void ShowErrorDialog(string msg, bool showMask = true)
+ {
+ UIMessageDialog.ShowMessageDialog(msg, UILocalize.ErrorTitle, false, UIStyle.Red, showMask);
+ }
+
+ ///
+ /// 确认信息提示框
+ ///
+ /// 信息
+ /// 显示遮罩层
+ /// 结果
+ public bool ShowAskDialog(string msg, bool showMask = true)
+ {
+ return UIMessageDialog.ShowMessageDialog(msg, UILocalize.AskTitle, true, UIStyle.Blue, showMask);
+ }
+
+ ///
+ /// 正确信息提示框
+ ///
+ /// 标题
+ /// 信息
+ /// 主题
+ /// 显示遮罩层
+ public void ShowSuccessDialog(string title, string msg, UIStyle style = UIStyle.Green, bool showMask = true)
+ {
+ UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask);
+ }
+
+ ///
+ /// 信息提示框
+ ///
+ /// 标题
+ /// 信息
+ /// 主题
+ /// 显示遮罩层
+ public void ShowInfoDialog(string title, string msg, UIStyle style = UIStyle.Gray, bool showMask = true)
+ {
+ UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask);
+ }
+
+ ///
+ /// 警告信息提示框
+ ///
+ /// 标题
+ /// 信息
+ /// 主题
+ /// 显示遮罩层
+ public void ShowWarningDialog(string title, string msg, UIStyle style = UIStyle.Orange, bool showMask = true)
+ {
+ UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask);
+ }
+
+ ///
+ /// 错误信息提示框
+ ///
+ /// 标题
+ /// 信息
+ /// 主题
+ /// 显示遮罩层
+ public void ShowErrorDialog(string title, string msg, UIStyle style = UIStyle.Red, bool showMask = true)
+ {
+ UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask);
+ }
+
+ ///
+ /// 确认信息提示框
+ ///
+ /// 标题
+ /// 信息
+ /// 主题
+ /// 显示遮罩层
+ /// 结果
+ public bool ShowAskDialog(string title, string msg, UIStyle style = UIStyle.Blue, bool showMask = true)
+ {
+ return UIMessageDialog.ShowMessageDialog(msg, title, true, style, showMask);
+ }
+
+ ///
+ /// 显示消息
+ ///
+ /// 消息文本
+ /// 消息停留时长(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, false, timeout);
+ }
+
+ public void ShowSuccessNotifier(string desc, bool isDialog = false, int timeout = 2000)
+ {
+ UINotifierHelper.ShowNotifier(desc, UINotifierType.OK, UILocalize.SuccessTitle, false, timeout);
+ }
+
+ public void ShowWarningNotifier(string desc, bool isDialog = false, int timeout = 2000)
+ {
+ UINotifierHelper.ShowNotifier(desc, UINotifierType.WARNING, UILocalize.WarningTitle, false, timeout);
+ }
+
+ public void ShowErrorNotifier(string desc, bool isDialog = false, int timeout = 2000)
+ {
+ UINotifierHelper.ShowNotifier(desc, UINotifierType.ERROR, UILocalize.ErrorTitle, false, timeout);
+ }
+
+ #endregion
}
}
\ No newline at end of file
diff --git a/SunnyUI/Static/UControl.cs b/SunnyUI/Static/UControl.cs
index 93beb7c6..dc551fe0 100644
--- a/SunnyUI/Static/UControl.cs
+++ b/SunnyUI/Static/UControl.cs
@@ -27,7 +27,6 @@ using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Reflection;
-using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Sunny.UI
@@ -170,9 +169,6 @@ namespace Sunny.UI
objects[index] = value;
}
- [DllImport("user32.dll")]
- private static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
-
///
/// 修改控件或窗体的边框,例如 TextBox 或是 Form 窗体
///
@@ -186,7 +182,7 @@ namespace Sunny.UI
using (Pen pen = new Pen(color, width))
{
//得到当前的句柄
- IntPtr hDC = GetWindowDC(m.HWnd);
+ IntPtr hDC = (IntPtr)Win32.User.GetWindowDC(m.HWnd);
if (hDC.ToInt32() == 0)
{
return;
@@ -196,7 +192,7 @@ namespace Sunny.UI
g.SmoothingMode = SmoothingMode.AntiAlias;
g.DrawRectangle(pen, 0, 0, control.Width - width, control.Height - width);
//释放
- ReleaseDC(m.HWnd, hDC);
+ Win32.User.ReleaseDC(m.HWnd, hDC);
}
}
@@ -310,24 +306,6 @@ namespace Sunny.UI
return values;
}
- [DllImport("gdi32.dll")]
- private static extern IntPtr CreateCompatibleDC(IntPtr hdc);
-
- [DllImport("gdi32.dll")]
- private static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight);
-
- [DllImport("gdi32.dll")]
- private static extern IntPtr SelectObject(IntPtr hdc, IntPtr obj);
-
- [DllImport("gdi32.dll")]
- private static extern int DeleteDC(IntPtr hdc);
-
- [DllImport("user32.dll")]
- private static extern bool PrintWindow(IntPtr window, IntPtr hdcBlt, uint nFlags);
-
- [DllImport("user32.dll")]
- private static extern IntPtr GetWindowDC(IntPtr window);
-
///
/// 控件保存为图片
///
@@ -335,14 +313,14 @@ namespace Sunny.UI
///
public static Bitmap SaveToImage(this Control ctrl)
{
- IntPtr hdc = GetWindowDC(ctrl.Handle);
- IntPtr bitmap = CreateCompatibleBitmap(hdc, ctrl.Width, ctrl.Height);
- IntPtr compatibleDc = CreateCompatibleDC(hdc);
- SelectObject(compatibleDc, bitmap);
- PrintWindow(ctrl.Handle, compatibleDc, 0);
+ IntPtr hdc = (IntPtr)Win32.User.GetWindowDC(ctrl.Handle);
+ IntPtr bitmap = (IntPtr)Win32.GDI.CreateCompatibleBitmap(hdc, ctrl.Width, ctrl.Height);
+ IntPtr compatibleDc = (IntPtr)Win32.GDI.CreateCompatibleDC(hdc);
+ Win32.GDI.SelectObject(compatibleDc, bitmap);
+ Win32.GDI.PrintWindow(ctrl.Handle, compatibleDc, 0);
Bitmap bmp = Image.FromHbitmap(bitmap);
- DeleteDC(hdc); //删除用过的对象
- DeleteDC(compatibleDc); //删除用过的对象
+ Win32.GDI.DeleteDC(hdc); //删除用过的对象
+ Win32.GDI.DeleteDC(compatibleDc); //删除用过的对象
return bmp;
}
diff --git a/SunnyUI/Static/UGDI.cs b/SunnyUI/Static/UGDI.cs
index 2650a255..514b5d91 100644
--- a/SunnyUI/Static/UGDI.cs
+++ b/SunnyUI/Static/UGDI.cs
@@ -28,6 +28,31 @@ namespace Sunny.UI
{
public static class GDIEx
{
+ ///
+ /// 设置窗体的圆角矩形
+ ///
+ /// 需要设置的窗体
+ /// 圆角矩形的半径
+ public static void SetFormRoundRectRegion(Form form, int rgnRadius)
+ {
+ if (form != null && form.FormBorderStyle == FormBorderStyle.None)
+ {
+ int region = Win32.GDI.CreateRoundRectRgn(0, 0, form.Width + 1, form.Height + 1, rgnRadius, rgnRadius);
+ Win32.User.SetWindowRgn(form.Handle, region, true);
+ Win32.GDI.DeleteObject(region);
+ }
+ }
+
+ public static PointF Center(this Rectangle rect)
+ {
+ return new PointF(rect.Left + rect.Width / 2.0f, rect.Top + rect.Height / 2.0f);
+ }
+
+ public static PointF Center(this RectangleF rect)
+ {
+ return new PointF(rect.Left + rect.Width / 2.0f, rect.Top + rect.Height / 2.0f);
+ }
+
public static Color Alpha(this Color color, int alpha)
{
alpha = Math.Max(0, alpha);
diff --git a/SunnyUI/Static/USystem.cs b/SunnyUI/Static/USystem.cs
index 571012bc..99707612 100644
--- a/SunnyUI/Static/USystem.cs
+++ b/SunnyUI/Static/USystem.cs
@@ -36,6 +36,59 @@ namespace Sunny.UI
///
public static class SystemEx
{
+ ///
+ /// 获取程序当前窗口的大小和位置
+ ///
+ ///
+ public static Rectangle GetForegroundWindowBounds()
+ {
+ IntPtr awin = GetForegroundWindow(); //获取当前窗口句柄
+ RECT rect = new RECT();
+ GetWindowRect(awin, ref rect);
+ return new Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top);
+ }
+
+ [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
+ static extern IntPtr GetForegroundWindow();
+
+ [DllImport("user32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);
+
+ [StructLayout(LayoutKind.Sequential)]
+ struct RECT
+ {
+ public int Left; //最左坐标
+ public int Top; //最上坐标
+ public int Right; //最右坐标
+ public int Bottom; //最下坐标
+ }
+
+ ///
+ /// 获取鼠标位置
+ ///
+ ///
+ public static Point GetCursorPos()
+ {
+ GetCursorPos(out POINT pos);
+ return new Point(pos.X, pos.Y);
+ }
+
+ [DllImport("user32.dll")]
+ static extern bool GetCursorPos(out POINT lpPoint);
+
+ [StructLayout(LayoutKind.Sequential)]
+ struct POINT
+ {
+ public int X;
+ public int Y;
+ public POINT(int x, int y)
+ {
+ this.X = x;
+ this.Y = y;
+ }
+ }
+
public static void ConsoleWriteLine(this object obj, string preText = "")
{
if (preText != "")