public static Bitmap GetSS(this Graphics grx, Rectangle bounds) { var res = new Bitmap(bounds.Width, bounds.Height); var gxc = Graphics.FromImage(res); IntPtr hdc = grx.GetHdc(); PlatformAPI.BitBlt(gxc.GetHdc(), 0, 0, bounds.Width, bounds.Height, hdc, bounds.Left, bounds.Top, PlatformAPI.SRCCOPY); grx.ReleaseHdc(hdc); return(res); }
private void UpdateGlobalUIStyle() { try { switch (Device.RuntimePlatform) { case Device.iOS: { // // Longread: https://stackoverflow.com/questions/46192280/detect-if-the-device-is-iphone-x?page=1&tab=votes#tab-top // bool hasNotch = PlatformAPI.HasTopNotch(); Thickness safeArea = PlatformAPI.SafeArea(); double statusH = Double.Parse(Application.Current.Resources["StatusBarHeight"].ToString()); double navH = Double.Parse(Application.Current.Resources["NavBarHeight"].ToString()); double bottomH = Double.Parse(Application.Current.Resources["BottomBarHeight"].ToString()); Application.Current.Resources["StatusBarHeight"] = hasNotch ? safeArea.Top : statusH; Application.Current.Resources["NavBarHeight"] = hasNotch ? 50 : navH; Application.Current.Resources["BottomBarHeight"] = hasNotch ? bottomH + safeArea.Bottom : bottomH; statusH = Double.Parse(Application.Current.Resources["StatusBarHeight"].ToString()); navH = Double.Parse(Application.Current.Resources["NavBarHeight"].ToString()); Application.Current.Resources["StatusBarInsets"] = new Thickness(0, statusH, 0, 0); Application.Current.Resources["NavBarInsets"] = new Thickness(0, navH, 0, 0); } break; default: { Application.Current.Resources["StatusBarInsets"] = new Thickness(0, 0, 0, 0); Application.Current.Resources["NavBarInsets"] = new Thickness(0, 35, 0, 0); } break; } } catch (Exception ex) { Debugger.Break(); AnalyticsManager.Instance.TrackError(ex); throw; } }