예제 #1
0
        // コンストラクタ / ドラッグ開始
        public NodeDragController(NodeDragControllerSetupArgs setupArgs)
        {
            if (setupArgs.Args.LeftButton == MouseButtonState.Pressed)
            {
                _isDrag = true;

                _dragStartPos   = setupArgs.Args.GetPosition(setupArgs.BaseControl);
                _originalPoints = setupArgs.Nodes.ToDictionary(x => x, x => new Point(x.X, x.Y));
            }

            _completedNodeMove = setupArgs.CompletedCommand;
            _selectedNodes     = setupArgs.Nodes;
            _useSnapGrid       = setupArgs.UseSnapGrid;
            _inputElement      = setupArgs.BaseControl;
            _gridSize          = setupArgs.GridSize;
            if (_selectedNodes.Any())
            {
                var control = _selectedNodes.First().FindVisualParentWithType <InfiniteScrollViewer>();
                if (Mouse.Captured == null)
                {
                    _isCaptured = _inputElement.CaptureMouse();
                }
                _scrollViewer = control;
            }
        }
        public void MouseDown(object sender, MouseButtonEventArgs eventArgs)
        {
            PositionToVolume(eventArgs.GetPosition(view).Y);

            _element = (IInputElement)eventArgs.Source;
            _element.CaptureMouse();
            _element.MouseMove += MouseMove;

            isDragging        = true;
            eventArgs.Handled = true;
        }
예제 #3
0
        private void primitivesPalette_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            paletteElement = sender as IInputElement;
            logger.Log("Primitives palette left mouse down " + paletteElement, Category.Debug, Priority.None);

            if (sender == cylinderThumb)
            {
                palettePrimitiveKind = PrimitiveKinds.Cylinder;
            }
            else if (sender == coneThumb)
            {
                palettePrimitiveKind = PrimitiveKinds.Cone;
            }
            else if (sender == sphereThumb)
            {
                palettePrimitiveKind = PrimitiveKinds.Sphere;
            }
            else if (sender == sgcThumb)
            {
                palettePrimitiveKind = PrimitiveKinds.SGC;
            }
            else if (sender == bgcThumb)
            {
                palettePrimitiveKind = PrimitiveKinds.BGC;
            }
            else if (sender == cubeThumb)
            {
                palettePrimitiveKind = PrimitiveKinds.Cuboid;
            }
            else
            {
                logger.Log("Invalid event sender", Category.Exception, Priority.High);
            }

            bool captureSucceeded = paletteElement.CaptureMouse();

            if (!captureSucceeded)
            {
                logger.Log("Unable to capture mouse by a palette element " + sender, Category.Exception, Priority.None);
            }
        }
예제 #4
0
        public void MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (_doubleClickDetected)
            {
                _doubleClickDetected = false;
            }
            else
            if ((DateTime.Now - _doubleClickFirst).TotalMilliseconds < 250)
            {
                ToggleFullscreen(true);
                _doubleClickDetected = true;
            }
            _doubleClickFirst = DateTime.Now;

            _mouseDownPoint   = e.GetPosition(null);
            _dragLastPosition = _mouseDownPoint;
            _drag             = false;
            _element          = (IInputElement)e.Source;
            _element.CaptureMouse();
            _element.MouseMove += MouseMove;
        }
예제 #5
0
        private void RootPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            MouseY = e.GetPosition(this).Y;

            CurrentTranslate = Translate.Y;
            Translate.Y      = CurrentTranslate;

            InputElement = (IInputElement)sender;
            InputElement.CaptureMouse();

            if (MoveBack.GetCurrentState() == ClockState.Active)
            {
                MoveBack.Stop();
            }

            if (MoveUp.GetCurrentState() == ClockState.Active)
            {
                MoveUp.Stop();
            }

            RootPanel.MouseMove += RootPanel_MouseMove;
        }
예제 #6
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
        }
예제 #7
0
 private void OnMouseDown(object sender, MouseButtonEventArgs e)
 {
     _capturing = (IInputElement)e.OriginalSource;
     _capturing.CaptureMouse();
     Console.WriteLine($"[Down] {e.Source.GetType().Name} | {e.OriginalSource.GetType().Name}");
 }
예제 #8
0
 private void ResizeCaptureElement(IInputElement element)
 {
     _isResize = true;
     element?.CaptureMouse();
 }
예제 #9
0
 private void DragCaptureElement(IInputElement element)
 {
     _isDrag = true;
     element?.CaptureMouse();
 }