Don't position tools to last saved position if that position is not visible on screen
This commit is contained in:
parent
b5730bda3a
commit
c61d432fd6
|
@ -1,6 +1,8 @@
|
||||||
using System.Drawing;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace BizHawk.Client.Common
|
namespace BizHawk.Client.Common
|
||||||
|
@ -56,6 +58,25 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the top left corner coordinate, if Wndx and Wndy form a valid point
|
||||||
|
/// Throws an InvalidOperationException if Wndx or Wndy is null
|
||||||
|
/// It is expected to check for this before using this property
|
||||||
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
|
public Point TopLeft
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_wndx.HasValue && _wndy.HasValue)
|
||||||
|
{
|
||||||
|
return new Point(_wndx.Value, _wndy.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new InvalidOperationException("TopLeft can not be used when one of the coordinates is null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int? Width { get; set; }
|
public int? Width { get; set; }
|
||||||
public int? Height { get; set; }
|
public int? Height { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_defaultWidth = Size.Width;
|
_defaultWidth = Size.Width;
|
||||||
_defaultHeight = Size.Height;
|
_defaultHeight = Size.Height;
|
||||||
|
|
||||||
if (Settings.UseWindowPosition)
|
if (Settings.UseWindowPosition && IsOnScreen(Settings.TopLeft))
|
||||||
{
|
{
|
||||||
Location = Settings.WindowPosition;
|
Location = Settings.WindowPosition;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void TI83KeyPad_Load(object sender, EventArgs e)
|
private void TI83KeyPad_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (Global.Config.TI83KeypadSettings.UseWindowPosition)
|
if (Global.Config.TI83KeypadSettings.UseWindowPosition && IsOnScreen(Global.Config.TI83KeypadSettings.TopLeft))
|
||||||
{
|
{
|
||||||
Location = Global.Config.TI83KeypadSettings.WindowPosition;
|
Location = Global.Config.TI83KeypadSettings.WindowPosition;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||||
|
|
||||||
using BizHawk.Client.Common;
|
using BizHawk.Client.Common;
|
||||||
using BizHawk.Client.EmuHawk.WinFormExtensions;
|
using BizHawk.Client.EmuHawk.WinFormExtensions;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
|
@ -131,5 +132,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
Owner = floatingWindow ? null : GlobalWin.MainForm;
|
Owner = floatingWindow ? null : GlobalWin.MainForm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected bool IsOnScreen(Point topLeft)
|
||||||
|
{
|
||||||
|
return ToolManager.IsOnScreen(topLeft);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
@ -244,7 +245,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
RefreshSettings(form, dest, settings, idx);
|
RefreshSettings(form, dest, settings, idx);
|
||||||
|
|
||||||
if (settings.UseWindowPosition)
|
if (settings.UseWindowPosition && IsOnScreen(settings.TopLeft))
|
||||||
{
|
{
|
||||||
form.StartPosition = FormStartPosition.Manual;
|
form.StartPosition = FormStartPosition.Manual;
|
||||||
form.Location = settings.WindowPosition;
|
form.Location = settings.WindowPosition;
|
||||||
|
@ -364,6 +365,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsOnScreen(Point topLeft)
|
||||||
|
{
|
||||||
|
return Screen.AllScreens.Any(
|
||||||
|
screen => screen.WorkingArea.Contains(topLeft));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns true if an instance of T exists
|
/// Returns true if an instance of T exists
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -233,7 +233,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_defaultWidth = Size.Width;
|
_defaultWidth = Size.Width;
|
||||||
_defaultHeight = Size.Height;
|
_defaultHeight = Size.Height;
|
||||||
|
|
||||||
if (Settings.UseWindowPosition)
|
if (Settings.UseWindowPosition && IsOnScreen(Settings.TopLeft))
|
||||||
{
|
{
|
||||||
Location = Settings.WindowPosition;
|
Location = Settings.WindowPosition;
|
||||||
}
|
}
|
||||||
|
|
|
@ -464,7 +464,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_defaultWidth = Size.Width;
|
_defaultWidth = Size.Width;
|
||||||
_defaultHeight = Size.Height;
|
_defaultHeight = Size.Height;
|
||||||
|
|
||||||
if (Settings.UseWindowPosition)
|
if (Settings.UseWindowPosition && IsOnScreen(Settings.TopLeft))
|
||||||
{
|
{
|
||||||
Location = Settings.WindowPosition;
|
Location = Settings.WindowPosition;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue