From 5bfb959c47017825c8cf7dc8570c55b04dab694c Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期三, 09 六月 2021 16:42:11 +0800 Subject: [PATCH] Merge branch 'dev-tzy' into wxr6 --- HDL_ON/UI/UI2/FuntionControlView/DoorLock/DoorLockPage.cs | 1065 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 1,065 insertions(+), 0 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/DoorLock/DoorLockPage.cs b/HDL_ON/UI/UI2/FuntionControlView/DoorLock/DoorLockPage.cs new file mode 100644 index 0000000..5b6d5ca --- /dev/null +++ b/HDL_ON/UI/UI2/FuntionControlView/DoorLock/DoorLockPage.cs @@ -0,0 +1,1065 @@ +锘縰sing Shared; +using HDL_ON.Stan; +using System; +using System.Collections.Generic; +using System.Text; +using HDL_ON.UI.CSS; +using HDL_ON.Entity; + +namespace HDL_ON.UI +{ + /// <summary> + /// 闂ㄩ攣鐨勬帶鍒剁晫闈� + /// </summary> + public class DoorLockPage : DeviceFunctionCardCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 鐢垫睜鎺т欢 + /// </summary> + private BatteryPersentControl batteryControl = null; + /// <summary> + /// 鍦ㄧ嚎鍥炬爣鎺т欢 + /// </summary> + private IconViewControl btnOnlineIcon = null; + /// <summary> + /// 鍦ㄧ嚎鏂囨湰鎺т欢 + /// </summary> + private NormalViewControl btnOnlineView = null; + /// <summary> + /// 澹伴煶鍥炬爣 + /// </summary> + private IconViewControl btnVoice = null; + /// <summary> + /// 澹伴煶鐨勬粦鍔ㄦ潯鎺т欢 + /// </summary> + private SeekBarImageControl seekBarVoiceControl = null; + /// <summary> + /// 澹伴煶鐧惧垎姣� + /// </summary> + private NormalViewControl btnVoicePersent = null; + /// <summary> + /// 甯稿紑妯″紡鍥炬爣 + /// </summary> + private IconViewControl btnNormallyOpenIcon = null; + /// <summary> + /// 涓棿鐨勫紑閿佹垨鑰呭叧閿佸浘鐗囨帶浠� + /// </summary> + private PicViewControl picLockControl = null; + /// <summary> + /// 涓存椂瀵嗙爜tab椤典腑闂寸殑鎺т欢瀹瑰櫒(瀹冪殑Y杞存槸 涓�閿紑閿�/涓存椂瀵嗙爜寮�閿佺殑搴曢儴(绮椾綋瀛椾綋)+4) + /// </summary> + private FrameLayout frameTempPsw = null; + /// <summary> + /// 1:閫夋嫨鐨勬槸涓�閿紑閿� 2:閫夋嫨鐨勬槸涓存椂瀵嗙爜寮�閿� + /// </summary> + private int nowSelectMenu = 1; + /// <summary> + /// 闂ㄩ攣鏁版嵁 + /// </summary> + private DoorLockData doorLockData = new DoorLockData(); + /// <summary> + /// 闂ㄩ攣鐨勫巻鍙茶褰� + /// </summary> + private List<DoorHistoryLog> listHistoryLog = null; + /// <summary> + /// 鎴愬憳鍒楄〃 + /// </summary> + private List<ResidenceMemberInfo> listMember = null; + /// <summary> + /// 鏂囨湰缂撳瓨 + /// </summary> + private Dictionary<string, string> dicText = new Dictionary<string, string>(); + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 闂ㄩ攣鐨勬帶鍒剁晫闈� + /// </summary> + public DoorLockPage() + { + //闂ㄩ攣涓嶅厑璁告敹钘� + this.ShowColltionButton = false; + } + + /// <summary> + /// 鍒濆鍖栫櫧鑹插尯鍩熺殑鍐呭 + /// </summary> + public override void InitFrameWhiteContent() + { + //鏅鸿兘闂ㄩ攣 + base.SetTitleText(Language.StringByID(StringId.DoorLock)); + + this.dicText["宸茶繛鎺�"] = Language.StringByID(StringId.Connected); + this.dicText["鏈繛鎺�"] = Language.StringByID(StringId.UnConnected); + + //宸﹀彸缈婚〉鐨勪簨浠� + base.PageChangeEvent += (index) => + { + if (index == 1) + { + //鍒濆鍖栭棬閿佸巻鍙茶褰曚互鍙婃帶浠� + this.InitDoorHistoryLogAndControl(); + } + }; + + //鍒锋柊褰撳墠璁惧鐨勭姸鎬佺紦瀛� + this.RefreshNowDeviceStatuMemory(this.device); + //鍒濆鍖栫涓�涓储寮曢〉鐨勫唴瀹� + this.InitFrameWhiteContent1(); + //鍒濆鍖栫浜屼釜绱㈠紩椤�(鍘嗗彶璁板綍) + this.InitFrameWhiteContent2(); + //鍒锋柊鐣岄潰鐘舵�� + this.RefreshFormStatu(); + } + + /// <summary> + /// 鍒濆鍖栫涓�涓储寮曢〉鐨勫唴瀹� + /// </summary> + private void InitFrameWhiteContent1() + { + //鐢垫睜鎺т欢 + this.batteryControl = new BatteryPersentControl(); + //瀹冩湁涓渶灏忕殑X杞� + batteryControl.X = Application.GetRealWidth(104) > base.btnRoomName.Right ? + Application.GetRealWidth(104) : base.btnRoomName.Right + Application.GetRealWidth(4); + FrameWhiteCentet1.AddChidren(batteryControl); + if (batteryControl.Height > base.btnRoomName.Height) + { + //涓�涓槸25锛屼竴涓槸21锛屽紕涓嶅噯鍒板簳璋佹洿楂�,鍥犱负璁$畻鏂规硶涓嶄竴鏍� + batteryControl.Y = base.btnRoomName.Y - (batteryControl.Height - base.btnRoomName.Height) / 2; + } + else + { + batteryControl.Y = base.btnRoomName.Y + (batteryControl.Height - base.btnRoomName.Height) / 2; + } + batteryControl.InitControl(); + batteryControl.SetValue(100); + + //鍦ㄧ嚎鐘舵�� + this.btnOnlineIcon = new IconViewControl(24); + btnOnlineIcon.X = batteryControl.Right + Application.GetRealWidth(12); + btnOnlineIcon.Y = batteryControl.Y; + btnOnlineIcon.UnSelectedImagePath = "FunctionIcon/DoorLock/Connect.png"; + FrameWhiteCentet1.AddChidren(btnOnlineIcon); + //鍦ㄧ嚎鏂囨湰 + this.btnOnlineView = new NormalViewControl(Application.GetRealWidth(100), btnOnlineIcon.Height, false); + btnOnlineView.X = btnOnlineIcon.Right + Application.GetRealWidth(4); + btnOnlineView.Y = btnOnlineIcon.Y; + btnOnlineView.TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel; + btnOnlineView.TextColor = CSS_Color.PromptingColor1; + btnOnlineView.TextID = StringId.Connected; + FrameWhiteCentet1.AddChidren(btnOnlineView); + //鍙充笂瑙掗厤缃粨鏉熺殑浜嬩欢 + base.SettionFinishEvent += () => + { + //浠庢柊璁剧疆鍧愭爣 + batteryControl.X = Application.GetRealWidth(104) > base.btnRoomName.Right ? + Application.GetRealWidth(104) : base.btnRoomName.Right + Application.GetRealWidth(4); + btnOnlineIcon.X = batteryControl.Right + Application.GetRealWidth(12); + btnOnlineView.X = btnOnlineIcon.Right + Application.GetRealWidth(4); + }; + + //涓棿鐨勫紑閿佹垨鑰呭叧閿佸浘鐗囨帶浠� + this.picLockControl = new PicViewControl(256, 260); + picLockControl.Y = Application.GetRealHeight(129); + picLockControl.Gravity = Gravity.CenterHorizontal; + picLockControl.UnSelectedImagePath = "FunctionIcon/DoorLock/LockPictrue1.png"; + FrameWhiteCentet1.AddChidren(picLockControl); + picLockControl.ButtonClickEvent += (sender, e) => + { + //涓�閿紑閿� + this.DoOneKeyToUnlockDoor(); + }; + + //涓存椂瀵嗙爜鐨勬帶浠跺鍣� + this.frameTempPsw = new FrameLayout(); + frameTempPsw.Y = Application.GetRealHeight(129); + frameTempPsw.Height = Application.GetRealHeight(260); + frameTempPsw.Visible = false; + FrameWhiteCentet1.AddChidren(frameTempPsw); + + //澹伴煶 + this.btnVoice = new IconViewControl(24); + btnVoice.UnSelectedImagePath = "FunctionIcon/DoorLock/Voice.png"; + btnVoice.X = Application.GetRealWidth(23); + btnVoice.Y = Application.GetRealHeight(410); + FrameWhiteCentet1.AddChidren(btnVoice); + + //澹伴煶鐨勬粦鍔ㄦ潯 + this.seekBarVoiceControl = new SeekBarImageControl(215); + seekBarVoiceControl.Gravity = Gravity.CenterHorizontal; + FrameWhiteCentet1.AddChidren(seekBarVoiceControl); + seekBarVoiceControl.Y = btnVoice.Y - (seekBarVoiceControl.Height - btnVoice.Height) / 2; + //缁戝畾PageLayout鎺т欢 + seekBarVoiceControl.BindPageLayout(); + + //澹伴煶鐧惧垎姣� + this.btnVoicePersent = new NormalViewControl(Application.GetRealWidth(50), btnVoice.Height, false); + btnVoicePersent.X = seekBarVoiceControl.Right + Application.GetRealWidth(8) - seekBarVoiceControl.SeekBarPadding; + btnVoicePersent.Y = btnVoice.Y; + btnVoicePersent.TextColor = CSS_Color.PromptingColor1; + btnVoicePersent.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; + btnVoicePersent.Text = "100%"; + FrameWhiteCentet1.AddChidren(btnVoicePersent); + + seekBarVoiceControl.ProgressChangedEvent += (div, value) => + { + btnVoicePersent.Text = value + "%"; + if (div == 1) + { + } + }; + + //鍒濆鍖栧紑閿佽彍鍗�(涓�閿紑閿�,涓存椂瀵嗙爜寮�閿�) + this.InitUnLockMenuControl(); + //鍒濆鍖栧簳閮ㄨ彍鍗曞浘鏍� + this.InitBottomMenuIconControl(); + } + + /// <summary> + /// 鍒濆鍖栧紑閿佽彍鍗�(涓�閿紑閿�,涓存椂瀵嗙爜寮�閿�) + /// </summary> + private void InitUnLockMenuControl() + { + //濡傛灉鏄垚鍛�,鍒欏彧鏈変竴閿紑閿� + if (DB_ResidenceData.Instance.CurrentRegion.isOtherShare == true) + { + //涓�閿紑閿� + var btnOneKey = new NormalViewControl(100, 25, true); + btnOneKey.Y = Application.GetRealHeight(100); + btnOneKey.TextSize = CSS_FontSize.HeadlineFontSize; + btnOneKey.TextColor = CSS_Color.MainColor; + btnOneKey.Text = Language.StringByID(StringId.OneKeyUnlocking); + btnOneKey.Width = this.GetTextRealWidth(btnOneKey.Text, CSS_FontSize.HeadlineFontSize, true); + btnOneKey.Gravity = Gravity.CenterHorizontal; + btnOneKey.IsBold = true; + FrameWhiteCentet1.AddChidren(btnOneKey); + } + else + { + //涓�閿紑閿� + var btnOneKey = new NormalViewControl(100, 25, true); + btnOneKey.Y = Application.GetRealHeight(100); + btnOneKey.TextSize = Language.CurrentLanguage == "Chinese" ? CSS_FontSize.HeadlineFontSize : CSS_FontSize.SubheadingFontSize; + btnOneKey.TextColor = CSS_Color.MainColor; + btnOneKey.Text = Language.StringByID(StringId.OneKeyUnlocking); + btnOneKey.TextAlignment = TextAlignment.CenterRight; + btnOneKey.IsBold = true; + btnOneKey.Width = this.GetTextRealWidth(btnOneKey.Text, CSS_FontSize.HeadlineFontSize, true); + FrameWhiteCentet1.AddChidren(btnOneKey); + btnOneKey.X = Application.GetRealWidth(140) - btnOneKey.Width; + + //涓存椂瀵嗙爜寮�閿� + var btnTempPsw = new NormalViewControl(100, 25, true); + btnTempPsw.X = btnOneKey.Right + Application.GetRealWidth(36); + btnTempPsw.Y = btnOneKey.Y; + btnTempPsw.TextColor = CSS_Color.PromptingColor1; + btnTempPsw.Text = Language.StringByID(StringId.TemporaryPasswordUnlocking); + btnTempPsw.Width = this.GetTextRealWidth(btnTempPsw.Text, CSS_FontSize.HeadlineFontSize, true); + FrameWhiteCentet1.AddChidren(btnTempPsw); + + btnOneKey.ButtonClickEvent += (sender, e) => + { + //閫夋嫨鐨勬槸鍚屼竴涓�,鍒欎笉澶勭悊 + if (this.nowSelectMenu == 1) { return; } + this.nowSelectMenu = 1; + + btnOneKey.IsBold = true; + btnOneKey.TextSize = Language.CurrentLanguage == "Chinese" ? CSS_FontSize.HeadlineFontSize : CSS_FontSize.SubheadingFontSize; + btnOneKey.TextColor = CSS_Color.MainColor; + + btnTempPsw.IsBold = false; + btnTempPsw.TextSize = CSS_FontSize.TextFontSize; + btnTempPsw.TextColor = CSS_Color.PromptingColor1; + + //璁剧疆涓棿瀹瑰櫒鎺т欢鍙鍖� + this.SetMiddleFrameControlVisible(); + }; + + btnTempPsw.ButtonClickEvent += (sender, e) => + { + //閫夋嫨鐨勬槸鍚屼竴涓�,鍒欎笉澶勭悊 + if (this.nowSelectMenu == 2) { return; } + this.nowSelectMenu = 2; + + btnOneKey.IsBold = false; + btnOneKey.TextSize = CSS_FontSize.TextFontSize; + btnOneKey.TextColor = CSS_Color.PromptingColor1; + + btnTempPsw.IsBold = true; + btnTempPsw.TextSize = Language.CurrentLanguage == "Chinese" ? CSS_FontSize.HeadlineFontSize : CSS_FontSize.SubheadingFontSize; + btnTempPsw.TextColor = CSS_Color.MainColor; + + //璁剧疆涓棿瀹瑰櫒鎺т欢鍙鍖� + this.SetMiddleFrameControlVisible(); + }; + } + } + + #endregion + + #region 鈻� 鍒濆鍖栫浜屼釜绱㈠紩椤�(鍘嗗彶璁板綍)_______ + + /// <summary> + /// 鍒濆鍖栫浜屼釜绱㈠紩椤�(鍘嗗彶璁板綍) + /// </summary> + private void InitFrameWhiteContent2() + { + //娣诲姞绗簩涓猵age + this.AddSecondPage(); + } + + /// <summary> + /// 鍒濆鍖栭棬閿佸巻鍙茶褰曚互鍙婃帶浠� + /// </summary> + private void InitDoorHistoryLogAndControl() + { + //宸茬粡鍒濆鍖� + if (this.listHistoryLog != null) { return; } + + this.ShowProgressBar(); + HdlThreadLogic.Current.RunThread(() => + { + //鍒濆鍖栨垚鍛樺垪琛ㄤ俊鎭� + if (this.InitMemberListInfo() == false) + { + this.CloseProgressBar(); + return; + } + //鑾峰彇闂ㄩ攣鍘嗗彶璁板綍 + this.listHistoryLog = new DAL.Server.HttpServerRequest().GetDoorHistoryLogs(this.device); + this.CloseProgressBar(); + if (this.listHistoryLog == null) + { + return; + } + HdlThreadLogic.Current.RunMain(() => + { + //鍒濆鍖栭棬閿佸巻鍙茶褰曞垪琛ㄦ帶浠� + this.InitDoorHistoryLogListControl(this.listHistoryLog); + }); + }); + } + + /// <summary> + /// 鍒濆鍖栭棬閿佸巻鍙茶褰曞垪琛ㄦ帶浠� + /// </summary> + /// <param name="listLog">鏄剧ず鐨勯棬閿佽褰�</param> + private void InitDoorHistoryLogListControl(List<DoorHistoryLog> listLog) + { + //鎸夊勾鍒嗙粍 + var dicData = new Dictionary<int, List<DoorHistoryLog>>(); + foreach (var info in listLog) + { + var year = info.Time.Year; + if (dicData.ContainsKey(year) == false) + { + dicData[year] = new List<DoorHistoryLog>(); + } + dicData[year].Add(info); + } + + //鍏堟竻绌� + base.FrameWhiteCentet2.RemoveAll(); + + //鏃ュ織 + var btnLog = new NormalViewControl(150, 35, true); + btnLog.Y = Application.GetRealHeight(15); + btnLog.X = HdlControlResourse.XXLeft; + btnLog.TextSize = CSS_FontSize.EmphasisFontSize_FirstLevel; + btnLog.TextColor = CSS_Color.FirstLevelTitleColor; + btnLog.TextID = StringId.Log; + FrameWhiteCentet2.AddChidren(btnLog); + + //鍒楄〃瀹瑰櫒 + var listView = new VerticalFrameControl(); + listView.Y = Application.GetRealHeight(72); + listView.Height = base.FrameWhiteCentet2.Height - Application.GetRealHeight(72); + base.FrameWhiteCentet2.AddChidren(listView); + + //鍒濆Y杞翠负0 + int yy = 0; + foreach (var strYear in dicData.Keys) + { + //骞� + var btnYear = new NormalViewControl(100, 24, true); + btnYear.X = HdlControlResourse.XXLeft; + btnYear.Y = yy; + btnYear.TextColor = CSS_Color.FirstLevelTitleColor; + btnYear.TextSize = CSS_FontSize.SubheadingFontSize; + btnYear.Text = strYear.ToString(); + //涓枃 + if (Language.CurrentLanguage == "Chinese") + { + btnYear.Text += Language.StringByID(StringId.Years); + } + listView.frameTable.AddChidren(btnYear); + + //骞翠笌娑堟伅璁板綍鐨勯棿璺濅负14 + yy = btnYear.Bottom + Application.GetRealHeight(14); + foreach (var logInfo in dicData[strYear]) + { + //娑堟伅 + var btnMsg = new NormalViewControl(295, 20, true); + btnMsg.Y = yy; + btnMsg.Gravity = Gravity.CenterHorizontal; + btnMsg.TextColor = CSS_Color.FirstLevelTitleColor; + btnMsg.Text = logInfo.StrMsg; + listView.frameTable.AddChidren(btnMsg); + //鏃堕棿 + var btnTime = new NormalViewControl(200, 18, true); + btnTime.Y = btnMsg.Bottom + Application.GetRealHeight(2); + btnTime.X = btnMsg.X; + btnTime.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; + btnTime.TextColor = CSS_Color.PromptingColor1; + btnTime.Text = HdlCommonLogic.Current.ConvertDayText(logInfo.Time.Month, logInfo.Time.Day) + " " + logInfo.Time.ToString("HH:mm"); + listView.frameTable.AddChidren(btnTime); + //绾� + var btnLine = new NormalViewControl(btnMsg.Width, HdlControlResourse.BottomLineHeight, false); + btnLine.Y = btnTime.Bottom + Application.GetRealHeight(11); + btnLine.Gravity = Gravity.CenterHorizontal; + btnLine.BackgroundColor = CSS_Color.DividingLineColor; + listView.frameTable.AddChidren(btnLine); + //涓ゆ潯娑堟伅鐨勯棿璺濅负10 + yy = btnLine.Bottom + Application.GetRealHeight(10); + } + //骞翠笌骞翠箣闂寸殑闂磋窛涓�24 + yy += Application.GetRealHeight(24); + } + //璋冩暣妗屽竷楂樺害 + listView.AdjustTableHeight(); + } + + #endregion + + #region 鈻� 鍒濆鍖栧簳閮ㄨ彍鍗曞浘鏍嘷________________ + + /// <summary> + /// 鍒濆鍖栧簳閮ㄨ彍鍗曞浘鏍� + /// </summary> + private void InitBottomMenuIconControl() + { + //濡傛灉鏄垚鍛�,鍒欏彧鏈夊紑閿佹柟寮忕鐞� + if (DB_ResidenceData.Instance.CurrentRegion.isOtherShare == true) + { + //寮�閿佹柟寮忕鐞嗗浘鏍� + var btnManagerIcon = new IconViewControl(40); + btnManagerIcon.Gravity = Gravity.CenterHorizontal; + btnManagerIcon.Y = Application.GetRealHeight(466); + btnManagerIcon.UnSelectedImagePath = "FunctionIcon/DoorLock/UnLockManager.png"; + this.FrameWhiteCentet1.AddChidren(btnManagerIcon); + btnManagerIcon.ButtonClickEvent += (sender, e) => + { + //鍒濆鍖栨垚鍛樺垪琛ㄤ俊鎭� + if (this.InitMemberListInfo() == false) + { + return; + } + var form = new DoorLockUnlockMethordManagerPage(); + form.AddForm(this.device, this.listMember); + }; + } + else + { + //寮�閿佹柟寮忕鐞嗗浘鏍� + var btnManagerIcon = new IconViewControl(40); + btnManagerIcon.Y = Application.GetRealHeight(466); + btnManagerIcon.UnSelectedImagePath = "FunctionIcon/DoorLock/UnLockManager.png"; + this.FrameWhiteCentet1.AddChidren(btnManagerIcon); + btnManagerIcon.X = (this.FrameWhiteCentet1.Width - btnManagerIcon.Width * 2 - Application.GetRealWidth(40)) / 2; + btnManagerIcon.ButtonClickEvent += (sender, e) => + { + //鍒濆鍖栨垚鍛樺垪琛ㄤ俊鎭� + if (this.InitMemberListInfo() == false) + { + return; + } + var form = new DoorLockUnlockMethordManagerPage(); + form.AddForm(this.device, this.listMember); + }; + + //甯稿紑妯″紡鍥炬爣 + this.btnNormallyOpenIcon = new IconViewControl(40); + btnNormallyOpenIcon.X = btnManagerIcon.Right + Application.GetRealWidth(40); + btnNormallyOpenIcon.Y = btnManagerIcon.Y; + btnNormallyOpenIcon.UnSelectedImagePath = "FunctionIcon/DoorLock/NormallyOpenIcon2.png"; + this.FrameWhiteCentet1.AddChidren(btnNormallyOpenIcon); + btnNormallyOpenIcon.ButtonClickEvent += (sender, e) => + { + var form = new DoorLockAlwaysOnListPage(); + form.AddForm(this.device); + }; + } + } + + #endregion + + #region 鈻� 鍒濆鍖栦复鏃跺瘑鐮佹帶浠禵________________ + + /// <summary> + /// 鍒濆鍖栦复鏃跺瘑鐮佹帶浠� + /// </summary> + private void InitTempPasswordControl() + { + this.frameTempPsw.RemoveAll(); + + //鐢熸垚涓存椂瀵嗙爜鐨勮儗鏅浘鐗� + var picBack = new PicViewControl(258, 165); + picBack.Gravity = Gravity.CenterHorizontal; + picBack.UnSelectedImagePath = "FunctionIcon/DoorLock/CrearPswBackgroud.png"; + this.frameTempPsw.AddChidren(picBack); + + //瀵嗙爜鏄剧ず鎺т欢 + var btnPassword = new NormalViewControl(150, 50, true); + btnPassword.Gravity = Gravity.CenterHorizontal; + btnPassword.TextSize = CSS_FontSize.SubheadingFontSize; + btnPassword.TextColor = CSS_Color.MainBackgroundColor; + btnPassword.TextAlignment = TextAlignment.Center; + this.frameTempPsw.AddChidren(btnPassword); + + //濡傛灉娌℃湁涓存椂瀵嗙爜 + if (this.doorLockData.TempPassword == string.Empty) + { + //褰撴病鏈変复鏃跺瘑鐮佹椂,杩欎釜鑳屾櫙鏀惧湪涓棿 + picBack.Y = Application.GetRealHeight(47); + //鍥犱负鍥剧墖鐨勫帇缂╅棶棰�,杩欎釜Y杞村拰钃濇箹鐨勪笉涓�鏍�,钃濇箹鏄�99 + btnPassword.Y = Application.GetRealHeight(88); + + //鐢熸垚涓存椂瀵嗙爜 + btnPassword.TextID = StringId.CreatTemporaryPassword; + btnPassword.ButtonClickEvent += (sender, e) => + { + //鏄剧ず鐢熸垚涓存椂瀵嗙爜鐨勫脊绐楃晫闈� + this.ShowCreatTemporaryPasswordDialog(DateTime.Now, DateTime.Now.AddDays(1).AddMinutes(-1)); + }; + } + //鎷ユ湁涓存椂瀵嗙爜 + else + { + //鏄剧ず涓存椂瀵嗙爜 + btnPassword.Text = this.doorLockData.TempPassword; + //鍥犱负鍥剧墖鐨勫帇缂╅棶棰�,杩欎釜Y杞村拰钃濇箹鐨勪笉涓�鏍�,钃濇箹鏄�51 + btnPassword.Y = Application.GetRealHeight(40); + + //鍒犻櫎涓存椂瀵嗙爜鍥炬爣 + var btnDelete = new IconViewControl(28); + btnDelete.UnSelectedImagePath = "FunctionIcon/DoorLock/Delete.png"; + btnDelete.X = Application.GetRealWidth(19); + btnDelete.Y = Application.GetRealHeight(115); + this.frameTempPsw.AddChidren(btnDelete); + btnDelete.ButtonClickEvent += (sender, e) => + { + //娓呴櫎褰撳墠涓存椂瀵嗙爜锛� + HdlMessageLogic.Current.ShowMassage(ShowMsgType.Confirm, Language.StringByID(StringId.ClearTempPsswordMsg), () => + { + //娓呯┖涓存椂瀵嗙爜 + this.doorLockData.TempPassword = string.Empty; + this.doorLockData.StatrtTime = string.Empty; + this.doorLockData.EndTime = string.Empty; + //閲嶆柊鍒濆鍖栦复鏃跺瘑鐮佹帶浠� + this.InitTempPasswordControl(); + }); + }; + + //澶嶅埗涓存椂瀵嗙爜鍥炬爣 + var btnCopy = new IconViewControl(28); + btnCopy.UnSelectedImagePath = "FunctionIcon/DoorLock/Shard.png"; + btnCopy.X = this.frameTempPsw.Width - btnCopy.IconSize - btnDelete.X; + btnCopy.Y = btnDelete.Y; + this.frameTempPsw.AddChidren(btnCopy); + btnCopy.ButtonClickEvent += (sender, e) => + { + //涓存椂瀵嗙爜宸茬粡澶嶅埗 + HdlCommonLogic.Current.SetTextToShearPlate(this.doorLockData.TempPassword, Language.StringByID(StringId.TempPsswordHasBeenCopy)); + }; + + //鐢熸晥鏃堕棿 + var frameEffective = this.CreatEffectiveTimeControl(this.frameTempPsw, Language.StringByID(StringId.EffectiveTime), this.doorLockData.StatrtTime); + frameEffective.X = Application.GetRealWidth(24); + frameEffective.Y = Application.GetRealHeight(180); + + //澶辨晥鏃堕棿 + var frameFailure = this.CreatEffectiveTimeControl(this.frameTempPsw, Language.StringByID(StringId.FailureTime), this.doorLockData.EndTime); + frameFailure.X = this.frameTempPsw.Width - frameFailure.Width - frameEffective.X; + frameFailure.Y = frameEffective.Y; + + //- + var btnLine = new NormalViewControl(frameFailure.X - frameEffective.Right, frameFailure.Height, false); + btnLine.X = frameEffective.Right; + btnLine.Y = frameEffective.Y; + btnLine.Text = "-"; + btnLine.TextAlignment = TextAlignment.Center; + btnLine.TextColor = CSS_Color.FirstLevelTitleColor; + btnLine.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; + this.frameTempPsw.AddChidren(btnLine); + } + } + + /// <summary> + /// 鐢熸垚鐢熸晥/澶辨晥鏃堕棿鎺т欢 + /// </summary> + /// <param name="frameTempPsw">鐖舵帶浠�</param> + /// <param name="i_text">鏄剧ず鐨勬枃鏈�</param> + /// <param name="i_time">鏄剧ず鐨勬椂闂�</param> + /// <returns></returns> + private FrameLayout CreatEffectiveTimeControl(FrameLayout frameTempPsw, string i_text, string i_time) + { + //绾挎鑳屾櫙鎺т欢 + var frameBack = new FrameLayout(); + frameBack.Width = Application.GetRealWidth(120); + frameBack.Height = Application.GetRealHeight(50); + frameBack.Radius = (uint)Application.GetRealWidth(7); + frameBack.BorderWidth = 1; + frameBack.BorderColor = CSS_Color.PromptingColor1; + frameTempPsw.AddChidren(frameBack); + + //鏄剧ず鏂囨湰 + var btnText = new NormalViewControl(frameBack.Width, Application.GetRealHeight(18), false); + btnText.Y = Application.GetRealHeight(8); + btnText.TextColor = CSS_Color.FirstLevelTitleColor; + btnText.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; + btnText.Text = i_text; + btnText.TextAlignment = TextAlignment.Center; + frameBack.AddChidren(btnText); + + //鏄剧ず鏃堕棿 + var btnTime = new NormalViewControl(frameBack.Width, Application.GetRealHeight(18), false); + btnTime.Y = btnText.Bottom; + btnTime.TextColor = CSS_Color.FirstLevelTitleColor; + btnTime.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; + btnTime.Text = i_time; + btnTime.TextAlignment = TextAlignment.Center; + frameBack.AddChidren(btnTime); + + return frameBack; + } + + #endregion + + #region 鈻� 鐢熸垚涓存椂瀵嗙爜_______________________ + + /// <summary> + /// 鏄剧ず鐢熸垚涓存椂瀵嗙爜鐨勫脊绐楃晫闈� + /// </summary> + private void ShowCreatTemporaryPasswordDialog(DateTime startTime, DateTime endTime) + { + //榛樿鏃堕棿Form-To涓轰竴澶� + var contr = new BottomItemEditorControl(2, string.Empty); + //鐐瑰嚮纭鏃�,涓嶅叧闂晫闈� + contr.CloseByConfirm = false; + + //鐢熸晥鏃堕棿 + var effectiveTime = Language.StringByID(StringId.EffectiveTime); + contr.AddRowMenu(effectiveTime, startTime.ToString("yyyy.MM.dd HH:mm"), (btnView, btnValue) => + { + //鍏虫帀鐣岄潰,鐒跺悗閲嶆柊璋冭捣鏉� + contr.Close(); + + var form = new DoorLockSelectTimePage(); + form.AddForm(startTime); + form.SelectFinshEvent += (selectTime) => + { + //閲嶆柊璋冭捣鐣岄潰 + this.ShowCreatTemporaryPasswordDialog(selectTime, endTime); + }; + }); + + //澶辨晥鏃堕棿 + var failTime = Language.StringByID(StringId.FailureTime); + contr.AddRowMenu(failTime, endTime.ToString("yyyy.MM.dd HH:mm"), (btnView, btnValue) => + { + //鍏虫帀鐣岄潰,鐒跺悗閲嶆柊璋冭捣鏉� + contr.Close(); + + var form = new DoorLockSelectTimePage(); + form.AddForm(endTime); + form.SelectFinshEvent += (selectTime) => + { + //閲嶆柊璋冭捣鐣岄潰 + this.ShowCreatTemporaryPasswordDialog(startTime, selectTime); + }; + }); + contr.FinishEvent += (div) => + { + //鐐瑰嚮浜嗙敓鎴� + if (div == 1) + { + if (this.CheckEffectiveTime(startTime, endTime) == false) + { + return; + } + //鍏虫帀鐣岄潰 + contr.Close(); + + //鐢熸垚涓存椂瀵嗙爜 + this.doorLockData.TempPassword = "987654"; + this.doorLockData.StatrtTime = startTime.ToString("yyyy.MM.dd HH:mm"); + this.doorLockData.EndTime = endTime.ToString("yyyy.MM.dd HH:mm"); + //閲嶆柊鍒濆鍖栦复鏃跺瘑鐮佹帶浠� + this.InitTempPasswordControl(); + } + }; + + //闇�瑕佸垵濮嬪寲涔嬪悗,鎸夐挳鎵嶄笉浼氫负null 鍙樻洿銆愮敓鎴愩�戞寜閽殑瀹藉害鍜孹杞� + contr.btnConfirm.TextID = StringId.Generate; + contr.btnConfirm.Width = contr.btnConfirm.GetRealWidthByText(); + contr.btnConfirm.X = contr.btnConfirm.Parent.Width - contr.btnConfirm.Width - contr.btnCancel.X; + } + + /// <summary> + /// 妫�娴嬬敓鏁堟椂闂存槸鍚︽纭� + /// </summary> + /// <param name="startTime">鐢熸晥鏃堕棿</param> + /// <param name="endTime">澶辨晥鏃堕棿</param> + /// <returns></returns> + private bool CheckEffectiveTime(DateTime startTime, DateTime endTime) + { + if (startTime >= endTime) + { + //鐢熸晥鏃堕棿蹇呴』澶т簬澶辨晥鏃堕棿 + HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, Language.StringByID(StringId.EffectiveTimeMustBeOverFailureTime)); + return false; + } + return true; + } + + #endregion + + #region 鈻� 璁惧鐘舵�佸弽棣坃______________________ + + /// <summary> + /// 璁惧鐘舵�佸弽棣� + /// </summary> + /// <param name="i_LocalDevice"></param> + public override void DeviceStatuPush(Function i_LocalDevice) + { + //涓嶆槸鍚屼竴涓笢瑗� + if (this.device.sid != i_LocalDevice.sid) { return; } + + //鍒锋柊褰撳墠璁惧鐨勭姸鎬佺紦瀛� + this.RefreshNowDeviceStatuMemory(i_LocalDevice); + //鍒锋柊鐣岄潰鐘舵�� + this.RefreshFormStatu(); + } + + #endregion + + #region 鈻� 鍒锋柊鐣岄潰鐘舵�乢______________________ + + /// <summary> + /// 鍒锋柊鐣岄潰鐘舵�� + /// </summary> + private void RefreshFormStatu() + { + //濡傛灉涓嶅湪绾� + if (this.doorLockData.IsOnline == false) + { + //寮�閿佸浘鐗� + this.picLockControl.UnSelectedImagePath = "FunctionIcon/DoorLock/LockPictrue2.png"; + //杩炴帴鐘舵�� + this.btnOnlineIcon.UnSelectedImagePath = "FunctionIcon/DoorLock/UnConnect.png"; + this.btnOnlineView.Text = this.dicText["鏈繛鎺�"]; + this.btnOnlineView.TextColor = CSS_Color.AuxiliaryColor2; + //甯稿紑妯″紡鍥炬爣 + if (this.btnNormallyOpenIcon != null) + { + this.btnNormallyOpenIcon.UnSelectedImagePath = "FunctionIcon/DoorLock/NormallyOpenIcon2.png"; + } + } + else + { + //寮�閿佸浘鐗� + this.picLockControl.UnSelectedImagePath = this.doorLockData.Open == true ? "FunctionIcon/DoorLock/UnLockPictrue3.png" : "FunctionIcon/DoorLock/LockPictrue1.png"; + //杩炴帴鐘舵�� + this.btnOnlineIcon.UnSelectedImagePath = "FunctionIcon/DoorLock/Connect.png"; + this.btnOnlineView.Text = this.dicText["宸茶繛鎺�"]; + this.btnOnlineView.TextColor = CSS_Color.PromptingColor1; + //甯稿紑妯″紡鍥炬爣 + if (this.btnNormallyOpenIcon != null) + { + this.btnNormallyOpenIcon.UnSelectedImagePath = "FunctionIcon/DoorLock/NormallyOpenIcon1.png"; + } + } + } + + /// <summary> + /// 璁剧疆涓棿瀹瑰櫒鎺т欢鍙鍖� + /// </summary> + private void SetMiddleFrameControlVisible() + { + //濡傛灉閫夋嫨鐨勬槸 涓�閿紑閿� + if (this.nowSelectMenu == 1) + { + this.picLockControl.Visible = true; + this.frameTempPsw.Visible = false; + } + else + { + this.picLockControl.Visible = false; + this.frameTempPsw.Visible = true; + //涓存椂瀵嗙爜宸茬粡鍙樻洿,闇�瑕佸埛鏂扮晫闈� + if (this.doorLockData.IsTempPasswordChanged == true) + { + //鍒濆鍖栦复鏃跺瘑鐮佹帶浠� + this.InitTempPasswordControl(); + this.doorLockData.IsTempPasswordChanged = false; + } + } + } + + #endregion + + #region 鈻� 鍙戦�佸悇绉嶅懡浠______________________ + + /// <summary> + /// 鍙戦�佸紑鍏冲懡浠� + /// </summary> + private void SendSwitchComand() + { + //this.btnSwitch.CanClick = false; + + //string statu = this.btnSwitch.IsSelected == true ? "off" : "on"; + //HdlThreadLogic.Current.RunThread(() => + //{ + // var dic = new Dictionary<string, string>(); + // dic.Add(FunctionAttributeKey.OnOff, statu); + // Control.Ins.SendWriteCommand(this.device, dic, true); + // HdlThreadLogic.Current.RunMain(() => + // { + // this.btnSwitch.CanClick = true; + // }); + //}); + } + + #endregion + + #region 鈻� 鍒濆鍖栨垚鍛樺垪琛ㄤ俊鎭痏________________ + + /// <summary> + /// 鍒濆鍖栨垚鍛樺垪琛ㄤ俊鎭� + /// </summary> + /// <returns></returns> + private bool InitMemberListInfo() + { + //宸茬粡鍒濆鍖� + if (this.listMember != null) { return true; } + + //涓昏处鍙烽渶瑕佸幓鑾峰彇鎴愬憳鍒楄〃,鑰屽瓙璐﹀彿鍙兘浠栬嚜宸� + if (DB_ResidenceData.Instance.CurrentRegion.isOtherShare == false) + { + //鑾峰彇鎴愬憳鍒楄〃 + var responePack = new DAL.Server.HttpServerRequest().GetResidenceMemberAccount(); + if (responePack.Code == DAL.Server.StateCode.SUCCESS) + { + this.listMember = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ResidenceMemberInfo>>(responePack.Data.ToString()); + } + //澶辫触 + else + { + //鎻愮ず + DAL.Server.IMessageCommon.Current.ShowErrorInfoAlter(responePack.Code); + return false; + } + } + else + { + //鍏堝垵濮嬪寲 + this.listMember = new List<ResidenceMemberInfo>(); + } + + //鑷韩鍔犺繘鍘�,鑷繁浣嶄簬棣栦綅 + var info = new ResidenceMemberInfo(); + info.childAccountId = OnAppConfig.Instance.LastLoginUserId; + info.childAccountType = DB_ResidenceData.Instance.CurrentRegion.isOtherShare == false ? "ADMIN" : "ORDINARY"; + info.nickName = UserInfo.Current.userName; + this.listMember.Insert(0, info); + if (string.IsNullOrEmpty(info.nickName)) + { + info.nickName = UserInfo.Current.AccountString; + } + + foreach (var info2 in this.listMember) + { + //璁剧疆鐢ㄦ埛鏄电О + if (string.IsNullOrEmpty(info2.nickName)) + { + info2.nickName = info2.memberName; + } + } + + return true; + } + #endregion + + #region 鈻� 涓�閿紑閿乢__________________________ + + /// <summary> + /// 涓�閿紑閿� + /// </summary> + private void DoOneKeyToUnlockDoor() + { + if (this.doorLockData.IsOnline == false) + { + //璁惧涓嶅湪绾� + HdlMessageLogic.Current.ShowMassage(ShowMsgType.TipRemind, Language.StringByID(StringId.DeviceNotOnline), null, null, null, 2); + return; + } + //绗竴娆′娇鐢紝璇峰厛缁戝畾闂ㄩ攣瀵嗙爜 + //HdlMessageLogic.Current.ShowMassage(ShowMsgType.Confirm, Language.StringByID(StringId.PleaseBindTheDoorPswFirst), () => + //{ + // var form = new TextInputDialog(Language.StringByID(StringId.PleaseInputDoorAdminPassword), string.Empty, Language.StringByID(StringId.PleaseInputDoorAdminPassword), null, null, true); + // form.Show((password) => + // { + // //闂ㄩ攣缁戝畾鎴愬姛 + // HdlMessageLogic.Current.ShowMassage(ShowMsgType.ConfirmSuccess, Language.StringByID(StringId.BindDoorLockSuccess), () => + // { + // }); + // }); + //}); + + if (UserInfo.Current.appUnlockPage.Contains("3") == true) + { + //璋冭捣瀹夊叏璁よ瘉 + HdlCheckLogic.Current.CheckUnlockSecurity(true, (div) => + { + //閿佸凡鎵撳紑 + if (div == 1) + { + HdlMessageLogic.Current.ShowMassage(ShowMsgType.TipSuccess, Language.StringByID(StringId.LockIsOpened), null, null, null, 2); + } + else + { + //涓轰簡瀹夊叏锛岃璺宠浆鑷充釜浜轰腑蹇儃0}璁剧疆涓汉瀵嗙爜锛屽苟搴旂敤浜庨棬閿佸紑閿� + HdlMessageLogic.Current.ShowMassage(ShowMsgType.Confirm, Language.StringByID(StringId.JumpToPersonalCentetToSetPasswordMsg), () => + { + var page = new AppUnlockSettingsPage(); + MainPage.BasePageView.AddChidren(page); + page.LoadPage(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + + }, Language.StringByID(StringId.Jump)); + } + }); + } + else + { + //涓轰簡瀹夊叏锛岃璺宠浆鑷充釜浜轰腑蹇儃0}璁剧疆涓汉瀵嗙爜锛屽苟搴旂敤浜庨棬閿佸紑閿� + HdlMessageLogic.Current.ShowMassage(ShowMsgType.Confirm, Language.StringByID(StringId.JumpToPersonalCentetToSetPasswordMsg), () => + { + var page = new AppUnlockSettingsPage(); + MainPage.BasePageView.AddChidren(page); + page.LoadPage(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + + }, Language.StringByID(StringId.Jump)); + } + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 鍒锋柊褰撳墠璁惧鐨勭姸鎬佺紦瀛� + /// </summary> + private void RefreshNowDeviceStatuMemory(Function i_LocalDevice) + { + this.doorLockData.IsOnline = i_LocalDevice.online; + for (int i = 0; i < i_LocalDevice.attributes.Count; i++) + { + var data = i_LocalDevice.attributes[i]; + //闂ㄩ攣鐘舵�� + if (data.key == "status") + { + if (data.state == "open") { this.doorLockData.Open = true; } + else if (data.state == "normal_open") + { + //甯稿紑妯″紡 + this.doorLockData.Open = true; + this.doorLockData.NormalOpen = true; + } + else + { + this.doorLockData.Open = false; + this.doorLockData.NormalOpen = false; + } + } + //闊抽噺 + else if (data.key == "volume") + { + var value = data.state; + if (value != string.Empty) + { + this.doorLockData.Voice = Convert.ToInt32(value); + } + } + //鐢垫睜鐧惧垎姣� + else if (data.key == "battery_percentage") + { + var value = data.state; + if (value != string.Empty) + { + this.doorLockData.BatteryPersent = Convert.ToInt32(value); + } + } + } + } + + #endregion + + #region 鈻� 缁撴瀯浣揰____________________________ + + /// <summary> + /// 闂ㄩ攣鐨勬暟鎹� + /// </summary> + private class DoorLockData + { + /// <summary> + /// 鏄惁鎵撳紑 + /// </summary> + public bool Open = true; + /// <summary> + /// 鐢垫睜鐢甸噺 + /// </summary> + public int BatteryPersent = 0; + /// <summary> + /// 鏄惁鍦ㄧ嚎 + /// </summary> + public bool IsOnline = false; + /// <summary> + /// 鏄惁闈欓煶 + /// </summary> + public bool Mute = false; + /// <summary> + /// 闊抽噺 + /// </summary> + public int Voice = 0; + /// <summary> + /// 鏄惁澶勪簬甯稿紑妯″紡 + /// </summary> + public bool NormalOpen = false; + /// <summary> + /// 涓存椂瀵嗙爜 + /// </summary> + public string TempPassword = string.Empty; + /// <summary> + /// 涓存椂瀵嗙爜鏄惁琚彉鏇� + /// </summary> + public bool IsTempPasswordChanged = true; + /// <summary> + /// 涓存椂瀵嗙爜鐢熸晥鏃堕棿(2020.03.17 13:27) + /// </summary> + public string StatrtTime = string.Empty; + /// <summary> + /// 涓存椂瀵嗙爜澶辨晥鏃堕棿(2020.03.17 13:27) + /// </summary> + public string EndTime = string.Empty; + } + + #endregion + } +} -- Gitblit v1.8.0