Ejemplo n.º 1
0
        private IDisposable OpenWindow(PixelSize?size, ShowWindowMode mode, WindowStartupLocation location)
        {
            var sizeTextBox      = _session.FindElementByAccessibilityId("ShowWindowSize");
            var modeComboBox     = _session.FindElementByAccessibilityId("ShowWindowMode");
            var locationComboBox = _session.FindElementByAccessibilityId("ShowWindowLocation");
            var showButton       = _session.FindElementByAccessibilityId("ShowWindow");

            if (size.HasValue)
            {
                sizeTextBox.SendKeys($"{size.Value.Width}, {size.Value.Height}");
            }

            modeComboBox.Click();
            _session.FindElementByName(mode.ToString()).SendClick();

            locationComboBox.Click();
            _session.FindElementByName(location.ToString()).SendClick();

            return(showButton.OpenWindowWithClick());
        }
Ejemplo n.º 2
0
        void UpdateSizeHints(PixelSize?preResize)
        {
            var min = _minMaxSize.minSize;
            var max = _minMaxSize.maxSize;

            if (!_canResize)
            {
                max = min = _realSize;
            }

            if (preResize.HasValue)
            {
                var desired = preResize.Value;
                max = new PixelSize(Math.Max(desired.Width, max.Width), Math.Max(desired.Height, max.Height));
                min = new PixelSize(Math.Min(desired.Width, min.Width), Math.Min(desired.Height, min.Height));
            }

            var hints = new XSizeHints
            {
                min_width  = min.Width,
                min_height = min.Height
            };

            hints.height_inc = hints.width_inc = 1;
            var flags = XSizeHintsFlags.PMinSize | XSizeHintsFlags.PResizeInc;

            // People might be passing double.MaxValue
            if (max.Width < 100000 && max.Height < 100000)
            {
                hints.max_width  = max.Width;
                hints.max_height = max.Height;
                flags           |= XSizeHintsFlags.PMaxSize;
            }

            hints.flags = (IntPtr)flags;

            XSetWMNormalHints(_x11.Display, _handle, ref hints);
        }