// along with this program; if not, see <http://www.gnu.org/licenses/>.\r
\r
using System.Collections.Generic;\r
+using System.Drawing;\r
using System.IO;\r
using System.Windows.Forms;\r
using Codeplex.Data;\r
{\r
private readonly string _configFileName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "config.json");\r
\r
+ public Point Location { get; set; }\r
public bool TopMost { get; set; }\r
public bool FlashWindow { get; set; }\r
public bool ShowBaloonTip { get; set; }\r
\r
public Config()\r
{\r
+ Location = new Point(int.MinValue, int.MinValue);\r
FlashWindow = ShowBaloonTip = PlaySound = true;\r
MarginShips = 4;\r
ResetHours = new List<int>();\r
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)\r
{\r
FiddlerApplication.Shutdown();\r
+ _config.Location = (WindowState == FormWindowState.Normal ? Bounds : RestoreBounds).Location;\r
_config.Save();\r
_sniffer.SaveState();\r
}\r
_wmp.settings.volume = _config.SoundVolume;\r
_sniffer.Item.MarginShips = _config.MarginShips;\r
_sniffer.Achievement.ResetHours = _config.ResetHours;\r
+ if (_config.Location.X == int.MinValue)\r
+ return;\r
+ var newBounds = Bounds;\r
+ newBounds.Location = _config.Location;\r
+ if (IsVisibleOnAnyScreen(newBounds))\r
+ Location = _config.Location;\r
+ }\r
+\r
+ private bool IsVisibleOnAnyScreen(Rectangle rect)\r
+ {\r
+ return Screen.AllScreens.Any(screen => screen.WorkingArea.IntersectsWith(rect));\r
}\r
\r
private void timerMain_Tick(object sender, EventArgs e)\r