本文整理汇总了C#中System.Windows.Forms.Control.PointToClient方法的典型用法代码示例。如果您正苦于以下问题:C# Control.PointToClient方法的具体用法?C# Control.PointToClient怎么用?C# Control.PointToClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Control
的用法示例。
在下文中一共展示了Control.PointToClient方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRelativePosition
public System.Drawing.PointF GetRelativePosition(Control c) {
System.Drawing.Point relPoint;
System.Drawing.PointF relPointF;
relPoint = c.PointToClient(new System.Drawing.Point((int)ScreenX,(int)ScreenY));
relPointF = new System.Drawing.PointF(relPoint.X + ScreenX - (float)((int)ScreenX),
relPoint.Y + ScreenY - (float)((int)ScreenY));
return relPointF;
}
示例2: FindTopControl
public static Control FindTopControl(Control parent, Point screen_pt)
{
Control c = parent.GetChildAtPoint(parent.PointToClient(screen_pt));
if (c == null) {
if (parent.RectangleToScreen(new Rectangle(0, 0, parent.Width, parent.Height)).Contains(screen_pt))
return parent;
else
return null;
}
else
return FindTopControl(c, screen_pt);
}
示例3: GetVisibleChildAtDesktopPoint
private static Control GetVisibleChildAtDesktopPoint( Control topControl, Point desktopPoint )
{
Control foundControl = topControl.GetChildAtPoint( topControl.PointToClient( desktopPoint ) );
if (foundControl != null)
{
if (foundControl.HasChildren)
{
foreach (Control control in foundControl.Controls)
{
foundControl = GetVisibleChildAtDesktopPoint(control, desktopPoint);
if (foundControl != null && foundControl.Visible)
break;
}
}
}
return foundControl ?? topControl;
}
示例4: requestColorDialog
public static Color requestColorDialog(Control sender)
{
Color res = Color.Empty;
ContextMenuStrip cm = new ContextMenuStrip();
var ColorDic = new Dictionary<string, Color>();
ColorDic.Add("Red", Color.Red);
ColorDic.Add("Blue", Color.Blue);
ColorDic.Add("Yellow", Color.Yellow);
ColorDic.Add("Green", Color.Green);
ColorDic.Add("Transparent", Color.FromArgb(0, 255, 255, 255));
foreach ( KeyValuePair<string, Color> pair in ColorDic)
{
Bitmap bmp = new Bitmap(10, 10);
for(int k = 0; k < bmp.Width; k++)
{
for(int v = 0; v < bmp.Height; v++)
{
bmp.SetPixel(k, v, pair.Value);
}
}
cm.Items.Add(new ToolStripMenuItem(pair.Key, bmp, (s, e) => { res = pair.Value; }));
}
cm.Items.Add(new ToolStripMenuItem("Custom...", new Bitmap(1, 1), (s, e) => { res = oldDialogPicker(); }));
cm.Show(sender, sender.PointToClient(new Point(Cursor.Position.X, Cursor.Position.Y)));
cm.Focus();
while (cm.Visible == true) { Application.DoEvents(); }
return res;
}
示例5: Input
public Input(Control control)
{
Control = control;
_keysDown = new List<Keys>();
_keysPressed = new List<Keys>();
_keysReleased = new List<Keys>();
_mousePoint = control.PointToClient(Cursor.Position);
_mouseWheelDelta = 0;
}
示例6: ShowForScope
public void ShowForScope(Control control, Point pos)
{
List<Rectangle> rects = textBox.GetSurroundingRects(scope);
Point screenPoint = control.PointToScreen(pos);
Point clientPoint = control.PointToClient(screenPoint);
Rectangle hitTest = new Rectangle(clientPoint, new Size(4,4));
if(rects.Count>0)
{
// ShowUnderScopeRect(rects[0], control.PointToScreen(pos), control);
foreach (Rectangle rect in rects)
{
if(rect.IntersectsWith(hitTest))
{
ShowUnderScopeRect(rect, control.PointToScreen(pos), control);
return;
}
}
base.Show(control, pos);
}
else
{
base.Show(control, pos);
}
}
示例7: RenderControlBgImage
public static void RenderControlBgImage(this Control destination, Control source, PaintEventArgs e)
{
var loc = source.PointToClient((destination.Parent ?? Program.MainWindow).PointToScreen(destination.Location));
if (source.BackgroundImage != null) e.Graphics.DrawImage(source.BackgroundImage, e.ClipRectangle, loc.X + e.ClipRectangle.X, loc.Y + e.ClipRectangle.Y, e.ClipRectangle.Width, e.ClipRectangle.Height, GraphicsUnit.Pixel);
}
示例8: FormIsHit
/// ------------------------------------------------------------------------------------
/// <summary>
/// finds the potential dockhost control at the specified location
/// </summary>
/// ------------------------------------------------------------------------------------
internal bool FormIsHit(Control c, Point pt)
{
if (c == null)
return false;
Point pc = c.PointToClient(pt);
bool hit = c.ClientRectangle.IntersectsWith(new Rectangle(pc, new Size(1, 1))); //.TopLevelControl; // this is tricky
return hit;
}
示例9: method_1
private void method_1(Control container, Control control, Graphics g, Rectangle bounds)
{
if (container.ClientRectangle.Width > 0 && container.ClientRectangle.Height > 0 && bounds.Width > 0 && bounds.Height > 0)
{
var p1 = control.PointToClient(container.PointToScreen(new Point(0, 0)));
var p2 = control.PointToClient(container.PointToScreen(new Point(container.ClientRectangle.Right, 0)));
using (var brush = new LinearGradientBrush(p1, p2, LayoutBackgroundColor1, LayoutBackgroundColor2))
g.FillRectangle(brush, bounds);
}
}
示例10: GetMouseEventArgs
/// <summary>
/// Returns NShapeMouseEventArgs extracted from information provided by the <see cref="T:System.Windows.Forms.Control" /> class.
/// </summary>
public static MouseEventArgsDg GetMouseEventArgs(Control control, MouseEventType eventType, int clicks, int delta)
{
Point mousePos = control.PointToClient(Control.MousePosition);
return GetMouseEventArgs(eventType, Control.MouseButtons, clicks, mousePos.X, mousePos.Y, delta, control.Bounds);
}
示例11: Show
public void Show(Control control, Rectangle area)
{
if (control == null)
{
throw new ArgumentNullException("Parent control could not be null");
}
SetOwnerItem(control);
Point location = control.PointToScreen(new Point(area.Left, area.Top + area.Height));
Rectangle screen = Screen.FromControl(control).WorkingArea;
if (location.X + Size.Width > (screen.Left + screen.Width))
{
location.X = (screen.Left + screen.Width) - Size.Width;
}
if (location.Y + Size.Height > (screen.Top + screen.Height))
{
location.Y -= Size.Height + area.Height;
}
location = control.PointToClient(location);
Show(control, location, ToolStripDropDownDirection.BelowRight);
}
示例12: UpdateTargetState
/// <summary>
/// Set the correct visual state of the target.
/// </summary>
/// <param name="c">Owning control.</param>
protected void UpdateTargetState(Control c)
{
// Check we have a valid control to convert coordinates against
if ((c != null) && !c.IsDisposed)
{
// Ensure control is inside a visible top level form
Form f = c.FindForm();
if ((f != null) && f.Visible)
{
UpdateTargetState(c.PointToClient(Control.MousePosition));
return;
}
}
UpdateTargetState(new Point(int.MaxValue, int.MaxValue));
}
示例13: PointToClientLeftUpperCorner
private Point PointToClientLeftUpperCorner(Control client)
{
return client.PointToClient(new Point(0, 0));
}
示例14: Show
/// <summary>
/// Shows pop-up window below the specified area of specified control.
/// </summary>
/// <param name="control">
/// The control used to compute screen location of specified area.
/// </param>
/// <param name="area">
/// The area of control below which the pop-up will be shown.
/// </param>
/// <remarks>
/// When there is no space below specified area, the pop-up control is shown above it.
/// </remarks>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="control"/> is
/// <code>
/// null
/// </code>
/// .
/// </exception>
public void Show(Control control, Rectangle area)
{
if (control == null)
{
throw new ArgumentNullException("control");
}
this.SetOwnerItem(control);
this.resizableTop = this.resizableRight = false;
Point location = control.PointToScreen(new Point(area.Left, area.Top + area.Height));
Rectangle screen = Screen.FromControl(control).WorkingArea;
if (location.X + this.Size.Width > (screen.Left + screen.Width))
{
this.resizableRight = true;
location.X = (screen.Left + screen.Width) - this.Size.Width;
}
if (location.Y + this.Size.Height > (screen.Top + screen.Height))
{
this.resizableTop = true;
location.Y -= this.Size.Height + area.Height;
}
location = control.PointToClient(location);
this.Show(control, location, ToolStripDropDownDirection.BelowRight);
}
示例15: DragOver
public static void DragOver(Control owner, DragEventArgs e)
{
Point p = new Point(e.X, e.Y);
Point point2 = owner.PointToClient(p);
ImageList_DragMove(point2.X, point2.Y);
if (Helper != null)
{
Helper.DragOver(ref p, (uint) e.Effect);
}
}