本文整理汇总了C#中System.Drawing.RectangleF.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.RectangleF.Contains方法的具体用法?C# System.Drawing.RectangleF.Contains怎么用?C# System.Drawing.RectangleF.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.RectangleF
的用法示例。
在下文中一共展示了System.Drawing.RectangleF.Contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _ParentContains
private static Control _ParentContains(Control control, System.Drawing.PointF mousePosition, Control currentControl, ref bool ok)
{
//Application.Log(control.Name);
if (control == null || control.Parent == null) return currentControl;
var parentLocation = control.Parent.PointToScreen(System.Drawing.Point.Zero);
var parentRect = new System.Drawing.RectangleF(parentLocation.X, parentLocation.Y, control.Parent.Width, control.Parent.Height);
if (parentRect.Contains(mousePosition) == true)
currentControl = control.Parent;
else
ok = false; // Control is not visible due to groups;
return _ParentContains(control.Parent, mousePosition, currentControl, ref ok);
}
示例2: _ProcessControl
private static bool _ProcessControl(System.Drawing.PointF mousePosition, Control control, bool ignore_rect)
{
// ignore_rect will call mouse_up & mouse_move in any case.
var c_location = control.PointToScreen(System.Drawing.Point.Zero);
var clientRect = new System.Drawing.RectangleF(c_location.X, c_location.Y, control.Width, control.Height);
var contains = clientRect.Contains(mousePosition);
if (contains && (_mouseEvent == MouseEvents.Down) || _mouseEvent == MouseEvents.Up)
{
if (control.Parent != null)
{
bool ok = true;
var clickedControl = _ParentContains(control, mousePosition, control, ref ok);
if (clickedControl != null && ok == false)
control = clickedControl;
}
}
if (ignore_rect || contains)
{
var client_mpos = control.PointToClient(mousePosition);
if (_mouseMovePosition != mousePosition)
{
MouseEventArgs m_args = new MouseEventArgs(MouseButtons.None, 0, (int)client_mpos.X, (int)client_mpos.Y, 0);
control.RaiseOnMouseMove(m_args);
if (_dragData != null)
_dragndrop = true;
}
if (!contains && _mouseEvent != MouseEvents.Up)
return true;
switch (_mouseEvent)
{
case MouseEvents.Down:
MouseEventArgs md_args = new MouseEventArgs(_mouseButton, 1, (int)client_mpos.X, (int)client_mpos.Y, 0);
control.RaiseOnMouseDown(md_args);
_mouseLastClickControl = control;
return true;
case MouseEvents.Up:
if (_dragndrop)
{
if (control.AllowDrop)
{
DataObject dnd_data = new DataObject(_dragData);
DragEventArgs dnd_args = new DragEventArgs(dnd_data, 0, (int)client_mpos.X, (int)client_mpos.Y, DragDropEffects.None, _dragControlEffects);
control.RaiseOnDragDrop(dnd_args);
}
_dragData = null;
_dragndrop = false;
}
MouseEventArgs mu_args = new MouseEventArgs(_mouseButton, 1, (int)client_mpos.X, (int)client_mpos.Y, 0);
control.RaiseOnMouseUp(mu_args);
if (_mouseLastClickControl == control)
control.RaiseOnMouseClick(mu_args);
if (_mouseLastClickControl != null && control != _mouseLastClickControl)
_mouseLastClickControl.RaiseOnMouseUp(mu_args);
return true;
case MouseEvents.DoubleClick:
MouseEventArgs mdc_args = new MouseEventArgs(_mouseButton, 2, (int)client_mpos.X, (int)client_mpos.Y, 0);
control.RaiseOnMouseDoubleClick(mdc_args);
return true;
case MouseEvents.Wheel:
MouseEventArgs mw_args = new MouseEventArgs(MouseButtons.Middle, 0, (int)client_mpos.X, (int)client_mpos.Y, (int)(-_mouseWheelDelta * 4));
control.RaiseOnMouseWheel(mw_args);
return true;
}
}
if (!contains)
control.RaiseOnMouseLeave(null);
return false;
}
示例3: DrawDebug
public void DrawDebug(DrawParameters p)
{
if (!(this is XImage) && !(this is XBlock))
return;
tmpBounds = this.GetScreenBounds();
#if WINDOWS
tmpVector1 = MouseProcessor.LastPosition;
#else
tmpVector1 = TouchPanelProcessor.LastPosition;
#endif
if (!tmpBounds.Contains((int)tmpVector1.X, (int)tmpVector1.Y))
return;
Color c = Color.Red * 0.3f;
p.SpriteBatch.Draw(p.Game.BlankTexture, tmpBounds, c);
if (!string.IsNullOrEmpty(this.Id))
{
tmpVector1.X = tmpBounds.X;
tmpVector1.Y = tmpBounds.Y;
p.SpriteBatch.DrawString(p.Game.SystemFont, this.Id, tmpVector1, Color.Yellow);
}
}