protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { _startOffset = e.GetPosition(this); _mouseAction = SetHitType(_startOffset); if((_mouseAction & BorderHitType.Border) != BorderHitType.None) { _borderDragInProgress = true; e.Handled = true; CaptureMouse(); } else { base.OnMouseLeftButtonDown(e); } }
protected override void OnMouseMove(MouseEventArgs e) { if(_borderDragInProgress) { var p = e.GetPosition(this); double offset_x = p.X - _startOffset.X; double offset_y = p.Y - _startOffset.Y; double left = 0; double top = 0; double right = Width; double bottom = Height; if((_mouseAction & BorderHitType.L) == BorderHitType.L) { left = CELL_SIZE * 2 * Math.Round((left + offset_x) / (CELL_SIZE * 2)); } else if((_mouseAction & BorderHitType.R) == BorderHitType.R) { right = CELL_SIZE * 2 * Math.Round((right + offset_x-10) / (CELL_SIZE * 2))+10; } if((_mouseAction & BorderHitType.T) == BorderHitType.T) { top = CELL_SIZE * 2 * Math.Round((top + offset_y) / (CELL_SIZE * 2)); } else if((_mouseAction & BorderHitType.B) == BorderHitType.B) { bottom = CELL_SIZE * 2 * Math.Round((bottom + offset_y-10) / (CELL_SIZE * 2))+10; } if((right > left + 10 + 2 * CELL_SIZE) && (bottom > top + 10 + 2 * CELL_SIZE)) { RenderBackground(left, top, right, bottom); } } else { _mouseAction = SetHitType(e.GetPosition(this)); base.OnMouseMove(e); } }