public void MoveDown() { if (_rectangle == null) { return; } var shape = GetShape(); if (shape.Y + shape.Height + 1 <= _canvas.Height) { shape.Y++; SetShape(shape); OnShapeChanged?.Invoke(shape); } }
public void MoveRight() { if (_rectangle == null) { return; } var shape = GetShape(); if (shape.X + shape.Width + 1 <= _canvas.Width) { shape.X++; SetShape(shape); OnShapeChanged?.Invoke(shape); } }
public void MoveUp() { if (_rectangle == null) { return; } var shape = GetShape(); if (shape.Y >= 1) { shape.Y--; SetShape(shape); OnShapeChanged?.Invoke(shape); } }
public void ShrinkRight() { if (_rectangle == null) { return; } var shape = GetShape(); if (shape.Width > 1) { shape.Width--; SetShape(shape); OnShapeChanged?.Invoke(shape); } }
public void ExpandBottom() { if (_rectangle == null) { return; } var shape = GetShape(); if (shape.Height + shape.Y + 1 <= _canvas.Height) { shape.Height = shape.Height + 1; SetShape(shape); OnShapeChanged?.Invoke(shape); } }
public void ShrinkBottom() { if (_rectangle == null) { return; } var shape = GetShape(); if (shape.Height > 1) { shape.Height = shape.Height - 1; SetShape(shape); OnShapeChanged?.Invoke(shape); } }
public void ExpandLeft() { if (_rectangle == null) { return; } var shape = GetShape(); if (shape.X >= 1) { shape.X--; shape.Width++; SetShape(shape); OnShapeChanged?.Invoke(shape); } }
public void ExpandTop() { if (_rectangle == null) { return; } var shape = GetShape(); if (shape.Y >= 1) { shape.Y = shape.Y - 1; shape.Height = shape.Height + 1; SetShape(shape); OnShapeChanged?.Invoke(shape); } }
public void OnMouseUp(object sender, MouseButtonEventArgs e) { Point position = e.GetPosition(_canvas); if (!IsInValidRegion(position)) { return; } if (!_inMovingState) { return; } position.X = Math.Round(position.X); position.Y = Math.Round(position.Y); OnMouseMove(position); LeaveModificationMode(); e.Handled = true; OnShapeChanged?.Invoke(GetShape()); }
void PassShapeChangedNotice(object sender, System.EventArgs e) { OnShapeChanged?.Invoke(this, null); }
private void RectangleOnOnShapeChanged(Rect shape) { OnShapeChanged?.Invoke(shape); }
/// <summary> /// Important: Only call this when self is Valid! /// 1. Update internal buffered values /// 2. Notify holding objects to repaint /// </summary> protected virtual void NotifyShapeChanged() { _length = null; OnShapeChanged?.Invoke(this, null); }