public override bool Equals(object obj) { if (obj == null) { return(false); } RemoteRect r = (RemoteRect)obj; return(r.X == X && r.Y == Y && r.Width == Width && r.Height == Height); }
protected override void OnPreviewMouseUp(MouseButtonEventArgs e) { base.OnPreviewMouseUp(e); if (_isMouseDown) { _isMouseDown = false; Rectangles.Add(CurrentRect); FinishRectangleCommand?.Execute(CurrentRect); CurrentRect = new RemoteRect(); } }
protected override void OnPreviewMouseDown(MouseButtonEventArgs e) { base.OnPreviewMouseDown(e); _startPoint = e.GetPosition(this); CurrentRect = new RemoteRect() { X = _startPoint.X, Y = _startPoint.Y, }; StartRectangleCommand?.Execute(new RemotePoint() { X = _startPoint.X, Y = _startPoint.Y }); _isMouseDown = true; }
protected override void OnPreviewMouseMove(MouseEventArgs e) { base.OnPreviewMouseMove(e); if (_isMouseDown) { Point position = e.GetPosition(this); double l = Math.Min(_startPoint.X, position.X); double t = Math.Min(_startPoint.Y, position.Y); double r = Math.Max(_startPoint.X, position.X); double b = Math.Max(_startPoint.Y, position.Y); CurrentRect = new RemoteRect() { X = l, Y = t, Width = r - l, Height = b - t }; SizeRectangleCommand?.Execute(CurrentRect); } }