wei
2021-09-28 db45c85a6ddebc5018b32a9d9dc04f839db3fa76
HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPage.cs
@@ -41,7 +41,7 @@
        /// <summary>
        /// 色温的滑动控件
        /// </summary>
        SeekBarControl barColorTemplatrue;
        CCTSeekBarControl barColorTemplatrue;
        /// <summary>
        /// 开关按钮
        /// </summary>
@@ -130,7 +130,7 @@
                UnSelectedImagePath = "Collection/CollectionGrayIcon.png",
                IsSelected = function.collect
            };
            //controlView.AddChidren(btnCollection);
            controlView.AddChidren(btnCollection);
            //2020-12-16 如果是成员隐藏收藏功能
            //if (!DB_ResidenceData.Instance.CurrentRegion.isOtherShare)
            //{
@@ -162,7 +162,7 @@
            btnBrightnessText = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = ((100 - Convert.ToInt32(function.GetAttrState(FunctionAttributeKey.Brightness))) * Application.GetRealHeight(222  - 16) / 100) + Application.GetRealWidth(80),
                Y = ((100 - Convert.ToInt32(function.GetAttrState(FunctionAttributeKey.Brightness))) * Application.GetRealHeight(222 - 16) / 100) + Application.GetRealWidth(80),
                Width = Application.GetRealWidth(56),
                Height = Application.GetRealWidth(46),
                UnSelectedImagePath = "FunctionIcon/Light/BrightnessBg.png",
@@ -176,7 +176,7 @@
            //色温
            var btnTempClolor = new Button();
            btnTempClolor.X = Application.GetRealWidth(35);
            btnTempClolor.Y = Application.GetRealHeight(306 +60);
            btnTempClolor.Y = Application.GetRealHeight(306 + 60);
            btnTempClolor.Width = Application.GetRealWidth(224);
            btnTempClolor.Height = Application.GetRealHeight(21);
            btnTempClolor.TextAlignment = TextAlignment.CenterLeft;
@@ -205,7 +205,7 @@
            btnColorTemplatrueBack.UnSelectedImagePath = "FunctionIcon/Light/ColorTemperatureBar.png";
            controlView.AddChidren(btnColorTemplatrueBack);
            //滑动条控件
            barColorTemplatrue = new SeekBarControl();
            barColorTemplatrue = new CCTSeekBarControl();
            barColorTemplatrue.X = btnTempClolorMin.Right;
            barColorTemplatrue.Y = Application.GetRealHeight(340);
            barColorTemplatrue.MinValue = 27;
@@ -537,241 +537,241 @@
                btnReadIcon.IsSelected = true;
            }
        }
    }
    /// <summary>
    /// 左右滑动的进度条控件
    /// </summary>
    public class CCTSeekBarControl : DiyImageSeekBar
    {
        #region ■ 变量声明___________________________
        /// <summary>
        /// 进度值改变,如果要设置初始进度值,此变量要在设置初始进度值之前进行设置(第一个参数0:滑动的时候,1:手指弹起的时候)
        /// </summary>
        public Action<int, int> ProgressChangedEvent = null;
        /// <summary>
        /// 进度条可用时的背景色
        /// </summary>
        private uint ProgressBarEnableColor = 0;
        /// <summary>
        /// 进度条不可用时的背景色(默认灰色)
        /// </summary>
        public uint ProgressBarUnEnableColor = 0xffe8e8e8;
        /// <summary>
        /// 当前可用状态
        /// </summary>
        private bool nowEnable = true;
        /// <summary>
        /// 控件能否使用
        /// </summary>
        public new bool Enable
        {
            set
            {
                //状态没有改变
                if (nowEnable == value) { return; }
                nowEnable = value;
                this.IsClickable = value;
                if (value == true)
                {
                    //原来的颜色
                    base.ProgressBarColor = ProgressBarEnableColor;
                }
                else
                {
                    //灰色
                    base.ProgressBarColor = ProgressBarUnEnableColor;
                }
            }
        }
        /// <summary>
        /// 进度条颜色
        /// </summary>
        public new uint ProgressBarColor
        {
            set
            {
                ProgressBarEnableColor = value;
                base.ProgressBarColor = value;
            }
        }
        private int m_SeekBarPadding = Application.GetRealWidth(20);
        /// <summary>
        /// 进度条与左右两边的边框的边距(重写底层属性)
        /// </summary>
        public new int SeekBarPadding
        {
            set
            {
                m_SeekBarPadding = value;
                base.SeekBarPadding = value;
            }
        }
        private int m_MaxValue = 0;
        /// <summary>
        /// 进度条最大值(重写底层属性)
        /// </summary>
        public new int MaxValue
        {
            set
            {
                m_MaxValue = value;
                base.MaxValue = value;
            }
        }
        private int m_MinValue = 0;
        /// <summary>
        /// 进度条最小值(重写底层属性)
        /// </summary>
        public new int MinValue
        {
            set
            {
                m_MinValue = value;
                base.MinValue = value;
            }
        }
        /// <summary>
        /// 上方显示的文本
        /// </summary>
        private Button btnTopView = null;
        #endregion
        #region ■ 初始化_____________________________
        /// <summary>
        /// 左右滑动的进度条控件
        /// </summary>
        private class SeekBarControl : DiyImageSeekBar
        {
            #region ■ 变量声明___________________________
            /// <summary>
            /// 进度值改变,如果要设置初始进度值,此变量要在设置初始进度值之前进行设置(第一个参数0:滑动的时候,1:手指弹起的时候)
            /// </summary>
            public Action<int, int> ProgressChangedEvent = null;
            /// <summary>
            /// 进度条可用时的背景色
            /// </summary>
            private uint ProgressBarEnableColor = 0;
            /// <summary>
            /// 进度条不可用时的背景色(默认灰色)
            /// </summary>
            public uint ProgressBarUnEnableColor = 0xffe8e8e8;
            /// <summary>
            /// 当前可用状态
            /// </summary>
            private bool nowEnable = true;
            /// <summary>
            /// 控件能否使用
            /// </summary>
            public new bool Enable
            {
                set
                {
                    //状态没有改变
                    if (nowEnable == value) { return; }
                    nowEnable = value;
                    this.IsClickable = value;
                    if (value == true)
                    {
                        //原来的颜色
                        base.ProgressBarColor = ProgressBarEnableColor;
                    }
                    else
                    {
                        //灰色
                        base.ProgressBarColor = ProgressBarUnEnableColor;
                    }
                }
            }
            /// <summary>
            /// 进度条颜色
            /// </summary>
            public new uint ProgressBarColor
            {
                set
                {
                    ProgressBarEnableColor = value;
                    base.ProgressBarColor = value;
                }
            }
            private int m_SeekBarPadding = Application.GetRealWidth(20);
            /// <summary>
            /// 进度条与左右两边的边框的边距(重写底层属性)
            /// </summary>
            public new int SeekBarPadding
            {
                set
                {
                    m_SeekBarPadding = value;
                    base.SeekBarPadding = value;
                }
            }
            private int m_MaxValue = 0;
            /// <summary>
            /// 进度条最大值(重写底层属性)
            /// </summary>
            public new int MaxValue
            {
                set
                {
                    m_MaxValue = value;
                    base.MaxValue = value;
                }
            }
            private int m_MinValue = 0;
            /// <summary>
            /// 进度条最小值(重写底层属性)
            /// </summary>
            public new int MinValue
            {
                set
                {
                    m_MinValue = value;
                    base.MinValue = value;
                }
            }
            /// <summary>
            /// 上方显示的文本
            /// </summary>
            private Button btnTopView = null;
            #endregion
            #region ■ 初始化_____________________________
            /// <summary>
            /// 左右滑动的进度条控件
            /// </summary>
            /// <param name="i_width">宽度,非真实值</param>
            public SeekBarControl(int i_width = 210)
            {
                this.Width = Application.GetRealWidth(i_width);
                this.Height = Application.GetRealHeight(54);
                //圆球的宽度
                this.ThumbImageHeight = Application.GetRealHeight(54);
                this.ThumbImagePath = "Public/ThumbImage.png";
                //进度条的宽度
                this.SeekBarViewHeight = Application.GetRealHeight(8);
                //上方是否显示文本
                this.IsProgressTextShow = false;
                this.Gravity = Gravity.CenterHorizontal;
                //进度条颜色
                this.ProgressBarColor = CSS_Color.MainColor;
                //左右边距
                this.SeekBarPadding = Application.GetRealWidth(20);
                //进度条值改变事件
                this.OnProgressChangedEvent += this.MyProgressChangedEvent;
                //手指弹起事件
                this.OnStopTrackingTouchEvent += this.MyStopTrackingTouchEvent;
            }
            #endregion
            #region ■ 事件_______________________________
            /// <summary>
            /// 进度条值改变事件
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="value"></param>
            private void MyProgressChangedEvent(object sender, int value)
            {
                if (this.ProgressChangedEvent == null)
                {
                    this.OnProgressChangedEvent -= this.MyProgressChangedEvent;
                    return;
                }
                this.ProgressChangedEvent(0, value);
            }
            /// <summary>
            /// 手指弹起事件
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="value"></param>
            private void MyStopTrackingTouchEvent(object sender, int value)
            {
                if (this.ProgressChangedEvent == null)
                {
                    this.OnStopTrackingTouchEvent -= this.MyStopTrackingTouchEvent;
                    return;
                }
                //弹起事件不需要判断时间
                this.ProgressChangedEvent(1, value);
            }
            #endregion
            #region ■ 自定义上方显示文本_________________
            /// <summary>
            /// 在上方显示自定义文本
            /// </summary>
            /// <param name="i_width">宽度(真实值)</param>
            /// <param name="textSize">文字大小</param>
            /// <param name="textColor">文字颜色</param>
            public void ShowCustomTextView(int i_width, int textSize, uint textColor)
            {
                if (this.btnTopView != null) { return; }
                int contrHeight = Application.GetRealHeight(24);
                this.btnTopView = new Button();
                btnTopView.Width = i_width;
                btnTopView.Height = contrHeight;
                btnTopView.TextColor = textColor;
                btnTopView.TextSize = textSize;
                btnTopView.TextAlignment = TextAlignment.Center;
                btnTopView.Y = this.Y - contrHeight + Application.GetRealHeight(20);
                //初始化时,X轴可以不用理会
                this.Parent.AddChidren(btnTopView);
            }
            /// <summary>
            /// 设置自定义文本信息
            /// </summary>
            /// <param name="i_text"></param>
            public void SetCustomText(string i_text)
            {
                if (this.btnTopView == null) { return; }
                this.btnTopView.Text = i_text;
                //滑条最左边的距离
                int XX = this.X + this.m_SeekBarPadding;
                //当前滑条所在的大致百分比
                int tempValue = this.Progress - this.m_MinValue;
                if (tempValue < 0) { tempValue = 0; }
                decimal persent = (decimal)tempValue / (this.m_MaxValue - this.m_MinValue);
                //当前滑条所在的大致位置
                XX += (int)((this.Width - this.m_SeekBarPadding * 2) * persent);
                //因为要居中,所以减掉自定义控件的宽度的一般
                XX = XX - this.btnTopView.Width / 2;
                this.btnTopView.X = XX;
            }
            #endregion
            #region ■ 一般方法___________________________
            /// <summary>
            /// 控件摧毁
            /// </summary>
            public override void RemoveFromParent()
            {
                this.ProgressChangedEvent = null;
                base.RemoveFromParent();
            }
            #endregion
        /// <param name="i_width">宽度,非真实值</param>
        public CCTSeekBarControl(int i_width = 210)
        {
            ProgressChangeDelayTime = 30;
            this.Width = Application.GetRealWidth(i_width);
            this.Height = Application.GetRealHeight(54);
            //圆球的宽度
            this.ThumbImageHeight = Application.GetRealHeight(54);
            this.ThumbImagePath = "Public/ThumbImage.png";
            //进度条的宽度
            this.SeekBarViewHeight = Application.GetRealHeight(8);
            //上方是否显示文本
            this.IsProgressTextShow = false;
            this.Gravity = Gravity.CenterHorizontal;
            //进度条颜色
            this.ProgressBarColor = CSS_Color.MainColor;
            //左右边距
            this.SeekBarPadding = Application.GetRealWidth(20);
            //进度条值改变事件
            this.OnProgressChangedEvent += this.MyProgressChangedEvent;
            //手指弹起事件
            this.OnStopTrackingTouchEvent += this.MyStopTrackingTouchEvent;
        }
        #endregion
        #region ■ 事件_______________________________
        /// <summary>
        /// 进度条值改变事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="value"></param>
        private void MyProgressChangedEvent(object sender, int value)
        {
            if (this.ProgressChangedEvent == null)
            {
                this.OnProgressChangedEvent -= this.MyProgressChangedEvent;
                return;
            }
            this.ProgressChangedEvent(0, value);
        }
        /// <summary>
        /// 手指弹起事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="value"></param>
        private void MyStopTrackingTouchEvent(object sender, int value)
        {
            if (this.ProgressChangedEvent == null)
            {
                this.OnStopTrackingTouchEvent -= this.MyStopTrackingTouchEvent;
                return;
            }
            //弹起事件不需要判断时间
            this.ProgressChangedEvent(1, value);
        }
        #endregion
        #region ■ 自定义上方显示文本_________________
        /// <summary>
        /// 在上方显示自定义文本
        /// </summary>
        /// <param name="i_width">宽度(真实值)</param>
        /// <param name="textSize">文字大小</param>
        /// <param name="textColor">文字颜色</param>
        public void ShowCustomTextView(int i_width, int textSize, uint textColor)
        {
            if (this.btnTopView != null) { return; }
            int contrHeight = Application.GetRealHeight(24);
            this.btnTopView = new Button();
            btnTopView.Width = i_width;
            btnTopView.Height = contrHeight;
            btnTopView.TextColor = textColor;
            btnTopView.TextSize = textSize;
            btnTopView.TextAlignment = TextAlignment.Center;
            btnTopView.Y = this.Y - contrHeight + Application.GetRealHeight(20);
            //初始化时,X轴可以不用理会
            this.Parent.AddChidren(btnTopView);
        }
        /// <summary>
        /// 设置自定义文本信息
        /// </summary>
        /// <param name="i_text"></param>
        public void SetCustomText(string i_text)
        {
            if (this.btnTopView == null) { return; }
            this.btnTopView.Text = i_text;
            //滑条最左边的距离
            int XX = this.X + this.m_SeekBarPadding;
            //当前滑条所在的大致百分比
            int tempValue = this.Progress - this.m_MinValue;
            if (tempValue < 0) { tempValue = 0; }
            decimal persent = (decimal)tempValue / (this.m_MaxValue - this.m_MinValue);
            //当前滑条所在的大致位置
            XX += (int)((this.Width - this.m_SeekBarPadding * 2) * persent);
            //因为要居中,所以减掉自定义控件的宽度的一般
            XX = XX - this.btnTopView.Width / 2;
            this.btnTopView.X = XX;
        }
        #endregion
        #region ■ 一般方法___________________________
        /// <summary>
        /// 控件摧毁
        /// </summary>
        public override void RemoveFromParent()
        {
            this.ProgressChangedEvent = null;
            base.RemoveFromParent();
        }
        #endregion
    }
}
}