diff --git a/SunnyUI/Controls/UITabControl.cs b/SunnyUI/Controls/UITabControl.cs index 95527694..fe5cfe3d 100644 --- a/SunnyUI/Controls/UITabControl.cs +++ b/SunnyUI/Controls/UITabControl.cs @@ -483,7 +483,6 @@ namespace Sunny.UI return; } - removeIndex.ConsoleWriteLine("removeIndex"); var menuItem = Helper[removeIndex]; bool showButton = menuItem == null || !menuItem.AlwaysOpen; if (showButton) diff --git a/SunnyUI/Forms/UIFormHelper.cs b/SunnyUI/Forms/UIFormHelper.cs index df71782b..df5f1161 100644 --- a/SunnyUI/Forms/UIFormHelper.cs +++ b/SunnyUI/Forms/UIFormHelper.cs @@ -528,4 +528,70 @@ namespace Sunny.UI UINotifier.Show(desc, type, title, isDialog, timeout, inApp); } } + + public static class FormEx + { + public static Form ShowFullMask(this Form form) + { + Point pt = SystemEx.GetCursorPos(); + Rectangle screen = Screen.GetBounds(pt); + + Form 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.TopMost = true; + mask.Show(); + return mask; + } + + public static Form ShowControlMask(this Control control) + { + bool topmost = false; + Form baseForm = control.RootForm(); + if (baseForm != null) + { + topmost = baseForm.TopMost; + baseForm.TopMost = true; + Application.DoEvents(); + } + + Form 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 = control.Bounds; + mask.Tag = baseForm; + mask.Text = topmost.ToString(); + + var pt = control.LocationOnScreen(); + mask.Left = pt.X; + mask.Top = pt.Y; + mask.Show(); + mask.TopMost = true; + return mask; + } + + public static void EndShow(this Form maskForm) + { + if (maskForm.Tag is Form form) + { + form.TopMost = maskForm.Text.ToBoolean(); + } + } + + public static void ShowInMask(this Form frm, Form maskForm) + { + frm.StartPosition = FormStartPosition.Manual; + frm.Left = maskForm.Left + (maskForm.Width - frm.Width) / 2; + frm.Top = maskForm.Top + (maskForm.Height - frm.Height) / 2; + frm.ShowInTaskbar = false; + frm.TopMost = true; + } + } } \ No newline at end of file diff --git a/SunnyUI/Static/UControl.cs b/SunnyUI/Static/UControl.cs index dc551fe0..7abe04e9 100644 --- a/SunnyUI/Static/UControl.cs +++ b/SunnyUI/Static/UControl.cs @@ -42,6 +42,30 @@ namespace Sunny.UI timer.Start(); } + public static Point LocationOnScreen(this Control ctrl) + { + Point point = new Point(0, 0); + do + { + point.Offset(ctrl.Location); + ctrl = ctrl.Parent; + } + while (ctrl != null); + + return point; + } + + public static Form RootForm(this Control ctrl) + { + if (ctrl == null) return null; + while (ctrl.Parent != null) + { + ctrl = ctrl.Parent; + } + + return ctrl as Form; + } + public static Form GetParentForm(this Control ctrl) { while (!IsForm(ctrl.Parent)) @@ -77,7 +101,7 @@ namespace Sunny.UI return (form.Height - form.ClientSize.Height) - form.BorderSize(); } - public static Point LocationOnClient(this Control c) + private static Point LocationOnClient(this Control c) { Point point = new Point(0, 0); for (; c.Parent != null; c = c.Parent) diff --git a/SunnyUI/Static/UEnum.cs b/SunnyUI/Static/UEnum.cs index f52ff0f0..2858a475 100644 --- a/SunnyUI/Static/UEnum.cs +++ b/SunnyUI/Static/UEnum.cs @@ -101,7 +101,7 @@ namespace Sunny.UI /// http://about.me/AlekseyNagovitsyn /// [AttributeUsage(AttributeTargets.Field | AttributeTargets.Enum)] - internal class DisplayTextAttribute : Attribute + public class DisplayTextAttribute : Attribute { /// /// The default value for the attribute DisplayTextAttribute, which is an empty string diff --git a/SunnyUI/Units/USuspendCtrlAltDel.cs b/SunnyUI/Units/USuspendCtrlAltDel.cs index 74a80078..480831c0 100644 --- a/SunnyUI/Units/USuspendCtrlAltDel.cs +++ b/SunnyUI/Units/USuspendCtrlAltDel.cs @@ -74,8 +74,8 @@ namespace Sunny.UI { Console.WriteLine("SeDebugPrivilege is now available"); } + CloseHandle(hToken); - Console.ReadLine(); } public static void Suspend()