From 79133766997cb86b2e463671b50137588ded6588 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期一, 08 三月 2021 10:07:55 +0800 Subject: [PATCH] Merge branch 'temp-wxr' into WJC --- HDL_ON/UI/UI2/FuntionControlView/AC/AcControlPage.cs | 625 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 625 insertions(+), 0 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/AC/AcControlPage.cs b/HDL_ON/UI/UI2/FuntionControlView/AC/AcControlPage.cs new file mode 100644 index 0000000..629a706 --- /dev/null +++ b/HDL_ON/UI/UI2/FuntionControlView/AC/AcControlPage.cs @@ -0,0 +1,625 @@ +锘縰sing System; +using HDL_ON.DriverLayer; +using HDL_ON.Entity; +using HDL_ON.Stan; +using HDL_ON.UI.CSS; +using Shared; + +namespace HDL_ON.UI +{ + public class AcControlPage : DeviceFunctionCardCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + /// <summary> + /// 绌鸿皟娓╁害鎺у埗鎺т欢 + /// </summary> + DiyArcSeekBar arcBar; + /// <summary> + /// 鍑忓彿鎸夐挳 + /// </summary> + Button btnMinus; + /// <summary> + /// 鍔犲彿鎸夐挳 + /// </summary> + Button btnPlus; + /// <summary> + /// 娓╁害鎸夐挳 + /// </summary> + Button btnTemp; + Button btnTempUint; + /// <summary> + /// 瀹ゅ唴娓╁害鎸夐挳 + /// </summary> + Button btnIndoorTemp; + /// <summary> + /// 妯″紡鎸夐挳 + /// </summary> + Button btnMode; + /// <summary> + /// 椋庨�熸寜閽� + /// </summary> + Button btnWindSpeed; + /// <summary> + /// 寮�鍏虫寜閽� + /// </summary> + Button btnSwitch; + + AC acFunction = new AC(); + + + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鍒濆鍖栫櫧鑹插尯鍩熺殑鍐呭 + /// </summary> + public override void InitFrameWhiteContent() + { + + base.ShowColltionButton = false; + base.SetTitleText(Language.StringByID(StringId.Electric)); + + //鍒濆鍖栫涓�涓储寮曢〉鐨勫唴瀹� + this.InitFrameWhiteContent1(); + + //鍒锋柊褰撳墠璁惧鐨勭姸鎬佺紦瀛� + this.RefreshNowDeviceStatuMemory(this.device); + //鍒锋柊鐣岄潰鐘舵�� + this.RefreshFormStatu(); + //璇诲彇鐘舵�� + new System.Threading.Thread(() => + { + Control.Ins.SendReadCommand(device); + }) + { IsBackground = true }.Start(); + } + + /// <summary> + /// 鍒濆鍖栫涓�涓储寮曢〉鐨勫唴瀹� + /// </summary> + private void InitFrameWhiteContent1() + { + + arcBar = new DiyArcSeekBar() + { + Gravity = Gravity.CenterHorizontal, + OpenAngle = 160, + ThumbImageHeight = Application.GetRealWidth(50), + ProgressBarColor = CSS_Color.MainColor, + OfflineProgressBarColor = CSS_Color.PromptingColor2, + ArcColor = CSS_Color.BackgroundColor, +#if __IOS__ + Y = Application.GetRealHeight(120 + 25), + Width = Application.GetRealWidth(260 - 40), + Height = Application.GetRealWidth(260 - 40), + SeekBarPadding = Application.GetRealWidth(8), +#else + Y = Application.GetRealHeight(120 + 40), + Width = Application.GetRealWidth(260 - 40), + Height = Application.GetRealWidth(260 - 40), + SeekBarPadding = Application.GetRealWidth(7), +#endif + + }; + FrameWhiteCentet1.AddChidren(arcBar); + + + arcBar.ThumbImagePath = device.GetAttrState(FunctionAttributeKey.OnOff) == "on" ? "FunctionIcon/AC/DiyThumbIconOn.png" : "FunctionIcon/AC/DiyThumbIcon.png"; + arcBar.IsOffline = device.GetAttrState(FunctionAttributeKey.OnOff) == "off"; + arcBar.MinValue = device.GetAttribute(FunctionAttributeKey.SetTemp).min; + arcBar.MaxValue = device.GetAttribute(FunctionAttributeKey.SetTemp).max; + arcBar.Progress = Convert.ToInt32(device.GetAttrState(FunctionAttributeKey.SetTemp)); + + btnTemp = new Button() + { + Gravity = Gravity.CenterHorizontal, + Y = Application.GetRealHeight(206), + Width = Application.GetRealWidth(71), + Height = Application.GetRealWidth(60), + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = 50, + IsBold = true, + Text = device.GetAttrState(FunctionAttributeKey.SetTemp), + TextAlignment = TextAlignment.Center, + }; + FrameWhiteCentet1.AddChidren(btnTemp); + + btnTempUint = new Button() + { + X = btnTemp.Right, + Y = btnTemp.Y, + Width = Application.GetRealWidth(30), + Height = Application.GetRealHeight(30), + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.EmphasisFontSize_Secondary, + IsBold = true, + TextAlignment = TextAlignment.CenterLeft, + Text = "掳C", + }; + FrameWhiteCentet1.AddChidren(btnTempUint); + + btnIndoorTemp = new Button() + { + Gravity = Gravity.CenterHorizontal, + Y = btnTemp.Bottom, + Width = Application.GetRealWidth(120), + Height = Application.GetRealHeight(20), + Text = Language.StringByID(StringId.IndoorTemp) + "20掳C", + TextColor = CSS_Color.PromptingColor1, + TextSize = CSS_FontSize.PromptFontSize_FirstLevel, + }; + FrameWhiteCentet1.AddChidren(btnIndoorTemp); + + btnMinus = new Button() + { + X = Application.GetRealWidth(21), + Y = Application.GetRealHeight(263), + Width = Application.GetRealWidth(32), + Height = Application.GetRealWidth(32), + UnSelectedImagePath = "Public/MinusSignIcon.png", + }; + FrameWhiteCentet1.AddChidren(btnMinus); + + btnPlus = new Button() + { + X = Application.GetRealWidth(275), + Y = Application.GetRealHeight(263), + Width = Application.GetRealWidth(32), + Height = Application.GetRealWidth(32), + UnSelectedImagePath = "Public/PlusSignIcon.png", + }; + FrameWhiteCentet1.AddChidren(btnPlus); + + btnMode = new Button() + { + X = Application.GetRealWidth(60), + Y = Application.GetRealHeight(334), + Width = Application.GetRealWidth(30), + Height = Application.GetRealWidth(30), + UnSelectedImagePath = acFunction.GetModeIconPath(device.GetAttrState(FunctionAttributeKey.Mode)), + }; + FrameWhiteCentet1.AddChidren(btnMode); + + btnWindSpeed = new Button() + { + X = Application.GetRealWidth(235), + Y = Application.GetRealHeight(337), + Width = Application.GetRealWidth(30), + Height = Application.GetRealWidth(30), + UnSelectedImagePath = acFunction.GetFanIconPath(device.GetAttrState(FunctionAttributeKey.FanSpeed)), + }; + FrameWhiteCentet1.AddChidren(btnWindSpeed); + + btnSwitch = new Button() + { + Gravity = Gravity.CenterHorizontal, + Y = Application.GetRealHeight(466), + Width = Application.GetRealWidth(32), + Height = Application.GetRealWidth(32), + UnSelectedImagePath = "Public/PowerClose.png", + SelectedImagePath = "Public/PowerOpen.png", + IsSelected = device.GetAttrState(FunctionAttributeKey.OnOff) == "on" + }; + FrameWhiteCentet1.AddChidren(btnSwitch); + + LoadEvent_TempChange(); + LoadEvent_AcStatesChange(); + } + + /// <summary> + /// 鍔犺浇淇敼妯″紡鍖哄煙 + /// </summary> + void LoadDiv_ChangeModeView() + { + Dialog dialog = new Dialog(); + + FrameLayout dialogView = new FrameLayout() + { + BackgroundColor = CSS_Color.DialogTransparentColor1, + }; + dialog.AddChidren(dialogView); + + FrameLayout modeChangeView; + modeChangeView = new FrameLayout() + { + X = Application.GetRealWidth(30), + Y = Application.GetRealHeight(128), + Width = Application.GetRealWidth(160), + Height = Application.GetRealHeight(287), + BackgroundImagePath = "FunctionIcon/AC/DivBg1.png", + }; + dialogView.AddChidren(modeChangeView); + + Button btnTitle; + btnTitle = new Button() + { + X = Application.GetRealWidth(8 + 16), + Y = Application.GetRealHeight(8), + Width = Application.GetRealWidth(112), + Height = Application.GetRealHeight(44), + TextID = StringId.ChooseMode, + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.EmphasisFontSize_Secondary, + }; + modeChangeView.AddChidren(btnTitle); + + Button btnLine = new Button() + { + X = btnTitle.X, + Y = btnTitle.Bottom, + Width = Application.GetRealWidth(112), + Height = Application.GetRealHeight(1), + BackgroundColor = CSS_Color.BackgroundColor, + }; + modeChangeView.AddChidren(btnLine); + + var modeList = device.GetAttribute(FunctionAttributeKey.Mode).value; + foreach (var m in modeList) + { + Button btnModeIcon = new Button() + { + X = btnTitle.X, + Y = Application.GetRealHeight(44 * (modeList.IndexOf(m) + 1) + 10 + 8), + Width = Application.GetRealWidth(24), + Height = Application.GetRealWidth(24), + IsSelected = device.GetAttrState(FunctionAttributeKey.Mode) == m, + }; + modeChangeView.AddChidren(btnModeIcon); + + Button btnModeText = new Button() + { + X = Application.GetRealWidth(12) + btnModeIcon.Right, + Y = Application.GetRealHeight(44 * (modeList.IndexOf(m) + 1) + 8), + Height = Application.GetRealHeight(44), + Width = Application.GetRealWidth(90), + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.FirstLevelTitleColor, + SelectedTextColor = CSS_Color.MainColor, + IsSelected = device.GetAttrState(FunctionAttributeKey.Mode) == m, + TextSize = CSS_FontSize.TextFontSize, + }; + modeChangeView.AddChidren(btnModeText); + + btnModeIcon.UnSelectedImagePath = acFunction.GetModeIconPath(m, false); + btnModeIcon.SelectedImagePath = acFunction.GetModeIconPath(m); + btnModeText.Text = acFunction.GetModeAttrText( m); + + if (modeList.IndexOf(m) < modeList.Count - 1) + { + modeChangeView.AddChidren(new Button() + { + X = btnTitle.X, + Y = btnModeText.Bottom, + Width = Application.GetRealWidth(112), + Height = Application.GetRealHeight(1), + BackgroundColor = CSS_Color.BackgroundColor, + }); + } + EventHandler<MouseEventArgs> eventHandler = (sender, e) => + { + dialog.Close(); + }; + EventHandler<MouseEventArgs> eventHandler1 = (sender, e) => + { + btnModeIcon.IsSelected = btnModeText.IsSelected = true; + device.SetAttrState(FunctionAttributeKey.Mode, m); + btnMode.UnSelectedImagePath = acFunction.GetModeIconPath(m); + System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); + btnMode.UnSelectedImagePath = btnModeIcon.UnSelectedImagePath; + d.Add(FunctionAttributeKey.Mode, m); + Control.Ins.SendWriteCommand(device, d); + dialog.Close(); + if (device.GetAttrState(FunctionAttributeKey.Mode) == "fan") + { + arcBar.IsClickable = false; + } + else + { + arcBar.IsClickable = true; + } + }; + btnModeIcon.MouseUpEventHandler = eventHandler1; + btnModeText.MouseUpEventHandler = eventHandler1; + dialogView.MouseUpEventHandler = eventHandler; + + } + + dialogView.MouseUpEventHandler = (sender, e) => { + dialog.Close(); + }; + dialog.Show(); + } + /// <summary> + /// 鍔犺浇淇敼妯″紡鍖哄煙 + /// </summary> + void LoadDiv_ChangeFanView() + { + Dialog dialog = new Dialog(); + + FrameLayout dialogView = new FrameLayout() + { + BackgroundColor = CSS_Color.DialogTransparentColor1, + }; + dialog.AddChidren(dialogView); + + FrameLayout modeChangeView; + modeChangeView = new FrameLayout() + { + X = Application.GetRealWidth(185), + Y = Application.GetRealHeight(172), + Width = Application.GetRealWidth(160), + Height = Application.GetRealHeight(243), + BackgroundImagePath = "FunctionIcon/AC/DivBg2.png", + }; + dialogView.AddChidren(modeChangeView); + + Button btnTitle; + btnTitle = new Button() + { + X = Application.GetRealWidth(8 + 16), + Y = Application.GetRealHeight(8), + Width = Application.GetRealWidth(112), + Height = Application.GetRealHeight(44), + TextID = StringId.ChooseFan, + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.EmphasisFontSize_Secondary, + }; + modeChangeView.AddChidren(btnTitle); + + Button btnLine = new Button() + { + X = btnTitle.X, + Y = btnTitle.Bottom, + Width = Application.GetRealWidth(112), + Height = Application.GetRealHeight(1), + BackgroundColor = CSS_Color.BackgroundColor, + }; + modeChangeView.AddChidren(btnLine); + + var modeList = device.GetAttribute(FunctionAttributeKey.FanSpeed).value; + foreach (var m in modeList) + { + Button btnFanIcon = new Button() + { + X = btnTitle.X, + Y = Application.GetRealHeight(44 * (modeList.IndexOf(m) + 1) + 10 + 8), + Width = Application.GetRealWidth(24), + Height = Application.GetRealWidth(24), + IsSelected = device.GetAttrState(FunctionAttributeKey.FanSpeed) == m, + }; + modeChangeView.AddChidren(btnFanIcon); + + Button btnFanText = new Button() + { + X = Application.GetRealWidth(12) + btnFanIcon.Right, + Y = Application.GetRealHeight(44 * (modeList.IndexOf(m) + 1) + 8), + Height = Application.GetRealHeight(44), + Width = Application.GetRealWidth(70), + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.FirstLevelTitleColor, + SelectedTextColor = CSS_Color.MainColor, + IsSelected = device.GetAttrState(FunctionAttributeKey.FanSpeed) == m, + TextSize = CSS_FontSize.TextFontSize, + }; + modeChangeView.AddChidren(btnFanText); + btnFanIcon.UnSelectedImagePath = acFunction.GetModeIconPath(m,false); + btnFanIcon.SelectedImagePath = acFunction.GetModeIconPath(m); + btnFanText.Text = acFunction.GetModeAttrText(m); + + if (modeList.IndexOf(m) < modeList.Count - 1) + { + modeChangeView.AddChidren(new Button() + { + X = btnTitle.X, + Y = btnFanText.Bottom, + Width = Application.GetRealWidth(112), + Height = Application.GetRealHeight(1), + BackgroundColor = CSS_Color.BackgroundColor, + }); + } + + EventHandler<MouseEventArgs> closeDialogEvent = (sender, e) => + { + dialog.Close(); + }; + EventHandler<MouseEventArgs> eventHandler1 = (sender, e) => + { + btnFanIcon.IsSelected = btnFanText.IsSelected = true; + device.SetAttrState(FunctionAttributeKey.FanSpeed, m); + btnWindSpeed.UnSelectedImagePath = acFunction.GetFanIconPath(m); + System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); + d.Add(FunctionAttributeKey.FanSpeed, m); + Control.Ins.SendWriteCommand(device, d); + btnWindSpeed.UnSelectedImagePath = btnFanIcon.UnSelectedImagePath; + dialog.Close(); + }; + btnFanIcon.MouseUpEventHandler = eventHandler1; + btnFanText.MouseUpEventHandler = eventHandler1; + dialogView.MouseUpEventHandler = closeDialogEvent; + } + + dialog.Show(); + } + + #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> + void LoadEvent_TempChange() + { + btnMinus.MouseUpEventHandler = (sender, e) => + { + if (device.trait_on_off.curValue.ToString() == "off" || device.GetAttrState(FunctionAttributeKey.Mode) == "fan") + { + return; + } + var temp = Convert.ToInt32(device.GetAttrState(FunctionAttributeKey.SetTemp)); + if (temp <= device.GetAttribute(FunctionAttributeKey.Mode).min) + { + return; + } + temp--; + arcBar.Progress = temp; + btnTemp.Text = temp.ToString(); + device.SetAttrState(FunctionAttributeKey.SetTemp, temp.ToString()); + System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); + d.Add(FunctionAttributeKey.SetTemp, temp.ToString()); + Control.Ins.SendWriteCommand(device, d); + }; + btnPlus.MouseUpEventHandler = (sender, e) => + { + if (device.trait_on_off.curValue.ToString() == "off" || device.GetAttrState(FunctionAttributeKey.Mode) == "fan") + { + return; + } + var temp = Convert.ToInt32(device.GetAttrState(FunctionAttributeKey.SetTemp)); + if (temp >= device.GetAttribute(FunctionAttributeKey.SetTemp).max) + { + return; + } + temp++; + arcBar.Progress = temp; + btnTemp.Text = temp.ToString(); + device.SetAttrState(FunctionAttributeKey.SetTemp, temp.ToString()); + System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); + d.Add(FunctionAttributeKey.SetTemp, temp.ToString()); + Control.Ins.SendWriteCommand(device, d); + }; + arcBar.OnStopTrackingTouchEvent = (sender, e) => + { + device.SetAttrState(FunctionAttributeKey.SetTemp, arcBar.Progress.ToString()); + btnTemp.Text = arcBar.Progress.ToString(); + System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); + d.Add(FunctionAttributeKey.SetTemp, arcBar.Progress.ToString()); + Control.Ins.SendWriteCommand(device, d); + }; + arcBar.OnProgressChangedEvent = (sender, e) => + { + device.SetAttrState(FunctionAttributeKey.SetTemp, e.ToString()); + btnTemp.Text = e.ToString(); + }; + } + /// <summary> + /// 鎺у埗妯″紡浜嬩欢 + /// </summary> + void LoadEvent_AcStatesChange() + { + btnMode.MouseUpEventHandler = (sender, e) => + { + if (device.trait_on_off.curValue.ToString() == "off") + { + return; + } + LoadDiv_ChangeModeView(); + }; + btnWindSpeed.MouseUpEventHandler = (sender, e) => + { + if (device.trait_on_off.curValue.ToString() == "off") + { + return; + } + LoadDiv_ChangeFanView(); + }; + + btnSwitch.MouseUpEventHandler = (sender, e) => + { + btnSwitch.IsSelected = !btnSwitch.IsSelected; + device.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off"; + if (device.trait_on_off.curValue.ToString() == "on") + { + arcBar.ThumbImagePath = "FunctionIcon/AC/DiyThumbIconOn.png"; + btnSwitch.IsSelected = true; + arcBar.IsOffline = false; + } + else + { + arcBar.ThumbImagePath = "FunctionIcon/AC/DiyThumbIcon.png"; + btnSwitch.IsBold = false; + arcBar.IsOffline = true; + } + System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); + d.Add(FunctionAttributeKey.OnOff, device.trait_on_off.curValue.ToString()); + Control.Ins.SendWriteCommand(device, d); + }; + } + + #endregion + + #region 鈻� 鍒锋柊鐣岄潰鐘舵�乢______________________ + + /// <summary> + /// 鍒锋柊鐣岄潰鐘舵�� + /// </summary> + private void RefreshFormStatu() + { + Application.RunOnMainThread(() => + { + btnTemp.Text = device.GetAttrState(FunctionAttributeKey.SetTemp); + btnIndoorTemp.Text = Language.StringByID(StringId.IndoorTemp) + Convert.ToInt32(Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.IndoorTemp))) + "掳C"; + btnMode.UnSelectedImagePath = acFunction.GetModeIconPath(device.GetAttrState(FunctionAttributeKey.Mode)); + btnWindSpeed.UnSelectedImagePath = acFunction.GetFanIconPath(device.GetAttrState(FunctionAttributeKey.FanSpeed)); + arcBar.Progress = Convert.ToInt32(Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.SetTemp))); + if (device.trait_on_off.curValue.ToString() == "on") + { + arcBar.IsOffline = false; + btnSwitch.IsSelected = true; + arcBar.ThumbImagePath = "FunctionIcon/AC/DiyThumbIconOn.png"; + if (device.GetAttrState(FunctionAttributeKey.Mode) == "fan") + { + arcBar.IsClickable = false; + } + else + { + arcBar.IsClickable = true; + } + } + else + { + arcBar.IsOffline = true; + btnSwitch.IsSelected = false; + arcBar.IsClickable = false; + arcBar.ThumbImagePath = "FunctionIcon/AC/DiyThumbIcon.png"; + } + }); + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 鍒锋柊褰撳墠璁惧鐨勭姸鎬佺紦瀛� + /// </summary> + private void RefreshNowDeviceStatuMemory(Function i_LocalDevice) + { + } + + #endregion + } +} \ No newline at end of file -- Gitblit v1.8.0