mirror of
https://github.com/SourMesen/Mesen-S.git
synced 2024-06-23 06:41:55 -04:00
UI: Prevent windows from appearing outside the available screens when restoring their position
This commit is contained in:
parent
2310e8d0e9
commit
8ee5bd5a10
|
@ -33,11 +33,7 @@ namespace Mesen.GUI.Debugger
|
|||
InitShortcuts();
|
||||
|
||||
EventViewerConfig config = ConfigManager.Config.Debug.EventViewer;
|
||||
if(!config.WindowSize.IsEmpty) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = config.WindowSize;
|
||||
this.Location = config.WindowLocation;
|
||||
}
|
||||
RestoreLocation(config.WindowLocation, config.WindowSize);
|
||||
|
||||
mnuRefreshOnBreakPause.Checked = ConfigManager.Config.Debug.EventViewer.RefreshOnBreakPause;
|
||||
ctrlPpuView.ImageScale = config.ImageScale;
|
||||
|
|
|
@ -82,11 +82,7 @@ namespace Mesen.GUI.Debugger
|
|||
this.mnuShowCharacters.CheckedChanged += this.mnuShowCharacters_CheckedChanged;
|
||||
this.mnuIgnoreRedundantWrites.CheckedChanged += mnuIgnoreRedundantWrites_CheckedChanged;
|
||||
|
||||
if(!config.WindowSize.IsEmpty) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = config.WindowSize;
|
||||
this.Location = config.WindowLocation;
|
||||
}
|
||||
RestoreLocation(config.WindowLocation, config.WindowSize);
|
||||
|
||||
this.InitShortcuts();
|
||||
}
|
||||
|
|
|
@ -49,11 +49,7 @@ namespace Mesen.GUI.Debugger
|
|||
InitShortcuts();
|
||||
|
||||
SpriteViewerConfig config = ConfigManager.Config.Debug.SpriteViewer;
|
||||
if(!config.WindowSize.IsEmpty) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = config.WindowSize;
|
||||
this.Location = config.WindowLocation;
|
||||
}
|
||||
RestoreLocation(config.WindowLocation, config.WindowSize);
|
||||
|
||||
_refreshManager = new WindowRefreshManager(this);
|
||||
_refreshManager.AutoRefresh = config.AutoRefresh;
|
||||
|
|
|
@ -55,11 +55,7 @@ namespace Mesen.GUI.Debugger
|
|||
InitShortcuts();
|
||||
|
||||
TileViewerConfig config = ConfigManager.Config.Debug.TileViewer;
|
||||
if(!config.WindowSize.IsEmpty) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = config.WindowSize;
|
||||
this.Location = config.WindowLocation;
|
||||
}
|
||||
RestoreLocation(config.WindowLocation, config.WindowSize);
|
||||
|
||||
cboMemoryType.SetEnumValue(config.Source);
|
||||
cboFormat.SetEnumValue(config.Format);
|
||||
|
|
|
@ -49,11 +49,7 @@ namespace Mesen.GUI.Debugger
|
|||
InitShortcuts();
|
||||
|
||||
TilemapViewerConfig config = ConfigManager.Config.Debug.TilemapViewer;
|
||||
if(!config.WindowSize.IsEmpty) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = config.WindowSize;
|
||||
this.Location = config.WindowLocation;
|
||||
}
|
||||
RestoreLocation(config.WindowLocation, config.WindowSize);
|
||||
|
||||
mnuAutoRefresh.Checked = config.AutoRefresh;
|
||||
chkShowTileGrid.Checked = config.ShowTileGrid;
|
||||
|
|
|
@ -98,11 +98,7 @@ namespace Mesen.GUI.Debugger
|
|||
LoadBuiltInScript("Example.lua");
|
||||
}
|
||||
|
||||
if(!cfg.WindowSize.IsEmpty) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = cfg.WindowSize;
|
||||
this.Location = cfg.WindowLocation;
|
||||
}
|
||||
RestoreLocation(cfg.WindowLocation, cfg.WindowSize);
|
||||
mnuSaveBeforeRun.Checked = cfg.SaveScriptBeforeRun;
|
||||
|
||||
if(cfg.CodeWindowHeight >= ctrlSplit.Panel1MinSize) {
|
||||
|
|
|
@ -291,11 +291,7 @@ namespace Mesen.GUI.Debugger
|
|||
ctrlDisassemblyView.CodeViewer.BaseFont = font;
|
||||
ctrlDisassemblyView.CodeViewer.TextZoom = cfg.TextZoom;
|
||||
|
||||
if(!cfg.WindowSize.IsEmpty) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = cfg.WindowSize;
|
||||
this.Location = cfg.WindowLocation;
|
||||
}
|
||||
RestoreLocation(cfg.WindowLocation, cfg.WindowSize);
|
||||
|
||||
if(cfg.SplitterDistance.HasValue) {
|
||||
ctrlSplitContainer.SplitterDistance = cfg.SplitterDistance.Value;
|
||||
|
|
|
@ -32,11 +32,7 @@ namespace Mesen.GUI.Debugger
|
|||
InitializeComponent();
|
||||
|
||||
TraceLoggerInfo config = ConfigManager.Config.Debug.TraceLogger;
|
||||
if(!config.WindowSize.IsEmpty) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = config.WindowSize;
|
||||
this.Location = config.WindowLocation;
|
||||
}
|
||||
RestoreLocation(config.WindowLocation, config.WindowSize);
|
||||
|
||||
txtTraceLog.BaseFont = new Font(config.FontFamily, config.FontSize, config.FontStyle);
|
||||
txtTraceLog.TextZoom = config.TextZoom;
|
||||
|
|
|
@ -160,7 +160,24 @@ namespace Mesen.GUI.Forms
|
|||
base.AutoScaleMode = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void RestoreLocation(Point location, Size size)
|
||||
{
|
||||
if(size.IsEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
|
||||
if(!Screen.AllScreens.Any((screen) => screen.Bounds.Contains(location))) {
|
||||
//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;
|
||||
}
|
||||
this.Size = size;
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
|
|
|
@ -44,12 +44,7 @@ namespace Mesen.GUI.Forms
|
|||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
if(!ConfigManager.Config.WindowSize.IsEmpty) {
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Location = ConfigManager.Config.WindowLocation;
|
||||
this.Size = ConfigManager.Config.WindowSize;
|
||||
}
|
||||
RestoreLocation(ConfigManager.Config.WindowLocation, ConfigManager.Config.WindowSize);
|
||||
}
|
||||
|
||||
protected override void OnShown(EventArgs e)
|
||||
|
|
Loading…
Reference in a new issue