public void switchToMiddleClick() { if (currentButton != MouseButtonType.MIDDLE) { // send the previous key up message unless we switched from the left click if (currentButton == MouseButtonType.RIGHT) { connection.ModKey(10, 10, false, NetworkConScript.keys.Ctrl); } // send the key down message connection.ModKey(10, 10, true, NetworkConScript.keys.Shift); currentButton = MouseButtonType.MIDDLE; Debug.Log ("now middle clicking"); } }
public void switchToLeftClick() { if (currentButton != MouseButtonType.LEFT) { // send the previous key up message if (currentButton == MouseButtonType.RIGHT) { connection.ModKey(10, 10, false, NetworkConScript.keys.Ctrl); } else { connection.ModKey(10, 10, false, NetworkConScript.keys.Shift); } currentButton = MouseButtonType.LEFT; Debug.Log ("now left clicking"); } }
protected override void OnMouseUp(int x, int y, MouseButtonType button) { if (button == MouseButtonType.Left && ShowLock) { Texture2D lock_texture = GumpsLoader.Instance.GetTexture(0x082C); if (lock_texture != null) { if (x >= Width - lock_texture.Width && x < Width && y >= 0 && y <= lock_texture.Height) { UIManager.AnchorManager.DetachControl(this); } } } base.OnMouseUp(x, y, button); }
public void switchToRightClick() { if (currentButton != MouseButtonType.RIGHT) { // send the previous key up message unless we switched from the left click if (currentButton == MouseButtonType.MIDDLE) { connection.ModKey(10, 10, false, NetworkConScript.keys.Shift); } // send the key down message connection.ModKey(10, 10, true, NetworkConScript.keys.Ctrl); currentButton = MouseButtonType.RIGHT; Debug.Log("now right clicking"); } }
protected override void OnMouseUp(int x, int y, MouseButtonType button) { if (button == MouseButtonType.Left) { UIManager.GetGump <ColorPickerGump>()?.Dispose(); ColorPickerGump pickerGump = new ColorPickerGump ( 0, 0, 100, 100, s => Hue = s ); UIManager.Add(pickerGump); } }
public static void DoMouseClickEvent(MouseButtonType btnType, int x, int y) { if (btnType == MouseButtonType.Right) { mouse_event((int)MouseEventFlags.RightDown, x, y, 0, 0); mouse_event((int)MouseEventFlags.RightUp, x, y, 0, 0); } else if (btnType == MouseButtonType.Middle) { mouse_event((int)MouseEventFlags.MiddleDown, x, y, 0, 0); mouse_event((int)MouseEventFlags.MiddleUp, x, y, 0, 0); } else // btnType == MouseButtonType.Left { mouse_event((int)MouseEventFlags.LeftDown, x, y, 0, 0); mouse_event((int)MouseEventFlags.LeftUp, x, y, 0, 0); } }
public void switchToLeftClick() { if (currentButton != MouseButtonType.LEFT) { // send the previous key up message if (currentButton == MouseButtonType.RIGHT) { connection.ModKey(10, 10, false, NetworkConScript.keys.Ctrl); } else { connection.ModKey(10, 10, false, NetworkConScript.keys.Shift); } currentButton = MouseButtonType.LEFT; Debug.Log("now left clicking"); } }
protected override void OnMouseUp(int x, int y, MouseButtonType button) { if (_focusPage >= 0 && _focusPage < _pageCoords.GetLength(0)) { if (_focusPage % 2 == 0) { x -= RIGHT_X + _gump.X; } else { x -= LEFT_X + _gump.X; } y += _pageCoords[_focusPage, 0] - (UPPER_MARGIN + _gump.Y); } base.OnMouseUp(x, y, button); }
protected override void OnMouseDown(int x, int y, MouseButtonType button) { if (button != MouseButtonType.Left) { return; } if (TargetManager.IsTargeting) { if (Mouse.IsDragging && Mouse.LDroppedOffset != Point.Zero) { return; } } _clickedCanDrag = true; _picUpTime = Time.Ticks + 500f; }
protected override void OnMouseUp(int x, int y, MouseButtonType button) { if (button == MouseButtonType.Left) { UIManager.GetGump <ColorPickerGump>()?.Dispose(); ColorPickerGump pickerGump = new ColorPickerGump ( 0, 0, 100, 100, s => _colorBox.SetColor(s, HuesLoader.Instance.GetPolygoneColor(CELL, s)) ); UIManager.Add(pickerGump); } }
protected override bool OnMouseDoubleClick(int x, int y, MouseButtonType button) { if (button == MouseButtonType.Left) { if (_isPrimary) { GameActions.UsePrimaryAbility(); } else { GameActions.UseSecondaryAbility(); } return(true); } return(false); }
private bool IsContinuousClick(int x, int y, MouseButtonType button) { // ダブルクリックとして認識するクリックの間隔よりも大きかった場合は継続的なクリックとみなさない var delta = (DateTime.Now - lastClickTime).TotalMilliseconds; if (delta > System.Windows.Forms.SystemInformation.DoubleClickTime) { return(false); } // クリック位置が違う、もしくはボタンが違う場合にも継続的なクリックとはみなさない if (lastClickPosX != x || lastClickPosY != y || lastClickButton != button) { return(false); } return(true); }
protected override void OnMouseUp(int x, int y, MouseButtonType button) { if (button == MouseButtonType.Left) { if (ItemHold.Enabled) { SetGraphic(ItemHold.Graphic, ItemHold.Hue); GameActions.DropItem(ItemHold.Serial, ItemHold.X, ItemHold.Y, 0, ItemHold.Container); } } else if (button == MouseButtonType.Right && Keyboard.Alt && Graphic != 0) { RemoveItem(); } else if (Graphic != 0) { base.OnMouseUp(x, y, button); } }
public void ProcessClick(int x, int y, MouseButtonType mouseButton, bool isKeyDown) { if (isKeyDown) { if (IsMultipleClick(x, y, mouseButton)) { ClickCount += 1; } else { ClickCount = 1; } } _lastMouseClickPositionX = x; _lastMouseClickPositionY = x; _lastMouseClickButton = mouseButton; _lastMouseClickTime = DateTime.UtcNow; }
public MouseEvent GetMouseEvent(int x, int y, MouseButtonType button) { var modifiers = CefEventFlags.None; if (button == MouseButtonType.Left) { modifiers = CefEventFlags.LeftMouseButton; } else if (button == MouseButtonType.Right) { modifiers = CefEventFlags.RightMouseButton; } else if (button == MouseButtonType.Middle) { modifiers = CefEventFlags.MiddleMouseButton; } return(new MouseEvent(x, y, modifiers)); }
protected override void OnMouseUp(int x, int y, MouseButtonType button) { if (button == MouseButtonType.Left) { _entry.Action?.Invoke(); RootParent?.Dispose(); if (_entry.CanBeSelected) { _entry.IsSelected = !_entry.IsSelected; _selectedPic.IsVisible = _entry.IsSelected; } Mouse.CancelDoubleClick = true; Mouse.LastLeftButtonClickTime = 0; base.OnMouseUp(x, y, button); } }
private static void UpdateMouseStates() { MouseState mouseState = Mouse.GetState(); // A total violation of the DRY principle. { // Update state for the left mouse button const MouseButtonType buttonType = MouseButtonType.Primary; bool currentState = mouseState.LeftButton == ButtonState.Pressed; if (!MouseStates.ContainsKey(buttonType)) { MouseStates.Add(buttonType, new InputState()); } MouseStates[buttonType].ToNextState(currentState); FireTriggeredMouseListenerEvents(buttonType, MouseStates[buttonType]); } { // Update state for the middle mouse button const MouseButtonType buttonType = MouseButtonType.Middle; bool currentState = mouseState.MiddleButton == ButtonState.Pressed; if (!MouseStates.ContainsKey(buttonType)) { MouseStates.Add(buttonType, new InputState()); } MouseStates[buttonType].ToNextState(currentState); FireTriggeredMouseListenerEvents(buttonType, MouseStates[buttonType]); } { // Update state for the right mouse button const MouseButtonType buttonType = MouseButtonType.Secondary; bool currentState = mouseState.RightButton == ButtonState.Pressed; if (!MouseStates.ContainsKey(buttonType)) { MouseStates.Add(buttonType, new InputState()); } MouseStates[buttonType].ToNextState(currentState); FireTriggeredMouseListenerEvents(buttonType, MouseStates[buttonType]); } // TODO: State updates for mouse scroll wheel, mouse motion etc. }
protected override void OnMouseUp(int x, int y, MouseButtonType button) { if (!UIManager.IsMouseOverWorld && UIManager.MouseOverControl != null) { var p = UIManager.MouseOverControl.GetFirstControlAcceptKeyboardInput(); p?.SetKeyboardFocus(); } else { if (UIManager.KeyboardFocusControl != UIManager.SystemChat.TextBoxControl) { UIManager.KeyboardFocusControl = UIManager.SystemChat.TextBoxControl; } //if (!(UIManager.KeyboardFocusControl is TextBox tb && tb.Parent is WorldViewportGump)) // Parent.GetFirstControlAcceptKeyboardInput()?.SetKeyboardFocus(); } base.OnMouseUp(x, y, button); }
/// <summary> /// Checks if the mouse button has been detected. /// </summary> /// <param name="sender">The sender.</param> /// <param name="type">The mouse button type.</param> /// <param name="mouseDown">if set to <c>true</c> [mouse down].</param> private static void CheckMouseDetected(object sender, MouseButtonType type, bool mouseDown) { var uiElement = sender as UIElement; if (uiElement == null) { return; } if (GetMouseButton(uiElement) != type) { return; } if (mouseDown) { MouseDownDetected(); } else { MouseUpDetected(); } }
protected override void OnMouseUp(int x, int y, MouseButtonType button) { if (button == MouseButtonType.Left) { if (TargetManager.IsTargeting) { TargetManager.Target(World.Player); Mouse.LastLeftButtonClickTime = 0; } else { Point p = new Point(x, y); Rectangle rect = new Rectangle(Bounds.Width - 42, Bounds.Height - 25, Bounds.Width, Bounds.Height); if (rect.Contains(p)) { UIManager.GetGump <BaseHealthBarGump>(World.Player)?.Dispose(); //TCH whole if else if (ProfileManager.CurrentProfile.CustomBarsToggled) { UIManager.Add(new HealthBarGumpCustom(World.Player) { X = ScreenCoordinateX, Y = ScreenCoordinateY }); } else { UIManager.Add(new HealthBarGump(World.Player) { X = ScreenCoordinateX, Y = ScreenCoordinateY }); } Dispose(); } } } }
public void SendMouseMove(int x, int y, MouseButtonType button) { if (this._browser != null && this._browser.IsBrowserInitialized) { var host = this._browser.GetBrowserHost(); var modifiers = CefEventFlags.None; if (button == MouseButtonType.Left) { modifiers = CefEventFlags.LeftMouseButton; } else if (button == MouseButtonType.Middle) { modifiers = CefEventFlags.MiddleMouseButton; } else if (button == MouseButtonType.Right) { modifiers = CefEventFlags.RightMouseButton; } var mouseEvent = new MouseEvent(x, y, modifiers); host.SendMouseMoveEvent(mouseEvent, false); } }
protected override void OnMouseDown(int x, int y, MouseButtonType button) { if (button != MouseButtonType.Left) { return; } _timeUntilNextClick = 0f; if (_showButtons && _rectDownButton.Contains(x, y)) { _btDownClicked = true; } else if (_showButtons && _rectUpButton.Contains(x, y)) { _btUpClicked = true; } else if (Contains(x, y)) { _btnSliderClicked = true; _clickPosition = new Point(x, y); } }
void Update() { #if UNITY_EDITOR || UNITY_STANDALONE Track(); MouseButtonType buttonType = GetInputMouseButton(); switch (buttonType) { case MouseButtonType.Left: break; case MouseButtonType.Right: Rotate(); break; case MouseButtonType.Middle: Move(); break; default: break; } #endif }
protected override void OnMouseUp(int x, int y, MouseButtonType button) { if (button == MouseButtonType.Left) { if (TargetManager.IsTargeting) { TargetManager.Target(World.Player); Mouse.LastLeftButtonClickTime = 0; } else if (x >= _point.X && x <= Width + 16 && y >= _point.Y && y <= Height + 16) { var offset = Mouse.LDroppedOffset; if (Math.Abs(offset.X) < 5 && Math.Abs(offset.Y) < 5) { UIManager.GetGump <BaseHealthBarGump>(World.Player)?.Dispose(); if (ProfileManager.Current.CustomBarsToggled) { UIManager.Add(new HealthBarGumpCustom(World.Player) { X = ScreenCoordinateX, Y = ScreenCoordinateY }); } else { UIManager.Add(new HealthBarGump(World.Player) { X = ScreenCoordinateX, Y = ScreenCoordinateY }); } Dispose(); } } } }
protected override void OnMouseUp(int x, int y, MouseButtonType button) { if (button != MouseButtonType.Left) { return; } GameScene gs = Client.Game.GetScene <GameScene>(); if (!ItemHold.Enabled || !gs.IsMouseOverUI) { return; } if (Item.Layer == Layer.Backpack || !Item.OnGround || Item.Distance < Constants.DRAG_ITEMS_DISTANCE) { SelectedObject.Object = Item; gs.DropHeldItemToContainer(Item, x, y); } else { gs.Audio.PlaySound(0x0051); } }
public void MouseMove(float x, float y, MouseButtonType button) { // Set value changed flag default to false bool valueChanged = false; if (_isTrackBarMoving && _mouseButtonDown) { // Evaluate tick height double tickWidth = _trackWidth / _valueRange; for (int a = Minimum; a < Maximum + 1; a++) { double startX = (a - Minimum) * tickWidth; double endX = (a - Minimum + 1) * tickWidth; // Adjust cursor position relative to margin double cursorX = x - Margin; // Does the cursor exceed min or max? if (cursorX <= 0) { // Don't change the value if it's already the same! if (Value != Minimum) { Value = Minimum; valueChanged = true; break; } } else if (cursorX >= _trackWidth) { // Don't change the value if it's already the same! if (Value != Maximum) { Value = Maximum; valueChanged = true; break; } } // Is the cursor in the current value? else if (cursorX >= startX && cursorX <= endX) { // Don't change the value if it's already the same! if (Value != a) { Value = a; valueChanged = true; break; } } } // If the value has changed, refresh control and raise event if (valueChanged) { if (OnTrackBarValueChanged != null) OnTrackBarValueChanged(); OnInvalidateVisual(); } } }
public void MouseUp(float x, float y, MouseButtonType button, KeysHeld keysHeld) { // Check if the track bar was moving (mouse down) //ReleaseMouseCapture(); if (!_isTrackBarMoving) { // The user clicked without dragging the mouse; we need to add or // substract a "step" depending on the mouse cursor position. if (x < _rectFader.X) { if (Value - StepSize < Minimum) Value = Minimum; else Value -= StepSize; } else if (x > _rectFader.X + _rectFader.Width) { if (Value + StepSize > Maximum) Value = Maximum; else Value += StepSize; } if (OnTrackBarValueChanged != null) OnTrackBarValueChanged(); OnInvalidateVisual(); } _mouseButtonDown = false; _isTrackBarMoving = false; }
protected override void OnMouseUp(int x, int y, MouseButtonType button) { if (button == MouseButtonType.Left) { if (UIManager.MouseOverControl?.RootParent == RootParent) { GameScene gs = Client.Game.GetScene <GameScene>(); if (gs != null) { Item item = World.Items.Get(LocalSerial); if (item != null) { if (TargetManager.IsTargeting) { if (Mouse.IsDragging && CanPickup()) { if (ItemHold.Enabled && gs.IsMouseOverUI) { if (item.ItemData.IsContainer) { gs.DropHeldItemToContainer(item); } else if (ItemHold.Graphic == item.Graphic && ItemHold.IsStackable) { gs.MergeHeldItem(item); } else { if (SerialHelper.IsItem(item.Container)) { gs.DropHeldItemToContainer(World.Items.Get(item.Container), X + (Mouse.Position.X - ScreenCoordinateX), Y + (Mouse.Position.Y - ScreenCoordinateY)); } } Mouse.CancelDoubleClick = true; return; } } switch (TargetManager.TargetingState) { case CursorTarget.Position: case CursorTarget.Object: case CursorTarget.Grab: case CursorTarget.SetGrabBag: if (item != null) { var p = RootParent; if (p != null) { DelayedObjectClickManager.X = Mouse.Position.X - p.ScreenCoordinateX; DelayedObjectClickManager.Y = Mouse.Position.Y - p.ScreenCoordinateY; } TargetManager.Target(item); Mouse.LastLeftButtonClickTime = 0; } break; case CursorTarget.SetTargetClientSide: if (item != null) { TargetManager.Target(item); Mouse.LastLeftButtonClickTime = 0; UIManager.Add(new InspectorGump(item)); } break; case CursorTarget.HueCommandTarget: if (item != null) { CommandManager.OnHueTarget(item); } break; } return; } else { Point offset = Mouse.LDroppedOffset; if ((Math.Abs(offset.X) < Constants.MIN_PICKUP_DRAG_DISTANCE_PIXELS && Math.Abs(offset.Y) < Constants.MIN_PICKUP_DRAG_DISTANCE_PIXELS) && (!ItemHold.Enabled || !gs.IsMouseOverUI)) { if (!DelayedObjectClickManager.IsEnabled) { var p = RootParent; if (p != null) { var off = Mouse.LDroppedOffset; DelayedObjectClickManager.Set(LocalSerial, (Mouse.Position.X - off.X) - p.ScreenCoordinateX, (Mouse.Position.Y - off.Y) - p.ScreenCoordinateY, Time.Ticks + Mouse.MOUSE_DELAY_DOUBLE_CLICK); } return; } } else if (item != null) { if (item.ItemData.IsContainer) { gs.DropHeldItemToContainer(item); } else if (ItemHold.Graphic == item.Graphic && ItemHold.IsStackable) { gs.MergeHeldItem(item); } else if (SerialHelper.IsItem(item.Container)) { gs.DropHeldItemToContainer(World.Items.Get(item.Container), X + (Mouse.Position.X - ScreenCoordinateX), Y + (Mouse.Position.Y - ScreenCoordinateY)); } else { base.OnMouseUp(x, y, button); } Mouse.CancelDoubleClick = true; return; } } } } } } else { base.OnMouseUp(x, y, button); } }
public bool IsMouseHeldDown(MouseButtonType button) { switch (button) { case MouseButtonType.Left: return mouseState.LeftButton == ButtonState.Pressed && prevMouseState.LeftButton == ButtonState.Pressed; case MouseButtonType.Middle: return mouseState.MiddleButton == ButtonState.Pressed && prevMouseState.MiddleButton == ButtonState.Pressed; case MouseButtonType.Right: return mouseState.RightButton == ButtonState.Pressed && prevMouseState.RightButton == ButtonState.Pressed; default: throw new ArgumentException(); } }
public void MouseMove(float x, float y, MouseButtonType button) { }
public void MouseMove(float x, float y, MouseButtonType button) { bool valueChanged = false; //Console.WriteLine("FaderControl - MouseMove - _isTrackBarMoving: {0} _mouseButtonDown: {1}", _isTrackBarMoving, _mouseButtonDown); if (_isTrackBarMoving && _mouseButtonDown) { // Evaluate tick height double tickHeight = _trackHeight / _valueRange; // Loop through "steps" for (int a = Minimum; a < Maximum + 1; a++) { double startY = _trackHeight - ((a - Minimum + 1) * tickHeight); double endY = _trackHeight - ((a - Minimum) * tickHeight); // Adjust cursor position relative to margin double cursorY = y - Margin; // Does the cursor exceed min or max? if (cursorY <= 0) { // Don't change the value if it's already the same! if (Value != Maximum) { Value = Maximum; valueChanged = true; break; } } else if (cursorY >= _trackHeight) { // Don't change the value if it's already the same! if (Value != Minimum) { Value = Minimum; valueChanged = true; break; } } // Is the cursor in the current value? else if (cursorY >= startY && cursorY <= endY) { // Don't change the value if it's already the same! if (Value != a) { Value = a; valueChanged = true; break; } } } // If the value has changed, refresh control and raise event if (valueChanged) { if (OnFaderValueChanged != null) OnFaderValueChanged(this, new EventArgs()); OnInvalidateVisual(); } } }
public void MouseUp(float x, float y, MouseButtonType button, KeysHeld keysHeld) { // Check if the track bar was moving (mouse down) //ReleaseMouseCapture(); if (!_isTrackBarMoving) { // The user clicked without dragging the mouse; we need to add or // substract a "step" depending on the mouse cursor position. if (y < _rectFader.Y) { if (Value + StepSize > Maximum) Value = Maximum; else Value += StepSize; } else if (y > _rectFader.Y + _rectFader.Height) { if (Value - StepSize < Minimum) Value = Minimum; else Value -= StepSize; } if (OnFaderValueChanged != null) OnFaderValueChanged(this, new EventArgs()); OnInvalidateVisual(); } //Console.WriteLine("FaderControl - MouseDown - Mouse up; stopping track bar movement"); _mouseButtonDown = false; _isTrackBarMoving = false; }
/// <summary> /// Occurs when the user double-clicks on the control. /// Starts the playback of a new song. /// </summary> /// <param name="e">Event arguments</param> public void MouseDoubleClick(float x, float y, MouseButtonType button, KeysHeld keysHeld) { if (_columns == null || _songCache == null) return; var partialRect = new BasicRectangle(); bool controlNeedsToBePartiallyInvalidated = false; int albumArtCoverWidth = _columns[0].Visible ? _columns[0].Width : 0; int scrollbarOffsetY = (_startLineNumber * _songCache.LineHeight) - VerticalScrollBar.Value; // Keep original songId in case the now playing value is set before invalidating the older value Guid originalId = Guid.Empty; // Set original id if (_mode == SongGridViewMode.AudioFile) originalId = _nowPlayingAudioFileId; else if (_mode == SongGridViewMode.Playlist) originalId = _nowPlayingPlaylistItemId; // Loop through visible lines for (int a = _startLineNumber; a < _startLineNumber + _numberOfLinesToDraw; a++) { if (_items[a].IsMouseOverItem) { // Set this item as the new now playing _nowPlayingAudioFileId = _items[a].AudioFile.Id; _nowPlayingPlaylistItemId = _items[a].PlaylistItemId; OnItemDoubleClick(_nowPlayingAudioFileId, a); var newPartialRect = new BasicRectangle(albumArtCoverWidth - HorizontalScrollBar.Value, ((a - _startLineNumber + 1) * _songCache.LineHeight) + scrollbarOffsetY, Frame.Width - albumArtCoverWidth + HorizontalScrollBar.Value, _songCache.LineHeight); partialRect.Merge(newPartialRect); controlNeedsToBePartiallyInvalidated = true; } else if (_mode == SongGridViewMode.AudioFile && _items[a].AudioFile != null && _items[a].AudioFile.Id == originalId) { var newPartialRect = new BasicRectangle(albumArtCoverWidth - HorizontalScrollBar.Value, ((a - _startLineNumber + 1) * _songCache.LineHeight) + scrollbarOffsetY, Frame.Width - albumArtCoverWidth + HorizontalScrollBar.Value, _songCache.LineHeight); partialRect.Merge(newPartialRect); controlNeedsToBePartiallyInvalidated = true; } else if (_mode == SongGridViewMode.Playlist && _items[a].PlaylistItemId == originalId) { var newPartialRect = new BasicRectangle(albumArtCoverWidth - HorizontalScrollBar.Value, ((a - _startLineNumber + 1) * _songCache.LineHeight) + scrollbarOffsetY, Frame.Width - albumArtCoverWidth + HorizontalScrollBar.Value, _songCache.LineHeight); partialRect.Merge(newPartialRect); controlNeedsToBePartiallyInvalidated = true; } } if (controlNeedsToBePartiallyInvalidated) OnInvalidateVisualInRect(partialRect); }
protected override void OnMouseUp(int x, int y, MouseButtonType button) { base.OnMouseUp(x, y, button); _currentPin = null; _lastPoint = Point.Zero; }
protected override void OnMouseUp(int x, int y, MouseButtonType button) { base.OnMouseUp(x, y, button); Parent?.InvokeMouseUp(new Point(x, y), button); }
public void MouseUp(float x, float y, MouseButtonType button, KeysHeld keysHeld) { _isMouseDown = false; if (AudioFile == null) return; if (_isDraggingScrollBar) { _isDraggingThumb = false; _isDraggingScrollBar = false; } else { ShowSecondaryPosition = false; long position = (long)(((x + ContentOffset.X) / ContentSize.Width) * Length); float positionPercentage = (float)position / (float)Length; if (button == MouseButtonType.Left) { Position = position; OnChangePosition(positionPercentage); } } }
/// <summary> /// Occurs when the mouse pointer is moving over the control. /// Manages the display of mouse on/off visual effects. /// </summary> public void MouseMove(float x, float y, MouseButtonType button) { //Console.WriteLine("SongGridViewControl - MouseMove - x: {0} y: {1}", x, y); bool controlNeedsToBeFullyInvalidated = false; bool controlNeedsToBePartiallyInvalidated = false; var partialRect = new BasicRectangle(); if (_columns == null || _songCache == null) return; // Calculate album cover art width int albumArtCoverWidth = _columns[0].Visible ? _columns[0].Width : 0; // Check if the user is currently resizing a column (loop through columns) foreach (var column in _songCache.ActiveColumns) { // Check if the user is currently resizing this column if (column.IsUserResizingColumn && column.Visible) { // Calculate the new column width int newWidth = _dragOriginalColumnWidth - (_dragStartX - (int)x); // Make sure the width isn't lower than the minimum width if (newWidth < MinimumColumnWidth) newWidth = MinimumColumnWidth; // Set column width column.Width = newWidth; // Refresh control (invalidate whole control) controlNeedsToBeFullyInvalidated = true; InvalidateSongCache(); // Auto adjust horizontal scrollbar value if it exceeds the value range (i.e. do not show empty column) if (HorizontalScrollBar.Value > HorizontalScrollBar.Maximum - HorizontalScrollBar.LargeChange) { // Set new value int tempValue = HorizontalScrollBar.Maximum - HorizontalScrollBar.LargeChange; if (tempValue < 0) tempValue = 0; HorizontalScrollBar.Value = tempValue; } } // Check if the user is moving the column if (column.IsMouseOverColumnHeader && column.CanBeMoved && CanMoveColumns && _isUserHoldingLeftMouseButton && !IsColumnResizing) { // Check if the X position has changed by at least 2 pixels (i.e. dragging) if (_dragStartX >= x + 2 || _dragStartX <= x - 2) { // Set resizing column flag column.IsUserMovingColumn = true; } } // Check if the user is currently moving this column if (column.IsUserMovingColumn) { // Loop through columns int currentX = 0; foreach (SongGridViewColumn columnOver in _songCache.ActiveColumns) { // Check if column is visible if (columnOver.Visible) { // Check if the cursor is over the left part of the column if (x >= currentX - HorizontalScrollBar.Value && x <= currentX + (columnOver.Width / 2) - HorizontalScrollBar.Value) _columnMoveMarkerX = (int)x; // Check if the cursor is over the right part of the column else if (x >= currentX + (columnOver.Width / 2) - HorizontalScrollBar.Value && x <= currentX + columnOver.Width - HorizontalScrollBar.Value) _columnMoveMarkerX = (int)x + columnOver.Width; x += columnOver.Width; } } controlNeedsToBeFullyInvalidated = true; } } if (!IsColumnMoving) { // Check if the cursor needs to be changed int offsetX = 0; bool mousePointerIsOverColumnLimit = false; foreach (var column in _songCache.ActiveColumns) { if (column.Visible) { // Increment offset by the column width offsetX += column.Width; if (column.CanBeResized) { // Check if the mouse pointer is over a column (add 1 pixel so it's easier to select) if (x >= offsetX - HorizontalScrollBar.Value && x <= offsetX + 1 - HorizontalScrollBar.Value) { mousePointerIsOverColumnLimit = true; column.IsMouseCursorOverColumnLimit = true; OnChangeMouseCursorType(MouseCursorType.VSplit); } else { column.IsMouseCursorOverColumnLimit = false; } } } } // Check if the default cursor needs to be restored if (!mousePointerIsOverColumnLimit) OnChangeMouseCursorType(MouseCursorType.Default); int columnOffsetX2 = 0; for (int b = 0; b < _songCache.ActiveColumns.Count; b++) { var column = _songCache.ActiveColumns[b]; if (column.Visible) { // Was mouse over this column header? if (column.IsMouseOverColumnHeader) { // Invalidate region column.IsMouseOverColumnHeader = false; var newPartialRect = new BasicRectangle(columnOffsetX2 - HorizontalScrollBar.Value, 0, column.Width, _songCache.LineHeight); partialRect.Merge(newPartialRect); controlNeedsToBePartiallyInvalidated = true; } // Increment offset columnOffsetX2 += column.Width; } } // Check if the mouse pointer is over the header if (y >= 0 && y <= _songCache.LineHeight) { // Check on what column the user has clicked int columnOffsetX = 0; for (int a = 0; a < _songCache.ActiveColumns.Count; a++) { var column = _songCache.ActiveColumns[a]; if (column.Visible) { // Check if the mouse pointer is over this column if (x >= columnOffsetX - HorizontalScrollBar.Value && x <= columnOffsetX + column.Width - HorizontalScrollBar.Value) { // Invalidate region column.IsMouseOverColumnHeader = true; var newPartialRect = new BasicRectangle(columnOffsetX - HorizontalScrollBar.Value, 0, column.Width, _songCache.LineHeight); partialRect.Merge(newPartialRect); controlNeedsToBePartiallyInvalidated = true; break; } columnOffsetX += column.Width; } } } // Check if the mouse cursor is over a line (loop through lines) int offsetY = 0; //int scrollbarOffsetY = (_startLineNumber * _songCache.LineHeight) - VerticalScrollBar.Value; // Check if there's at least one item if (_items.Count > 0) { // Reset mouse over item flags for (int b = _startLineNumber; b < _startLineNumber + _numberOfLinesToDraw; b++) { //Console.WriteLine("SongGridViewControl - MouseMove - Checking for resetting mouse over flag for line {0}", b); // Check if the mouse was over this item if (_items[b].IsMouseOverItem) { // Reset flag and invalidate region //Console.WriteLine("SongGridViewControl - MouseMove - Resetting mouse over flag for line {0}", b); _items[b].IsMouseOverItem = false; //OnInvalidateVisualInRect(new BasicRectangle(albumArtCoverWidth - HorizontalScrollBar.Value, ((b - _startLineNumber + 1) * _songCache.LineHeight) + scrollbarOffsetY, Frame.Width - albumArtCoverWidth + HorizontalScrollBar.Value, _songCache.LineHeight)); break; } } // Put new mouse over flag for (int a = _startLineNumber; a < _startLineNumber + _numberOfLinesToDraw; a++) { // Calculate offset offsetY = (a * _songCache.LineHeight) - VerticalScrollBar.Value + _songCache.LineHeight; //Console.WriteLine("SongGridViewControl - MouseMove - Checking for setting mouse over flag for line {0} - offsetY: {1}", a, offsetY); // Check if the mouse cursor is over this line (and not already mouse over) if (x >= albumArtCoverWidth - HorizontalScrollBar.Value && y >= offsetY && y <= offsetY + _songCache.LineHeight && !_items[a].IsEmptyRow && !_items[a].IsMouseOverItem) { // Set item as mouse over //Console.WriteLine("SongGridViewControl - MouseMove - Mouse is over item {0} {1}/{2}/{3}", a, _items[a].AudioFile.ArtistName, _items[a].AudioFile.AlbumTitle, _items[a].AudioFile.Title); _items[a].IsMouseOverItem = true; // Invalidate region and update control //OnInvalidateVisualInRect(new BasicRectangle(albumArtCoverWidth - HorizontalScrollBar.Value, offsetY, Frame.Width - albumArtCoverWidth + HorizontalScrollBar.Value, _songCache.LineHeight)); //controlNeedsToBeFullyInvalidated = true; break; } } } } if (controlNeedsToBeFullyInvalidated) OnInvalidateVisual(); else if (controlNeedsToBePartiallyInvalidated) OnInvalidateVisualInRect(partialRect); }
public void MouseClick(float x, float y, MouseButtonType button, KeysHeld keysHeld) { float scrollUnit = ScrollBarHeight * Zoom; if (ShowScrollBar && y >= Frame.Height - ScrollBarHeight) { // Make sure we are outside the thumb/visible area float visibleAreaWidth = (1 / Zoom) * Frame.Width; float visibleAreaX = (1 / Zoom) * ContentOffset.X; if (x < visibleAreaX) OnContentOffsetChanged(new BasicPoint(ContentOffset.X - scrollUnit, 0)); else if (x > visibleAreaX + visibleAreaWidth) OnContentOffsetChanged(new BasicPoint(ContentOffset.X + scrollUnit, 0)); } }
protected override bool OnMouseDoubleClick(int x, int y, MouseButtonType button) { return(true); }
public void MouseClick(float x, float y, MouseButtonType button, KeysHeld keysHeld) { bool controlNeedsToBeFullyInvalidated = false; bool controlNeedsToBePartiallyInvalidated = false; var partialRect = new BasicRectangle(); if (_columns == null || _songCache == null) return; // Show context menu strip if the button click is right and not the album art column if (button == MouseButtonType.Right && x > _columns[0].Width && y > _songCache.LineHeight) OnDisplayContextMenu(ContextMenuType.Item, x, y); int albumArtCoverWidth = _columns[0].Visible ? _columns[0].Width : 0; var columnResizing = _columns.FirstOrDefault(col => col.IsUserResizingColumn == true); int scrollbarOffsetY = (_startLineNumber * _songCache.LineHeight) - VerticalScrollBar.Value; // Check if the user has clicked on the header (for orderBy) if (y >= 0 && y <= _songCache.LineHeight && columnResizing == null && !IsColumnMoving) { // Check on what column the user has clicked int offsetX = 0; for (int a = 0; a < _songCache.ActiveColumns.Count; a++) { var column = _songCache.ActiveColumns[a]; if (column.Visible) { // Check if the mouse pointer is over this column if (x >= offsetX - HorizontalScrollBar.Value && x <= offsetX + column.Width - HorizontalScrollBar.Value) { if (button == MouseButtonType.Left && CanChangeOrderBy) { // Check if the column order was already set if (_orderByFieldName == column.FieldName) { // Reverse ascending/descending _orderByAscending = !_orderByAscending; } else { // Set order by field name _orderByFieldName = column.FieldName; _orderByAscending = true; } //_items = null; _songCache = null; // Raise column click event (if an event is subscribed) if (OnColumnClick != null) { var data = new SongGridViewColumnClickData(); data.ColumnIndex = a; OnColumnClick(data); } OnInvalidateVisual(); return; } else if (button == MouseButtonType.Right) { //// Refresh column visibility in menu before opening //foreach (ToolStripMenuItem menuItem in _menuColumns.Items) //{ // SongGridViewColumn menuItemColumn = _columns.FirstOrDefault(x => x.Title == menuItem.Tag.ToString()); // if (menuItemColumn != null) // menuItem.Checked = menuItemColumn.Visible; //} OnDisplayContextMenu(ContextMenuType.Header, x, y); } } offsetX += column.Width; } } } // Loop through visible lines to find the original selected items var tuple = GetStartIndexAndEndIndexOfSelectedRows(); int startIndex = tuple.Item1; int endIndex = tuple.Item2; // Make sure the indexes are set if (startIndex > -1 && endIndex > -1) { // Invalidate the original selected lines int startY = ((startIndex - _startLineNumber + 1) * _songCache.LineHeight) + scrollbarOffsetY; int endY = ((endIndex - _startLineNumber + 2) * _songCache.LineHeight) + scrollbarOffsetY; var newPartialRect = new BasicRectangle(albumArtCoverWidth - HorizontalScrollBar.Value, startY, Frame.Width - albumArtCoverWidth + HorizontalScrollBar.Value, endY - startY); partialRect.Merge(newPartialRect); controlNeedsToBePartiallyInvalidated = true; } // Reset selection (make sure SHIFT or CTRL isn't held down) if (!keysHeld.IsShiftKeyHeld && !keysHeld.IsCtrlKeyHeld) { // Make sure the mouse is over at least one item var mouseOverItem = _items.FirstOrDefault(item => item.IsMouseOverItem == true); if (mouseOverItem != null) ResetSelection(); } // Loop through visible lines to update the new selected items bool invalidatedNewSelection = false; for (int a = _startLineNumber; a < _startLineNumber + _numberOfLinesToDraw; a++) { // Check if mouse is over this item if (_items[a].IsMouseOverItem) { invalidatedNewSelection = true; // Check if SHIFT is held if (keysHeld.IsShiftKeyHeld) { // Find the start index of the selection int startIndexSelection = _lastItemIndexClicked; if (a < startIndexSelection) startIndexSelection = a; if (startIndexSelection < 0) startIndexSelection = 0; // Find the end index of the selection int endIndexSelection = _lastItemIndexClicked; if (a > endIndexSelection) endIndexSelection = a + 1; // Loop through items to selected for (int b = startIndexSelection; b < endIndexSelection; b++) _items [b].IsSelected = true; controlNeedsToBeFullyInvalidated = true; } // Check if CTRL is held else if(keysHeld.IsCtrlKeyHeld) { // Invert selection _items[a].IsSelected = !_items[a].IsSelected; var newPartialRect = new BasicRectangle(albumArtCoverWidth - HorizontalScrollBar.Value, ((a - _startLineNumber + 1) * _songCache.LineHeight) + scrollbarOffsetY, Frame.Width - albumArtCoverWidth + HorizontalScrollBar.Value, _songCache.LineHeight); partialRect.Merge(newPartialRect); controlNeedsToBePartiallyInvalidated = true; } else { // Set this item as the new selected item _items[a].IsSelected = true; var newPartialRect = new BasicRectangle(albumArtCoverWidth - HorizontalScrollBar.Value, ((a - _startLineNumber + 1) * _songCache.LineHeight) + scrollbarOffsetY, Frame.Width - albumArtCoverWidth + HorizontalScrollBar.Value, _songCache.LineHeight); partialRect.Merge(newPartialRect); controlNeedsToBePartiallyInvalidated = true; } // Set the last item clicked index _lastItemIndexClicked = a; break; } } // Raise selected item changed event (if an event is subscribed) if (invalidatedNewSelection && OnSelectedIndexChanged != null) { var data = new SongGridViewSelectedIndexChangedData(); OnSelectedIndexChanged(data); } if (controlNeedsToBeFullyInvalidated) OnInvalidateVisual(); else if (controlNeedsToBePartiallyInvalidated) OnInvalidateVisualInRect(partialRect); }
public void MouseDown(float x, float y, MouseButtonType button, KeysHeld keysHeld) { // Make sure the mouse button pressed was the left mouse button _mouseButtonDown = true; //CaptureMouse(); if (button == MouseButtonType.Left) { // Check if the user clicked in the fader area if (x >= _rectFader.X && x <= _rectFader.Width + _rectFader.X && y >= _rectFader.Y && y <= _rectFader.Height + _rectFader.Y) { //Console.WriteLine("FaderControl - MouseDown - Mouse down on track bar; track bar is now moving"); _isTrackBarMoving = true; } } }
protected override void OnMouseUp(int x, int y, MouseButtonType button) { base.OnMouseUp(x, y, button); if (button == MouseButtonType.Left) { GameScene gs = Client.Game.GetScene <GameScene>(); if (gs == null) { return; } if (Item == null || Item.IsDestroyed) { Dispose(); } if (IsDisposed) { return; } if (TargetManager.IsTargeting) { _clickedCanDrag = false; if (Mouse.IsDragging && CanPickup()) { if (!ItemHold.Enabled || !gs.IsMouseOverUI) { return; } SelectedObject.Object = Item; if (Item.ItemData.IsContainer) { gs.DropHeldItemToContainer(Item); } else if (ItemHold.Graphic == Item.Graphic && ItemHold.IsStackable) { gs.MergeHeldItem(Item); } else { if (SerialHelper.IsItem(Item.Container)) { gs.DropHeldItemToContainer(World.Items.Get(Item.Container), X + (Mouse.Position.X - ScreenCoordinateX), Y + (Mouse.Position.Y - ScreenCoordinateY)); } } return; } switch (TargetManager.TargetingState) { case CursorTarget.Position: case CursorTarget.Object: case CursorTarget.Grab: case CursorTarget.SetGrabBag: SelectedObject.Object = Item; if (Item != null) { TargetManager.Target(Item); Mouse.LastLeftButtonClickTime = 0; } break; case CursorTarget.SetTargetClientSide: SelectedObject.Object = Item; if (Item != null) { TargetManager.Target(Item); Mouse.LastLeftButtonClickTime = 0; UIManager.Add(new InspectorGump(Item)); } break; case CursorTarget.HueCommandTarget: SelectedObject.Object = Item; if (Item != null) { CommandManager.OnHueTarget(Item); } break; } } else { if (!ItemHold.Enabled || !gs.IsMouseOverUI) { //if (_clickedCanDrag) //{ // _clickedCanDrag = false; // _sendClickIfNotDClick = true; // _sClickTime = Time.Ticks + Mouse.MOUSE_DELAY_DOUBLE_CLICK; //} if (!DelayedObjectClickManager.IsEnabled) { DelayedObjectClickManager.Set(Item.Serial, Mouse.Position.X, Mouse.Position.Y, Time.Ticks + Mouse.MOUSE_DELAY_DOUBLE_CLICK); } } else { SelectedObject.Object = Item; if (Item.ItemData.IsContainer) { gs.DropHeldItemToContainer(Item); } else if (ItemHold.Graphic == Item.Graphic && ItemHold.IsStackable) { gs.MergeHeldItem(Item); } else { if (SerialHelper.IsItem(Item.Container)) { gs.DropHeldItemToContainer(World.Items.Get(Item.Container), X + (Mouse.Position.X - ScreenCoordinateX), Y + (Mouse.Position.Y - ScreenCoordinateY)); } } } } _clickedCanDrag = false; } }
public void MouseDoubleClick(float x, float y, MouseButtonType button, KeysHeld keysHeld) { }
public void MouseDown(float x, float y, MouseButtonType button, KeysHeld keysHeld) { _isMouseDown = true; if (AudioFile == null) return; if (ShowScrollBar && y >= Frame.Height - ScrollBarHeight) { // ScrollBar area _isDraggingScrollBar = true; float visibleAreaWidth = (1 / Zoom) * Frame.Width; float visibleAreaX = (1 / Zoom) * ContentOffset.X; if (x >= visibleAreaX && x <= visibleAreaX + visibleAreaWidth) { // User is dragging the thumb _isDraggingThumb = true; _mouseDownX = x; _thumbMouseDownX = visibleAreaX; //Console.WriteLine("Dragging thumb - _thumbMouseDownX: {0}", _thumbMouseDownX); } } else { // Wave form area ShowSecondaryPosition = true; long position = (long)(((x + ContentOffset.X) / ContentSize.Width) * Length); float positionPercentage = (float)position / (float)Length; //Console.WriteLine("positionPercentage: {0} x: {1} ContentSize.Width: {2}", positionPercentage, x, ContentSize.Width); SecondaryPosition = (long)(positionPercentage * Length); } }
protected override void OnMouseUp(int x, int y, MouseButtonType button) { SelectedObject.Object = World.Get(LocalSerial); base.OnMouseUp(x, y, button); }
/// <summary> /// Occurs when the user is pressing down a mouse button. /// </summary> public void MouseDown(float x, float y, MouseButtonType button, KeysHeld keysHeld) { _dragStartX = (int) x; if (_columns == null || _songCache == null) return; // Loop through columns foreach (SongGridViewColumn column in _songCache.ActiveColumns) { // Check for resizing column if (column.IsMouseCursorOverColumnLimit && column.CanBeResized && CanResizeColumns) { column.IsUserResizingColumn = true; _dragOriginalColumnWidth = column.Width; } } // Check if the left mouse button is held if(button == MouseButtonType.Left) _isUserHoldingLeftMouseButton = true; }
public void MouseUp(float x, float y, MouseButtonType button, KeysHeld keysHeld) { }
public void MouseMove(float x, float y, MouseButtonType button) { //Console.WriteLine("WaveFormControl - MouseMove - x: {0} y: {1}", x, y); if (AudioFile == null) return; if (_isMouseDown) { if (_isDraggingScrollBar) { if (_isDraggingThumb) { float visibleAreaWidth = (1 / Zoom) * Frame.Width; float trackWidth = Frame.Width - visibleAreaWidth; float newThumbX = (x - _mouseDownX) + _thumbMouseDownX; float scrollWidth = (Frame.Width * Zoom) - Frame.Width; float newThumbRatio = newThumbX / trackWidth; float newContentOffsetX = newThumbRatio * scrollWidth; //Console.WriteLine("ContentOffset change to {0} - _thumbMouseDownX: {1}", newContentOffsetX, _thumbMouseDownX); OnContentOffsetChanged(new BasicPoint(newContentOffsetX, 0)); } } else { long position = (long)(((x + ContentOffset.X) / ContentSize.Width) * Length); float positionPercentage = (float)position / (float)Length; //Console.WriteLine("positionPercentage: {0} x: {1} ContentSize.Width: {2}", positionPercentage, x, ContentSize.Width); SecondaryPosition = position; OnChangeSecondaryPosition(positionPercentage); } } }
public static void SendMouseClickEvent(this IBrowserHost host, int x, int y, MouseButtonType mouseButtonType, bool mouseUp, int clickCount, CefEventFlags modifiers) { ThrowExceptionIfBrowserHostNull(host); host.SendMouseClickEvent(new MouseEvent(x, y, modifiers), mouseButtonType, mouseUp, clickCount); }
/// <summary> /// Occurs when the user releases a mouse button. /// </summary> public void MouseUp(float x, float y, MouseButtonType button, KeysHeld keysHeld) { _dragStartX = -1; bool controlNeedsToBeFullyInvalidated = false; _isUserHoldingLeftMouseButton = false; if (_columns == null || _songCache == null) return; // Get reference to the moving column SongGridViewColumn columnMoving = null; foreach (var column in _songCache.ActiveColumns) { column.IsUserResizingColumn = false; if (column.IsUserMovingColumn) columnMoving = column; } // Check if the user is moving a column if (columnMoving != null) { columnMoving.IsUserMovingColumn = false; controlNeedsToBeFullyInvalidated = true; // Find out on what column the mouse cursor is SongGridViewColumn columnOver = null; int currentX = 0; bool isPastCurrentlyMovingColumn = false; for (int a = 0; a < _songCache.ActiveColumns.Count; a++) { var currentColumn = _songCache.ActiveColumns[a]; if (currentColumn.FieldName == columnMoving.FieldName) isPastCurrentlyMovingColumn = true; if (currentColumn.Visible) { // Check if the cursor is over the left part of the column if (x >= currentX - HorizontalScrollBar.Value && x <= currentX + (currentColumn.Width/2) - HorizontalScrollBar.Value) { if (isPastCurrentlyMovingColumn && currentColumn.FieldName != columnMoving.FieldName) columnOver = _songCache.ActiveColumns[a - 1]; else columnOver = _songCache.ActiveColumns[a]; break; } // Check if the cursor is over the right part of the column else if (x >= currentX + (currentColumn.Width/2) - HorizontalScrollBar.Value && x <= currentX + currentColumn.Width - HorizontalScrollBar.Value) { // Check if there is a next item if (a < _songCache.ActiveColumns.Count - 1) { if (isPastCurrentlyMovingColumn) columnOver = _songCache.ActiveColumns[a]; else columnOver = _songCache.ActiveColumns[a + 1]; } break; } // Increment x currentX += currentColumn.Width; } } //// Check if the column was found (the cursor might be past the last column //if (columnOver == null) //{ // return; //} // Order columns by their current order var columnsOrdered = _columns.OrderBy(q => q.Order).ToList(); // Move column int indexRemove = -1; int indexAdd = -1; for (int a = 0; a < columnsOrdered.Count; a++) { // Find the moving column index if (columnsOrdered[a].FieldName == columnMoving.FieldName) indexRemove = a; // Find the column index with the mouse over if (columnOver != null && columnsOrdered[a].FieldName == columnOver.FieldName) indexAdd = a; } // Remove column columnsOrdered.RemoveAt(indexRemove); // Check if the item needs to be inserted at the end if (indexAdd == -1) columnsOrdered.Insert(columnsOrdered.Count, columnMoving); else columnsOrdered.Insert(indexAdd, columnMoving); // Loop through columns to change the order of columnns for (int a = 0; a < columnsOrdered.Count; a++) columnsOrdered[a].Order = a; } if (controlNeedsToBeFullyInvalidated) { InvalidateSongCache(); OnInvalidateVisual(); } }