public void FormAllowedRightOffScreenToPixelBuffer(int pixelsAllowed, bool equal)
        {
            var form = new MainForm();

            _settingsPath = form.LocatorSettings;

            // for multiple screens, be sure our test case uses the max right value.
            for (int i = 0; i < Screen.AllScreens.Length; i++)
            {
                SetFormLocation(pixelsAllowed, form);
            }

            // save the initialized setting.
            var testPoint = form.Location;

            form.Show();
            form.Close();

            var settings      = FormSettings.GetSettingsList(_settingsPath);
            var offScreenTest = settings.FirstOrDefault(s => s.Name == "MainForm");

            Console.WriteLine($"Before: {testPoint} - After: {offScreenTest.Location}");

            AssertLocationPosition(testPoint, offScreenTest, equal);
        }
        public void FormWillNotAppearOffScreenTest(int X, int Y, string msg)
        {
            var form = new MainForm();

            _settingsPath = form.LocatorSettings;
            var testPoint = new Point(X, Y);

            form.Location = testPoint;
            form.Show();
            form.Close();

            var settings      = FormSettings.GetSettingsList(_settingsPath);
            var offScreenTest = settings.FirstOrDefault(s => s.Name == "MainForm");

            Assert.AreNotEqual(testPoint, offScreenTest.Location);
            Console.WriteLine($"Message: {msg} ---- Before: {testPoint} - After: {offScreenTest.Location}");
        }
        public void FormAllowedBottomOffScreenToPixelBuffer(int pixelsAllowed, bool equal)
        {
            var form   = new MainForm();
            var screen = Screen.FromControl(form).Bounds;

            var taskBarHeight = 40;
            var X             = 200;
            var Y             = screen.Bottom - taskBarHeight - pixelsAllowed;

            _settingsPath = form.LocatorSettings;
            var testPoint = new Point(X, Y);

            form.Location = testPoint;
            form.Show();
            form.Close();

            var settings      = FormSettings.GetSettingsList(_settingsPath);
            var offScreenTest = settings.FirstOrDefault(s => s.Name == "MainForm");

            Console.WriteLine($"Before: {testPoint} - After: {offScreenTest.Location}");

            AssertLocationPosition(testPoint, offScreenTest, equal);
        }
Example #4
0
        public void SetFormIntoSecondScreenOutOfBounds()
        {
            if (File.Exists(_settingsPath))
            {
                File.Delete(_settingsPath);
            }

            var _form = new MainForm();

            _form.Size = new Size(640, 480);
            // location to the right screen
            _form.Location = new Point(_bounds.Right - 49, 200);
            _form.Name     = "Chewbaca";

            _settingsPath = _form.LocatorSettings;

            _form.Show();
            _form.Close();

            var settings    = FormSettings.GetSettingsList(_settingsPath);
            var thisSetting = settings.FirstOrDefault(f => f.Name == _form.Name);

            Assert.AreEqual(200, thisSetting.Location.X);
        }
        private FormLocator GetFormLocator()
        {
            var formSettings = FormSettings.GetSettingsList(_locator.SettingsPath);

            return(formSettings.FirstOrDefault(f => f.Name == _form.Name));
        }