HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-09-30 404cdc88627f942df7944af04ee05b9d527752d6
ZigbeeApp/Shared/Phone/UserCenter/Safety/LightAlarmSettionForm.cs
@@ -6,29 +6,24 @@
namespace Shared.Phone.UserCenter.Safety
{
    /// <summary>
    /// 灯光的安防报警设置界面
    /// 灯光类的安防报警设置界面
    /// </summary>
    public class LightAlarmSettionForm : UserCenterCommonForm
    public class LightAlarmSettionForm : EditorCommonForm
    {
        /// <summary>
        /// 画面关闭事件
        /// </summary>
        /// <param name="statuText"></param>
        /// <param name="listTaskinfo"></param>
        public delegate void _FormCloseEvent(string statuText, List<Safeguard.TaskListInfo> listTaskinfo);
        /// <summary>
        /// 画面关闭事件
        /// </summary>
        public _FormCloseEvent formCloseEvent;
        #region ■ 变量声明___________________________
        /// <summary>
        /// 列表控件
        /// 画面关闭事件
        /// </summary>
        private VerticalScrolViewLayout listView = null;
        public Action<string, List<Safeguard.TaskListInfo>> ActionFormClose = null;
        /// <summary>
        /// 动作信息
        /// 动作信息  1 开关/ 3亮度调节
        /// </summary>
        private List<Safeguard.TaskListInfo> listTaskinfo = null;
        private Dictionary<int, Safeguard.TaskListInfo> dicTaskinfo = new Dictionary<int, Safeguard.TaskListInfo>();
        #endregion
        #region ■ 初始化_____________________________
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
@@ -37,17 +32,25 @@
        /// <param name="i_listTaskInfo"></param>
        public void ShowForm(CommonDevice device, List<Safeguard.TaskListInfo> i_listTaskInfo)
        {
            this.listTaskinfo = i_listTaskInfo;
            UserView.HomePage.Instance.ScrollEnabled = false;
            if (i_listTaskInfo != null)
            {
                foreach (var data in i_listTaskInfo)
                {
                    //以防万一,剔除不合法数据
                    if (data.TaskType == 1 || data.TaskType == 3)
                    {
                        dicTaskinfo[data.TaskType] = data;
                    }
                }
            }
            //设置头部信息
            base.SetTitleText(Common.LocalDevice.Current.GetDeviceEpointName(device));
            //初始化中部信息
            this.InitMiddleFrame();
            if (this.listTaskinfo == null)
            {
                this.listTaskinfo = new List<Safeguard.TaskListInfo>();
            }
        }
        /// <summary>
@@ -55,65 +58,232 @@
        /// </summary>
        private void InitMiddleFrame()
        {
            listView = new VerticalScrolViewLayout();
            listView.Height = bodyFrameLayout.Height;
            //清空bodyFrame
            this.ClearBodyFrame();
            var frameTemp = new FrameLayout();
            frameTemp.Height = Application.GetRealHeight(6);
            frameTemp.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(frameTemp);
            var listView = new VerticalListControl(29);
            listView.Y = frameTemp.Bottom;
            listView.BackgroundColor = UserCenterColor.Current.White;
            listView.Height = Application.GetRealHeight(700 - 256 + 46);
            if (dicTaskinfo.ContainsKey(5) == true)
            {
                //展开百分比调节
                listView.Height = Application.GetRealHeight(700);
            }
            bodyFrameLayout.AddChidren(listView);
            //开
            var staRow = new StatuRowLayout(listView);
            var btnOpen = new RowCenterView(false);
            btnOpen.TextID = R.MyInternationalizationString.uSimpleOpen;
            staRow.AddChidren(btnOpen);
            staRow.MouseUpEvent += (sender, e) =>
            var btnOpenRow = new FrameRowControl(listView.rowSpace / 2);
            listView.AddChidren(btnOpenRow);
            //图标
            var btnOpenIcon = btnOpenRow.AddLeftIcon(81);
            btnOpenIcon.UnSelectedImagePath = "Item/OpenIcon.png";
            //文字
            var btnOpenView = btnOpenRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uSimpleOpen), 400);
            btnOpenView.TextSize = 15;
            //状态
            var btnOpenStatu = btnOpenRow.AddMostRightEmptyIcon(58, 58);
            if (dicTaskinfo.ContainsKey(1) == false || dicTaskinfo[1].Data1 != 1)
            {
                var info = new Safeguard.TaskListInfo();
                info.TaskType = 1;
                info.Data1 = 1;
                this.listTaskinfo.Add(info);
                //关闭画面之前
                this.BeforeCloseForm();
                btnOpenStatu.Visible = false;
            }
            btnOpenStatu.UnSelectedImagePath = "Item/Tick.png";
            //底线
            btnOpenRow.AddBottomLine();
            //===========================================================================
            //关
            var btnCloseRow = new FrameRowControl(listView.rowSpace / 2);
            listView.AddChidren(btnCloseRow);
            //图标
            var btnCloseIcon = btnCloseRow.AddLeftIcon(81);
            btnCloseIcon.UnSelectedImagePath = "Item/CloseIcon.png";
            //文字
            var btnCloseView = btnCloseRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uSimpleClose), 400);
            btnCloseView.TextSize = 15;
            //状态
            var btnCloseStatu = btnCloseRow.AddMostRightEmptyIcon(58, 58);
            if (dicTaskinfo.ContainsKey(1) == false || dicTaskinfo[1].Data1 != 0)
            {
                btnCloseStatu.Visible = false;
            }
            btnCloseStatu.UnSelectedImagePath = "Item/Tick.png";
            //底线
            btnCloseRow.AddBottomLine();
            //===========================================================================
            //百分比调节
            var btnPersentRow = new FrameRowControl(listView.rowSpace / 2);
            btnPersentRow.UseClickStatu = false;
            listView.AddChidren(btnPersentRow);
            //图标
            var btnPersentIcon = btnPersentRow.AddLeftIcon(81);
            btnPersentIcon.UnSelectedImagePath = "Item/PersentIcon.png";
            //文字
            var btnPersentView = btnPersentRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uPersentAdjust), 400);
            btnPersentView.TextSize = 15;
            //右图标
            var btnPersentRight = btnPersentRow.AddMostRightEmptyIcon(58, 58);
            btnPersentRight.UnSelectedImagePath = "Item/Next.png";
            btnPersentRight.SelectedImagePath = "Item/Down.png";
            if (dicTaskinfo.ContainsKey(3) == true)
            {
                //展开百分比调节
                btnPersentRight.IsSelected = true;
            }
            //===========================================================================
            //进度条的背景容器
            var frameProfra = new FrameLayout();
            frameProfra.Height = Application.GetRealHeight(256);
            listView.AddChidren(frameProfra);
            //当前XX%
            string persentText = Language.StringByID(R.MyInternationalizationString.uNow1);
            var nowProValue = 0;
            if (dicTaskinfo.ContainsKey(3) == true)
            {
                //3:亮度调节
                nowProValue = dicTaskinfo[3].Data1;
            }
            var btnPersentValue = new NormalViewControl(400, 49, true);
            btnPersentValue.Text = persentText + nowProValue + "%";
            btnPersentValue.X = btnPersentView.X;
            btnPersentValue.Y = Application.GetRealHeight(35);
            btnPersentValue.TextColor = UserCenterColor.Current.TextGrayColor2;
            btnPersentValue.TextSize = 12;
            frameProfra.AddChidren(btnPersentValue);
            //进度条
            var seekBar = new HorizontalSeekBar();
            seekBar.X = btnPersentValue.X;
            seekBar.Y = btnPersentValue.Bottom + Application.GetRealHeight(46);
            seekBar.Width = Application.GetRealWidth(850);
            seekBar.Height = Application.GetRealHeight(60);
            seekBar.Max = 100;
            seekBar.BackgroundColor = 0xfff5f5f5;
            seekBar.ThumbColor = Common.ZigbeeColor.Current.GXCButtonBlueColor;
            seekBar.ProgressColor = 0xff232323;
            seekBar.Progress = nowProValue;
            frameProfra.AddChidren(seekBar);
            seekBar.ProgressChanged += (sender, value) =>
            {
                nowProValue = value;
                btnPersentValue.Text = persentText + value + "%";
            };
            //百分比调节点击
            btnPersentRow.ButtonClickEvent += (sender, e) =>
            {
                btnPersentRight.IsSelected = !btnPersentRight.IsSelected;
                if (btnPersentRight.IsSelected == true)
                {
                    listView.Height += frameProfra.Height - Application.GetRealHeight(23);
                }
                else
                {
                    listView.Height -= frameProfra.Height - Application.GetRealHeight(23);
                }
            };
            //开
            btnOpenRow.ButtonClickEvent += (sender, e) =>
            {
                if (btnOpenStatu.Visible == true)
                {
                    //取消
                    dicTaskinfo.Remove(1);
                    btnOpenStatu.Visible = false;
                }
                else
                {
                    //添加
                    btnOpenStatu.Visible = true;
                    btnCloseStatu.Visible = false;
                    dicTaskinfo[1] = new Safeguard.TaskListInfo();
                    dicTaskinfo[1].TaskType = 1;
                    dicTaskinfo[1].Data1 = 1;
                }
            };
            //关
            staRow = new StatuRowLayout(listView);
            var btnClose = new RowCenterView(false);
            btnClose.TextID = R.MyInternationalizationString.uSimpleClose;
            staRow.AddChidren(btnClose);
            staRow.MouseUpEvent += (sender, e) =>
            btnCloseRow.ButtonClickEvent += (sender, e) =>
            {
                var info = new Safeguard.TaskListInfo();
                info.TaskType = 1;
                info.Data1 = 0;
                this.listTaskinfo.Add(info);
                //关闭画面之前
                this.BeforeCloseForm();
                if (btnCloseStatu.Visible == true)
                {
                    //取消
                    dicTaskinfo.Remove(1);
                }
                else
                {
                    //添加
                    btnOpenStatu.Visible = false;
                    btnCloseStatu.Visible = true;
                    dicTaskinfo[1] = new Safeguard.TaskListInfo();
                    dicTaskinfo[1].TaskType = 1;
                    dicTaskinfo[1].Data1 = 0;
                }
            };
            //无动作
            staRow = new StatuRowLayout(listView);
            var btnNotAction = new RowCenterView(false);
            btnNotAction.TextID = R.MyInternationalizationString.uNotAction;
            staRow.AddChidren(btnNotAction);
            staRow.MouseUpEvent += (sender, e) =>
            //完成
            var btnFinish = new BottomClickButton();
            btnFinish.TextID = R.MyInternationalizationString.uFinish;
            bodyFrameLayout.AddChidren(btnFinish);
            btnFinish.ButtonClickEvent += (sender, e) =>
            {
                this.listTaskinfo = null;
                //关闭画面之前
                this.BeforeCloseForm();
                if (this.ActionFormClose != null)
                {
                    if (btnPersentRight.IsSelected == false || seekBar.Progress == 0)
                    {
                        dicTaskinfo.Remove(3);
                    }
                    else
                    {
                        //百分比调节
                        dicTaskinfo[3] = new Safeguard.TaskListInfo();
                        dicTaskinfo[3].TaskType = 3;
                        dicTaskinfo[3].Data1 = seekBar.Progress;
                    }
                    var listData = new List<Safeguard.TaskListInfo>();
                    foreach (var data in dicTaskinfo.Values)
                    {
                        listData.Add(data);
                    }
                    dicTaskinfo = null;
                    //获取状态的显示文本
                    string statuText = HdlSafeguardLogic.Current.GetLightAlarmStatuText(listData);
                    this.ActionFormClose(statuText, listData);
                }
                this.CloseForm();
            };
        }
        #endregion
        #region ■ 界面关闭___________________________
        /// <summary>
        /// 关闭画面之前
        /// 界面关闭
        /// </summary>
        private void BeforeCloseForm()
        public override void CloseForm()
        {
            if (this.formCloseEvent != null)
            {
                //获取状态的显示文本
                string statuText = SafeguardLogic.GetLightAlarmStatuText(this.listTaskinfo);
                this.formCloseEvent(statuText, this.listTaskinfo);
            }
            this.CloseForm();
            UserView.HomePage.Instance.ScrollEnabled = true;
            ActionFormClose = null;
            base.CloseForm();
        }
        #endregion
    }
}