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


C# System.GetPosition方法代码示例

本文整理汇总了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;
 }
开发者ID:Sugz,项目名称:SugzTools,代码行数:13,代码来源:Helpers.cs

示例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);
        }
开发者ID:ChuckSavage,项目名称:ZoomAndPanControl,代码行数:31,代码来源:ZoomAndPanControl_Mouse.cs

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

示例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));
    
 }
开发者ID:Kelin-Hong,项目名称:Becle.Phone,代码行数:7,代码来源:PublisherRegisterPage.xaml.cs

示例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);
     
 }
开发者ID:lee-icebow,项目名称:CREM.EVO,代码行数:9,代码来源:MainWindow.xaml.cs

示例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();
            }


        }
开发者ID:okubomkmk,项目名称:englishPaper,代码行数:10,代码来源:Class2.cs

示例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;                 
            }            
        }
开发者ID:ssickles,项目名称:archive,代码行数:12,代码来源:CustomWindowChromes.cs

示例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++;
        }
开发者ID:dbremner,项目名称:ScreenToGif,代码行数:14,代码来源:DragScrollGrid.cs

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

                    }
                }
            }
        }
开发者ID:naimheshmati,项目名称:Sanofi,代码行数:29,代码来源:LineString.cs

示例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);
                    }
                  
                }
            }
        }
开发者ID:ramazanguclu,项目名称:EnUcuzUrun,代码行数:31,代码来源:Scan.xaml.cs

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

            }
        }
开发者ID:sonicrang,项目名称:RangPaint,代码行数:32,代码来源:DrawRectangle.cs

示例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
        }
开发者ID:joaonetogodoy,项目名称:AgendaAtendimento,代码行数:7,代码来源:WindowHistoricoAlteracao.xaml.cs

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

            }
        }
开发者ID:ascendedguard,项目名称:regionmeasure,代码行数:26,代码来源:MainWindow.xaml.cs

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

示例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);
            }
             }
        }
开发者ID:visualstudioextensibility,项目名称:VSX-Samples,代码行数:35,代码来源:ToolWindowControl.xaml.cs


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