wxr
2021-07-01 43b0d5870d528f23ecd6aeceb6cfd4325188b46f
HDL_ON/UI/UI0-Stan/Controls/BaseControl/ButtonCtrBase.cs
@@ -62,7 +62,7 @@
        #region ■ 重写彪哥的属性_____________________
        /// <summary>
        /// 重写Text属性
        /// 重写Text属性(文本中有{0}的话,会自动全部替换为换行符)
        /// </summary>
        public new string Text
        {
@@ -70,7 +70,87 @@
            get { return base.Text == null ? string.Empty : base.Text; }
            set
            {
                base.Text = value == null ? string.Empty : value;
                base.Text = value == null ? string.Empty : value.Replace("{0}", "\r\n");
            }
        }
        /// <summary>
        /// 选中状态(重写底层属性)
        /// </summary>
        public new bool IsSelected
        {
            get { return base.IsSelected; }
            set
            {
                //只有状态不一样,才变更
                if (base.IsSelected != value)
                {
                    base.IsSelected = value;
                }
            }
        }
        /// <summary>
        /// 非选中状态的背景图路径(重写底层属性)
        /// </summary>
        public new string UnSelectedImagePath
        {
            get { return base.UnSelectedImagePath; }
            set
            {
                //只有图片不一样,才变更
                if (base.UnSelectedImagePath != value)
                {
                    base.UnSelectedImagePath = value;
                }
            }
        }
        /// <summary>
        /// 选中状态的背景图路径(重写底层属性)
        /// </summary>
        public new string SelectedImagePath
        {
            get { return base.SelectedImagePath; }
            set
            {
                //只有图片不一样,才变更
                if (base.SelectedImagePath != value)
                {
                    base.SelectedImagePath = value;
                }
            }
        }
        /// <summary>
        /// 背景色(重写底层属性)
        /// </summary>
        public new uint BackgroundColor
        {
            get { return base.BackgroundColor; }
            set
            {
                //只有不一样,才变更
                if (base.BackgroundColor != value)
                {
                    base.BackgroundColor = value;
                }
            }
        }
        /// <summary>
        /// 字体颜色(重写底层属性)
        /// </summary>
        public new uint TextColor
        {
            get { return base.TextColor; }
            set
            {
                //只有不一样,才变更
                if (base.TextColor != value)
                {
                    base.TextColor = value;
                }
            }
        }
@@ -115,20 +195,6 @@
                i_Height = Application.GetRealHeight(i_Height);
            }
            this.Height = i_Height;
            this.Width = i_Width;
        }
        /// <summary>
        /// 初始化控件大小(不以平均值进行真实数值计算)
        /// </summary>
        /// <param name="i_Width">宽度</param>
        /// <param name="real">是否计算真实值</param>
        public void InitSize(int i_Width, bool real = false)
        {
            if (real == true)
            {
                i_Width = Application.GetRealWidth(i_Width);
            }
            this.Width = i_Width;
        }
@@ -304,25 +370,9 @@
        /// <returns></returns>
        public int GetRealWidthByText()
        {
            if (string.IsNullOrEmpty(this.Text) == true) { return Application.GetRealWidth(25); }
            if (string.IsNullOrEmpty(this.Text) == true) { return Application.GetRealWidth(4); }
            return base.GetTextWidth();
        }
        /// <summary>
        /// 根据文本,计算它需要的总行数
        /// </summary>
        /// <returns></returns>
        public int GetRealRowCountByText()
        {
            //先获取它的真实宽度
            int realWidth = this.GetRealWidthByText();
            int row = realWidth / this.Width;
            if (realWidth % this.Width > 0)
            {
                row++;
            }
            return row;
        }
        /// <summary>
@@ -335,6 +385,27 @@
            return Application.GetRealWidth(i_size);
        }
        /// <summary>
        /// 根据文本,计算它需要的总行数
        /// </summary>
        /// <param name="i_width">当值为-1时,需要父控件,真实值</param>
        /// <returns></returns>
        public int GetRealRowCountByText(int i_width = -1)
        {
            if (i_width == -1)
            {
                i_width = this.Width;
            }
            //先获取它的真实宽度
            int realWidth = this.GetRealWidthByText();
            int row = realWidth / i_width;
            if (realWidth % i_width > 0)
            {
                row++;
            }
            return row;
        }
        #endregion
    }
}