/// <summary> /// 比较. /// </summary> /// <param name="x">比较对象X.</param> /// <returns><c>true</c> 相等; 不相等, <c>false</c>.</returns> public bool Equal(DisplaySafePadding x) { if (null == x) { return(false); } return((this.Padding.left == x.Padding.left) && (this.Padding.right == x.Padding.right) && (this.Padding.top == x.Padding.top) && (this.Padding.right == x.Padding.right) && (this.isRetina == x.isRetina) && (this.RetinaScale == x.RetinaScale)); }
/// <summary> /// 取得边距余白(全面凭手机,因为有刘海,圆角等情况,需要调整显示范围。其他的安全区域即屏幕区域). /// </summary> /// <returns>安全区域.</returns> /// <param name="iIsDebugTest">Debug测试标志位.</param> public DisplaySafePadding GetSafePadding(bool iIsDebugTest = false) { DisplaySafePadding _safePadding = DisplaySafePadding.Create(0, 0, 0, 0); if (null == _safePadding) { this.Error("GetSafePadding():Failed!!!"); return(null); } if (true == Application.isMobilePlatform) { // Retina _safePadding.isRetina = this.IsRetina(); _safePadding.RetinaScale = this.GetRetinaScale(); // 取得安全区域 float _left = 0.0f; float _right = 0.0f; float _top = 0.0f; float _bottom = 0.0f; _GetSafePaddingImpl( out _left, out _right, out _top, out _bottom); _safePadding.Padding.left = (int)_left; _safePadding.Padding.right = (int)_right; _safePadding.Padding.top = (int)_top; _safePadding.Padding.bottom = (int)_bottom; } #if BUILD_DEBUG if ((true == iIsDebugTest) && (false == Application.isMobilePlatform)) { // 测试iPhoneX的尺寸数据(去掉刘海和圆角的数据) _safePadding.Padding.left = 44; _safePadding.Padding.right = 44; _safePadding.Padding.top = 0; _safePadding.Padding.bottom = 21; _safePadding.isRetina = true; _safePadding.RetinaScale = 3.0f; } #endif Rect a; this.Info("GetSafePadding():{0}", _safePadding.ToString()); return(_safePadding); }
/// <summary> /// 创建 /// </summary> /// <param name="iLeft">边距:.</param> /// <param name="iRight">边距:.</param> /// <param name="iTop">边距:.</param> /// <param name="iBottom">边距:.</param> /// <param name="isRetina">是否为Retina.</param> /// <param name="iRetinaScale">Retina缩放率.</param> public static DisplaySafePadding Create( int iLeft, int iRight, int iTop, int iBottom, bool iIsRetina = false, float iRetinaScale = 1.0f) { DisplaySafePadding _padding = new DisplaySafePadding(); if (null != _padding) { _padding.Padding.left = iLeft; _padding.Padding.right = iRight; _padding.Padding.top = iTop; _padding.Padding.bottom = iBottom; _padding.isRetina = iIsRetina; _padding.RetinaScale = iRetinaScale; } else { _padding = null; } return(_padding); }