当前位置: 首页>>代码示例>>C#>>正文


C# MouseEventArgs.GetPosition方法代码示例

本文整理汇总了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();
 }
开发者ID:redliontom,项目名称:SWP2,代码行数:7,代码来源:AddEllipse.cs

示例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)
                {
                }
            }
        }
开发者ID:caesay,项目名称:Hurricane,代码行数:27,代码来源:MagicMetroWindowDragging.cs

示例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();
            }
        }
开发者ID:noelpush,项目名称:noelpush,代码行数:32,代码来源:Selector.cs

示例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;
                    }
                }
            }
        }
开发者ID:abdulbaruwa,项目名称:AdeTyper,代码行数:34,代码来源:HomeWindow.xaml.cs

示例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;
        }
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:33,代码来源:Flag.xaml.cs

示例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;
 }
开发者ID:timitoc,项目名称:Algoritmi-pe-grafuri,代码行数:7,代码来源:Graf.cs

示例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();
        }
开发者ID:KinectProject-ITKMITL,项目名称:Kinect,代码行数:34,代码来源:Form1.Designer.cs

示例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;

        }
开发者ID:JuRogn,项目名称:OA,代码行数:12,代码来源:TipWindow.xaml.cs

示例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);
		}
开发者ID:neem,项目名称:Nilas,代码行数:32,代码来源:ChatPresenter_Selecting.cs

示例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;
        }
开发者ID:nonconforme,项目名称:UrContent,代码行数:25,代码来源:GraphCanvas.xaml.cs

示例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;
            }
        }
开发者ID:cipjota,项目名称:Chronos,代码行数:29,代码来源:ListBoxDragDropDataProvider.cs

示例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;
            }
        }
开发者ID:D2-FEST-2014,项目名称:Image-Secure-Extension,代码行数:26,代码来源:MultiSelectionCanvas.xaml.cs

示例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');
            }
        }
开发者ID:mohsenboojari,项目名称:offwind,代码行数:32,代码来源:CWorldMap.xaml.cs

示例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();
                }
            }
        }
开发者ID:mbonitho,项目名称:ClockTwo,代码行数:29,代码来源:MainWindow.xaml.cs

示例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();
 }
开发者ID:Erronsing,项目名称:CSE485-Columba,代码行数:8,代码来源:MainPage.xaml.cs


注:本文中的System.Windows.Input.MouseEventArgs.GetPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。