private void MouseMove(LowLevelMouseInput input) { if (_buttonDown) { Point mousePosition = input.Point; Point delta = new Point() { X = 0, Y = 0 }; delta.X = mousePosition.X - _startPoint.X; delta.Y = mousePosition.Y - _startPoint.Y; if (_selectedOverlayText != null) { if (_editState == OverlayEditState.Position) { _selectedOverlayText.X = _overlayPoint.X + delta.X; _selectedOverlayText.Y = _overlayPoint.Y + delta.Y; } else if (_editState == OverlayEditState.Size) { if (_selectedOverlayText.UseMaxWidth) { _selectedOverlayText.MaxWidth = _overlayPoint.X + delta.X; } if (_selectedOverlayText.UseMaxHeight) { _selectedOverlayText.MaxHeight = _overlayPoint.Y + delta.Y; } } } } }
private void MouseButtonUp(LowLevelMouseInput input) { if (_buttonDown) { _buttonDown = false; _startPoint = new Point() { X = 0, Y = 0 }; _overlayPoint = new Point() { X = 0, Y = 0 }; _editState = OverlayEditState.None; _selectedOverlayText = null; } }
private void MouseButtonDown(LowLevelMouseInput input) { Point mousePosition = input.Point; if (!_buttonDown) { _buttonDown = true; foreach (var item in _overlayComponent.Overlays) { if (item.GetType().IsSubclassOf(typeof(OverlayItemText))) { var textOverlay = (item as OverlayItemText).Overlay; if (textOverlay.IsValidID && textOverlay.Active) { var useMaxWidth = textOverlay.UseMaxWidth; var useMaxHeight = textOverlay.UseMaxHeight; var x = textOverlay.X; var y = textOverlay.Y; var width = useMaxWidth ? textOverlay.MaxWidth : textOverlay.Width; var height = useMaxHeight ? textOverlay.MaxHeight : textOverlay.Height; if (mousePosition.X >= x && mousePosition.X <= (x + width) && mousePosition.Y >= y && mousePosition.Y <= (y + height)) { _selectedOverlayText = textOverlay; _startPoint = mousePosition; if ((useMaxWidth || useMaxHeight) && mousePosition.X >= (x + width - 10) && mousePosition.X <= (x + width) && mousePosition.Y >= (y + height - 10) && mousePosition.Y <= (y + height)) { _overlayPoint.X = width; _overlayPoint.Y = height; _editState = OverlayEditState.Size; } else { _overlayPoint.X = _selectedOverlayText.X; _overlayPoint.Y = _selectedOverlayText.Y; _editState = OverlayEditState.Position; } } } } } } }