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


C# MouseButtonEventArgs.GetPosition方法代码示例

本文整理汇总了C#中System.Windows.Input.MouseButtonEventArgs.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# MouseButtonEventArgs.GetPosition方法的具体用法?C# MouseButtonEventArgs.GetPosition怎么用?C# MouseButtonEventArgs.GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Input.MouseButtonEventArgs的用法示例。


在下文中一共展示了MouseButtonEventArgs.GetPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DragWindow

 private void DragWindow(object sender, MouseButtonEventArgs e)
 {
     if (e.GetPosition(this).Y < 36 || e.GetPosition(this).Y > this.Height - 43)
     {
         this.DragMove();
     }
 }
开发者ID:hjb912,项目名称:wpf-skin-iphoneClean,代码行数:7,代码来源:MainWindow.xaml.cs

示例2: maingrid_MouseDown

        private void maingrid_MouseDown(object sender, MouseButtonEventArgs e)
        {
            _mousePosition = e.GetPosition(this);

            if (OnMouseMoveDown != null)
                OnMouseMoveDown(e.GetPosition(this));
        }
开发者ID:AtiX,项目名称:objectTable,代码行数:7,代码来源:BeamerDisplayUC.xaml.cs

示例3: TextBlock_MouseRightButtonDown

        private void TextBlock_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            var textblock = (TextBlock)sender;
            OperationViewModel operation = textblock.DataContext as OperationViewModel;
            ContextMenu contextMenu = new ContextMenu();
            CustomerViewModel vm = Customer.Data as CustomerViewModel;

            if (vm.Tags != null)
            {
                foreach (TagViewModel tag in vm.Tags)
                {
                    contextMenu.Items.Add(new MenuItem { Header = tag.Title, Command = operation.TagCommand, CommandParameter = tag });
                }
            }

            contextMenu.Items.Add(new Separator());

            var referentialVM = App.Current.Resources["Referential"] as ReferentialDataViewModel;

            foreach (TagViewModel tag in referentialVM.StandardTags)
            {
                contextMenu.Items.Add(new MenuItem { Header = tag.Title, Command = operation.TagCommand, CommandParameter = tag });
            }

            ContextMenuService.SetContextMenu(textblock, contextMenu);

            contextMenu.HorizontalOffset = e.GetPosition(null).X;
            contextMenu.VerticalOffset = e.GetPosition(null).Y;
            contextMenu.IsOpen = true;

            e.Handled = true;
        }
开发者ID:al-main,项目名称:CloudyBank,代码行数:32,代码来源:Account.xaml.cs

示例4: lineBetweenElipses

        void lineBetweenElipses(object sender, MouseButtonEventArgs e)
        {
            boolean = true;
            if (_lineStart == null)
            {
                _lineStart = e.GetPosition(this);

            }
            else
            {
                _lineEnd = e.GetPosition(this);

                Line lne = new Line();
                lne.X1 = _lineStart.Value.X;
                lne.X2 = _lineEnd.Value.X;
                lne.Y1 = _lineStart.Value.Y;
                lne.Y2 = _lineEnd.Value.Y;
                lne.Stroke = Brushes.Red;
                lne.StrokeThickness = 2;
                Canvas.SetLeft(lne, 0);
                Canvas.SetTop(lne, 0);
                canvas.Children.Add(lne);
                _lineStart = null;
            }

            //    bool isSecondElipse = false;
            //    if (isSecondElipse == false)
            //    {
            //}
        }
开发者ID:Edza,项目名称:Drawing-test,代码行数:30,代码来源:MainWindow.xaml.cs

示例5: Window_MouseDown

        private void Window_MouseDown(object sender, MouseButtonEventArgs e)
        {
            // Создадим элллипс
            Ellipse эллипс = new Ellipse();

            // Создадим SolidColorBrush, который заполнит эллипс
            SolidColorBrush цветЭллипса = new SolidColorBrush();

            // Задаётся цвет случайными значениями от 100
            Random r = new Random();
            цветЭллипса.Color = Color.FromArgb((byte)r.Next(0, 255), (byte)r.Next(0, 255), (byte)r.Next(0, 255), 0);// Заполняем случайным цветом
            эллипс.Fill = цветЭллипса;
            эллипс.StrokeThickness = 1;// Толщина линии
            эллипс.Stroke = Brushes.Red;// Цвет линии красный

            // Установим ширину и высоту эллипса - случайные числа от 50 до 700
            int ширина = r.Next(50,700);
            int высота = r.Next(50, 700);

            // Установим координаты центра - это те координаты, которые получились в результате клика мышью
            double X = (e.GetPosition(null)).X;
            double Y = (e.GetPosition(null)).Y;

            // Установим ширину и высоту эллипса
            эллипс.Width = ширина;
            эллипс.Height = высота;
            // И поставим эллипс в координаты
            эллипс.Margin = new Thickness(X-ширина/2,Y-высота/2,0,0);

            // На нашу канву добавим новый созданный эллипс
            canv.Children.Add(эллипс);
        }
开发者ID:GarageInc,项目名称:all,代码行数:32,代码来源:MainWindow.xaml.cs

示例6: GameObjectsGrid_MouseDown

 public void GameObjectsGrid_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (sender is UIElement)
     {
         UIElement uiElement = sender as UIElement;
         uiElement.Focus();
     }
     if (e.LeftButton == MouseButtonState.Pressed || e.RightButton == MouseButtonState.Pressed)
     {
         if (e.LeftButton == MouseButtonState.Pressed)
         {
             m_leftDown = true;
         }
         m_oldPos = e.GetPosition((Canvas)sender);
         if (Main.ObjectBuilder.click(e.GetPosition((Canvas)sender)) != null)
         {
             // we're done
             return;
         }
         if (e.LeftButton == MouseButtonState.Pressed)
         {
             // start selecting
             m_selection.startSelection(m_oldPos, sender as Canvas);
         }
     }
     if (e.MiddleButton == MouseButtonState.Pressed)
     {
         m_oldPos = e.GetPosition((Canvas)sender);
         m_middleDown = true;
     }
     //this.Canvas1.InvalidateVisual();
 }
开发者ID:DelBero,项目名称:XnaScrapEdit,代码行数:32,代码来源:TemplateTemplates.cs

示例7: canvas1_MouseLeftButtonDown

        private void canvas1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (toolState == 0)
            {
                canvas1.CaptureMouse();
                if (!activelyDrawing && toolState == 0) //just started to draw, save state first (in order to undo)
                {
                    updateUndoList();
                    activelyDrawing = true;
                }

                cur_p.x = (short)e.GetPosition(canvas1).X;
                cur_p.y = (short)e.GetPosition(canvas1).Y;

                prev_p = cur_p;
            }
            else if (toolState == 2)
            {
                bm = new WriteableBitmap(canvas1, null);
                Globals.scb.Color = bm.GetPixel((int)e.GetPosition(canvas1).X, (int)e.GetPosition(canvas1).Y);
                border2.Background = Globals.scb;
                makeToast("Color Sampled", "");
                toolState++;
                fillClick(null, null); //to move to pencil mode
                //NavigationService.Navigate(new Uri("/ColorPicker.xaml", UriKind.Relative));
            }
        }
开发者ID:Nesszors,项目名称:PaintApp,代码行数:27,代码来源:MainPage.xaml.cs

示例8: MouseLeftButtonDown

 private void MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     _popup.Child.CaptureMouse();
     _mouseCaptured = true;
     _mouseY = e.GetPosition(null).Y;
     _mouseX = e.GetPosition(null).X;
 }
开发者ID:sk8tz,项目名称:Orc.Controls,代码行数:7,代码来源:PopupDragDrop.cs

示例9: Window_MouseLeftButtonDown

 private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     beginX = (int)e.GetPosition(null).X;
     beginY = (int)e.GetPosition(null).Y;
     isMousePressed = true;
     Boarder.Margin = new Thickness(100, 100, 100, 100);
 }
开发者ID:juyingnan,项目名称:VS,代码行数:7,代码来源:FullScreenWhite.xaml.cs

示例10: OnInboundParamComp_MouseLeftButtonDown

        private void OnInboundParamComp_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point currPos =
                         new Point(e.GetPosition(ParamCanvas).X,
                                   e.GetPosition(ParamCanvas).Y);

            ParameterModel model = GetParamModelByCoord(currPos);
            currModel = model;
            ObservableCollection<ParameterModel> models = new ObservableCollection<ParameterModel>();

            for (int i = 0; i < model.SiblingModels.Length; i++)
                models.Add(model.SiblingModels[i]);


            ParamValueEditor valueEditor = new ParamValueEditor()
            {
                DataContext = models,
            };

            valueEditor.OnRefresh += new ParamValueEditor.RefreshEventHandler(valueEditor_OnRefresh);
            valueEditor.ParamDataForm.CurrentItem = model;

            valueEditor.Show();

            ParamValueChangesEvent(new EventArgs()); //Commitment was made
        }
开发者ID:SamuelToh,项目名称:Masters_Degree_Major_Project,代码行数:26,代码来源:ParamInboundComp.xaml.cs

示例11: NetworkControl_MouseDown

        /// <summary>
        /// Event raised on mouse down in the NetworkView.
        /// </summary> 
        private void NetworkControl_MouseDown(object sender, MouseButtonEventArgs e)
        {
            NetworkView networkView = sender as NetworkView;
            networkView.Focus();
            Keyboard.Focus(networkView);

            mouseButtonDown = e.ChangedButton;
            origZoomAndPanControlMouseDownPoint = e.GetPosition(zoomAndPanControl);
            origContentMouseDownPoint = e.GetPosition(networkView);

            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 &&
                     (Keyboard.Modifiers & ModifierKeys.Control) == 0)
            {
                //
                // Initiate panning, when control is not held down.
                // When control is held down left dragging is used for drag selection.
                // After panning has been initiated the user must drag further than the threshold value to actually start drag panning.
                //
                mouseHandlingMode = MouseHandlingMode.Panning;
            }

            if (mouseHandlingMode != MouseHandlingMode.None)
            {
                // Capture the mouse so that we eventually receive the mouse up event.
                networkView.CaptureMouse();
                e.Handled = true;
            }
        }
开发者ID:kweinberg1,项目名称:SoundAtlas,代码行数:38,代码来源:Atlas_ZoomAndPan.cs

示例12: IsDoubleClick

        /// <summary>
        /// Determines whether [is double click] [the specified element].
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="e">The <see cref="System.Windows.Input.MouseButtonEventArgs"/> instance containing the event data.</param>
        /// <param name="clickTime">The click time.</param>
        /// <returns><c>true</c> if [is double click] [the specified element]; otherwise, <c>false</c>.</returns>
        public bool IsDoubleClick( UIElement element, MouseButtonEventArgs e, DateTime clickTime )
        {
            var isDoubleClick = false;

            var span = clickTime - _firstClickTime;

            if ( span.TotalMilliseconds > 300 || _firstClickDone == false )
            {
                _firstClickPosition = e.GetPosition ( element );
                _firstClickDone = true;
                _firstClickTime = DateTime.Now;
            }
            else
            {
                var position = e.GetPosition ( element );
                if ( Math.Abs ( _firstClickPosition.X - position.X ) < 4 &&
                     Math.Abs ( _firstClickPosition.Y - position.Y ) < 4 )
                {
                    isDoubleClick = true;
                }
                _firstClickDone = false;
            }

            return isDoubleClick;
        }
开发者ID:divyang4481,项目名称:REM,代码行数:32,代码来源:DoubleClickDetector.cs

示例13: canvasDrawingArea_MouseLeftButtonDown

        private void canvasDrawingArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Shape shapeToRender = null;

            // Configure the correct shape to draw.
            switch (currentShape)
            {
                case SelectedShape.Circle:
                    shapeToRender = new Ellipse() { Fill = Brushes.Green, Height = 35, Width = 35 };
                    break;
                case SelectedShape.Rectangle:
                    shapeToRender = new Rectangle() { Fill = Brushes.Red, Height = 35, Width = 35, RadiusX = 10, RadiusY = 10 };
                    break;
                case SelectedShape.Line:
                    shapeToRender = new Line() { Fill = Brushes.Blue, StrokeThickness = 10, X1 = 0, X2 = 50, Y1 = 0, Y2 = 50 };
                    break;
                default:
                    return;
            }

            // Set top/left position to draw in the canvas.
            Canvas.SetLeft(shapeToRender, e.GetPosition(canvasDrawingArea).X);
            Canvas.SetTop(shapeToRender, e.GetPosition(canvasDrawingArea).Y);

            // Draw shape!
            canvasDrawingArea.Children.Add(shapeToRender);
        }
开发者ID:JamesPinkard,项目名称:WalkthroughSolutions,代码行数:27,代码来源:MainWindow.xaml.cs

示例14: MouseDownEvent

 public void MouseDownEvent(MouseButtonEventArgs e)
 {
     if (e.ButtonState != MouseButtonState.Pressed) return;
     if (!_bDrawStarted)
     {
         Mouse.Capture(_mainCanvas);
         _pMouseStart = e.GetPosition(_mainCanvas);
         _pMouseEnd = e.GetPosition(_mainCanvas);
         _mainCanvas.MouseMove += MainCanvas_MouseMove;
         DoLinePreviewDraw();
     }
     else
     {
         if (_bShiftMode)
         {
             DoLineDraw();
             Mouse.Capture(_mainCanvas);
             DoLinePreviewDraw();
             _pMouseStart = e.GetPosition(_mainCanvas);
         }
         else
         {
             Mouse.Capture(null);
             _pMouseEnd = e.GetPosition(_mainCanvas);
             DoLineDraw();
             _mainCanvas.MouseMove -= MainCanvas_MouseMove;
         }
     }
 }
开发者ID:Neakas,项目名称:ProjectSWN,代码行数:29,代码来源:LineManager.cs

示例15: canvasDrawingArea_MouseLeftButtonDown

        private void canvasDrawingArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Shape shapeToRender = null;

            switch (currentShape)
            { 
                case SelectedShape.Circle:
                    shapeToRender = new Ellipse() { Fill = Brushes.Green, Height = 35, Width = 35 };
                    break;
                case SelectedShape.Rectangle:
                    shapeToRender = new Rectangle() { Fill = Brushes.Red, Height = 35, Width = 35 ,RadiusX = 10, RadiusY = 10};
                    break;
                case SelectedShape.Line:
                    shapeToRender = new Line()
                    {
                        Stroke = Brushes.Blue,
                        StrokeThickness = 10,
                        X1 = 0,
                        X2 = 50,
                        Y1 = 0,
                        Y2 = 50,
                        StrokeStartLineCap = PenLineCap.Triangle,
                        StrokeEndLineCap = PenLineCap.Round
                    };
                    break;
                default:
                    return;
            }

            Canvas.SetLeft(shapeToRender, e.GetPosition(canvasDrawingArea).X);
            Canvas.SetTop(shapeToRender, e.GetPosition(canvasDrawingArea).Y);

            canvasDrawingArea.Children.Add(shapeToRender);
        }
开发者ID:neziry,项目名称:Argeset,代码行数:34,代码来源:MainWindow.xaml.cs


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