private static void OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            IInputElement    inputElement     = (IInputElement)sender;
            DependencyObject dependencyObject = (DependencyObject)sender;

            if (inputElement.IsMouseCaptured)
            {
                inputElement.ReleaseMouseCapture();
            }
            if ((bool)dependencyObject.GetValue(Hyperlink.IsHyperlinkPressedProperty))
            {
                dependencyObject.SetValue(Hyperlink.IsHyperlinkPressedProperty, false);
                if (inputElement.IsMouseOver)
                {
                    if (e.UserInitiated)
                    {
                        Hyperlink.DoUserInitiatedNavigation(sender);
                    }
                    else
                    {
                        Hyperlink.DoNonUserInitiatedNavigation(sender);
                    }
                }
            }
            e.Handled = true;
        }
예제 #2
0
        public void MouseUp(MouseButtonEventArgs e)
        {
            if (!_waitingForDoubleClickTimeout)
            {
                _waitingPoint = e.GetPosition(null);
                _waitingForDoubleClickTimeout = true;
                Task.Factory.StartNew(() =>
                {
                    Thread.Sleep(280);
                    Execute.OnUIThread(() =>
                    {
                        if (!_doubleClickDetected)
                        {
                            if (_mouseDownPoint == _waitingPoint && !_drag)
                            {
                                PlayPause();
                            }
                            else
                            {
                            }
                        }
                        _waitingForDoubleClickTimeout = false;
                    });
                });
            }

            if (_element != null)
            {
                _element.ReleaseMouseCapture();
                _element.MouseMove -= MouseMove;
            }
        }
예제 #3
0
        /// <summary>
        /// This is the method that responds to the MouseLeftButtonUpEvent event.
        /// </summary>
        private static void OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            IInputElement    element = (IInputElement)sender;
            DependencyObject dp      = (DependencyObject)sender;

            if (element.IsMouseCaptured)
            {
                element.ReleaseMouseCapture();
            }

            //
            // ISSUE - Leave this here because of 1111993.
            //
            if ((bool)dp.GetValue(IsHyperlinkPressedProperty))
            {
                dp.SetValue(IsHyperlinkPressedProperty, false);

                // Make sure we're mousing up over the hyperlink
                if (element.IsMouseOver)
                {
                    if (e.UserInitiated)
                    {
                        DoUserInitiatedNavigation(sender);
                    }
                    else
                    {
                        DoNonUserInitiatedNavigation(sender);
                    }
                }
            }

            e.Handled = true;
        }
 public void MouseUp(object sender, MouseButtonEventArgs eventArgs)
 {
     if (isDragging && _element != null)
     {
         _element.ReleaseMouseCapture();
         isDragging = false;
     }
 }
        void UIElement_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            IInputElement inputElement = sender as IInputElement;

            if (inputElement == null)
            {
                return;
            }

            inputElement.ReleaseMouseCapture();
            Focus();
            BringToFront();
        }
예제 #6
0
        public static void SetFocus(FrameworkElement frameworkElement)
        {
            IInputElement focusedControl = Keyboard.FocusedElement;


            if (focusedControl != null)
            {
                Keyboard.ClearFocus();

                FocusManager.SetFocusedElement(frameworkElement, frameworkElement);
                focusedControl.ReleaseMouseCapture();
                frameworkElement.Focus();
            }
        }
 protected override void OnDetaching()
 {
     AssociatedObject.RemoveHandler(Mouse.PreviewMouseDownOutsideCapturedElementEvent, _previewMouseDownEventOutsideCapturedElementDelegate);
     if (_capturedFrom != null && _capturedFrom.IsMouseCaptured)
     {
         _capturedFrom.ReleaseMouseCapture();
     }
     AssociatedObject.LostMouseCapture -= AssociatedObjectSubTree_LostMouseCapture;
     if (AssociatedObject.IsMouseCaptured)
     {
         AssociatedObject.ReleaseMouseCapture();
     }
     base.OnDetaching();
 }
예제 #8
0
        public static void Unregister(this IInputElement element)
        {
            if (!dragDatas.ContainsKey(element))
            {
                return;
            }

            dragDatas.Remove(element);

            element.MouseLeftButtonDown      -= Element_MouseLeftButtonDown;
            element.PreviewMouseLeftButtonUp -= Element_PreviewMouseLeftButtonUp;
            element.PreviewMouseMove         -= Element_PreviewMouseMove;

            if (Mouse.Captured.Equals(element))
            {
                element.ReleaseMouseCapture();
            }
        }
예제 #9
0
        private void RootPanel_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (InputElement != null)
            {
                RootPanel.MouseMove -= RootPanel_MouseMove;
                InputElement.ReleaseMouseCapture();
                InputElement     = null;
                CurrentTranslate = 0;

                if (Translate.Y < 0 && Translate.Y > (-ScreenHeight / 2))
                {
                    MoveBack.Begin();
                }
                else if (Translate.Y <= (-ScreenHeight / 2))
                {
                    ((DoubleAnimation)MoveUp.Children[0]).To = -ScreenHeight;
                    MoveUp.Begin();
                }
            }
        }
예제 #10
0
        // ドラッグ完了処理
        private void Completed()
        {
            if (_isCaptured)
            {
                _inputElement.ReleaseMouseCapture();
            }

            if (_isDrag)
            {
                _isDrag = false;
                if (_isMoved & _completedNodeMove != null)
                {
                    // ドラッグ開始前座標
                    var initial = _originalPoints.ToDictionary(x => x.Key.DataContext as INodeDataContext, x => x.Value);

                    // ドラッグ完了後座標
                    var completed = _selectedNodes.ToDictionary(x => x.DataContext as INodeDataContext, x => new Point(x.X, x.Y));

                    //! 完了コマンドを発行する(undo / redo したい場合等に利用する)
                    _completedNodeMove?.Execute(new CompletedMoveNodeEventArgs(initial, completed));
                }
            }
        }
        // Token: 0x06003050 RID: 12368 RVA: 0x000D90F4 File Offset: 0x000D72F4
        private static void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            IInputElement    inputElement     = (IInputElement)sender;
            DependencyObject dependencyObject = (DependencyObject)sender;

            inputElement.Focus();
            if (e.ButtonState == MouseButtonState.Pressed)
            {
                Mouse.Capture(inputElement);
                if (inputElement.IsMouseCaptured)
                {
                    if (e.ButtonState == MouseButtonState.Pressed)
                    {
                        dependencyObject.SetValue(Hyperlink.IsHyperlinkPressedProperty, true);
                    }
                    else
                    {
                        inputElement.ReleaseMouseCapture();
                    }
                }
            }
            e.Handled = true;
        }
예제 #12
0
        /// <summary>
        /// This is the method that responds to the MouseLeftButtonEvent event.
        /// </summary>
        private static void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            IInputElement    element = (IInputElement)sender;
            DependencyObject dp      = (DependencyObject)sender;

            // Hyperlink should take focus when left mouse button is clicked on it
            // This is consistent with all ButtonBase controls and current Win32 behavior
            element.Focus();

            // It is possible that the mouse state could have changed during all of
            // the call-outs that have happened so far.
            if (e.ButtonState == MouseButtonState.Pressed)
            {
                // Capture the mouse, and make sure we got it.
                Mouse.Capture(element);
                if (element.IsMouseCaptured)
                {
                    // Though we have already checked this state, our call to CaptureMouse
                    // could also end up changing the state, so we check it again.

                    //
                    // ISSUE - Leave this here because of 1111993.
                    //
                    if (e.ButtonState == MouseButtonState.Pressed)
                    {
                        dp.SetValue(IsHyperlinkPressedProperty, true);
                    }
                    else
                    {
                        // Release capture since we decided not to press the button.
                        element.ReleaseMouseCapture();
                    }
                }
            }

            e.Handled = true;
        }
예제 #13
0
        /// <summary>
        /// Cancels the drag operation
        /// </summary>
        public void CancelDrag()
        {
            if (!IsDragging)
            {
                return;
            }

            var delta = _last - _origin;

            OnDragCompleted(new MouseDragEventArgs(
                                Mouse.MouseMoveEvent,
                                Mouse.PrimaryDevice,
                                0,
                                MouseButton.Left,
                                _origin,
                                Mouse.GetPosition(_parent),
                                delta));

            _origin     = new Point();
            _last       = new Point();
            _isDragging = false;

            _listItem.ReleaseMouseCapture();
        }
        void UIElement_OnPreviewMouseMove(object sender, MouseEventArgs e)
        {
            IInputElement inputElement = sender as IInputElement;

            if (inputElement == null)
            {
                return;
            }

            Point  tempPoint = e.GetPosition(sender as IInputElement);
            double xDelta    = Math.Abs(tempPoint.X - _mousedownPoint.X);
            double yDelta    = Math.Abs(tempPoint.Y - _mousedownPoint.Y);

            if (e.LeftButton == MouseButtonState.Pressed && _startManualDrag && Math.Max(xDelta, yDelta) >= 5)
            {
#pragma warning disable 618
                DragDropHelper.DoDragMove(this, e.GetPosition(this));
#pragma warning restore 618
                _startManualDrag = false;
                inputElement.ReleaseMouseCapture();
                Focus();
                BringToFront();
            }
        }
예제 #15
0
 private void ReleaseResizeCaptureElement(IInputElement element)
 {
     element?.ReleaseMouseCapture();
     _isResize  = false;
     _lastPoint = default(Point);
 }
예제 #16
0
 private void OnMouseUp(object sender, MouseButtonEventArgs e)
 {
     Console.WriteLine($"[ Up ] {e.Source.GetType().Name} | {e.OriginalSource.GetType().Name}");
     _capturing?.ReleaseMouseCapture();
 }
예제 #17
0
파일: ThemedWindow.cs 프로젝트: Techide/DMC
        private void RegisterBorderEvents(WindowBorderEdge borderEdge, IInputElement border)
        {
            #region MouseEnter
            border.MouseEnter += (sender, e) =>
                {
                    if (WindowState != WindowState.Maximized && ResizeMode == ResizeMode.CanResize)
                    {
                        _normalBorderStyle = (Brush)TryFindResource("BorderBrush");
                        _highlightBorderBrush = (Brush)TryFindResource("BorderHighlightBrush");

                        switch (borderEdge)
                        {
                            case WindowBorderEdge.Left:
                                using (var cursor = new OverrideCursor(Cursors.SizeWE))
                                {
                                    _borderLeft.Background = _highlightBorderBrush;
                                }
                                    _borderLeft.Background = _highlightBorderBrush;
                                break;
                            case WindowBorderEdge.Right:
                                using (var cursor = new OverrideCursor(Cursors.SizeWE))
                                {

                                }
                            //Cursor = Cursors.SizeWE;
                                break;
                            case WindowBorderEdge.Top:
                            case WindowBorderEdge.Bottom:
                                using (var cursor = new OverrideCursor(Cursors.SizeNS))
                                {

                                }
                                //Cursor = Cursors.SizeNS;
                                break;
                            case WindowBorderEdge.TopLeft:
                            case WindowBorderEdge.BottomRight:
                                using (var cursor = new OverrideCursor(Cursors.SizeNWSE))
                                {

                                }
                                //Cursor = Cursors.SizeNWSE;
                                break;
                            case WindowBorderEdge.TopRight:
                            case WindowBorderEdge.BottomLeft:
                                using (var cursor = new OverrideCursor(Cursors.SizeNESW))
                                {

                                }
                                //Cursor = Cursors.SizeNESW;
                                break;
                        }
                    }
                    //else
                    //{
                    //    Cursor = Cursors.Arrow;
                    //}
                };
            #endregion

            #region MouseLeave
            //border.MouseLeave += (sender, e) => Cursor = Cursors.Arrow;
            #endregion

            #region MouseLeftButtonDown
            border.MouseLeftButtonDown += (sender, e) =>
                {
                    if (WindowState != WindowState.Maximized && ResizeMode == ResizeMode.CanResize)
                    {
                        var cursorLocation = e.GetPosition(this);
                        var cursorOffset = new Point();

                        switch (borderEdge)
                        {
                            case WindowBorderEdge.Left:
                                cursorOffset.X = cursorLocation.X;
                                break;
                            case WindowBorderEdge.TopLeft:
                                cursorOffset.X = cursorLocation.X;
                                cursorOffset.Y = cursorLocation.Y;
                                break;
                            case WindowBorderEdge.Top:
                                cursorOffset.Y = cursorLocation.Y;
                                break;
                            case WindowBorderEdge.TopRight:
                                cursorOffset.X = (Width - cursorLocation.X);
                                cursorOffset.Y = cursorLocation.Y;
                                break;
                            case WindowBorderEdge.Right:
                                cursorOffset.X = (Width - cursorLocation.X);
                                break;
                            case WindowBorderEdge.BottomRight:
                                cursorOffset.X = (Width - cursorLocation.X);
                                cursorOffset.Y = (Height - cursorLocation.Y);
                                break;
                            case WindowBorderEdge.Bottom:
                                cursorOffset.Y = (Height - cursorLocation.Y);
                                break;
                            case WindowBorderEdge.BottomLeft:
                                cursorOffset.X = cursorLocation.X;
                                cursorOffset.Y = (Height - cursorLocation.Y);
                                break;
                        }

                        _cursorOffset = cursorOffset;

                        border.CaptureMouse();
                    }
                };
            #endregion

            #region MouseMove
            //border.PreviewMouseMove

            border.MouseMove += (sender, e) =>
                {
                    if (WindowState != WindowState.Maximized && border.IsMouseCaptured && ResizeMode == ResizeMode.CanResize)
                    {
                        var cursorLocation = e.GetPosition(this);

                        var nHorizontalChange = (cursorLocation.X - _cursorOffset.X);
                        var pHorizontalChange = (cursorLocation.X + _cursorOffset.X);
                        var nVerticalChange = (cursorLocation.Y - _cursorOffset.Y);
                        var pVerticalChange = (cursorLocation.Y + _cursorOffset.Y);

                        switch (borderEdge)
                        {
                            case WindowBorderEdge.Left:
                                if (Width - nHorizontalChange <= MinWidth) break;
                                Left += nHorizontalChange;
                                Width -= nHorizontalChange;
                                break;
                            case WindowBorderEdge.TopLeft:
                                if (!(Width - nHorizontalChange <= MinWidth))
                                {
                                    Left += nHorizontalChange;
                                    Width -= nHorizontalChange;
                                }
                                if (!(Height - nVerticalChange <= MinHeight))
                                {
                                    Top += nVerticalChange;
                                    Height -= nVerticalChange;
                                }
                                break;
                            case WindowBorderEdge.Top:
                                if (Height - nVerticalChange <= MinHeight) break;
                                Top += nVerticalChange;
                                Height -= nVerticalChange;
                                break;
                            case WindowBorderEdge.TopRight:
                                if (!(pHorizontalChange <= MinWidth))
                                {
                                    Width = pHorizontalChange;
                                }
                                if (!(Height - nVerticalChange <= MinHeight))
                                {
                                    Top += nVerticalChange;
                                    Height -= nVerticalChange;
                                }
                                break;
                            case WindowBorderEdge.Right:
                                if (pHorizontalChange <= MinWidth) break;
                                Width = pHorizontalChange;
                                break;
                            case WindowBorderEdge.BottomRight:
                                if (!(pHorizontalChange <= MinWidth))
                                {
                                    Width = pHorizontalChange;
                                }
                                if (!(pVerticalChange <= MinHeight))
                                {
                                    Height = pVerticalChange;
                                }
                                break;
                            case WindowBorderEdge.Bottom:
                                if (pVerticalChange <= MinHeight) break;
                                Height = pVerticalChange;
                                break;
                            case WindowBorderEdge.BottomLeft:
                                if (!(Width - nHorizontalChange <= MinWidth))
                                {
                                    Left += nHorizontalChange;
                                    Width -= nHorizontalChange;
                                }
                                if (!(pVerticalChange <= MinHeight))
                                {
                                    Height = pVerticalChange;
                                }

                                break;
                        }
                    }
                };
            #endregion

            #region MouseLeftButtonUp
            border.MouseLeftButtonUp += (sender, e) => border.ReleaseMouseCapture();
            #endregion
        }