Beispiel #1
0
        /// <summary>
        /// 填充拖动信息.
        /// </summary>
        /// <param name="tw">文本输出者.</param>
        /// <param name="e">鼠标事件.</param>
        private void FillDragInfo(TextWriter tw, MouseEventArgs e)
        {
            if (null == e)
            {
                return;
            }
            ContentControl btnDrag = this.lblDrag;

            tw.WriteLine("[MouseEventArgs]");
            tw.WriteLine(string.Format("Timestamp: {0}", e.Timestamp));
            tw.WriteLine(string.Format("GetPosition(btnDrag): {0}", e.GetPosition(btnDrag)));
            tw.WriteLine(string.Format("GetPosition(grdMain): {0}", e.GetPosition(grdMain)));
            tw.WriteLine(string.Format("GetPosition(grdRoot): {0}", e.GetPosition(grdRoot)));
            tw.WriteLine();
            // MouseDevice
            MouseDevice md = e.MouseDevice;

            if (null == md)
            {
                return;
            }
            tw.WriteLine("[MouseDevice]");
            //tw.WriteLine(string.Format("ToString: {0}", md));
            tw.WriteLine(string.Format("GetPosition(btnDrag): {0}", md.GetPosition(btnDrag)));
            tw.WriteLine();
            // PointToScreen.
            tw.WriteLine("[Screen Point]");
            tw.WriteLine(string.Format("MouseEventArgs: {0}", btnDrag.PointToScreen(e.GetPosition(btnDrag))));
            tw.WriteLine(string.Format("MouseDevice: {0}", btnDrag.PointToScreen(md.GetPosition(btnDrag))));
            tw.WriteLine(string.Format("Control.MousePosition: {0}", System.Windows.Forms.Control.MousePosition));
            tw.WriteLine(string.Format("Cursor.Position: {0}", System.Windows.Forms.Cursor.Position));
            tw.WriteLine();
        }
        //-------------------------------------------------------------------------------
        //
        // Protected Methods
        //
        //-------------------------------------------------------------------------------

        #region Protected Methods

        /// <summary>
        ///     Attaching to the element, we get attached in StylusDown
        /// </summary>
        protected override void OnActivate()
        {
            _actionStarted = false;

            // Capture the mouse.
            InitializeCapture();

            // Hittest for the grab handle
            MouseDevice mouse = Mouse.PrimaryDevice;

            _hitResult = InkCanvas.SelectionAdorner.SelectionHandleHitTest(
                mouse.GetPosition((IInputElement)(InkCanvas.SelectionAdorner)));

            Debug.Assert(_hitResult != InkCanvasSelectionHitResult.None);
            EditingCoordinator.InvalidateBehaviorCursor(this);

            // Get the current selection bounds.
            _selectionRect = InkCanvas.GetSelectionBounds( );

            // Set the initial tracking position and rectangle
            _previousLocation = mouse.GetPosition(InkCanvas.SelectionAdorner);
            _previousRect     = _selectionRect;

            // Start the feedback rubber band.
            InkCanvas.InkCanvasSelection.StartFeedbackAdorner(_selectionRect, _hitResult);

            // Add handlers to the mouse events.
            InkCanvas.SelectionAdorner.AddHandler(Mouse.MouseUpEvent, new MouseButtonEventHandler(OnMouseUp));
            InkCanvas.SelectionAdorner.AddHandler(Mouse.MouseMoveEvent, new MouseEventHandler(OnMouseMove));
            InkCanvas.SelectionAdorner.AddHandler(UIElement.LostMouseCaptureEvent,
                                                  new MouseEventHandler(OnLostMouseCapture));
        }
        // Token: 0x06006DD3 RID: 28115 RVA: 0x001F9918 File Offset: 0x001F7B18
        protected override void OnActivate()
        {
            this._actionStarted = false;
            this.InitializeCapture();
            MouseDevice primaryDevice = Mouse.PrimaryDevice;

            this._hitResult = base.InkCanvas.SelectionAdorner.SelectionHandleHitTest(primaryDevice.GetPosition(base.InkCanvas.SelectionAdorner));
            base.EditingCoordinator.InvalidateBehaviorCursor(this);
            this._selectionRect    = base.InkCanvas.GetSelectionBounds();
            this._previousLocation = primaryDevice.GetPosition(base.InkCanvas.SelectionAdorner);
            this._previousRect     = this._selectionRect;
            base.InkCanvas.InkCanvasSelection.StartFeedbackAdorner(this._selectionRect, this._hitResult);
            base.InkCanvas.SelectionAdorner.AddHandler(Mouse.MouseUpEvent, new MouseButtonEventHandler(this.OnMouseUp));
            base.InkCanvas.SelectionAdorner.AddHandler(Mouse.MouseMoveEvent, new MouseEventHandler(this.OnMouseMove));
            base.InkCanvas.SelectionAdorner.AddHandler(UIElement.LostMouseCaptureEvent, new MouseEventHandler(this.OnLostMouseCapture));
        }
Beispiel #4
0
        public Point GetExtentPoint(MouseDevice device)
        {
            var point = device.GetPosition(this);

            var x = point.X + _horizontalOffset;
            var y = point.Y + _verticalOffset;

            if (x < 0)
            {
                x = 0;
            }
            else if (x > _extentWidth)
            {
                x = _extentWidth;
            }

            if (y < 0)
            {
                y = 0;
            }
            else if (y > _extentHeight)
            {
                y = _extentHeight;
            }

            return(new Point(x, y));
        }
Beispiel #5
0
        public FSharpOption <VimPoint> GetPosition(ITextView textView)
        {
            if (textView is IWpfTextView wpfTextView)
            {
                var position = _mouseDevice.GetPosition(wpfTextView.VisualElement);
                return(FSharpOption.Create(new VimPoint(x: position.X, y: position.Y)));
            }

            return(null);
        }
        public Point?GetPosition(ITextView textView)
        {
            var wpfTextView = textView as IWpfTextView;

            if (wpfTextView != null)
            {
                return(_mouseDevice.GetPosition(wpfTextView.VisualElement));
            }

            return(null);
        }
        Point?GetMousePoint(MouseDevice device)
        {
            if (wpfHexView == null)
            {
                return(null);
            }
            var mousePos = device.GetPosition(wpfHexView.VisualElement);

            mousePos.X += wpfHexView.ViewportLeft;
            mousePos.Y += wpfHexView.ViewportTop;
            return(mousePos);
        }
Beispiel #8
0
        private void ImgMain_MouseMove(object sender, MouseEventArgs e)
        {
            try
            {
                Refresh();


                //Console.WriteLine(@" debut moseMove ");

                UIElement element = sender as UIElement;

                if (element != null)
                {
                    UIElement ele = element;

                    MouseDevice mouse = e.MouseDevice;
                    Point       point = mouse.GetPosition(ele);


                    //Console.WriteLine(@" emouse.GetPosition : " + point);


                    using (DrawingContext dc = this.m_drawingGroup.Open())
                    {
                        m_goHInterface.AddVisualInterface(dc, this.ZoneDessinRectangle);

                        if (mouse.LeftButton.Equals(MouseButtonState.Pressed))
                        {
                            this.m_bw = m_goHInterface.AddMainFermer(point, dc, this.ZoneDessinRectangle);
                            this.m_bw.RunWorkerCompleted += Bw_RunWorkerCompleted;
                        }
                        else
                        {
                            m_goHInterface.AddMainOuverte(point, dc, ImageSource.Width, ImageSource.Height);
                        }
                    }

                    this.ImgMain.Source = this.ImageSource;
                }
                else
                {
                    Console.WriteLine(@" element <=> null ");
                }

                //Console.WriteLine(@" fin mouseMove ");
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.ToString());
                Console.ForegroundColor = ConsoleColor.Gray;
            }
        }
Beispiel #9
0
        private void OnScrollTimer(object sender, EventArgs e)
        {
            // Don't attempt to scroll the text view during a layout.
            if (_wpfTextView.InLayout)
            {
                return;
            }

            // Make sure the timer event is still relevant.
            if (_wpfTextView.IsClosed ||
                !_wpfTextView.HasAggregateFocus ||
                !_mouseCaptured ||
                !_wpfTextView.VisualElement.IsMouseCaptured ||
                _mouseDevice.LeftButton != MouseButtonState.Pressed)
            {
                _mouseCaptured         = false;
                _scrollTimer.IsEnabled = false;
                return;
            }

            // Check whether we should scroll the text view.
            var mousePoint      = _mouseDevice.GetPosition(_wpfTextView.VisualElement);
            var lineHeight      = _wpfTextView.LineHeight;
            var scrollDirection = null as ScrollDirection?;
            var lines           = 1;

            if (mousePoint.Y < 0)
            {
                if (!GetIsFirstLineVisible())
                {
                    scrollDirection = ScrollDirection.Up;
                    lines           = (int)Math.Ceiling((0 - mousePoint.Y) / lineHeight);
                }
            }
            if (mousePoint.Y > _wpfTextView.ViewportHeight)
            {
                if (!GetIsLastLineVisible())
                {
                    scrollDirection = ScrollDirection.Down;
                    lines           = (int)Math.Ceiling((mousePoint.Y - _wpfTextView.ViewportHeight) / lineHeight);
                }
            }

            // If we should scroll, scroll the text view and process a virtual
            // drag event.
            if (scrollDirection.HasValue)
            {
                _wpfTextView.ViewScroller.ScrollViewportVerticallyByLines(scrollDirection.Value, lines);
                TryProcessDrag(MouseButtonState.Pressed, VimKey.LeftDrag);
            }
        }
Beispiel #10
0
 public static string ToText(this MouseDevice d)
 {
     if (d != null)
     {
         return("Position: " + d.GetPosition(d.Target).ToText()
                + " Left: " + d.LeftButton.ToString()
                + " Middle: " + d.MiddleButton.ToString()
                + " Right: " + d.RightButton.ToString());
     }
     else
     {
         return("MouseDevice: null");
     }
 }
        private void FirstTouchPad(Image TargetButton)
        {
            MouseDevice myStylusDevice = Mouse.PrimaryDevice;

            Stylus.Capture(TargetButton);
            Point pos = myStylusDevice.GetPosition(TargetButton);

            Stylus.Capture(Pad01);
            dPadPointX   = Pad01.RenderSize.Width / 2;
            dPadPointY   = Pad01.RenderSize.Height / 2;
            dStartPointX = pos.X - dPadPointX;
            dStartPointY = pos.Y - dPadPointY;
            flg          = true;
        }
Beispiel #12
0
        //<SnippetMouseRelatedSnippetsPositionMouseDevice>
        private void MouseMoveMouseDeviceHandler(object sender, RoutedEventArgs e)
        {
            MouseDevice currentMouseDevice = Mouse.PrimaryDevice;
            Point       position;
            StackPanel  source;

            source = e.Source as StackPanel;

            if (source != null)
            {
                position = currentMouseDevice.GetPosition(source);
                txtBoxMouseDevicePosition.Text = "X: " + position.X +
                                                 "\n" +
                                                 "Y: " + position.Y;
            }
        }
        void ToggleCombobox(MouseDevice mouse, ComboBox comboBox)
        {
            Point cursorPos = mouse.GetPosition(comboBox);
            Size  size      = comboBox.RenderSize;

            if (cursorPos.X >= 0 &&
                cursorPos.X <= size.Width &&
                cursorPos.Y >= 0 &&
                cursorPos.Y <= size.Height)
            {
                EnableDisableCombobox(comboBox);
            }
            //MessageBox.Show(string.Format(
            //    "{0} = ({1}, {2})\n[{3};{4}]",
            //    comboBox.Name, cursorPos.X, cursorPos.Y,
            //    size.Width, size.Height));
        }
        /// <summary>
        ///アクティブなソフトによってはスタイラスイベントが発生しない場合があるので
        ///ウィンドウメッセージを拾ってこっちを呼び出す
        /// </summary>
        /// <param name="TargetButton">処理対象偽ボタンコントロール</param>
        private void FirstTouch(Image TargetButton, FrickData fd)
        {
            MouseDevice myStylusDevice = Mouse.PrimaryDevice;

            Stylus.Capture(TargetButton);
            Point pos = myStylusDevice.GetPosition(TargetButton);

            dStartPointX             = pos.X;
            dStartPointY             = pos.Y;
            FrickPopImage.Source     = PopImageC;
            PopTextC.Text            = fd.PopText[0];
            PopTextU.Text            = fd.PopText[1];
            PopTextD.Text            = fd.PopText[2];
            PopTextL.Text            = fd.PopText[3];
            PopTextR.Text            = fd.PopText[4];
            FrickPop.PlacementTarget = TargetButton;
            FrickPop.IsOpen          = true;
        }
        /******************************************************************************/

        #region Private Methods
        /// <summary>
        /// Process a mouse event.
        /// </summary>
        /// <param name="mouse"></param>
        private void ProcessMouse(MouseDevice mouse)
        {
            if ((mouse.Captured == this))
            {
                Point position = mouse.GetPosition(Container);

                List <Manipulator2D> manipulators = new List <Manipulator2D>();
                manipulators.Add(new Manipulator2D(
                                     0,
                                     (float)(position.X),
                                     (float)(position.Y)));

                // If translation is turned off and the pivot is turned on,
                // make it act like there's a manipulator on the pivot point,
                // to allow us to do scaling
                if (((SupportedManipulations & Manipulations2D.Translate) == Manipulations2D.None) &&
                    IsPivotActive)
                {
                    manipulators.Add(new Manipulator2D(
                                         1,
                                         (float)(Center.X),
                                         (float)(Center.Y)));
                }

                const Manipulations2D translateAndRotate = Manipulations2D.Translate | Manipulations2D.Rotate;
                if ((manipulators.Count == 1) &&
                    ((manipulationProcessor.SupportedManipulations & translateAndRotate) == translateAndRotate) &&
                    IsPivotActive)
                {
                    dragCenter = position;
                }
                else
                {
                    dragCenter.X = double.NaN;
                    dragCenter.Y = double.NaN;
                }

                manipulationProcessor.ProcessManipulators(
                    Timestamp,
                    manipulators);
            }
        }
Beispiel #16
0
        private void ImgMain_MouseMove(object sender, MouseEventArgs e)
        {
            //Console.WriteLine(@" debut moseMove ");

            UIElement element = sender as UIElement;

            if (element != null)
            {
                UIElement ele = element;

                MouseDevice mouse = e.MouseDevice;
                Point       point = mouse.GetPosition(ele);


                //Console.WriteLine(@" emouse.GetPosition : " + point);


                using (DrawingContext dc = this.m_drawingGroup.Open())
                {
                    m_goHInterface.AddVisualInterface(dc, this.ZoneDessinRectangle);

                    if (mouse.LeftButton.Equals(MouseButtonState.Pressed))
                    {
                        m_goHInterface.AddMainFermer(point, dc, this.ZoneDessinRectangle);
                    }
                    else
                    {
                        m_goHInterface.AddMainOuverte(point, dc, ImageSource.Width, ImageSource.Height);
                    }
                }
            }
            else
            {
                Console.WriteLine(@" element <=> null ");
            }

            Refresh();


            //Console.WriteLine(@" fin mouseMove ");
        }
Beispiel #17
0
        private void UpdateBrushPreview()
        {
            double      num;
            double      canvasHairWidth;
            PointDouble position;

            base.VerifyAccess();
            if (base.Tool == null)
            {
                num = 0.0;
            }
            else
            {
                num = (double)base.Tool.ToolSettings.Pen.Width.Value;
            }
            if (base.CanvasView == null)
            {
                canvasHairWidth = 1.0;
            }
            else
            {
                canvasHairWidth = base.CanvasView.CanvasHairWidth;
            }
            MouseDevice mouseDevice = base.GetMouseDevice();

            if ((mouseDevice == null) || !mouseDevice.CurrentTargetPosition.HasValue)
            {
                position = new PointDouble(-131072.0, -131072.0);
            }
            else
            {
                position = mouseDevice.GetPosition(this);
            }
            double num4 = (num / 2.0) / canvasHairWidth;

            this.brushPreviewDrawing.Radius = num4;
            RectDouble num5 = new RectDouble(position, new SizeDouble(canvasHairWidth, canvasHairWidth));

            this.mouseCenterPt.Value = num5.Center;
        }
        private bool HandleMouse(MouseDevice mouse)
        {
            var position = mouse.GetPosition(GraphicsControl);
            var state    = new MouseState(
                (int)position.X, (int)position.Y, 0,
                mouse.LeftButton == MouseButtonState.Pressed ? ButtonState.Pressed : ButtonState.Released,
                mouse.MiddleButton == MouseButtonState.Pressed ? ButtonState.Pressed : ButtonState.Released,
                mouse.RightButton == MouseButtonState.Pressed ? ButtonState.Pressed : ButtonState.Released,
                mouse.XButton1 == MouseButtonState.Pressed ? ButtonState.Pressed : ButtonState.Released,
                mouse.XButton2 == MouseButtonState.Pressed ? ButtonState.Pressed : ButtonState.Released);

            if (_skipHandleMouseMove)
            {
                _previousMouseState  = _currentMouseState;
                _currentMouseState   = state;
                _skipHandleMouseMove = false;
                return(false);
            }

            UpdateMouse(state);

            return(true);
        }
Beispiel #19
0
        public Point GetPointInViewRootCoordinates(MouseDevice mouseDevice, bool snapPoint)
        {
            Point point = this.View.Artboard.CalculateTransformFromArtboardToContent().Value.Transform(mouseDevice.GetPosition((IInputElement)this.View.Artboard));

            if (snapPoint)
            {
                point = this.ViewModel.DesignerContext.SnappingEngine.SnapPoint(point);
            }
            return(point);
        }
Beispiel #20
0
 public IAdorner GetHitAdorner(MouseDevice mouseDevice, Type[] adornerFilterTypes)
 {
     return(this.GetHitAdorner(mouseDevice.GetPosition((IInputElement)this.ContentArea), adornerFilterTypes));
 }
        public void UpdateTarget(MouseDevice mouseDevice, FrameworkElement target, Orientation orientation)
        {
            Point  itemsControlTestPoint = mouseDevice.GetPosition(AdornedElement);
            Point  targetTestPoint       = mouseDevice.GetPosition(target);
            Vector offset = itemsControlTestPoint - targetTestPoint;
            double width  = target.ActualWidth;
            double height = target.ActualHeight;

            this.leftTop     = new Point(offset.X, offset.Y);
            this.topRight    = new Point(offset.X + width, offset.Y);
            this.rightBottom = new Point(offset.X + width, offset.Y + height);
            this.bottomLeft  = new Point(offset.X, offset.Y + height);

            double centerWidth = width / 2d;
            double centerHight = height / 2d;

            this.direction = DirectionEnum.None;
            switch (orientation)
            {
            case Orientation.Horizontal:
            {
                this.direction |= DirectionEnum.Top;
                this.direction |= DirectionEnum.Bottom;
                if (targetTestPoint.X <= centerWidth)
                {
                    this.direction |= DirectionEnum.Left;
                }
                else
                {
                    this.direction |= DirectionEnum.Right;
                }
            }
            break;

            default:
            case Orientation.Vertical:
            {
                this.direction |= DirectionEnum.Right;
                this.direction |= DirectionEnum.Left;
                if (targetTestPoint.Y <= centerHight)
                {
                    this.direction |= DirectionEnum.Top;
                }
                else
                {
                    this.direction |= DirectionEnum.Bottom;
                }
            }
            break;
            }

            if ((this.direction & DirectionEnum.TopLine) == DirectionEnum.TopLine)
            {
                DropPosition = DropPositionEnum.Before;
            }

            if ((this.direction & DirectionEnum.RightLine) == DirectionEnum.RightLine)
            {
                DropPosition = DropPositionEnum.After;
            }

            if ((this.direction & DirectionEnum.BottomLine) == DirectionEnum.BottomLine)
            {
                DropPosition = DropPositionEnum.After;
            }

            if ((this.direction & DirectionEnum.LeftLine) == DirectionEnum.LeftLine)
            {
                DropPosition = DropPositionEnum.Before;
            }

            InvalidateVisual();
        }