-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: a lot of different things to move the card and reset it's position
- Loading branch information
Showing
11 changed files
with
479 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using Hearthstone_Deck_Tracker; | ||
using Core = Hearthstone_Deck_Tracker.API.Core; | ||
using System; | ||
using System.Windows.Controls; | ||
using System.Windows; | ||
using Hearthstone_Deck_Tracker.Controls; | ||
using Hearthstone_Deck_Tracker.Utility; | ||
|
||
namespace HDTAnomalyDisplay | ||
{ | ||
public class MoveCardManager | ||
{ | ||
private User32.MouseInput _mouseInput; | ||
private CardImage _card; | ||
|
||
private bool _selected; | ||
|
||
public MoveCardManager(CardImage cardImageToMove) | ||
{ | ||
_card = cardImageToMove; | ||
} | ||
|
||
public bool ToggleUILockState() | ||
{ | ||
if (Hearthstone_Deck_Tracker.Core.Game.IsRunning && _mouseInput == null) | ||
{ | ||
_mouseInput = new User32.MouseInput(); | ||
_mouseInput.LmbDown += MouseInputOnLmbDown; | ||
_mouseInput.LmbUp += MouseInputOnLmbUp; | ||
_mouseInput.MouseMoved += MouseInputOnMouseMoved; | ||
return true; | ||
} | ||
Dispose(); | ||
return false; | ||
} | ||
|
||
public bool isUILocked() | ||
{ | ||
return _mouseInput == null; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_mouseInput?.Dispose(); | ||
_mouseInput = null; | ||
_selected = false; | ||
} | ||
|
||
private void MouseInputOnLmbDown(object sender, EventArgs eventArgs) | ||
{ | ||
var pos = User32.GetMousePos(); | ||
var _mousePos = new Point(pos.X, pos.Y); | ||
if (PointInsideControl(_mousePos, _card)) | ||
{ | ||
_selected = true; | ||
} | ||
} | ||
|
||
private void MouseInputOnLmbUp(object sender, EventArgs eventArgs) | ||
{ | ||
_selected = false; | ||
} | ||
|
||
private void MouseInputOnMouseMoved(object sender, EventArgs eventArgs) | ||
{ | ||
if (!_selected) | ||
{ | ||
return; | ||
} | ||
|
||
var pos = User32.GetMousePos(); | ||
var p = Core.OverlayCanvas.PointFromScreen(new Point(pos.X, pos.Y)); | ||
|
||
// TODO check max height and width, does not work yet | ||
if (p.Y < 0) | ||
{ | ||
p.Y = 0; | ||
} | ||
else if (p.Y > Core.OverlayCanvas.Height) | ||
{ | ||
|
||
p.Y = Core.OverlayCanvas.Height; | ||
} | ||
|
||
if (p.X < 0) | ||
{ | ||
p.X = 0; | ||
} | ||
else if (p.X > Core.OverlayCanvas.Width) | ||
{ | ||
p.X = Core.OverlayCanvas.Width; | ||
} | ||
|
||
Settings.Default.AnomalyCardTop = p.Y; | ||
Settings.Default.AnomalyCardLeft = p.X; | ||
} | ||
|
||
private bool PointInsideControl(Point p, FrameworkElement control) | ||
{ | ||
var pos = control.PointFromScreen(p); | ||
return pos.X > 0 && pos.X < control.ActualWidth && pos.Y > 0 && pos.Y < control.ActualHeight; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.