control extension to ensure onscreen dialog spawn
applied to tastudio dialogs (branch/marker text will use it later)
This commit is contained in:
parent
d89035c400
commit
2211a4186f
|
@ -79,6 +79,22 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return control.PointToScreen(new Point(child.Location.X, child.Location.Y));
|
return control.PointToScreen(new Point(child.Location.X, child.Location.Y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static DialogResult ShowDialogOnScreen(this Form form)
|
||||||
|
{
|
||||||
|
var topLeft = new Point(
|
||||||
|
Math.Max(0, form.Location.X),
|
||||||
|
Math.Max(0, form.Location.Y));
|
||||||
|
var screen = Screen.AllScreens
|
||||||
|
.Where(s => s.WorkingArea.Contains(topLeft))
|
||||||
|
.FirstOrDefault();
|
||||||
|
var w = screen.WorkingArea.Right - form.Bounds.Right;
|
||||||
|
var h = screen.WorkingArea.Bottom - form.Bounds.Bottom;
|
||||||
|
if (h < 0) topLeft.Y += h;
|
||||||
|
if (w < 0) topLeft.X += w;
|
||||||
|
form.SetDesktopLocation(topLeft.X, topLeft.Y);
|
||||||
|
return form.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
public static Color Add(this Color color, int val)
|
public static Color Add(this Color color, int val)
|
||||||
{
|
{
|
||||||
var col = color.ToArgb();
|
var col = color.ToArgb();
|
||||||
|
|
|
@ -590,7 +590,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private void CloneFramesXTimesMenuItem_Click(object sender, EventArgs e)
|
private void CloneFramesXTimesMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
using var framesPrompt = new FramesPrompt("Clone # Times", "Insert times to clone:");
|
using var framesPrompt = new FramesPrompt("Clone # Times", "Insert times to clone:");
|
||||||
if (framesPrompt.ShowDialog().IsOk())
|
if (framesPrompt.ShowDialogOnScreen().IsOk())
|
||||||
{
|
{
|
||||||
CloneFramesXTimes(framesPrompt.Frames);
|
CloneFramesXTimes(framesPrompt.Frames);
|
||||||
}
|
}
|
||||||
|
@ -649,7 +649,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
var insertionFrame = TasView.SelectionStartIndex ?? 0;
|
var insertionFrame = TasView.SelectionStartIndex ?? 0;
|
||||||
using var framesPrompt = new FramesPrompt();
|
using var framesPrompt = new FramesPrompt();
|
||||||
if (framesPrompt.ShowDialog().IsOk())
|
if (framesPrompt.ShowDialogOnScreen().IsOk())
|
||||||
{
|
{
|
||||||
InsertNumFrames(insertionFrame, framesPrompt.Frames);
|
InsertNumFrames(insertionFrame, framesPrompt.Frames);
|
||||||
}
|
}
|
||||||
|
@ -779,7 +779,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
InitialValue = CurrentTasMovie.ChangeLog.MaxSteps.ToString()
|
InitialValue = CurrentTasMovie.ChangeLog.MaxSteps.ToString()
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = MainForm.DoWithTempMute(() => prompt.ShowDialog());
|
var result = MainForm.DoWithTempMute(() => prompt.ShowDialogOnScreen());
|
||||||
if (result.IsOk())
|
if (result.IsOk())
|
||||||
{
|
{
|
||||||
int val = 0;
|
int val = 0;
|
||||||
|
@ -811,7 +811,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
InitialValue = (Settings.AutosaveInterval / 1000).ToString()
|
InitialValue = (Settings.AutosaveInterval / 1000).ToString()
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = MainForm.DoWithTempMute(() => prompt.ShowDialog());
|
var result = MainForm.DoWithTempMute(() => prompt.ShowDialogOnScreen());
|
||||||
if (result.IsOk())
|
if (result.IsOk())
|
||||||
{
|
{
|
||||||
uint val = uint.Parse(prompt.PromptText) * 1000;
|
uint val = uint.Parse(prompt.PromptText) * 1000;
|
||||||
|
@ -912,7 +912,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Owner = Owner,
|
Owner = Owner,
|
||||||
Location = this.ChildPointToScreen(TasView)
|
Location = this.ChildPointToScreen(TasView)
|
||||||
};
|
};
|
||||||
form.ShowDialog();
|
form.ShowDialogOnScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StateHistorySettingsMenuItem_Click(object sender, EventArgs e)
|
private void StateHistorySettingsMenuItem_Click(object sender, EventArgs e)
|
||||||
|
@ -926,7 +926,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Owner = Owner,
|
Owner = Owner,
|
||||||
Location = this.ChildPointToScreen(TasView)
|
Location = this.ChildPointToScreen(TasView)
|
||||||
};
|
};
|
||||||
form.ShowDialog();
|
form.ShowDialogOnScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CommentsMenuItem_Click(object sender, EventArgs e)
|
private void CommentsMenuItem_Click(object sender, EventArgs e)
|
||||||
|
@ -937,7 +937,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
StartPosition = FormStartPosition.Manual,
|
StartPosition = FormStartPosition.Manual,
|
||||||
Location = this.ChildPointToScreen(TasView)
|
Location = this.ChildPointToScreen(TasView)
|
||||||
};
|
};
|
||||||
form.ShowDialog();
|
form.ShowDialogOnScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SubtitlesMenuItem_Click(object sender, EventArgs e)
|
private void SubtitlesMenuItem_Click(object sender, EventArgs e)
|
||||||
|
@ -952,7 +952,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
StartPosition = FormStartPosition.Manual,
|
StartPosition = FormStartPosition.Manual,
|
||||||
Location = this.ChildPointToScreen(TasView)
|
Location = this.ChildPointToScreen(TasView)
|
||||||
};
|
};
|
||||||
form.ShowDialog();
|
form.ShowDialogOnScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DefaultStateSettingsMenuItem_Click(object sender, EventArgs e)
|
private void DefaultStateSettingsMenuItem_Click(object sender, EventArgs e)
|
||||||
|
@ -966,7 +966,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Owner = Owner,
|
Owner = Owner,
|
||||||
Location = this.ChildPointToScreen(TasView)
|
Location = this.ChildPointToScreen(TasView)
|
||||||
};
|
};
|
||||||
form.ShowDialog();
|
form.ShowDialogOnScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SettingsSubMenu_DropDownOpened(object sender, EventArgs e)
|
private void SettingsSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||||
|
@ -1089,7 +1089,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
StartPosition = FormStartPosition.Manual,
|
StartPosition = FormStartPosition.Manual,
|
||||||
Location = this.ChildPointToScreen(TasView)
|
Location = this.ChildPointToScreen(TasView)
|
||||||
};
|
};
|
||||||
form.ShowDialog();
|
form.ShowDialogOnScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WheelScrollSpeedMenuItem_Click(object sender, EventArgs e)
|
private void WheelScrollSpeedMenuItem_Click(object sender, EventArgs e)
|
||||||
|
|
Loading…
Reference in New Issue