本文整理汇总了C#中System.Windows.Input.MouseEventArgs.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# MouseEventArgs.GetPosition方法的具体用法?C# MouseEventArgs.GetPosition怎么用?C# MouseEventArgs.GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Input.MouseEventArgs
的用法示例。
在下文中一共展示了MouseEventArgs.GetPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: myPath_MouseDown
private void myPath_MouseDown(object sender, MouseEventArgs e)
{
mouseVerticalPosition = e.GetPosition(scene).Y;
mouseHorizontalPosition = e.GetPosition(scene).X;
isDragging = true;
((Path)sender).CaptureMouse();
}
示例2: WindowSkin_TitleBarMouseMove
private void WindowSkin_TitleBarMouseMove(object sender, MouseEventArgs e)
{
if (_canRestore)
{
_canRestore = false;
var percentHorizontal = e.GetPosition(this).X / ActualWidth;
var targetHorizontal = RestoreBounds.Width * percentHorizontal;
var percentVertical = e.GetPosition(this).Y / ActualHeight;
var targetVertical = RestoreBounds.Height * percentVertical;
WindowState = WindowState.Normal;
var mousePosition = Utilities.Cursor.Position;
Left = mousePosition.X - targetHorizontal;
Top = mousePosition.Y - targetVertical;
try
{
DragMove();
}
catch (InvalidOperationException)
{
}
}
}
示例3: OnMouseMove
private void OnMouseMove(object sender, MouseEventArgs e)
{
if (!this.isMouseDown) return;
double curx = e.GetPosition(null).X;
double cury = e.GetPosition(null).Y;
var r = new System.Windows.Shapes.Rectangle
{
Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(145, 0, 0)),
StrokeThickness = 2,
Fill = new SolidColorBrush(Colors.White),
Width = Math.Abs(curx - this.x),
Height = Math.Abs(cury - this.y)
};
cnv.Children.Clear();
cnv.Children.Add(r);
Canvas.SetLeft(r, this.x);
Canvas.SetTop(r, this.y);
if (e.LeftButton == MouseButtonState.Released)
{
cnv.Children.Clear();
this.width = e.GetPosition(null).X - this.x;
this.height = e.GetPosition(null).Y - this.y;
this.CaptureScreen(this.x, this.y, this.width, this.height);
this.x = this.y = 0;
this.isMouseDown = false;
this.Hide();
}
}
示例4: Resizeing_Form
private void Resizeing_Form(object sender, MouseEventArgs e)
{
if (ResizeInProcess)
{
var senderRect = sender as Rectangle;
if (senderRect != null)
{
double width = e.GetPosition(this).X;
double height = e.GetPosition(this).Y;
senderRect.CaptureMouse();
if (senderRect.Name == "ResizeWidth")
{
width += 5;
if (width > 0)
Width = width;
}
else if (senderRect.Name == "ResizeHeigth")
{
height += 5;
if (height > 0)
Height = height;
}
}
}
}
示例5: Handle_MouseMove
public void Handle_MouseMove(object sender, MouseEventArgs args)
{
var item = sender as StackPanel;
if (!_isMouseCaptured) return;
// Calculate the current position of the object.
var deltaV = args.GetPosition(null).Y - _mouseVerticalPosition;
var deltaH = args.GetPosition(null).X - _mouseHorizontalPosition;
var oldTop = (double)item.GetValue(Canvas.TopProperty);
var oldLeft = (double)item.GetValue(Canvas.LeftProperty);
var newTop = deltaV + (double) item.GetValue(Canvas.TopProperty);
var newLeft = deltaH + (double) item.GetValue(Canvas.LeftProperty);
// Set new position of object.
item.SetValue(Canvas.TopProperty, newTop);
item.SetValue(Canvas.LeftProperty, newLeft);
var generalTransform = flagPanel.TransformToVisual(Current.Instance.MapControl);
var childToParentCoordinates = generalTransform.Transform(new Point(0, 0));
if(childToParentCoordinates.X <= 0)
item.SetValue(Canvas.LeftProperty, oldLeft);
if ((childToParentCoordinates.X + 1) + flagPanel.ActualWidth >= Current.Instance.MapControl.ActualWidth)
item.SetValue(Canvas.LeftProperty, oldLeft);
if (childToParentCoordinates.Y <= 0)
item.SetValue(Canvas.TopProperty, oldTop);
if ((childToParentCoordinates.Y + 1) + flagPanel.ActualHeight >= Current.Instance.MapControl.ActualHeight)
item.SetValue(Canvas.TopProperty, oldTop);
// Update position global variables.
_mouseVerticalPosition = args.GetPosition(null).Y;
_mouseHorizontalPosition = args.GetPosition(null).X;
}
示例6: MouseDown
void MouseDown(object sender, MouseEventArgs e)
{
if (can_move == 0 || can_edit == 0) return;
MovingObject = sender;
FirstX = e.GetPosition(sender as Control).X;
FirstY = e.GetPosition(sender as Control).Y;
}
示例7: DrawPixel
// The DrawPixel method updates the WriteableBitmap by using
// unsafe code to write a pixel into the back buffer.
static void DrawPixel(MouseEventArgs e)
{
int column = (int)e.GetPosition(i).X;
int row = (int)e.GetPosition(i).Y;
// Reserve the back buffer for updates.
writeableBitmap.Lock();
unsafe
{
// Get a pointer to the back buffer.
int pBackBuffer = (int)writeableBitmap.BackBuffer;
// Find the address of the pixel to draw.
pBackBuffer += row * writeableBitmap.BackBufferStride;
pBackBuffer += column * 4;
// Compute the pixel's color.
int color_data = 255 << 16; // R
color_data |= 128 << 8; // G
color_data |= 255 << 0; // B
// Assign the color data to the pixel.
*((int*)pBackBuffer) = color_data;
}
// Specify the area of the bitmap that changed.
writeableBitmap.AddDirtyRect(new Int32Rect(column, row, 1, 1));
// Release the back buffer and make it available for display.
writeableBitmap.Unlock();
}
示例8: ti_MouseMove
/// <summary>
/// 鼠标在自定义控件上移动式时,提示框也跟随移动
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ti_MouseMove(object sender, MouseEventArgs e)
{
this.tip.IsOpen = true;
this.tip.HorizontalOffset = e.GetPosition(null).X - 158;
this.tip.VerticalOffset = e.GetPosition(null).Y - 202;
}
示例9: OnMouseMove
protected override void OnMouseMove(MouseEventArgs e)
{
var p = e.GetPosition(this);
if (_isSelecting)
{
Mouse.OverrideCursor = Cursors.IBeam;
_selEnd = this.GetCharIndexAt(e.GetPosition(this));
this.InvalidateVisual();
e.Handled = true;
}
else if (_isDragging)
{
this.ColumnWidth = Math.Max(0.0, Math.Min(this.ViewportWidth / 2.0, p.X));
this.FormatAll();
}
else if (this.UseTabularView && Math.Abs(p.X - (this.ColumnWidth + SeparatorPadding)) < SeparatorPadding / 2.0)
{
Mouse.OverrideCursor = Cursors.SizeWE;
}
else
{
Mouse.OverrideCursor = null;
this.SelectedLink = this.HitTest(p);
if (this.SelectedLink != null)
{
Mouse.OverrideCursor = Cursors.Hand;
}
}
base.OnMouseMove(e);
}
示例10: sp_MouseMove
void sp_MouseMove(object sender, MouseEventArgs e)
{
if (dragging_ && !firstDown_) {
Point currentPosition = e.GetPosition(dragTarget_);
var transform = dragTarget_.RenderTransform as TranslateTransform;
if (transform == null) {
transform = new TranslateTransform();
dragTarget_.RenderTransform = transform;
}
transform.X += currentPosition.X - clickPosition.X;
transform.Y += currentPosition.Y - clickPosition.Y;
clickPosition = e.GetPosition(dragTarget_);
//transform.X = currentPosition.X - clickPosition.X;
//transform.Y = currentPosition.Y - clickPosition.Y;
if (transform.X + dragTarget_.ActualWidth > canvas.MinWidth) {
canvas.MinWidth = canvas.Width = transform.X + dragTarget_.ActualWidth * 2;
canvas.InvalidateMeasure();
scroller.InvalidateMeasure();
scroller.InvalidateScrollInfo();
}
} else if (firstDown_)
firstDown_ = false;
}
示例11: AppendData
public void AppendData(ref IDataObject data, MouseEventArgs e)
{
if (!(this.list.InputHitTest(e.GetPosition(e.OriginalSource as UIElement)) is ListBox)
&& !(this.list.InputHitTest(e.GetPosition(e.OriginalSource as UIElement)) is ScrollViewer)
&& !(e.OriginalSource is Thumb))
{
object o = this.list.SelectedItem;
// This is cheating .. just for an example's sake..
Debug.Assert(!data.GetDataPresent(DataFormats.Text));
if (o.GetType() == typeof(XmlElement))
{
data.SetData(DataFormats.Text, ((XmlElement)o).OuterXml);
}
else
{
data.SetData(DataFormats.Text, o.ToString());
}
Debug.Assert(!data.GetDataPresent(o.GetType().ToString()));
data.SetData(o.GetType().ToString(), o);
}
else
{
data = null;
}
}
示例12: OnMouseMove
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (isDraggingSelectionRect)
{
Point curMouseDownPoint = e.GetPosition(this);
UpdateDragSelectionRect(origMouseDownPoint, curMouseDownPoint);
e.Handled = true;
}
else if (isLeftMouseButtonDownOnWindow)
{
Point curMouseDownPoint = e.GetPosition(this);
var dragDelta = curMouseDownPoint - origMouseDownPoint;
double dragDistance = Math.Abs(dragDelta.Length);
if (dragDistance > DragThreshold)
{
isDraggingSelectionRect = true;
InitDragSelectionRect(origMouseDownPoint, curMouseDownPoint);
}
e.Handled = true;
}
}
示例13: EmbeddedMap_MouseMove
private void EmbeddedMap_MouseMove(object sender, MouseEventArgs e)
{
if (image.IsMouseCaptured)
{
Debug.WriteLine("Capture Move");
var tt = (TranslateTransform) ((TransformGroup) image.RenderTransform)
.Children.First(tr => tr is TranslateTransform);
Vector v = start - e.GetPosition(border);
tt.X = origin.X - v.X;
tt.Y = origin.Y - v.Y;
}
else
{
Debug.WriteLine("Normal Move");
Point p = e.GetPosition(image);
double scale = 360/image.ActualWidth;
Point pGeo = new Point(p.X*scale - 180, 90 - p.Y*scale);
locationLong.Text = string.Format("{0}", pGeo.X);
locationLat.Text = string.Format("{0}", pGeo.Y);
//Transform to UTM
CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();
ICoordinateSystem wgs84geo = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84;
int zone = (int) Math.Ceiling((pGeo.X + 180)/6);
//ICoordinateSystem utm = ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WGS84_UTM(zone, pGeo.Y > 0);
//ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems(wgs84geo, utm);
//Point pUtm = trans.MathTransform.Transform(pGeo);
//locationX.Text = string.Format("N{0}", pUtm.Y);
//locationY.Text = string.Format("E{0}", pUtm.X);
locationZone.Text = string.Format("Zone {0}{1}", zone, pGeo.Y > 0 ? 'N' : 'S');
}
}
示例14: Window_MouseMove
private void Window_MouseMove(object sender, MouseEventArgs e)
{
//si la souris bouge
if (e.LeftButton == MouseButtonState.Pressed)
{
mousePosMove.X = e.GetPosition(this.mainGrid).X;
mousePosMove.Y = e.GetPosition(this.mainGrid).Y;
double deplX = mousePosDown.X - mousePosMove.X;
//Déplacement du mainComponent
this.mainComponent.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
this.mainComponent.Margin = new Thickness(-deplX, 0, 0, 0);
this.mainComponent.Width = 500;
//déplacement de la souris vers la gauche avec bouton gauche enfoncé
if (this.mainComponent.Margin.Left <= -350)
{
for (int i = 0; i < 250; i++)
{
this.mainComponent.Margin = new Thickness(this.mainComponent.Margin.Left - 1, 0, 0, 0);
}
this.mainGrid.Children.Remove(mainComponent);
//ajout brikComponent
ajoutBrikComponent();
}
}
}
示例15: Handle_MouseDown
public void Handle_MouseDown(object sender, MouseEventArgs args)
{
Canvas item = sender as Canvas;
mouseVerticalPosition = args.GetPosition(null).Y;
mouseHorizontalPosition = args.GetPosition(null).X;
isMouseCaptured = true;
item.CaptureMouse();
}