From 6b6a3fd9c292a75196c4cc15c6d9bf52537efbd4 Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期二, 07 九月 2021 10:12:20 +0800 Subject: [PATCH] 1.窗帘问题。2.智能空开。3.组合调光部分。 --- HDL_ON/UI/UI2/FuntionControlView/Light/LightScene/AddLightScene.cs | 620 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 613 insertions(+), 7 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/LightScene/AddLightScene.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/LightScene/AddLightScene.cs index e5aba0b..3822475 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Light/LightScene/AddLightScene.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Light/LightScene/AddLightScene.cs @@ -27,18 +27,19 @@ static VerticalScrolViewLayout functionListView; #endregion - List<Function> functionList; - - public AddLightScene() + List<Function> sceneLishtList; + Scene lightScene; + public AddLightScene(List<Function> functions,Scene scene) { bodyView = this; - functionList = new List<Function>(); + sceneLishtList = functions; + lightScene = scene; } - public void LoadPage(int titleId) + public void LoadPage() { bodyView.BackgroundColor = CSS_Color.BackgroundColor; - new TopViewDiv(bodyView, Language.StringByID(titleId)).LoadTopView(); + new TopViewDiv(bodyView, Language.StringByID(StringId.CombinedDimming)).LoadTopView(); /// <summary> /// 鎴块棿鍐呭鏄剧ず鍖哄煙 @@ -81,10 +82,615 @@ }; bodyView.AddChidren(functionListView); - functionList.AddRange(FunctionList.List.GetLightList()); + var lightList = FunctionList.List.GetLightList(); + + foreach (var function in lightList) + { + var functionDiv = new LightRow(function) + { + Gravity = Gravity.CenterHorizontal, + Width = Application.GetRealWidth(343), + Height = Application.GetRealHeight(62), + Radius = (uint)Application.GetMinRealAverage(12), + BorderColor = 0x00FFFFFF, + BorderWidth = 1, + BackgroundColor = CSS_Color.MainBackgroundColor, + Tag = function.spk + function.sid + }; + functionDiv.LoadDiv(sceneLishtList); + functionListView.AddChidren(functionDiv); + + functionListView.AddChidren(new Button() { Height = Application.GetRealHeight(12) }); + } + #region 搴曢儴view + var bottomView = new FrameLayout() + { + Y = Application.GetRealHeight(591), + Height = Application.GetRealHeight(100), + BackgroundColor = CSS_Color.MainBackgroundColor, + Radius = (uint)Application.GetRealWidth(12), + }; + this.AddChidren(bottomView); + + var btnConfrim = new Button() + { + Y = Application.GetRealHeight(12), + Gravity = Gravity.CenterHorizontal, + Width = Application.GetRealWidth(220), + Height = Application.GetRealHeight(44), + Radius = (uint)Application.GetRealHeight(22), + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.MainBackgroundColor, + BackgroundColor = CSS_Color.MainColor, + TextID = StringId.Confirm, + }; + bottomView.AddChidren(btnConfrim); + btnConfrim.MouseUpEventHandler = (sender, e) => { + var lightSceneDialog = new LightSceneEditDialog(sceneLishtList,lightScene); + lightSceneDialog.ShowDialog(); + }; + + #endregion } } + + + public class LightRow : FrameLayout + { + #region 鍖哄煙鎺т欢 + static FrameLayout bodyDiv; + /// <summary> + /// 鍔熻兘/鍦烘櫙icon + /// </summary> + Button btnIcon; + /// <summary> + /// 鍔熻兘鍚嶇О/鍦烘櫙鍚嶇О + /// </summary> + Button btnName; + /// <summary> + /// 妤煎眰淇℃伅鏄剧ず鎸夐挳 + /// </summary> + Button btnFromFloor; + /// <summary> + /// 閫変腑鎸夐挳 + /// </summary> + Button btnSelect; + #endregion + + #region 鍖哄煙鍙橀噺 + Function function; + #endregion + public LightRow(Function func) + { + bodyDiv = this; + bodyDiv.Tag = func.sid; + function = func; + } + + + /// <summary> + /// 鍔犺浇鎺у埗鍗$墖鍖哄煙 + /// </summary> + public void LoadDiv(List<Function> functions) + { + btnIcon = new Button() + { + X = Application.GetRealWidth(10), + Y = Application.GetRealHeight(15), + Width = Application.GetRealWidth(32), + Height = Application.GetRealWidth(32), + UnSelectedImagePath = $"FunctionIcon/Icon/{function.IconName}.png" + }; + bodyDiv.AddChidren(btnIcon); + + btnName = new Button() + { + X = Application.GetRealWidth(8 + 10 + 32), + Y = Application.GetRealHeight(10), + Width = Application.GetRealWidth(200), + Height = Application.GetRealHeight(24), + Text = function.name, + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.TextFontSize, + }; + bodyDiv.AddChidren(btnName); + + btnFromFloor = new Button() + { + X = Application.GetRealWidth(8 + 10 + 32), + Y = Application.GetRealHeight(10 + 24), + Width = Application.GetRealWidth(200), + Height = Application.GetRealHeight(18), + Text = function.GetRoomListName(), + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.PromptingColor1, + TextSize = CSS_FontSize.PromptFontSize_FirstLevel, + }; + bodyDiv.AddChidren(btnFromFloor); + + btnSelect = new Button() + { + X = Application.GetRealWidth(303), + Gravity = Gravity.CenterVertical, + Width = Application.GetRealWidth(32), + Height = Application.GetRealWidth(32), + UnSelectedImagePath = "FunctionIcon/Light/LightScene/CheckIcon.png", + SelectedImagePath = "FunctionIcon/Light/LightScene/CheckOnIcon.png", + IsSelected = functions.Find((obj) => obj.deviceId == function.deviceId) != null + }; + bodyDiv.AddChidren(btnSelect); + + btnSelect.MouseUpEventHandler = (sender, e) => { + btnSelect.IsSelected = !btnSelect.IsSelected; + if(btnSelect.IsSelected) + { + var addTemp = functions.Find((obj) => obj.deviceId == function.deviceId); + if (addTemp == null) + { + functions.Add(function); + } + } + else + { + var removeTemp = functions.Find((obj) => obj.deviceId == function.deviceId); + if (removeTemp != null) + { + functions.Remove(removeTemp); + } + } + }; + + } + + + } + + /// <summary> + /// 鐏厜鍦烘櫙缂栬緫寮圭獥 + /// </summary> + public class LightSceneEditDialog :Dialog + { + List<Function> lights; + + Scene editScene; + + public LightSceneEditDialog(List<Function> functions,Scene scene) + { + lights = functions; + editScene = scene; + } + + + public void ShowDialog() + { + var hadDimming = lights.Find((obj) => obj.spk == SPK.LightDimming) != null; + var hadCCT = lights.Find((obj) => obj.spk == SPK.LightCCT) != null; + var hadRGB = lights.Find((obj) => obj.spk == SPK.LightRGB) != null; + + var bodyView = new FrameLayout(); + this.AddChidren(bodyView); + bodyView.MouseUpEventHandler = (sender, e) => { + this.Close(); + }; + + var contentView = new FrameLayout() { + BackgroundColor = CSS_Color.MainBackgroundColor, + Width = Application.GetRealWidth(343), + Radius = (uint)Application.GetRealWidth(12), + }; + bodyView.AddChidren(contentView); + + #region 鏍囬鍖� + bool inEdit = false;//鏄惁鍦ㄧ紪杈戞爣棰� + var titleView = new FrameLayout() + { + Width = Application.GetRealWidth(343), + Height = Application.GetRealHeight(52), + }; + contentView.AddChidren(titleView); + + var btnTitle = new Button() + { + Height = Application.GetRealHeight(52), + Gravity = Gravity.Center, + TextSize = CSS_FontSize.SubheadingFontSize, + TextColor = CSS_Color.MainColor, + TextID = StringId.CombinedDimming, + TextAlignment = TextAlignment.Center, + }; + if (btnTitle.GetTextWidth() > Application.GetRealWidth(197))//247 + { + btnTitle.Width = Application.GetRealWidth(197); + btnTitle.IsMoreLines = true; + } + else + { + btnTitle.Width = btnTitle.GetTextWidth()+ Application.GetRealWidth(10); + btnTitle.IsMoreLines = false; + } + titleView.AddChidren(btnTitle); + + var btnEditIcon = new Button() + { + Width = Application.GetRealWidth(24), + Height = Application.GetRealWidth(24), + X = Application.GetRealWidth(12) + btnTitle.Right, + Gravity = Gravity.CenterVertical, + UnSelectedImagePath = "Public/Edit.png", + SelectedImagePath = "Public/HookIcon.png" + }; + titleView.AddChidren(btnEditIcon); + + EventHandler<MouseEventArgs> dd = (sender, e) => + { + inEdit = !inEdit; + btnEditIcon.IsSelected = inEdit; + + if (inEdit) + { + btnTitle.Width = btnTitle.GetTextWidth(); + } + else + { + if (btnTitle.GetTextWidth() > Application.GetRealWidth(197))//247 + { + btnTitle.Width = Application.GetRealWidth(197); + } + else + { + btnTitle.Width = btnTitle.GetTextWidth(); + } + editScene.name = btnTitle.Text.Trim(); + } + }; + btnTitle.MouseUpEventHandler = dd; + btnEditIcon.MouseUpEventHandler = dd; + + titleView.AddChidren(new Button() { Height = 1, BackgroundColor = CSS_Color.DividingLineColor, Y = Application.GetRealHeight(51) }); + + #endregion + + + var dimmingLight = editScene.functions.Find((obj) => obj.localFunction.spk == SPK.LightDimming); + var cctLight = editScene.functions.Find((obj) => obj.localFunction.spk == SPK.LightCCT); + var rgbLight = editScene.functions.Find((obj) => obj.localFunction.spk == SPK.LightRGB); + var brightnessValue = 0; + var cctValue = 27; + if (cctLight != null) + { + int.TryParse(cctLight.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness).value, out brightnessValue); + int.TryParse(cctLight.status.Find((obj) => obj.key == FunctionAttributeKey.CCT).value, out cctValue); + } + + + //灞炴�ц缃尯鍩� + var attrView = new VerticalScrolViewLayout() + { + Y = Application.GetRealHeight(52), + Width = Application.GetRealWidth(343), + }; + //灞炴�ц缃尯鍩熼珮搴� + int attrViewHight = Application.GetRealHeight(27 + 22); + attrView.AddChidren(new Button() { Height = Application.GetRealHeight(27) }); + + if (hadDimming) + { + attrViewHight += Application.GetRealHeight(54 + 11); + var dimmingView = new FrameLayout(); + attrView.AddChidren(dimmingView); + + + #region 浜害璋冭妭 + var btnBrightnessText = new Button() + { + X = Application.GetRealWidth(35), + Y = Application.GetRealHeight(1), + Width = Application.GetRealWidth(224), + Height = Application.GetRealHeight(21), + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.PromptFontSize_FirstLevel, + TextID = StringId.Brightness, + BackgroundColor = 0xFFFF0000 + }; + dimmingView.AddChidren(btnBrightnessText); + + var btnMinValuesText = new Button() + { + X = Application.GetRealWidth(35), + Y = btnBrightnessText.Bottom, + Width = Application.GetRealWidth(30), + Height = Application.GetRealHeight(21), + Text = "0%", + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.PromptingColor1, + TextSize = CSS_FontSize.PromptFontSize_FirstLevel, + }; + dimmingView.AddChidren(btnMinValuesText); + + var dimmerBar = new DiyImageSeekBar() + { + X = Application.GetRealWidth(35 + 22), + Y = Application.GetRealHeight(11), + Width = Application.GetRealWidth(210), + Height = Application.GetRealHeight(54), + SeekBarViewHeight = Application.GetRealHeight(8), + ThumbImagePath = "Public/ThumbImage.png", + ThumbImageHeight = Application.GetRealHeight(54), + ProgressTextColor = CSS_Color.FirstLevelTitleColor, + ProgressTextSize = CSS_FontSize.PromptFontSize_FirstLevel, + ProgressBarColor = CSS_Color.AuxiliaryColor1, + MaxValue = 100, + Progress = brightnessValue, + SeekBarPadding = Application.GetRealWidth(20), + }; + //dimmingView.AddChidren(dimmerBar); + + var btnMaxValuesText = new Button() + { + X = dimmerBar.Right, + Y = btnBrightnessText.Bottom, + Width = Application.GetRealWidth(45), + Height = Application.GetRealHeight(21), + Text = "100%", + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.PromptingColor1, + TextSize = CSS_FontSize.PromptFontSize_FirstLevel, + }; + dimmingView.AddChidren(btnMaxValuesText); + #endregion + + + } + + attrView.Height = attrViewHight; + contentView.AddChidren(attrView); + contentView.Height = Application.GetRealHeight(52 + 44) + attrViewHight; + contentView.Gravity = Gravity.Center; + + + + + #region bottom View + var bottomView = new FrameLayout() + { + Y = Application.GetRealHeight(52) + attrViewHight, + Height = Application.GetRealHeight(44), + }; + contentView.AddChidren(bottomView); + + var btnSave = new Button() + { + Width = Application.GetRealWidth(172), + Height = Application.GetRealHeight(44), + TextAlignment = TextAlignment.Center, + TextSize = CSS_FontSize.SubheadingFontSize, + TextColor = CSS_Color.TextualColor, + TextID = StringId.Save, + }; + bottomView.AddChidren(btnSave); + + var btnComplete = new Button() + { + X = Application.GetRealWidth(172), + Width = Application.GetRealWidth(172), + Height = Application.GetRealHeight(44), + BackgroundColor = CSS_Color.MainColor, + TextColor = CSS_Color.MainBackgroundColor, + TextAlignment = TextAlignment.Center, + TextSize = CSS_FontSize.SubheadingFontSize, + TextID = StringId.Complete + }; + bottomView.AddChidren(btnComplete); + + bottomView.AddChidren(new Button() { Height = 1, BackgroundColor = CSS_Color.DividingLineColor }); + + + btnSave.MouseUpEventHandler = (sender, e) => { + this.Close(); + + + }; + + btnComplete.MouseUpEventHandler = (sender, e) => { + this.Close(); + + }; + + + #endregion + + + this.Show(); + return; + //鍙湁璋冨厜鍣� + if (!hadDimming&&!hadCCT&&!hadRGB) + { + contentView.Height = Application.GetRealHeight(520); + contentView.Width = Application.GetRealWidth(343); + contentView.Gravity = Gravity.Center; + contentView.Radius = (uint)Application.GetRealWidth(12); + contentView.AddChidren(titleView); + } + else if (hadCCT && hadRGB)// + { + contentView.Height = Application.GetRealHeight(520); + contentView.Width = Application.GetRealWidth(343); + contentView.Gravity = Gravity.Center; + contentView.Radius = (uint)Application.GetRealWidth(12); + contentView.AddChidren(titleView); + #region 浜害璋冭妭 + var btnBrightnessText = new Button() + { + X = Application.GetRealWidth(35), + Y = Application.GetRealHeight(82), + Width = Application.GetRealWidth(224), + Height = Application.GetRealHeight(21), + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.PromptFontSize_FirstLevel, + TextID = StringId.Brightness, + }; + contentView.AddChidren(btnBrightnessText); + + var btnMinValuesText = new Button() + { + X = Application.GetRealWidth(35), + Y = btnBrightnessText.Bottom, + Width = Application.GetRealWidth(30), + Height = Application.GetRealHeight(21), + Text = "0%", + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.PromptingColor1, + TextSize = CSS_FontSize.PromptFontSize_FirstLevel, + }; + contentView.AddChidren(btnMinValuesText); + + var dimmerBar = new DiyImageSeekBar() + { + X = Application.GetRealWidth(35 + 22), + Y = Application.GetRealHeight(312), + Width = Application.GetRealWidth(210), + Height = Application.GetRealHeight(54), + SeekBarViewHeight = Application.GetRealHeight(8), + ThumbImagePath = "Public/ThumbImage.png", + ThumbImageHeight = Application.GetRealHeight(54), + ProgressTextColor = CSS_Color.FirstLevelTitleColor, + ProgressTextSize = CSS_FontSize.PromptFontSize_FirstLevel, + ProgressBarColor = CSS_Color.AuxiliaryColor1 , + MaxValue = 100, + Progress = brightnessValue, + SeekBarPadding = Application.GetRealWidth(20), + }; + contentView.AddChidren(dimmerBar); + + var btnMaxValuesText = new Button() + { + X = dimmerBar.Right, + Y = btnBrightnessText.Bottom, + Width = Application.GetRealWidth(45), + Height = Application.GetRealHeight(21), + Text = "100%", + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.PromptingColor1, + TextSize = CSS_FontSize.PromptFontSize_FirstLevel, + }; + contentView.AddChidren(btnMaxValuesText); + #endregion + + + + #region 鑹叉俯 + //鑹叉俯 + var btnTempClolor = new Button(); + btnTempClolor.X = Application.GetRealWidth(35); + btnTempClolor.Y = Application.GetRealHeight(159); + btnTempClolor.Width = Application.GetRealWidth(224); + btnTempClolor.Height = Application.GetRealHeight(21); + btnTempClolor.TextAlignment = TextAlignment.CenterLeft; + btnTempClolor.TextColor = CSS_Color.FirstLevelTitleColor; + btnTempClolor.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; + btnTempClolor.TextID = StringId.ColorTemperature; + contentView.AddChidren(btnTempClolor); + + //2700K + var btnTempClolorMin = new Button(); + btnTempClolorMin.Y = btnTempClolor.Bottom + Application.GetRealHeight(9); + btnTempClolorMin.Width = Application.GetRealWidth(54); + btnTempClolorMin.Height = Application.GetRealHeight(21); + btnTempClolorMin.Text = "2700K"; + btnTempClolorMin.TextAlignment = TextAlignment.CenterRight; + btnTempClolorMin.TextColor = CSS_Color.PromptingColor1; + btnTempClolorMin.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; + contentView.AddChidren(btnTempClolorMin); + + //婊戝姩鏉$殑鑳屾櫙鍥剧墖 + var btnColorTemplatrueBack = new Button(); + //闇�瑕佸噺鎺夋粦鍔ㄦ潯鐨勫乏鍙抽棿璺� + btnColorTemplatrueBack.Width = Application.GetRealWidth(210 - 20 * 2); + btnColorTemplatrueBack.Height = Application.GetRealHeight(8); + btnColorTemplatrueBack.Gravity = Gravity.CenterHorizontal; + btnColorTemplatrueBack.UnSelectedImagePath = "FunctionIcon/Light/ColorTemperatureBar.png"; + contentView.AddChidren(btnColorTemplatrueBack); + //婊戝姩鏉℃帶浠� + var barColorTemplatrue = new CCTSeekBarControl(); + barColorTemplatrue.X = btnTempClolorMin.Right; + barColorTemplatrue.Y = Application.GetRealHeight(340); + barColorTemplatrue.MinValue = 27; + barColorTemplatrue.MaxValue = 65; + barColorTemplatrue.ProgressBarColor = 0x00000000;//鍏ㄩ儴閫忔槑 + barColorTemplatrue.ProgressBarUnEnableColor = 0x00000000; + barColorTemplatrue.SeekBarBackgroundColor = 0x00000000; + contentView.AddChidren(barColorTemplatrue); + barColorTemplatrue.Y = btnTempClolorMin.Y - (barColorTemplatrue.Height - btnTempClolorMin.Height) / 2; + //鏄剧ず涓婃柟鐨凾xt + barColorTemplatrue.ShowCustomTextView(Application.GetRealWidth(50), CSS_FontSize.PromptFontSize_FirstLevel, CSS_Color.FirstLevelTitleColor); + var cct = 27; + int.TryParse(cctLight.status.Find((obj)=>obj.key == FunctionAttributeKey.CCT).value, out cct); + barColorTemplatrue.Progress = cct; + //璁剧疆鍒濆鍊� + barColorTemplatrue.SetCustomText(barColorTemplatrue.Progress * 100 + "K"); + + //鍙樻洿鑳屾櫙鍥剧殑Y杞村潗鏍� + btnColorTemplatrueBack.Y = barColorTemplatrue.Y + (barColorTemplatrue.Height - btnColorTemplatrueBack.Height) / 2; + + //6500K + var btnTempClolorMax = new Button(); + btnTempClolorMax.Y = btnTempClolorMin.Y; + btnTempClolorMax.X = barColorTemplatrue.Right; + btnTempClolorMax.Width = Application.GetRealWidth(54); + btnTempClolorMax.Height = Application.GetRealHeight(21); + btnTempClolorMax.Text = "6500K"; + btnTempClolorMax.TextAlignment = TextAlignment.CenterLeft; + btnTempClolorMax.TextColor = CSS_Color.PromptingColor1; + btnTempClolorMax.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; + contentView.AddChidren(btnTempClolorMax); + + #endregion + + #region RGB + + var btnCurColor = new Button() + { + X = Application.GetRealWidth(24), + Y = Application.GetRealHeight(241), + Width = Application.GetMinRealAverage(24), + Height = Application.GetMinRealAverage(24), + Radius = (uint)Application.GetMinRealAverage(8), + BorderColor = CSS_Color.PromptingColor2, + BorderWidth = 1, + BackgroundColor = (uint)(0xFF000000 + new Light().GetRGBcolor(new Function(),rgbLight.status.Find((obj) => obj.key == FunctionAttributeKey.RGB).value)) + }; + contentView.AddChidren(btnCurColor); + + //鑹茬洏鐨勬甯冩帶浠�(闄愬埗閭d釜鐧借壊婊戝姩鐞冧娇鐢�) + var framePickerBack = new FrameLayout(); + framePickerBack.Gravity = Gravity.CenterHorizontal; + framePickerBack.Y = Application.GetRealHeight(249); + framePickerBack.Width = Application.GetMinRealAverage(198); + framePickerBack.Height = Application.GetMinRealAverage(198); + contentView.AddChidren(framePickerBack); + + var colorPicker = new ColorPicker() + { + ColorImagePath = "FunctionIcon/Light/ColorWheel.png", + }; + framePickerBack.AddChidren(colorPicker); + #endregion + } + else if (hadDimming && !hadCCT && !hadRGB) + { + contentView.Height = Application.GetRealHeight(211); + contentView.Width = Application.GetRealWidth(343); + contentView.Gravity = Gravity.Center; + contentView.Radius = (uint)Application.GetRealWidth(12); + contentView.AddChidren(titleView); + } + } + } + } \ No newline at end of file -- Gitblit v1.8.0