功能调整
This commit is contained in:
1 parent
42acf1b1cb
commit
772d9f4780
40 files changed
+4953
-389
No files matched your search
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Work.Extension
|
||||
{
|
||||
public static class ControlExtension
|
||||
{
|
||||
public static Point GetRelativePosition(this Control control, Form form)
|
||||
{
|
||||
Point location = control.Location;
|
||||
Control parent = control.Parent;
|
||||
while (parent != null && parent != form)
|
||||
{
|
||||
location.X += parent.Location.X;
|
||||
location.Y += parent.Location.Y;
|
||||
parent = parent.Parent;
|
||||
}
|
||||
return location;
|
||||
}
|
||||
public static Point GetRelativePosition(this Control control, Control parentControl)
|
||||
{
|
||||
if (control == null || parentControl == null)
|
||||
return new Point(0, 0);
|
||||
|
||||
Point location = control.Location;
|
||||
Control parent = control.Parent;
|
||||
while (parent != null && parent != parentControl)
|
||||
{
|
||||
location.X += parent.Location.X;
|
||||
location.Y += parent.Location.Y;
|
||||
parent = parent.Parent;
|
||||
}
|
||||
return location;
|
||||
}
|
||||
public static Point GetRelativePosition(this Control control)
|
||||
{
|
||||
Point location = control.Location;
|
||||
Control parent = control.Parent;
|
||||
while (parent != null && !(parent is Form))
|
||||
{
|
||||
location.X += parent.Location.X;
|
||||
location.Y += parent.Location.Y;
|
||||
parent = parent.Parent;
|
||||
}
|
||||
return location;
|
||||
}
|
||||
public static Control GetParentNotTable(this Control contorl)
|
||||
{
|
||||
Control parent = contorl.Parent;
|
||||
while (parent != null && (parent is TableLayoutPanel || parent is FlowLayoutPanel))
|
||||
{
|
||||
parent = parent.Parent;
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user