/// <summary> /// Processes windows messages /// </summary> /// <param name="args"> /// The event data /// </param> public override void OnWndProc(WindowsKeys args) { if (this.Component.Visible) { if (args.Msg == WindowsMessages.MOUSEMOVE && this.dragging && !MenuCustomizer.Instance.LockPosition.Value) { MenuSettings.Position = new Vector2(args.Cursor.X - this.xd, args.Cursor.Y - this.yd); this.hasDragged = true; } if (args.Cursor.IsUnderRectangle(this.Component.Position.X, this.Component.Position.Y, this.Component.MenuWidth, MenuSettings.ContainerHeight)) { if (args.Msg == WindowsMessages.LBUTTONDOWN && this.Component.Root) { var pos = MenuSettings.Position; this.xd = args.Cursor.X - pos.X; this.yd = args.Cursor.Y - pos.Y; this.dragging = true; } this.hovering = true; if (args.Msg == WindowsMessages.LBUTTONUP && !this.hasDragged) { this.Component.Toggle(); } } else { this.hovering = false; } } if (args.Msg == WindowsMessages.LBUTTONUP) { this.hasDragged = false; this.dragging = false; } }
/// <summary> /// KeyBind Item Windows Process Messages callback. /// </summary> /// <param name="args"> /// <see cref="WindowsKeys" /> data /// </param> public override void WndProc(WindowsKeys args) { //do nothing, we use the fast OnWndProc for keybinds }
/// <summary> /// Processes windows events /// </summary> /// <param name="args"> /// The event data /// </param> public override void OnWndProc(WindowsKeys args) { if (!this.Component.Visible) { return; } var previewRect = PreviewBoundaries(this.Component); if (args.Msg == WindowsMessages.MOUSEMOVE) { this.Component.HoveringPreview = args.Cursor.IsUnderRectangle( previewRect.X, previewRect.Y, previewRect.Width, previewRect.Height); if (this.Component.Active) { if (this.InteractingColorBox) { this.colorBox.ColorBoxMouseMove(args); } else if (this.InteractingVerticalColorSlider) { this.verticalColorSlider.VerticalColorSlider_MouseMove(args); } else if (this.InteractingVerticalAlphaSlider) { this.verticalAlphaSlider.VerticalAlphaSlider_MouseMove(args); } } } if (args.Msg == WindowsMessages.LBUTTONUP) { if (this.InteractingColorBox) { this.InteractingColorBox = false; this.colorBox.ColorBoxMouseUp(args); } if (this.InteractingVerticalColorSlider) { this.InteractingVerticalColorSlider = false; this.verticalColorSlider.VerticalColorSlider_MouseUp(args); } if (this.InteractingVerticalAlphaSlider) { this.InteractingVerticalAlphaSlider = false; this.verticalAlphaSlider.VerticalAlphaSlider_MouseUp(args); } } if (args.Msg == WindowsMessages.LBUTTONDOWN) { if (args.Cursor.IsUnderRectangle( this.ColorPickerBoundaries().X, this.ColorPickerBoundaries().Y, this.ColorPickerBoundaries().Width, this.ColorPickerBoundaries().Height)) { this.Component.Active = true; if (args.Cursor.IsUnderRectangle( this.ColorBoxBoundaries().X, this.ColorBoxBoundaries().Y, this.ColorBoxBoundaries().Width, this.ColorBoxBoundaries().Height)) { this.InteractingColorBox = true; this.colorBox.ColorBoxMouseDown(args); } else if (args.Cursor.IsUnderRectangle( this.VerticalColorSliderBoundaries().X, this.VerticalColorSliderBoundaries().Y, this.VerticalColorSliderBoundaries().Width, this.VerticalColorSliderBoundaries().Height)) { this.InteractingVerticalColorSlider = true; this.verticalColorSlider.VerticalColorSlider_MouseDown(args); } else if (args.Cursor.IsUnderRectangle( this.VerticalAlphaSliderBoundaries().X, this.VerticalAlphaSliderBoundaries().Y, this.VerticalAlphaSliderBoundaries().Width, this.VerticalAlphaSliderBoundaries().Height)) { this.InteractingVerticalAlphaSlider = true; this.verticalAlphaSlider.VerticalAlphaSlider_MouseDown(args); } else if (args.Cursor.IsUnderRectangle( this.ApplyButtonBoundaries().X, this.ApplyButtonBoundaries().Y, this.ApplyButtonBoundaries().Width, this.ApplyButtonBoundaries().Height)) { this.Component.Active = false; this.Component.Color = this.colorBox.Rgb.ToSharpDxColor(); } else if (args.Cursor.IsUnderRectangle( this.CancelButtonBoundaries().X, this.CancelButtonBoundaries().Y, this.CancelButtonBoundaries().Width, this.CancelButtonBoundaries().Height)) { this.Component.Active = false; this.colorBox.Rgb = this.Component.Color.ToSystemColor(); this.verticalColorSlider.Rgb = this.Component.Color.ToSystemColor(); this.verticalAlphaSlider.Rgb = this.Component.Color.ToSystemColor(); } } else if (args.Cursor.IsUnderRectangle( previewRect.X, previewRect.Y, previewRect.Width, previewRect.Height)) { this.Component.Active = true; } else { this.Component.Active = false; } } }
/// <summary> /// <c>OnWndProc</c> event, occurs on a windows process message to the thread. /// </summary> /// <param name="basePosition"> /// The base position /// </param> /// <param name="windowsKeys"> /// The windows keys /// </param> /// <param name="isEdit"> /// Indicates whether it's an edit message. /// </param> public override void OnWndProc(Vector2 basePosition, WindowsKeys windowsKeys, bool isEdit) { basePosition.X += this.hideOffsetX; if (!isEdit) { if (windowsKeys.Msg == WindowsMessages.LBUTTONDOWN && windowsKeys.Cursor.IsUnderRectangle( basePosition.X - this.Width - 5, basePosition.Y, this.Width, this.HeaderHeight)) { windowsKeys.Process = false; this.IsOpen = !this.IsOpen; } if (windowsKeys.Msg == WindowsMessages.LBUTTONDOWN && windowsKeys.Cursor.IsUnderRectangle( basePosition.X - this.Width + 5f, basePosition.Y + this.HeaderHeight + this.BodyHeight + 1.5f, HideBitmap.Width - 3, HideBitmap.Height * 0.7f) && this.DrawBodyHeight >= this.BodyHeight && this.DrawFooterHeight >= this.FooterHeight) { windowsKeys.Process = false; this.hideAnimation = !this.hideAnimation; } } }
/// <summary> /// Processes windows messages /// </summary> /// <param name="args">The event data</param> public override void OnWndProc(WindowsKeys args) { if (!this.Component.Visible) { return; } var dropdownRect = this.DropDownBoundaries(this.Component); var entireDropdownRect = this.DropDownExpandedBoundaries(this.Component); if (args.Cursor.IsUnderRectangle(dropdownRect.X, dropdownRect.Y, dropdownRect.Width, dropdownRect.Height)) { this.Component.Hovering = true; if (args.Msg == WindowsMessages.LBUTTONDOWN) { this.Component.Active = !this.Component.Active; } } else { this.Component.Hovering = false; } const int Buffer = 20; if (this.Component.Active && !args.Cursor.IsUnderRectangle( entireDropdownRect.X - Buffer, entireDropdownRect.Y - Buffer, entireDropdownRect.Width + (2 * Buffer), entireDropdownRect.Height + (2 * Buffer))) { this.Component.Active = false; } if (this.Component.Active) { var found = false; var dropdownRectangles = this.DropDownListBoundaries(this.Component); for (var i = 0; i < dropdownRectangles.Count; i++) { if (args.Cursor.IsUnderRectangle( dropdownRectangles[i].X, dropdownRectangles[i].Y, dropdownRectangles[i].Width, dropdownRectangles[i].Height)) { this.Component.HoveringIndex = i; found = true; } } if (!found) { this.Component.HoveringIndex = -1; } else if (args.Msg == WindowsMessages.LBUTTONDOWN) { this.Component.Index = this.Component.HoveringIndex; args.Process = false; } } }
/// <summary> /// <c>OnWndProc</c> event. /// </summary> /// <param name="args"> /// The event data. /// </param> private static void OnWndProc(WndEventArgs args) { var windowsKeys = new WindowsKeys(args); var height = Position.Y; var edit = Menu["edit"].GetValue<MenuBool>().Value; foreach (var notification in NotificationsList.ToArray()) { notification.OnWndProc(new Vector2(Position.X, height), windowsKeys, edit); height += notification.GetReservedHeight(); } var notificationW = NotificationsList.MaxOrDefault(n => n.GetReservedWidth()); var widthRectangle = notificationW != null ? notificationW.GetReservedWidth() : 300f; if (windowsKeys.Msg == WindowsMessages.LBUTTONDOWN || windowsKeys.Msg == WindowsMessages.LBUTTONUP) { var heightRectangle = NotificationsList.Where((t, i) => i < NotificationsList.Count).Sum(t => t.GetReservedHeight()); if (Math.Abs(heightRectangle) < float.Epsilon) { heightRectangle = 30f; } var value = windowsKeys.Msg == WindowsMessages.LBUTTONDOWN; EditButtonDown = value && windowsKeys.Cursor.IsUnderRectangle( Position.X - widthRectangle, Position.Y, widthRectangle, heightRectangle); if (!value) { MouseLocation = null; MouseOffsetX = 0f; } } if (edit && EditButtonDown) { if (MouseLocation.HasValue) { Position += MouseLocation.Value - Position; Position = new Vector2(Position.X + MouseOffsetX, Position.Y + MouseOffsetY); } else { MouseOffsetX = Position.X - windowsKeys.Cursor.X; MouseOffsetY = Position.Y - windowsKeys.Cursor.Y; } MouseLocation = windowsKeys.Cursor; } }
/// <summary> /// Windows Process Messages callback. /// </summary> /// <param name="args"><see cref="WindowsKeys" /> data</param> public override void WndProc(WindowsKeys args) { this.Handler.OnWndProc(args); }
/// <summary> /// Handles the window events for this <see cref="AMenuComponent" />. /// </summary> /// <param name="args">Event data</param> public abstract void OnWndProc(WindowsKeys args);
/// <summary> /// <c>OnWndProc</c> event, occurs on a windows process message to the thread. /// </summary> /// <param name="basePosition"> /// The base position /// </param> /// <param name="windowsKeys"> /// The windows keys /// </param> /// <param name="isEdit"> /// Indicates whether it's an edit message. /// </param> public abstract void OnWndProc(Vector2 basePosition, WindowsKeys windowsKeys, bool isEdit);
/// <summary> /// Handles the window events for this <see cref="AMenuComponent" />. /// </summary> /// <param name="args">Event data</param> public override void OnWndProc(WindowsKeys args) { // Do nothing. }
/// <summary> /// Gets fired when the mouse is released and pressed before /// </summary> /// <param name="args">Keys</param> public void ColorBoxMouseUp(WindowsKeys args) { if (this.mDragging && args.Msg == WindowsMessages.LBUTTONUP && !this.mDisabled) { this.mDragging = false; var x = (int)args.Cursor.X - 2 - (int)this.mPos.X; var y = (int)args.Cursor.Y - 2 - (int)this.mPos.Y; if (x < 0) { x = 0; } if (x > (this.mWidth - 4)) { x = (this.mWidth - 4); } if (y < 0) { y = 0; } if (y > (this.mHeight - 4)) { y = (this.mHeight - 4); } this.mMarkerX = x; this.mMarkerY = y; this.DrawMarker(x, y, true); // Redraw the marker this.ResetHslrgb(); // Reset the color if (this.ColorBoxScrolled != null) { this.ColorBoxScrolled(); } } }
/// <summary> /// Gets fired when the mouse is released and pressed before /// </summary> /// <param name="args">Keys</param> public void VerticalAlphaSlider_MouseUp(WindowsKeys args) { if (this.mBDragging && args.Msg == WindowsMessages.LBUTTONUP && !mDisabled) { this.mBDragging = false; var y = (int)args.Cursor.Y - (int)this.Position.Y; y -= 4; if (y < 0) { y = 0; } if (y > (this.mHeight - 9)) { y = (this.mHeight - 9); } this.ArrowPos = y; this.DrawSlider(y, false); this.ResetHslrgb(); if (this.AlphaSliderScroll != null) { this.AlphaSliderScroll(); } } }
/// <summary> /// Gets fired when the mouse is moved and pressed before /// </summary> /// <param name="args">Keys</param> public void VerticalColorSlider_MouseMove(WindowsKeys args) { if (this.mDragging && args.Msg == WindowsMessages.MOUSEMOVE && !this.mDisabled) { var y = (int)args.Cursor.Y - (int)this.Position.Y; y -= 4; if (y < 0) { y = 0; } if (y > (this.mHeight - 9)) { y = (this.mHeight - 9); } this.ArrowPos = y; this.DrawSlider(y, false); this.ResetHslrgb(); if (this.ColorSliderScroll != null) { this.ColorSliderScroll(); } } }
/// <summary> /// Gets fired when the left mouse button is pressed /// </summary> /// <param name="args">Keys</param> public void VerticalColorSlider_MouseDown(WindowsKeys args) { if (args.Msg == WindowsMessages.LBUTTONDOWN) { this.mDragging = true; var y = (int)args.Cursor.Y - (int)this.Position.Y; y -= 4; if (y < 0) { y = 0; } if (y > (this.mHeight - 9)) { y = (this.mHeight - 9); } this.ArrowPos = y; this.DrawSlider(y, false); this.ResetHslrgb(); if (this.ColorSliderScroll != null) { this.ColorSliderScroll(); } } }
/// <summary> /// On Window Process Message event. /// </summary> /// <param name="args"> /// Event data /// </param> private void Game_OnWndProc(WndEventArgs args) { if (MenuGUI.IsChatOpen) { return; } var keys = new WindowsKeys(args); if (!this.ForcedOpen) { if (keys.SingleKey == Keys.ShiftKey || keys.Key == (Keys.Return | Keys.Shift)) { var keyDown = keys.Msg == WindowsMessages.KEYDOWN; var keyUp = keys.Msg == WindowsMessages.KEYUP || keys.Msg == WindowsMessages.CHAR; if (keyDown) { if (!this.MenuVisible) { this.MenuVisible = true; this.FireOnOpen(); } } else if (keyUp) { if (this.MenuVisible) { this.MenuVisible = false; this.FireOnClose(); } } } else if (keys.SingleKey == Keys.CapsLock && keys.Msg == WindowsMessages.KEYDOWN) { this.MenuVisible = !this.MenuVisible; if (this.MenuVisible) { this.FireOnOpen(); } else { this.FireOnClose(); } } } foreach (var component in this.menus) { component.OnWndProc(keys); } }