當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。