mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Cubes multi monitor fix
This commit is contained in:
parent
475ce001a7
commit
578354c7eb
4 changed files with 24 additions and 15 deletions
|
@ -46,7 +46,8 @@ public static class CompanionCubeManager
|
|||
private static Timer timer;
|
||||
private static Stopwatch startTime;
|
||||
private static TimeSpan previousElapsed;
|
||||
private static Rectangle screen;
|
||||
private static Rectangle area;
|
||||
private static Bitmap companionCube;
|
||||
|
||||
public static void Toggle()
|
||||
{
|
||||
|
@ -65,20 +66,23 @@ public static void Start()
|
|||
if (!IsActive)
|
||||
{
|
||||
IsActive = true;
|
||||
screen = CaptureHelpers.GetScreenWorkingArea();
|
||||
|
||||
companionCube = Resources.CompanionCube;
|
||||
|
||||
if (cubesForm != null) cubesForm.Close();
|
||||
cubesForm = new CompanionCubesForm();
|
||||
cubesForm.MouseClick += CubesForm_MouseClick;
|
||||
cubesForm.Show();
|
||||
|
||||
area = new Rectangle(0, 0, cubesForm.Width, cubesForm.Height);
|
||||
|
||||
Cubes = new List<CompanionCube>(CubeCount);
|
||||
|
||||
for (int i = 0; i < CubeCount; i++)
|
||||
{
|
||||
CompanionCube cube = new CompanionCube(MathHelpers.Random(50, 100), MathHelpers.Random(250, 500));
|
||||
cube.Location = new Point(MathHelpers.Random(screen.X, screen.X + screen.Width - cube.Size.Width),
|
||||
MathHelpers.Random(screen.Y - cube.Size.Height - 500, screen.Y - cube.Size.Height));
|
||||
cube.Location = new Point(MathHelpers.Random(area.X, area.X + area.Width - cube.Size.Width),
|
||||
MathHelpers.Random(area.Y - cube.Size.Height - 500, area.Y - cube.Size.Height));
|
||||
Cubes.Add(cube);
|
||||
}
|
||||
|
||||
|
@ -86,7 +90,7 @@ public static void Start()
|
|||
startTime = Stopwatch.StartNew();
|
||||
|
||||
timer = new Timer();
|
||||
timer.Interval = 10;
|
||||
timer.Interval = 20;
|
||||
timer.Tick += Timer_Tick;
|
||||
timer.Start();
|
||||
}
|
||||
|
@ -116,6 +120,12 @@ public static void Stop()
|
|||
cubesForm = null;
|
||||
}
|
||||
|
||||
if (companionCube != null)
|
||||
{
|
||||
companionCube.Dispose();
|
||||
companionCube = null;
|
||||
}
|
||||
|
||||
if (Cubes != null)
|
||||
{
|
||||
Cubes.Clear();
|
||||
|
@ -150,9 +160,9 @@ private static void Timer_Tick(object sender, EventArgs e)
|
|||
}
|
||||
}
|
||||
|
||||
if (!intersect && newLocation.Y + cube.Size.Height > screen.Y + screen.Height)
|
||||
if (!intersect && newLocation.Y + cube.Size.Height > area.Y + area.Height)
|
||||
{
|
||||
newLocation = new Point(cube.Location.X, screen.Height - cube.Size.Height);
|
||||
newLocation = new Point(cube.Location.X, area.Height - cube.Size.Height);
|
||||
}
|
||||
|
||||
cube.Location = newLocation;
|
||||
|
@ -163,15 +173,14 @@ private static void Timer_Tick(object sender, EventArgs e)
|
|||
|
||||
private static void DrawCubes()
|
||||
{
|
||||
using (Bitmap companionCube = Resources.CompanionCube)
|
||||
using (Bitmap surface = new Bitmap(screen.Width, screen.Height))
|
||||
using (Bitmap surface = new Bitmap(area.Width, area.Height))
|
||||
using (Graphics g = Graphics.FromImage(surface))
|
||||
{
|
||||
foreach (CompanionCube cube in Cubes)
|
||||
{
|
||||
if (cube.IsActive)
|
||||
if (cube.IsActive && area.IntersectsWith(cube.Rectangle))
|
||||
{
|
||||
g.DrawImage(companionCube, new Rectangle(CaptureHelpers.ScreenToClient(cube.Location), cube.Size));
|
||||
g.DrawImage(companionCube, new Rectangle(cube.Location, cube.Size));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public class CompanionCubesForm : LayeredForm
|
|||
public CompanionCubesForm()
|
||||
{
|
||||
StartPosition = FormStartPosition.Manual;
|
||||
Bounds = CaptureHelpers.GetScreenBounds();
|
||||
Bounds = CaptureHelpers.GetScreenWorkingArea();
|
||||
Shown += CompanionCubesForm_Shown;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public static ShareXBuild Build
|
|||
}
|
||||
}
|
||||
|
||||
public static bool IsBeta { get; } = true;
|
||||
public static bool IsBeta { get; } = false;
|
||||
|
||||
public static string Title
|
||||
{
|
||||
|
|
|
@ -11,5 +11,5 @@
|
|||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("82E6AC09-0FEF-4390-AD9F-0DD3F5561EFC")]
|
||||
[assembly: AssemblyVersion("10.2.6")]
|
||||
[assembly: AssemblyFileVersion("10.2.6")]
|
||||
[assembly: AssemblyVersion("10.3.0")]
|
||||
[assembly: AssemblyFileVersion("10.3.0")]
|
Loading…
Reference in a new issue