UI: Prevent windows from appearing outside the available screens when restoring their position
This commit is contained in:
parent
da4aed5405
commit
ccb689dbdd
15 changed files with 36 additions and 68 deletions
|
@ -25,10 +25,7 @@ namespace Mesen.GUI.Debugger
|
|||
this.Width = (int)(this.Width * 1.2);
|
||||
}
|
||||
|
||||
if(ConfigManager.Config.DebugInfo.ApuViewerLocation.HasValue) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Location = ConfigManager.Config.DebugInfo.ApuViewerLocation.Value;
|
||||
}
|
||||
RestoreLocation(ConfigManager.Config.DebugInfo.ApuViewerLocation);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,11 +36,8 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
DebugInfo config = ConfigManager.Config.DebugInfo;
|
||||
|
||||
if(!config.AssemblerSize.IsEmpty) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = config.AssemblerSize;
|
||||
this.Location = config.AssemblerLocation;
|
||||
}
|
||||
RestoreLocation(config.AssemblerLocation, config.AssemblerSize);
|
||||
|
||||
mnuEnableSyntaxHighlighting.Checked = config.AssemblerCodeHighlighting;
|
||||
|
||||
txtCode.Font = new Font(config.AssemblerFontFamily, config.AssemblerFontSize, config.AssemblerFontStyle);
|
||||
|
|
|
@ -134,10 +134,7 @@ namespace Mesen.GUI.Debugger
|
|||
ctrlDebuggerCodeSplit.ShowMemoryValues = mnuShowMemoryValues.Checked;
|
||||
|
||||
if(ConfigManager.Config.DebugInfo.WindowWidth > -1) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Width = ConfigManager.Config.DebugInfo.WindowWidth;
|
||||
this.Height = ConfigManager.Config.DebugInfo.WindowHeight;
|
||||
this.Location = ConfigManager.Config.DebugInfo.WindowLocation;
|
||||
RestoreLocation(ConfigManager.Config.DebugInfo.WindowLocation, new Size(ConfigManager.Config.DebugInfo.WindowWidth, ConfigManager.Config.DebugInfo.WindowHeight));
|
||||
}
|
||||
|
||||
tsToolbar.Visible = mnuShowToolbar.Checked;
|
||||
|
|
|
@ -63,10 +63,7 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
DebugWorkspaceManager.GetWorkspace();
|
||||
|
||||
if(!ConfigManager.Config.DebugInfo.EventViewerLocation.IsEmpty) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Location = ConfigManager.Config.DebugInfo.EventViewerLocation;
|
||||
}
|
||||
RestoreLocation(ConfigManager.Config.DebugInfo.EventViewerLocation);
|
||||
|
||||
this._notifListener = new InteropEmu.NotificationListener(ConfigManager.Config.DebugInfo.DebugConsoleId);
|
||||
this._notifListener.OnNotification += this._notifListener_OnNotification;
|
||||
|
|
|
@ -94,11 +94,7 @@ namespace Mesen.GUI.Debugger
|
|||
this.mnuShowCharacters.CheckedChanged += this.mnuShowCharacters_CheckedChanged;
|
||||
this.mnuIgnoreRedundantWrites.CheckedChanged += mnuIgnoreRedundantWrites_CheckedChanged;
|
||||
|
||||
if(!ConfigManager.Config.DebugInfo.MemoryViewerSize.IsEmpty) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = ConfigManager.Config.DebugInfo.MemoryViewerSize;
|
||||
this.Location = ConfigManager.Config.DebugInfo.MemoryViewerLocation;
|
||||
}
|
||||
RestoreLocation(ConfigManager.Config.DebugInfo.MemoryViewerLocation, ConfigManager.Config.DebugInfo.MemoryViewerSize);
|
||||
|
||||
this.InitShortcuts();
|
||||
}
|
||||
|
|
|
@ -48,10 +48,7 @@ namespace Mesen.GUI.Debugger
|
|||
default: startupLocation = ConfigManager.Config.DebugInfo.PpuWindowLocation; break;
|
||||
}
|
||||
|
||||
if(startupLocation.HasValue) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Location = startupLocation.Value;
|
||||
}
|
||||
RestoreLocation(startupLocation);
|
||||
}
|
||||
|
||||
public static int GetNextPpuViewerId()
|
||||
|
|
|
@ -24,11 +24,7 @@ namespace Mesen.GUI.Debugger
|
|||
ctrlProfiler.RefreshData();
|
||||
tmrRefresh.Start();
|
||||
|
||||
if(!ConfigManager.Config.DebugInfo.ProfilerSize.IsEmpty) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = ConfigManager.Config.DebugInfo.ProfilerSize;
|
||||
this.Location = ConfigManager.Config.DebugInfo.ProfilerLocation;
|
||||
}
|
||||
RestoreLocation(ConfigManager.Config.DebugInfo.ProfilerLocation, ConfigManager.Config.DebugInfo.ProfilerSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -103,11 +103,7 @@ namespace Mesen.GUI.Debugger
|
|||
}
|
||||
}
|
||||
|
||||
if(!config.ScriptWindowSize.IsEmpty) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = config.ScriptWindowSize;
|
||||
this.Location = config.ScriptWindowLocation;
|
||||
}
|
||||
RestoreLocation(config.ScriptWindowLocation, config.ScriptWindowSize);
|
||||
mnuSaveBeforeRun.Checked = config.SaveScriptBeforeRun;
|
||||
|
||||
if(config.ScriptCodeWindowHeight >= ctrlSplit.Panel1MinSize) {
|
||||
|
|
|
@ -36,10 +36,7 @@ namespace Mesen.GUI.Debugger
|
|||
this.mnuAutoRefresh.Checked = ConfigManager.Config.DebugInfo.TextHookerAutoRefresh;
|
||||
this.mnuRefreshOnBreak.Checked = ConfigManager.Config.DebugInfo.TextHookerRefreshOnBreak;
|
||||
|
||||
if(ConfigManager.Config.DebugInfo.TextHookerWindowLocation.HasValue) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Location = ConfigManager.Config.DebugInfo.TextHookerWindowLocation.Value;
|
||||
}
|
||||
RestoreLocation(ConfigManager.Config.DebugInfo.TextHookerWindowLocation);
|
||||
}
|
||||
|
||||
static frmTextHooker()
|
||||
|
|
|
@ -32,11 +32,7 @@ namespace Mesen.GUI.Debugger
|
|||
InitializeComponent();
|
||||
|
||||
DebugInfo debugInfo = ConfigManager.Config.DebugInfo;
|
||||
if(!debugInfo.TraceLoggerSize.IsEmpty) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = debugInfo.TraceLoggerSize;
|
||||
this.Location = debugInfo.TraceLoggerLocation;
|
||||
}
|
||||
RestoreLocation(debugInfo.TraceLoggerLocation, debugInfo.TraceLoggerSize);
|
||||
|
||||
_tooltipManager = new CodeTooltipManager(this, txtTraceLog);
|
||||
|
||||
|
|
|
@ -21,12 +21,7 @@ namespace Mesen.GUI.Debugger
|
|||
InitializeComponent();
|
||||
|
||||
if(!DesignMode) {
|
||||
if(!ConfigManager.Config.DebugInfo.WatchWindowSize.IsEmpty) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = ConfigManager.Config.DebugInfo.WatchWindowSize;
|
||||
this.Location = ConfigManager.Config.DebugInfo.WatchWindowLocation;
|
||||
}
|
||||
|
||||
RestoreLocation(ConfigManager.Config.DebugInfo.WatchWindowLocation, ConfigManager.Config.DebugInfo.WatchWindowSize);
|
||||
this.toolTip.SetToolTip(picWatchHelp, ctrlWatch.GetTooltipText());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -197,7 +197,27 @@ namespace Mesen.GUI.Forms
|
|||
base.AutoScaleMode = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void RestoreLocation(Point? location, Size? size = null)
|
||||
{
|
||||
if(!location.HasValue || size.HasValue && size.Value.IsEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
|
||||
if(!Screen.AllScreens.Any((screen) => screen.Bounds.Contains(location.Value))) {
|
||||
//If no screen contains the top left corner of the form, reset it to the primary screen
|
||||
this.Location = Screen.PrimaryScreen.Bounds.Location;
|
||||
} else {
|
||||
this.Location = location.Value;
|
||||
}
|
||||
|
||||
if(size != null) {
|
||||
this.Size = size.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
|
|
|
@ -33,11 +33,7 @@ namespace Mesen.GUI.Forms.Cheats
|
|||
|
||||
ctrlCheatFinder.OnAddCheat += CtrlCheatFinder_OnAddCheat;
|
||||
|
||||
if(!ConfigManager.Config.CheatWindowSize.IsEmpty) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = ConfigManager.Config.CheatWindowSize;
|
||||
this.Location = ConfigManager.Config.CheatWindowLocation;
|
||||
}
|
||||
RestoreLocation(ConfigManager.Config.CheatWindowLocation, ConfigManager.Config.CheatWindowSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,13 +27,7 @@ namespace Mesen.GUI.Forms
|
|||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
if(ConfigManager.Config.HistoryViewerInfo.WindowSize.HasValue) {
|
||||
this.Size = ConfigManager.Config.HistoryViewerInfo.WindowSize.Value;
|
||||
}
|
||||
if(ConfigManager.Config.HistoryViewerInfo.WindowLocation.HasValue) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Location = ConfigManager.Config.HistoryViewerInfo.WindowLocation.Value;
|
||||
}
|
||||
RestoreLocation(ConfigManager.Config.HistoryViewerInfo.WindowLocation, ConfigManager.Config.HistoryViewerInfo.WindowSize);
|
||||
|
||||
_isNsf = InteropEmu.IsNsf();
|
||||
tlpRenderer.Visible = !_isNsf;
|
||||
|
|
|
@ -237,10 +237,7 @@ namespace Mesen.GUI.Forms
|
|||
InitializeStateMenu(mnuSaveState, true);
|
||||
InitializeStateMenu(mnuLoadState, false);
|
||||
|
||||
if(ConfigManager.Config.WindowLocation.HasValue) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Location = ConfigManager.Config.WindowLocation.Value;
|
||||
}
|
||||
RestoreLocation(ConfigManager.Config.WindowLocation);
|
||||
|
||||
if(ConfigManager.Config.PreferenceInfo.CloudSaveIntegration) {
|
||||
Task.Run(() => CloudSyncHelper.Sync());
|
||||
|
|
Loading…
Add table
Reference in a new issue