Exemplo n.º 1
0
        static CGRect GetXapHostRect()
        {
            foreach (var window in InspectableWindow.GetWindows("com.xamarin.androiddevice",
                                                                onScreenOnly: false))
            {
                if (window.Title == null || !window.Title.StartsWith("Xamarin Android Player - ",
                                                                     StringComparison.Ordinal))
                {
                    continue;
                }

                var xapRect = window.Bounds;
                xapRect.Y      += 22;
                xapRect.Height -= 22;
                return(xapRect);
            }

            return(CGRect.Empty);
        }
        public iOSSimulatorCoordinateMapper(AgentIdentity agentIdentity)
        {
            // TODO: Pick the correct window with extra information available when Device Switching work
            //       lands. For now, we know we always launch 5s, but in Xcode 9 there may be multiple
            //       sims open simultaneously.
            var window = InspectableWindow
                         .GetWindows("com.apple.iphonesimulator")
                         .FirstOrDefault(w => w.Title != null &&
                                         (ClientInfo.Flavor == ClientFlavor.Inspector || w.Title.Contains("5s")));

            if (window == null)
            {
                Log.Error(TAG, "Unable to locate simulator window");
                return;
            }

            if (!ShowDeviceBezels(window))
            {
                appBounds         = window.Bounds;
                appBounds.Y      += 22;
                appBounds.Height -= 22;
            }
            else
            {
                var shape            = GetDeviceShape(window);
                var chromeScale      = window.Bounds.Height / GetDeviceFullHeight(shape);
                var verticalMargin   = GetDeviceVerticalMargin(shape) * chromeScale;
                var horizontalMargin = GetDeviceHorizontalMargin(shape) * chromeScale;

                appBounds = new CGRect {
                    X      = window.Bounds.X + horizontalMargin,
                    Y      = window.Bounds.Y + verticalMargin,
                    Width  = window.Bounds.Width - (horizontalMargin * 2),
                    Height = window.Bounds.Height - (verticalMargin * 2),
                };
            }

            scale = agentIdentity.ScreenWidth / appBounds.Width;
        }