Update Sprite.cs
This commit is contained in:
1 parent
630f888fbe
commit
41566e8829
1 file changed
-40
@@ -1,46 +1,13 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
|
||||||
|
|
||||||
namespace HandyControl.Controls
|
namespace HandyControl.Controls
|
||||||
{
|
{
|
||||||
public sealed class Sprite : System.Windows.Window
|
public sealed class Sprite : System.Windows.Window
|
||||||
{
|
{
|
||||||
private bool _isLeftButtonPressed;
|
|
||||||
|
|
||||||
private double _leftMax;
|
|
||||||
|
|
||||||
private double _topMax;
|
|
||||||
|
|
||||||
private Sprite()
|
private Sprite()
|
||||||
{
|
{
|
||||||
WindowStyle = WindowStyle.None;
|
WindowStyle = WindowStyle.None;
|
||||||
AllowsTransparency = true;
|
AllowsTransparency = true;
|
||||||
InputManager.Current.PostProcessInput += Current_PostProcessInput;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Current_PostProcessInput(object sender, ProcessInputEventArgs e)
|
|
||||||
{
|
|
||||||
if (Mouse.LeftButton == MouseButtonState.Pressed)
|
|
||||||
{
|
|
||||||
_isLeftButtonPressed = true;
|
|
||||||
}
|
|
||||||
else if (_isLeftButtonPressed)
|
|
||||||
{
|
|
||||||
if (Left < 0)
|
|
||||||
{
|
|
||||||
Left = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Left > _leftMax)
|
|
||||||
{
|
|
||||||
Left = _leftMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Top > _topMax)
|
|
||||||
{
|
|
||||||
Top = _topMax;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Sprite Show(object content)
|
public static Sprite Show(object content)
|
||||||
@@ -51,13 +18,6 @@ namespace HandyControl.Controls
|
|||||||
};
|
};
|
||||||
|
|
||||||
sprite.Show();
|
sprite.Show();
|
||||||
|
|
||||||
var desktopWorkingArea = SystemParameters.WorkArea;
|
|
||||||
sprite._leftMax = desktopWorkingArea.Width - sprite.ActualWidth;
|
|
||||||
sprite._topMax = desktopWorkingArea.Height - sprite.ActualHeight;
|
|
||||||
sprite.Left = sprite._leftMax - 50;
|
|
||||||
sprite.Top = 50 - sprite.Padding.Top;
|
|
||||||
|
|
||||||
return sprite;
|
return sprite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user