-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
508 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Windows.Forms; | ||
|
||
namespace Crystallography.Controls | ||
{ | ||
public static class CheckLocation | ||
{ | ||
public static void Adjust(Form form) | ||
{ | ||
double fX = form.Location.X, fY = form.Location.Y, fW = form.Size.Width, fH = form.Size.Height; | ||
|
||
var needsAdjust = true; | ||
foreach (var scr in Screen.AllScreens) | ||
{ | ||
double bX = scr.Bounds.X, bY = scr.Bounds.Y, bW = scr.Bounds.Width, bH = scr.Bounds.Height; | ||
//どれかのウィンドウの中に20%以上含まれていたら、needsAdjustをfalse (=更新の必要なし) にする。 | ||
if ((fX - bX) / fW > -0.8 && (bX + bW - fX - fW) / fW > -0.8 && (fY - bY) / fH > -0.8 && (bY + bH - fY - fH) / fH > -0.8) | ||
needsAdjust = false; | ||
} | ||
|
||
if (needsAdjust) | ||
{ | ||
var scr = Screen.AllScreens.First(e => e.DeviceName == Screen.FromControl(form).DeviceName); | ||
form.Location = new Point(scr.Bounds.X + 100, scr.Bounds.Y + 100); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.