本文整理汇总了C#中System.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# System.GetPosition方法的具体用法?C# System.GetPosition怎么用?C# System.GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System.GetPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsMouseOver
/// <summary>
/// Return wheter the mouse is over a control
/// </summary>
/// <param name="s"></param>
/// <param name="e"></param>
/// <returns>True if the mouse is over a control, false otherwise</returns>
internal static bool IsMouseOver(FrameworkElement s, System.Windows.Input.MouseEventArgs e)
{
Rect bounds = new Rect(0, 0, s.ActualWidth, s.ActualHeight);
if (bounds.Contains(e.GetPosition(s)))
return true;
return false;
}
示例2: OnMouseDown
protected override void OnMouseDown(System.Windows.Input.MouseButtonEventArgs e)
{
content.Focus();
Keyboard.Focus(content);
mouseButtonDown = e.ChangedButton;
origZoomAndPanControlMouseDownPoint = e.GetPosition(this);
origContentMouseDownPoint = e.GetPosition(content);
if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0 &&
(e.ChangedButton == MouseButton.Left ||
e.ChangedButton == MouseButton.Right))
{
// Shift + left- or right-down initiates zooming mode.
mouseHandlingMode = MouseHandlingMode.Zooming;
}
else if (mouseButtonDown == MouseButton.Left)
{
// Just a plain old left-down initiates panning mode.
mouseHandlingMode = MouseHandlingMode.Panning;
}
if (mouseHandlingMode != MouseHandlingMode.None)
{
// Capture the mouse so that we eventually receive the mouse up event.
this.CaptureMouse();
e.Handled = true;
}
base.OnMouseDown(e);
}
示例3: Window_MouseMove
private void Window_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
if (this.isMouseDown)
{
double curx = e.GetPosition(null).X;
double cury = e.GetPosition(null).Y;
System.Windows.Shapes.Rectangle r = new System.Windows.Shapes.Rectangle();
SolidColorBrush brush = new SolidColorBrush(Colors.White);
r.Stroke = brush;
r.Fill = brush;
r.StrokeThickness = 1;
r.Width = Math.Abs(curx - x);
r.Height = Math.Abs(cury - y);
cnv.Children.Clear();
cnv.Children.Add(r);
Canvas.SetLeft(r, Math.Min(x , curx));
Canvas.SetTop(r, Math.Min(y, cury));
if (e.LeftButton == MouseButtonState.Released)
{
cnv.Children.Clear();
width = Math.Abs(curx - x);
height = Math.Abs(cury - y);
bitmap = ScreenShotMaker.CaptureScreen(width, height, Math.Min(x, curx) - 7, Math.Min(y, cury) - 7);
this.x = this.y = 0;
this.isMouseDown = false;
this.Close();
}
}
}
示例4: map_Tap
void map_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
layer.Children.Clear();
layer.AddChild(Pin_My, map.ViewportPointToLocation(e.GetPosition(map)));
Pin_My.Tag = map.ViewportPointToLocation(e.GetPosition(map));
}
示例5: Element_MouseMove
private void Element_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
if (!isdrag) return;
var control = (sender as UIElement);
control.SetValue(Canvas.LeftProperty, e.GetPosition(container).X - control.DesiredSize.Width / 2);
control.SetValue(Canvas.TopProperty, e.GetPosition(container).Y - control.DesiredSize.Height / 2);
var vector = VisualTreeHelper.GetOffset(control);
}
示例6: Picture_MouseLeftButtonDown
private void Picture_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (!WritingFlag)
{
this.textXlock.Text = e.GetPosition(Picture).X.ToString();
this.textYlock.Text = e.GetPosition(Picture).Y.ToString();
}
}
示例7: window_Resize
private void window_Resize(object sender, System.Windows.Input.MouseEventArgs e)
{
Rectangle rect = (Rectangle)sender;
Window win = (Window)rect.TemplatedParent;
if (isResizing)
{
rect.CaptureMouse();
if (resizeType == ResizeType.Width) win.Width = e.GetPosition(win).X + 5;
if (resizeType == ResizeType.Height) win.Height = e.GetPosition(win).Y + 5;
}
}
示例8: DragScrollGrid_MouseMove
private void DragScrollGrid_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
if (!IsMouseCaptured) return;
if ((int)_lastPosition.X == (int)e.GetPosition(this).X) return;
if (_lastPosition.X > e.GetPosition(this).X)
{
//To the Left.
//Value--;
}
//To the right.
//Value++;
}
示例9: LineString_MouseLeftButtonDown
void LineString_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (DrawControl.LinesPointsLayer.Visibility == Visibility.Visible)
{
double min_distance = 10000;
int insert_index = 0;
Point _CurrentMousePoint = MapInstance.CoordHelper.PixelToGeo(e.GetPosition(MapInstance));
for (int j = 0; j < this.Points.Count - 1; j++)
{
if (min_distance > Math.Abs(GetDistance(Points[j], Points[j + 1]) - GetDistance(Points[j], _CurrentMousePoint) - GetDistance(Points[j + 1], _CurrentMousePoint)))
{
min_distance = Math.Abs(GetDistance(Points[j], Points[j + 1]) - GetDistance(Points[j], _CurrentMousePoint) - GetDistance(Points[j + 1], _CurrentMousePoint));
insert_index = j + 1;
}
}
Points.Insert(insert_index, _CurrentMousePoint);
DrawControl.LinesPointsLayer.Add(new DrawPoint { Point = _CurrentMousePoint, LineString = this, Index = insert_index });
for (int i = 0; i < DrawControl.LinesPointsLayer.Children.Count - 1; i++)
{
if ((DrawControl.LinesPointsLayer.Children[i] as DrawPoint).LineString == this)
{
if ((DrawControl.LinesPointsLayer.Children[i] as DrawPoint).Index >= insert_index)
(DrawControl.LinesPointsLayer.Children[i] as DrawPoint).Index++;
}
}
}
}
示例10: focus_Tapped
void focus_Tapped(object sender, System.Windows.Input.GestureEventArgs e)
{
if (_phoneCamera != null)
{
if (_phoneCamera.IsFocusAtPointSupported == true)
{
// Determine the location of the tap.
Point tapLocation = e.GetPosition(viewfinderCanvas);
// Position the focus brackets with the estimated offsets.
focusBrackets.SetValue(Canvas.LeftProperty, tapLocation.X - 30);
focusBrackets.SetValue(Canvas.TopProperty, tapLocation.Y - 28);
// Determine the focus point.
double focusXPercentage = tapLocation.X / viewfinderCanvas.ActualWidth;
double focusYPercentage = tapLocation.Y / viewfinderCanvas.ActualHeight;
// Show the focus brackets and focus at point.
try
{
focusBrackets.Visibility = Visibility.Visible;
_phoneCamera.FocusAtPoint(focusXPercentage, focusYPercentage);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
示例11: OnMouseMove
public override void OnMouseMove(System.Windows.Controls.InkCanvas inkCanvas, System.Windows.Input.MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
bottomRight = e.GetPosition(inkCanvas);
if(topLeft != bottomRight)
{
StylusPointCollection pts = new StylusPointCollection();
GetRectangle(pts, (s) =>
{
if (StrokeResult != null)
inkCanvas.Strokes.Remove(StrokeResult);
DrawingAttributes drawingAttributes = new DrawingAttributes
{
Color = inkCanvas.DefaultDrawingAttributes.Color,
Width = inkCanvas.DefaultDrawingAttributes.Width,
StylusTip = StylusTip.Ellipse,
IgnorePressure = true,
FitToCurve = true
};
var BackgroundColor = inkCanvas.DefaultDrawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor);
drawingAttributes.AddPropertyData(DrawAttributesGuid.BackgroundColor, BackgroundColor);
StrokeResult = new RectangleStroke(s, drawingAttributes);
inkCanvas.Strokes.Add(StrokeResult);
}
);
}
}
}
示例12: Window_MouseMove
private void Window_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
Point p = e.GetPosition(this);
posX = p.X; // private double posX is a class member
posY = p.Y; // private double posY is a class member
}
示例13: Canvas_MouseMove
private void Canvas_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)
{
var canvas = (Canvas)sender;
var pos = e.GetPosition(canvas);
var left = Canvas.GetLeft(rect);
var top = Canvas.GetTop(rect);
var width = pos.X - left;
var height = pos.Y - top;
if (height > 0 && width > 0)
{
rect.Width = width;
rect.Height = height;
}
txtHeight.Text = height.ToString();
txtWidth.Text = width.ToString();
txtXPosition.Text = left.ToString();
txtYPosition.Text = top.ToString();
}
}
示例14: MouseHover
private new void MouseHover(object sender, System.Windows.Input.MouseEventArgs e) {
var pos = codeEditor.TextArea.TextView.GetPositionFloor(e.GetPosition(codeEditor.TextArea.TextView) + codeEditor.TextArea.TextView.ScrollOffset);
bool inDocument = pos.HasValue;
if (inDocument) {
TextLocation logicalPosition = pos.Value.Location;
int offset = codeEditor.Document.GetOffset(logicalPosition);
var markersAtOffset = textMarkerService.GetMarkersAtOffset(offset);
TextMarkerService.TextMarker markerWithToolTip = markersAtOffset.FirstOrDefault(marker => marker.ToolTip != null);
if (markerWithToolTip != null) {
if (toolTip == null) {
toolTip = new System.Windows.Controls.ToolTip();
toolTip.Closed += ToolTipClosed;
// toolTip.PlacementTarget = this;
toolTip.Content = new System.Windows.Controls.TextBlock {
Text = markerWithToolTip.ToolTip,
TextWrapping = System.Windows.TextWrapping.Wrap
};
toolTip.IsOpen = true;
e.Handled = true;
}
}
}
}
示例15: frame_MouseUp
private void frame_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
// Warning!!: Keep these values in sync with the .vsct file
const string guidVSPackageContextMenuCmdSet = "c1a3a312-e25a-4cd1-b557-011428323a99";
const int MyContextMenuId = 0x0200;
System.IServiceProvider serviceProvider;
IVsUIShell uiShell;
System.Guid contextMenuGuid = new System.Guid(guidVSPackageContextMenuCmdSet);
System.Windows.Point relativePoint;
System.Windows.Point screenPoint;
POINTS point;
POINTS[] points;
if (e.ChangedButton == System.Windows.Input.MouseButton.Right)
{
serviceProvider = (System.IServiceProvider)m_package;
uiShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell;
if (uiShell != null)
{
relativePoint = e.GetPosition(this);
screenPoint = this.PointToScreen(relativePoint);
point = new POINTS();
point.x = (short)screenPoint.X;
point.y = (short)screenPoint.Y;
points = new[] { point };
// TODO: error handling
uiShell.ShowContextMenu(0, ref contextMenuGuid, MyContextMenuId, points, null);
}
}
}