New file |
| | |
| | | using Shared; |
| | | using HDL_ON.UI.CSS; |
| | | using HDL_ON.Stan; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using HDL_ON.Entity; |
| | | |
| | | namespace HDL_ON.UI |
| | | { |
| | | /// <summary> |
| | | /// 门锁常开自动化编辑界面 |
| | | /// </summary> |
| | | public class DoorLockAlwaysOnManagerPage : EditorCommonForm |
| | | { |
| | | #region ■ 变量声明___________________________ |
| | | |
| | | /// <summary> |
| | | /// 常开自动化信息 |
| | | /// </summary> |
| | | private AlwayOnAutomationInfo automationInfo = null; |
| | | /// <summary> |
| | | /// 一些文本 |
| | | /// </summary> |
| | | private Dictionary<string, string> dicText = new Dictionary<string, string>(); |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 初始化_____________________________ |
| | | |
| | | /// <summary> |
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建) |
| | | /// </summary> |
| | | public void ShowForm(AlwayOnAutomationInfo info) |
| | | { |
| | | this.automationInfo = info; |
| | | if (info == null) |
| | | { |
| | | this.automationInfo = new AlwayOnAutomationInfo(); |
| | | //新建自动化 |
| | | base.SetTitleText(Language.StringByID(StringId.newAutomation)); |
| | | } |
| | | else |
| | | { |
| | | //编辑自动化 |
| | | base.SetTitleText(Language.StringByID(StringId.editAutomation)); |
| | | } |
| | | |
| | | this.dicText["周1"] = Language.StringByID(StringId.monday); |
| | | this.dicText["周2"] = Language.StringByID(StringId.tuesday); |
| | | this.dicText["周3"] = Language.StringByID(StringId.wednesday); |
| | | this.dicText["周4"] = Language.StringByID(StringId.thursday); |
| | | this.dicText["周5"] = Language.StringByID(StringId.friday); |
| | | this.dicText["周6"] = Language.StringByID(StringId.saturday); |
| | | this.dicText["周7"] = Language.StringByID(StringId.sunday); |
| | | |
| | | //初始化中部信息 |
| | | this.InitMiddleFrame(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 初始化中部信息 |
| | | /// </summary> |
| | | private void InitMiddleFrame() |
| | | { |
| | | //清空bodyFrame |
| | | this.ClearBodyFrame(); |
| | | |
| | | //初始化条件控件 |
| | | this.InitConditionControl(); |
| | | //初始化目标控件 |
| | | this.InitTargetControl(); |
| | | //初始化循环方式控件 |
| | | this.InitLoopControl(); |
| | | |
| | | //确认按钮 |
| | | var btnSave = this.AddBottomClickButton(Language.StringByID(StringId.Confirm)); |
| | | btnSave.ButtonClickEvent += (sender, e) => |
| | | { |
| | | }; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 初始化条件控件_____________________ |
| | | |
| | | /// <summary> |
| | | /// 初始化条件控件 |
| | | /// </summary> |
| | | private void InitConditionControl() |
| | | { |
| | | //如果 |
| | | var btnIf = new NormalViewControl(300, 22, true); |
| | | btnIf.X = HdlControlResourse.XXLeft; |
| | | btnIf.Y = Application.GetRealHeight(12); |
| | | btnIf.TextID = StringId.ifCondition; |
| | | btnIf.TextSize = CSS_FontSize.SubheadingFontSize; |
| | | btnIf.TextColor = CSS_Color.FirstLevelTitleColor; |
| | | btnIf.IsBold = true; |
| | | bodyFrameLayout.AddChidren(btnIf); |
| | | |
| | | //白色背景容器 |
| | | var frameBack = new FrameLayout(); |
| | | frameBack.Y = btnIf.Bottom + Application.GetRealHeight(12); |
| | | frameBack.Width = Application.GetRealWidth(343); |
| | | frameBack.Height = Application.GetRealHeight(88); |
| | | frameBack.Gravity = Gravity.CenterHorizontal; |
| | | frameBack.BackgroundColor = CSS_Color.MainBackgroundColor; |
| | | frameBack.Radius = (uint)Application.GetRealWidth(12); |
| | | bodyFrameLayout.AddChidren(frameBack); |
| | | |
| | | //条件 |
| | | var rowConditon = new FrameRowControl(); |
| | | rowConditon.LeftOffset = Application.GetRealWidth(12) - HdlControlResourse.XXLeft; |
| | | rowConditon.Width = frameBack.Width; |
| | | frameBack.AddChidren(rowConditon); |
| | | var btnConditon = rowConditon.AddLeftCaption(Language.StringByID(StringId.Condtion), 300); |
| | | btnConditon.TextColor = CSS_Color.FirstLevelTitleColor; |
| | | //底线 |
| | | rowConditon.AddBottomLine(); |
| | | |
| | | //时刻 |
| | | var rowTime = new FrameRowControl(); |
| | | rowTime.Y = rowConditon.Bottom; |
| | | rowTime.LeftOffset = Application.GetRealWidth(12) - HdlControlResourse.XXLeft; |
| | | rowTime.Width = frameBack.Width; |
| | | frameBack.AddChidren(rowTime); |
| | | rowTime.AddLeftIcon(28, "LogicIcon/time.png"); |
| | | var btnTime = rowTime.AddLeftCaption(Language.StringByID(StringId.hour), 300); |
| | | btnTime.TextColor = CSS_Color.FirstLevelTitleColor; |
| | | rowTime.AddRightArrow(); |
| | | var btnValue = rowTime.AddMostRightView(this.automationInfo.Hour + ":" + this.automationInfo.Minute.ToString().PadLeft(2, '0'), 80); |
| | | rowTime.ButtonClickEvent += (sender, e) => |
| | | { |
| | | //时间选择弹窗 |
| | | var form = new BottomTimeSelectControl(); |
| | | form.InitControl(this.automationInfo.Hour, this.automationInfo.Minute); |
| | | form.FinishEvent += (div, selectHour, selectMin) => |
| | | { |
| | | if (div != 1) { return; } |
| | | this.automationInfo.Hour = selectHour; |
| | | this.automationInfo.Minute = selectMin; |
| | | btnValue.Text = this.automationInfo.Hour + ":" + this.automationInfo.Minute.ToString().PadLeft(2, '0'); |
| | | }; |
| | | }; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 初始化目标控件_____________________ |
| | | |
| | | /// <summary> |
| | | /// 初始化目标控件 |
| | | /// </summary> |
| | | private void InitTargetControl() |
| | | { |
| | | //就执行 |
| | | var btnExecuted = new NormalViewControl(300, 22, true); |
| | | btnExecuted.X = HdlControlResourse.XXLeft; |
| | | btnExecuted.Y = Application.GetRealHeight(154); |
| | | btnExecuted.TextID = StringId.isExecuted; |
| | | btnExecuted.TextSize = CSS_FontSize.SubheadingFontSize; |
| | | btnExecuted.TextColor = CSS_Color.FirstLevelTitleColor; |
| | | btnExecuted.IsBold = true; |
| | | bodyFrameLayout.AddChidren(btnExecuted); |
| | | |
| | | //白色背景容器 |
| | | var frameBack = new FrameLayout(); |
| | | frameBack.Y = btnExecuted.Bottom + Application.GetRealHeight(12); |
| | | frameBack.Width = Application.GetRealWidth(343); |
| | | frameBack.Height = Application.GetRealHeight(88); |
| | | frameBack.Gravity = Gravity.CenterHorizontal; |
| | | frameBack.BackgroundColor = CSS_Color.MainBackgroundColor; |
| | | frameBack.Radius = (uint)Application.GetRealWidth(12); |
| | | bodyFrameLayout.AddChidren(frameBack); |
| | | |
| | | //动作行控件 |
| | | var rowAction = new FrameRowControl(); |
| | | rowAction.LeftOffset = Application.GetRealWidth(12) - HdlControlResourse.XXLeft; |
| | | rowAction.Width = frameBack.Width; |
| | | frameBack.AddChidren(rowAction); |
| | | //动作 |
| | | var btnAction = rowAction.AddLeftCaption(Language.StringByID(StringId.Action), 300); |
| | | btnAction.TextColor = CSS_Color.FirstLevelTitleColor; |
| | | //底线 |
| | | rowAction.AddBottomLine(); |
| | | |
| | | //常开模式行控件 |
| | | var rowModel = new FrameRowControl(); |
| | | rowModel.Y = rowAction.Bottom; |
| | | rowModel.LeftOffset = Application.GetRealWidth(12) - HdlControlResourse.XXLeft; |
| | | rowModel.Width = frameBack.Width; |
| | | frameBack.AddChidren(rowModel); |
| | | //图标 |
| | | rowModel.AddLeftIcon(28, "FunctionIcon/DoorLock/NormallyOpenIcon2.png"); |
| | | //常开模式 |
| | | var btnAlwayOn = rowModel.AddLeftCaption(Language.StringByID(StringId.AlwaysOnModel), 300); |
| | | btnAlwayOn.TextColor = CSS_Color.FirstLevelTitleColor; |
| | | //右箭头 |
| | | rowModel.AddRightArrow(); |
| | | //值 |
| | | var btnValue = rowModel.AddMostRightView(this.automationInfo.IsOpenAlwayOn == true ? |
| | | Language.StringByID(StringId.kaiqi) : Language.StringByID(StringId.Close), 80); |
| | | |
| | | rowModel.ButtonClickEvent += (sender, e) => |
| | | { |
| | | //选择弹窗 |
| | | var form = new BottomMenuSelectControl(2); |
| | | //开启 |
| | | form.AddMenu(Language.StringByID(StringId.kaiqi), () => |
| | | { |
| | | this.automationInfo.IsOpenAlwayOn = true; |
| | | btnValue.Text = Language.StringByID(StringId.kaiqi); |
| | | }); |
| | | //关闭 |
| | | form.AddMenu(Language.StringByID(StringId.Close), () => |
| | | { |
| | | this.automationInfo.IsOpenAlwayOn = false; |
| | | btnValue.Text = Language.StringByID(StringId.Close); |
| | | },CSS_Color.PromptingColor1); |
| | | }; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 初始化循环方式控件_________________ |
| | | |
| | | /// <summary> |
| | | /// 初始化循环方式控件 |
| | | /// </summary> |
| | | private void InitLoopControl() |
| | | { |
| | | //循环方式 |
| | | var btnloop = new NormalViewControl(300, 22, true); |
| | | btnloop.X = HdlControlResourse.XXLeft; |
| | | btnloop.Y = Application.GetRealHeight(296); |
| | | btnloop.TextID = StringId.cyclic; |
| | | btnloop.TextSize = CSS_FontSize.SubheadingFontSize; |
| | | btnloop.TextColor = CSS_Color.FirstLevelTitleColor; |
| | | btnloop.IsBold = true; |
| | | bodyFrameLayout.AddChidren(btnloop); |
| | | |
| | | //周期的白色背景容器 |
| | | var frameDayBack = new FrameLayout(); |
| | | frameDayBack.Y = btnloop.Bottom + Application.GetRealHeight(12); |
| | | frameDayBack.Width = Application.GetRealWidth(343); |
| | | frameDayBack.Height = Application.GetRealHeight(50); |
| | | frameDayBack.Gravity = Gravity.CenterHorizontal; |
| | | frameDayBack.BackgroundColor = CSS_Color.MainBackgroundColor; |
| | | frameDayBack.Radius = (uint)Application.GetRealWidth(12); |
| | | bodyFrameLayout.AddChidren(frameDayBack); |
| | | |
| | | //周期行控件 |
| | | var rowLoop = new FrameRowControl(); |
| | | rowLoop.LeftOffset = Application.GetRealWidth(12) - HdlControlResourse.XXLeft; |
| | | rowLoop.Width = frameDayBack.Width; |
| | | rowLoop.Height = Application.GetRealHeight(50); |
| | | frameDayBack.AddChidren(rowLoop); |
| | | //周期 |
| | | var cycleText = this.GetLoopCondtionText(); |
| | | var btnCycle = rowLoop.AddLeftCaption(cycleText, 270); |
| | | btnCycle.TextColor = CSS_Color.FirstLevelTitleColor; |
| | | btnCycle.IsMoreLines = false;//让它不换行了,不然有点难看 |
| | | //右箭头 |
| | | rowLoop.AddRightArrow(); |
| | | rowLoop.ButtonClickEvent += (sender, e) => |
| | | { |
| | | //显示周期循环配置窗口 |
| | | this.ShowLoopMethordSettionDialog(btnCycle); |
| | | }; |
| | | |
| | | //推送的白色背景容器 |
| | | var framePushBack = new FrameLayout(); |
| | | framePushBack.Y = frameDayBack.Bottom + Application.GetRealHeight(8); |
| | | framePushBack.Width = Application.GetRealWidth(343); |
| | | framePushBack.Height = Application.GetRealHeight(100); |
| | | framePushBack.Gravity = Gravity.CenterHorizontal; |
| | | framePushBack.BackgroundColor = CSS_Color.MainBackgroundColor; |
| | | framePushBack.Radius = (uint)Application.GetRealWidth(12); |
| | | bodyFrameLayout.AddChidren(framePushBack); |
| | | |
| | | //推送行控件 |
| | | var rowPush = new FrameRowControl(); |
| | | rowPush.Width = framePushBack.Width; |
| | | rowPush.Height = Application.GetRealHeight(50); |
| | | rowPush.LeftOffset = Application.GetRealWidth(12) - HdlControlResourse.XXLeft; |
| | | framePushBack.AddChidren(rowPush); |
| | | //执行推送 |
| | | var btnPush = rowPush.AddLeftCaption(Language.StringByID(StringId.push), 300); |
| | | btnPush.TextColor = CSS_Color.FirstLevelTitleColor; |
| | | //底线 |
| | | rowPush.AddBottomLine(); |
| | | //推送的开关按钮 |
| | | var btnPushSwitch = rowPush.AddMostRightSwitchIcon(); |
| | | btnPushSwitch.ButtonClickEvent += (sender, e) => |
| | | { |
| | | btnPushSwitch.IsSelected = !btnPushSwitch.IsSelected; |
| | | }; |
| | | |
| | | //发送通知行控件 |
| | | var rowNotice = new FrameRowControl(); |
| | | rowNotice.Y = rowPush.Bottom; |
| | | rowNotice.Width = framePushBack.Width; |
| | | rowNotice.Height = Application.GetRealHeight(50); |
| | | rowNotice.LeftOffset = Application.GetRealWidth(12) - HdlControlResourse.XXLeft; |
| | | framePushBack.AddChidren(rowNotice); |
| | | //发送通知 |
| | | var btnNotice = rowNotice.AddLeftCaption(Language.StringByID(StringId.notification), 300); |
| | | btnNotice.TextColor = CSS_Color.FirstLevelTitleColor; |
| | | //右箭头 |
| | | rowNotice.AddRightArrow(); |
| | | rowNotice.ButtonClickEvent += (sender, e) => |
| | | { |
| | | var form = new UI2.Intelligence.Automation.InputPushText(); |
| | | MainPage.BasePageView.AddChidren(form); |
| | | //form.Show(this.automationInfo.PushSettion); |
| | | form.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | //form.action += (pushInfo) => |
| | | //{ |
| | | // //赋值 |
| | | // this.automationInfo.PushSettion = pushInfo; |
| | | //}; |
| | | }; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 显示周期循环配置窗口_______________ |
| | | |
| | | /// <summary> |
| | | /// 显示周期循环配置窗口 |
| | | /// </summary> |
| | | private void ShowLoopMethordSettionDialog(NormalViewControl btnCycle) |
| | | { |
| | | //之前选择的控件 |
| | | NormalViewControl btnOldView = null; |
| | | |
| | | var form = new BottomItemEditorControl(4, Language.StringByID(StringId.cyclic)); |
| | | form.ClickConfirmClose = false; |
| | | //执行一次 |
| | | form.AddRowMenu(Language.StringByID(StringId.performA), string.Empty, (btnView, btnValue) => |
| | | { |
| | | this.automationInfo.LoopDiv = 1; |
| | | if (btnOldView != null) |
| | | { |
| | | //还原颜色 |
| | | btnOldView.TextColor = CSS_Color.FirstLevelTitleColor; |
| | | } |
| | | //变更颜色 |
| | | btnView.TextColor = CSS_Color.textConfirmColor; |
| | | btnOldView = btnView; |
| | | //变更显示文本 |
| | | btnCycle.Text = this.GetLoopCondtionText(); |
| | | |
| | | }, false); |
| | | |
| | | //每天 |
| | | form.AddRowMenu(Language.StringByID(StringId.days), string.Empty, (btnView, btnValue) => |
| | | { |
| | | this.automationInfo.LoopDiv = 2; |
| | | if (btnOldView != null) |
| | | { |
| | | //还原颜色 |
| | | btnOldView.TextColor = CSS_Color.FirstLevelTitleColor; |
| | | } |
| | | //变更颜色 |
| | | btnView.TextColor = CSS_Color.textConfirmColor; |
| | | btnOldView = btnView; |
| | | //变更显示文本 |
| | | btnCycle.Text = this.GetLoopCondtionText(); |
| | | |
| | | }, false); |
| | | |
| | | //每周 |
| | | form.AddRowMenu(Language.StringByID(StringId.weekly), string.Empty, (btnView, btnValue) => |
| | | { |
| | | //关闭弹窗,显示周期循环(星期)的配置窗口 |
| | | form.Close(); |
| | | this.ShowLoopMethordWeekDialog(btnCycle); |
| | | }); |
| | | |
| | | //每月 |
| | | form.AddRowMenu(Language.StringByID(StringId.monthly), string.Empty, (btnView, btnValue) => |
| | | { |
| | | //关闭弹窗,显示周期循环(月份)的配置窗口 |
| | | form.Close(); |
| | | this.ShowLoopMethordMonthDialog(btnCycle); |
| | | }); |
| | | |
| | | form.FinishEvent += (div) => |
| | | { |
| | | //当点击了确认时,如果还没选择,则无反应 |
| | | if (div != 1 || btnOldView == null) { return; } |
| | | |
| | | form.Close(); |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 显示周期循环(星期)的配置窗口 |
| | | /// </summary> |
| | | private void ShowLoopMethordWeekDialog(NormalViewControl btnCycle) |
| | | { |
| | | //星期一到星期日 |
| | | var listText = new List<string>(); |
| | | listText.Add(this.dicText["周1"]); |
| | | listText.Add(this.dicText["周2"]); |
| | | listText.Add(this.dicText["周3"]); |
| | | listText.Add(this.dicText["周4"]); |
| | | listText.Add(this.dicText["周5"]); |
| | | listText.Add(this.dicText["周6"]); |
| | | listText.Add(this.dicText["周7"]); |
| | | |
| | | var listSelect = new List<int>(); |
| | | if (this.automationInfo.LoopDiv == 3) |
| | | { |
| | | //之前选择的是这个区分才能有默认选择 |
| | | foreach (var value in this.automationInfo.ListLoopValue) |
| | | { |
| | | //默认选择 |
| | | listSelect.Add(value - 1); |
| | | } |
| | | } |
| | | |
| | | var form = new BottomItemSelectControl(7, Language.StringByID(StringId.cyclic)); |
| | | form.AddRowMenu(listText, listSelect); |
| | | form.FinishEvent += (div, listIndex) => |
| | | { |
| | | if (div == 0) |
| | | { |
| | | //如果点击了取消,则调起 周期循环配置窗口 |
| | | this.ShowLoopMethordSettionDialog(btnCycle); |
| | | return; |
| | | } |
| | | //更改缓存 |
| | | this.automationInfo.LoopDiv = 3; |
| | | this.automationInfo.ListLoopValue = new List<int>(); |
| | | |
| | | foreach (var index in listIndex) |
| | | { |
| | | this.automationInfo.ListLoopValue.Add(index + 1); |
| | | } |
| | | //变更显示文本 |
| | | btnCycle.Text = this.GetLoopCondtionText(); |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 显示周期循环(月份)的配置窗口 |
| | | /// </summary> |
| | | private void ShowLoopMethordMonthDialog(NormalViewControl btnCycle) |
| | | { |
| | | var listSelect = new List<int>(); |
| | | if (this.automationInfo.LoopDiv == 4) |
| | | { |
| | | //之前选择的是这个区分才能有默认选择 |
| | | foreach (var value in this.automationInfo.ListLoopValue) |
| | | { |
| | | //默认选择 |
| | | listSelect.Add(value); |
| | | } |
| | | } |
| | | |
| | | var form = new BottomSomeDaySelectControl(Language.StringByID(StringId.monthly)); |
| | | form.InitControl(listSelect); |
| | | form.FinishEvent += (div, listIndex) => |
| | | { |
| | | if (div == 0) |
| | | { |
| | | //如果点击了取消,则调起 周期循环配置窗口 |
| | | this.ShowLoopMethordSettionDialog(btnCycle); |
| | | return; |
| | | } |
| | | //更改缓存 |
| | | this.automationInfo.LoopDiv = 4; |
| | | this.automationInfo.ListLoopValue = new List<int>(); |
| | | |
| | | foreach (var day in listIndex) |
| | | { |
| | | this.automationInfo.ListLoopValue.Add(day); |
| | | } |
| | | //变更显示文本 |
| | | btnCycle.Text = this.GetLoopCondtionText(); |
| | | }; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 一般方法___________________________ |
| | | |
| | | /// <summary> |
| | | /// 获取循环条件的翻译文本 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private string GetLoopCondtionText() |
| | | { |
| | | //执行一次 |
| | | if (this.automationInfo.LoopDiv == 1) |
| | | { |
| | | return Language.StringByID(StringId.performA); |
| | | } |
| | | //每天 |
| | | else if (this.automationInfo.LoopDiv == 2) |
| | | { |
| | | return Language.StringByID(StringId.days); |
| | | } |
| | | //每周 |
| | | else if (this.automationInfo.LoopDiv == 3) |
| | | { |
| | | var textValue = string.Empty; |
| | | foreach (var weekValue in this.automationInfo.ListLoopValue) |
| | | { |
| | | textValue += this.dicText["周" + weekValue] + ","; |
| | | } |
| | | //去掉最后的逗号 |
| | | return textValue.Substring(0, textValue.Length - 1); |
| | | } |
| | | //每月 |
| | | else if (this.automationInfo.LoopDiv == 4) |
| | | { |
| | | var textValue = Language.StringByID(StringId.monthly) + " "; |
| | | foreach (var day in this.automationInfo.ListLoopValue) |
| | | { |
| | | textValue += day.ToString() + ","; |
| | | } |
| | | //去掉最后的逗号 |
| | | return textValue.Substring(0, textValue.Length - 1); |
| | | } |
| | | return string.Empty; |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |