protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (_isMouseDown) { if (!IsMouseCaptured) { CaptureMouse(); } Point ptMouseMove = e.GetPosition(this); if (Math.Abs(ptMouseMove.X - _mouseDownPoint.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(ptMouseMove.Y - _mouseDownPoint.Y) > SystemParameters.MinimumVerticalDragDistance) { _isMouseDown = false; if (IsMouseCaptured) { ReleaseMouseCapture(); } if (Mouse.Captured != null) { Mouse.Captured.ReleaseMouseCapture(); } if (DragCommand != null) { DragCommand.Execute(CommandParameter); } UpdateCursor(); } } }
public NodeViewModel(object key, int size) : base(new NodeViewModelValidator()) { SelectCommand = new SelectCommand(this); DragCommand = new DragCommand(this); ReSizeCommand = new ReSizeCommand(this); Size = size; Key = key; this.PropertyChanged += NodeViewModel_PropertyChanged; }
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { base.OnMouseLeftButtonDown(e); if (e.ClickCount == 1 && ((DragCommand != null && DragCommand.CanExecute(CommandParameter)) || (ClickCommand != null && ClickCommand.CanExecute(CommandParameter)))) { _mouseDownPoint = e.GetPosition(this); _isMouseDown = true; CaptureMouse(); } }
private void InitCommands() { DragCommand = new DragCommand(this); MinimizeCommand = new MinimizeCommand(this); MaximizeCommand = new MaximizeCommand(this); QuitCommand = new QuitCommand(this); NewCommand = new NewCommand(this); ExportCommand = new ExportCommand(this); ChangeHeightCommand = new ChangeHeightCommand(this); DetailResolutionCommand = new DetailResolutionCommand(this); HelpCommand = new HelpCommand(this); }
public FluentSessionRecorder To(IElement elementB) { IActionCommand command = null; switch (_refToPointA) { case RefToPointA.Selector: command = new DragCommand(_selectorA, elementB); break; case RefToPointA.Element: throw new NotImplementedException(); case RefToPointA.Offset: command = new DragCommand(_xOffsetToA, _yOffsetToA, elementB); break; } _performer.Perform(command); return(_recorder); }
/*-------------------------------------------------------------------*/ public FluentSessionRecorder To(string selectorB) { IActionCommand command = null; switch (_refToPointA) { case RefToPointA.Selector: command = new DragCommand(_selectorA, selectorB); break; case RefToPointA.Element: command = new DragCommand(_elementA, selectorB); break; case RefToPointA.Offset: command = new DragCommand(_xOffsetToA, _yOffsetToA, selectorB); break; } _performer.Perform(command); return(_recorder); }
private void UpdateCursor() { Cursor = (DragCommand != null && DragCommand.CanExecute(CommandParameter)) || (ClickCommand != null && ClickCommand.CanExecute(CommandParameter)) ? Cursors.Hand : Cursors.Arrow; }
public void SetUp() { _defaultCommand = new DragCommand(DefaultSelector, DefaultSelector); }