* 增加几个函数
This commit is contained in:
parent
ae82b36d3f
commit
1f653fb053
@ -483,7 +483,6 @@ namespace Sunny.UI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeIndex.ConsoleWriteLine("removeIndex");
|
|
||||||
var menuItem = Helper[removeIndex];
|
var menuItem = Helper[removeIndex];
|
||||||
bool showButton = menuItem == null || !menuItem.AlwaysOpen;
|
bool showButton = menuItem == null || !menuItem.AlwaysOpen;
|
||||||
if (showButton)
|
if (showButton)
|
||||||
|
@ -528,4 +528,70 @@ namespace Sunny.UI
|
|||||||
UINotifier.Show(desc, type, title, isDialog, timeout, inApp);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -42,6 +42,30 @@ namespace Sunny.UI
|
|||||||
timer.Start();
|
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)
|
public static Form GetParentForm(this Control ctrl)
|
||||||
{
|
{
|
||||||
while (!IsForm(ctrl.Parent))
|
while (!IsForm(ctrl.Parent))
|
||||||
@ -77,7 +101,7 @@ namespace Sunny.UI
|
|||||||
return (form.Height - form.ClientSize.Height) - form.BorderSize();
|
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);
|
Point point = new Point(0, 0);
|
||||||
for (; c.Parent != null; c = c.Parent)
|
for (; c.Parent != null; c = c.Parent)
|
||||||
|
@ -101,7 +101,7 @@ namespace Sunny.UI
|
|||||||
/// http://about.me/AlekseyNagovitsyn
|
/// http://about.me/AlekseyNagovitsyn
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Enum)]
|
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Enum)]
|
||||||
internal class DisplayTextAttribute : Attribute
|
public class DisplayTextAttribute : Attribute
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The default value for the attribute <c>DisplayTextAttribute</c>, which is an empty string
|
/// The default value for the attribute <c>DisplayTextAttribute</c>, which is an empty string
|
||||||
|
@ -74,8 +74,8 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
Console.WriteLine("SeDebugPrivilege is now available");
|
Console.WriteLine("SeDebugPrivilege is now available");
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseHandle(hToken);
|
CloseHandle(hToken);
|
||||||
Console.ReadLine();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Suspend()
|
public static void Suspend()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user