From c2348ebb81ca12b72eee6fbe9eee47925c1a5b07 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期三, 06 九月 2023 12:02:54 +0800
Subject: [PATCH] Merge branch 'wxr-2.1' into wxr-2.0
---
HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs | 310 +++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 246 insertions(+), 64 deletions(-)
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs b/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs
index e730aaa..62dc7d0 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs
@@ -3,6 +3,7 @@
using HDL_ON.UI.CSS;
using Shared;
using System.Collections.Generic;
+using System.Linq;
namespace HDL_ON.UI
{
@@ -25,12 +26,14 @@
SceneFunction rgbColorful;
bool isOnStatus = false;
- public SceneFunctionInfoEditPage(Scene s, SceneFunction fc,Action action)
+
+ public SceneFunctionInfoEditPage(Scene s, SceneFunction fc, Action action)
{
+
bodyView = this;
scene = s;
- sceneFunction = fc.localFunction.ConvertSceneFunction();
- foreach(var ll in sceneFunction.status)
+ sceneFunction = fc.localFunction.ConvertSceneFunction();
+ foreach (var ll in sceneFunction.status)
{
try
{
@@ -76,13 +79,13 @@
if (sceneFunction.localFunction.spk == SPK.LightRGB || sceneFunction.localFunction.spk == SPK.GroupControl)
{
- //var colorfulStatus = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Colorful);
- //if (colorfulStatus != null)
- //{
- // isColorful = true;
- // LoadColorfulRow(colorfulStatus);
- // isColorful = colorfulStatus.value == "on";
- //}
+ var colorfulStatus = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Colorful);
+ if (colorfulStatus != null)
+ {
+ isColorful = true;
+ LoadColorfulRow(colorfulStatus);
+ isColorful = colorfulStatus.value == "on";
+ }
}
foreach (var attr in sceneFunction.status)
{
@@ -118,6 +121,18 @@
case "security"://澶у崕鎽勫儚甯冮槻鎾ら槻
LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == "security"));
break;
+ case FunctionAttributeKey.SetVolume:
+ LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.SetVolume));
+ break;
+ case FunctionAttributeKey.Signal:
+ LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Signal));
+ break;
+ case FunctionAttributeKey.SongName:
+ LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.SongName));
+ break;
+ case FunctionAttributeKey.Volume:
+ LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Volume));
+ break;
}
}
@@ -146,14 +161,15 @@
BackgroundColor = CSS_Color.MainColor,
TextSize = CSS_FontSize.SubheadingFontSize,
IsBold = true,
- Radius = (uint) Application.GetRealWidth(22),
+ Radius = (uint)Application.GetRealWidth(22),
TextID = StringId.Complete
};
bottomView.AddChidren(btnConfrim);
btnConfrim.MouseUpEventHandler = (sender, e) =>
{
- if (sceneFunction.localFunction.spk == SPK.GroupControl) {
+ if (sceneFunction.localFunction.spk == SPK.GroupControl)
+ {
var colorBegin = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.ColorfulBegin);
if (colorBegin != null)
{
@@ -254,14 +270,14 @@
void UpdataFunctionRow()
{
contentView.RemoveAll();
- for (var i =0;i< functionRowList.Count; i++)
+ for (var i = 0; i < functionRowList.Count; i++)
{
try
{
var view = functionRowList[i];
- if(view!= null)
+ if (view != null)
{
- if(view.GetType() == typeof(FrameLayout))
+ if (view.GetType() == typeof(FrameLayout))
{
if (view.Tag != null)
{
@@ -276,7 +292,7 @@
{
if (isColorful && sceneFunction.localFunction.spk == SPK.LightRGB)
{
- if(view.Tag.ToString() != FunctionAttributeKey.Colorful)
+ if (view.Tag.ToString() != FunctionAttributeKey.Colorful)
{
view.RemoveFromParent();
}
@@ -301,7 +317,8 @@
}
}
}
- }catch(Exception ex)
+ }
+ catch (Exception ex)
{
MainPage.Log($"UpdataFuntionRow error:{ex.Message}");
}
@@ -490,8 +507,8 @@
break;
case "angle":
- //鍛堢幇鐨勫脊绐�
- LoadEditDialog_Angle(sceneStatus, btnFunctionText);
+ //鍛堢幇鐨勫脊绐�
+ LoadEditDialog_Angle(sceneStatus, btnFunctionText);
break;
case "cct":
@@ -510,11 +527,67 @@
case FunctionAttributeKey.Percent:
LoadEditDialog_Percent(sceneStatus, btnFunctionText);
break;
+ case FunctionAttributeKey.SetVolume:
+ BrightnessView(btnFunctionText.Text, btnFunctionName.Text, (volume, uintStr) =>
+ {
+ btnFunctionText.Text = volume;
+ sceneStatus.value = volume;
+ });
+ break;
+ case FunctionAttributeKey.Signal:
+ var p = new UI2.Intelligence.Automation.PublicInterface();
+ var dic = p.GetHisenseSignalSourceDic();
+ ListView(dic.Keys.ToList(), btnFunctionText.Text, btnFunctionName.Text, (valueStr) =>
+ {
+ btnFunctionText.Text = valueStr;
+ sceneStatus.value = p.GetValue(dic, valueStr);
+ });
+ break;
+ case FunctionAttributeKey.Volume:
+ BrightnessView(btnFunctionText.Text, btnFunctionName.Text, (volume, uintStr) =>
+ {
+ btnFunctionText.Text = volume;
+ sceneStatus.value = volume;
+ });
+ break;
+ case FunctionAttributeKey.SongName:
+ MusicListView(btnFunctionText.Text, (playListName, song) =>
+ {
+ btnFunctionText.Text = song.name;
+ sceneStatus.value = song.name;
+ //杩藉姞灞炴��
+ var oldList = new List<SceneFunctionStatus>();
+ for (int i = 0; i < sceneFunction.status.Count; i++)
+ {
+ var status = sceneFunction.status[i];
+ if (status.key == FunctionAttributeKey.PlaylistName)
+ {
+ //鎺у埗闇�瑕侊紙鐣岄潰涓嶉渶瑕佹樉绀猴級
+ sceneFunction.status.RemoveAt(i);
+ sceneFunction.status.Insert(i, new SceneFunctionStatus { key = FunctionAttributeKey.PlaylistName, value = playListName });
+ }
+ else if (status.key == FunctionAttributeKey.Url)
+ {
+ //瀛樺湪url灏变竴璧峰彂杩囧幓
+ if (!string.IsNullOrEmpty(song.url))
+ {
+ //鎺у埗闇�瑕侊紙鐣岄潰涓嶉渶瑕佹樉绀猴級
+ sceneFunction.status.RemoveAt(i);
+ sceneFunction.status.Insert(i, new SceneFunctionStatus { key = FunctionAttributeKey.Url, value = song.url });
+ }
+ }
+
+ }
+
+ });
+ break;
+
}
};
#endregion
- }catch(Exception ex)
+ }
+ catch (Exception ex)
{
MainPage.Log($"鍦烘櫙鍔犺浇璁惧灞炴�у紓甯革細{ex.Message}");
}
@@ -672,8 +745,10 @@
delayRow.AddChidren(btnSceneDelayTitle);
- btnSceneDelayTitle.MouseUpEventHandler = (sender, e) => {
- Action<string> action = (obj) => {
+ btnSceneDelayTitle.MouseUpEventHandler = (sender, e) =>
+ {
+ Action<string> action = (obj) =>
+ {
sceneFunction.delay = obj;
btnDelayInfo.Text = new Scene() { delay = sceneFunction.delay }.GetDelayText();
};
@@ -974,21 +1049,25 @@
dialog.Show();
- pView.MouseUpEventHandler = (sender, e) => {
+ pView.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
};
- btnCancel.MouseUpEventHandler = (sender, e) => {
+ btnCancel.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
};
- btnOn.MouseUpEventHandler = (sender, e) => {
+ btnOn.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
trait.value = "true";
sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Security).value = "true";
btn.Text = trait.GetValueText() + trait.GetUintString();
};
- btnOff.MouseUpEventHandler = (sender, e) => {
+ btnOff.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
trait.value = "false";
sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Security).value = "false";
@@ -1011,7 +1090,7 @@
trait.value = temp.ToString();
List<string> pickerItems = new List<string>();
- if(trait == null)
+ if (trait == null)
{
return;
}
@@ -1026,7 +1105,7 @@
var optionBaseView = new FrameLayout()
{
- Y = Application.GetRealHeight(456-60),
+ Y = Application.GetRealHeight(456 - 60),
Gravity = Gravity.CenterHorizontal,
Width = Application.GetRealWidth(343),
Height = Application.GetRealHeight(260),
@@ -1046,7 +1125,7 @@
Radius = (uint)Application.GetRealWidth(12),
};
optionBaseView.AddChidren(topView);
- topView.AddChidren(new Button() {Y = Application.GetRealHeight(39), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.DividingLineColor });
+ topView.AddChidren(new Button() { Y = Application.GetRealHeight(39), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.DividingLineColor });
var btnCancel = new Button()
{
@@ -1088,26 +1167,30 @@
if (pickerItems.Contains(trait.value + trait.GetUintString()))
{
selectItem = trait.value.ToString() + trait.GetUintString();
- uIPickerView.setCurrentItems(pickerItems.IndexOf(selectItem),0,0);
+ uIPickerView.setCurrentItems(pickerItems.IndexOf(selectItem), 0, 0);
}
dialog.Show();
- pView.MouseUpEventHandler = (sender, e) => {
+ pView.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
};
- btnCancel.MouseUpEventHandler = (sender, e) => {
+ btnCancel.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
};
- uIPickerView.OnSelectChangeEvent = (int1, int2, int3) => {
+ uIPickerView.OnSelectChangeEvent = (int1, int2, int3) =>
+ {
selectItem = pickerItems[int1];
};
- btnConfrim.MouseUpEventHandler = (sender, e) => {
+ btnConfrim.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
btn.Text = selectItem;
//sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = trait.value.ToString() ;
- trait.value = selectItem.Replace(trait.GetUintString(),"");
+ trait.value = selectItem.Replace(trait.GetUintString(), "");
};
}
@@ -1117,7 +1200,7 @@
/// </summary>
/// <param name="function"></param>
/// <param name="btn"></param>
- void LoadEditDialog_Angle (SceneFunctionStatus trait, Button btn)
+ void LoadEditDialog_Angle(SceneFunctionStatus trait, Button btn)
{
double temp = trait.min;
double.TryParse(trait.value, out temp);
@@ -1196,7 +1279,7 @@
}
uIPickerView.setNPicker(pickerItems, null, null);
optionBaseView.AddChidren(uIPickerView);
- uIPickerView.setCurrentItems(pickerItems.IndexOf(trait.value.ToString()+ "掳"), 0, 0);
+ uIPickerView.setCurrentItems(pickerItems.IndexOf(trait.value.ToString() + "掳"), 0, 0);
string selectItem = pickerItems[pickerItems.IndexOf(trait.value.ToString() + "掳")];
if (pickerItems.Contains(trait.value + trait.GetUintString()))
@@ -1206,17 +1289,21 @@
//uIPickerView.setCurrentItems
dialog.Show();
- pView.MouseUpEventHandler = (sender, e) => {
+ pView.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
};
- btnCancel.MouseUpEventHandler = (sender, e) => {
+ btnCancel.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
};
- uIPickerView.OnSelectChangeEvent = (int1, int2, int3) => {
+ uIPickerView.OnSelectChangeEvent = (int1, int2, int3) =>
+ {
selectItem = pickerItems[int1];
};
- btnConfrim.MouseUpEventHandler = (sender, e) => {
+ btnConfrim.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
btn.Text = selectItem;
//sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = trait.value.ToString() ;
@@ -1416,7 +1503,7 @@
}
double temp = trait.min;
-
+
double.TryParse(trait.value, out temp);
trait.value = temp.ToString();
@@ -1494,24 +1581,28 @@
uIPickerView.setCurrentItems(pickerItems.IndexOf(trait.value.ToString()), 4, 5);
string selectItem = pickerItems[0];
- if (pickerItems.Contains(trait.value + trait.GetUintString()))
+ if (pickerItems.Contains(trait.value + trait.GetUintString()))
{
selectItem = trait.value.ToString() + trait.GetUintString();
}
dialog.Show();
- pView.MouseUpEventHandler = (sender, e) => {
+ pView.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
};
- btnCancel.MouseUpEventHandler = (sender, e) => {
+ btnCancel.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
};
- uIPickerView.OnSelectChangeEvent = (int1, int2, int3) => {
+ uIPickerView.OnSelectChangeEvent = (int1, int2, int3) =>
+ {
selectItem = pickerItems[int1];
};
- btnConfrim.MouseUpEventHandler = (sender, e) => {
+ btnConfrim.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
btn.Text = selectItem;
//sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = trait.value.ToString() ;
@@ -1574,7 +1665,7 @@
#endregion
- int attrViewHight = Application.GetRealHeight(18 + 22+ 248);
+ int attrViewHight = Application.GetRealHeight(18 + 22 + 248);
//灞炴�ц缃尯鍩�
var attrView = new FrameLayout()
{
@@ -1585,7 +1676,7 @@
contentView.AddChidren(attrView);
attrView.AddChidren(new Button() { Height = Application.GetRealHeight(18) });
-
+
#region RGB
var rgbView = new FrameLayout()
@@ -1642,7 +1733,8 @@
int circleR = colorPicker.Width / 2 - Application.GetRealWidth(12);
- colorPicker.ColorChaged += (sender2, e2) => {
+ colorPicker.ColorChaged += (sender2, e2) =>
+ {
rgbString = (e2[0] + "," + e2[1] + "," + e2[2]).ToString();
//trait.value = rgbString;
btnCurColor.BackgroundColor = (uint)(0xFF000000 + tempLight.GetRGBcolor(rgbString));
@@ -1695,7 +1787,8 @@
TextID = StringId.Cancel,
};
bottomView.AddChidren(btnCancel);
- btnCancel.MouseUpEventHandler = (sender, e) => {
+ btnCancel.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
};
@@ -1715,7 +1808,8 @@
//渚嬶細鍙充笅鍦嗚 澶у皬涓�50
int mRectCornerID = HDLUtils.RectCornerBottomRight;
btnComplete.SetCornerWithSameRadius((uint)Application.GetRealWidth(14), mRectCornerID);
- btnComplete.MouseUpEventHandler = (sender, e) => {
+ btnComplete.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
trait.value = rgbString;
btn.BackgroundColor = (uint)(0xFF000000 + tempLight.GetRGBcolor(rgbString));
@@ -1745,7 +1839,8 @@
return;
}
- Dialog dialog = new Dialog() {
+ Dialog dialog = new Dialog()
+ {
Height = Application.GetRealHeight(647),
};
@@ -1845,7 +1940,8 @@
int circleR = colorPicker.Width / 2 - Application.GetRealWidth(12);
- colorPicker.ColorChaged += (sender2, e2) => {
+ colorPicker.ColorChaged += (sender2, e2) =>
+ {
rgbString = (e2[0] + "," + e2[1] + "," + e2[2]).ToString();
//trait.value = rgbString;
btnCurColor.BackgroundColor = (uint)(0xFF000000 + tempLight.GetRGBcolor(rgbString));
@@ -1879,7 +1975,7 @@
#region
var btnCancel = new Button()
{
- X = Application.GetRealWidth(20),
+ X = Application.GetRealWidth(20),
Width = Application.GetRealWidth(100),
Height = Application.GetRealHeight(44),
TextAlignment = TextAlignment.CenterLeft,
@@ -1888,7 +1984,8 @@
TextID = StringId.Cancel,
};
titleView.AddChidren(btnCancel);
- btnCancel.MouseUpEventHandler = (sender, e) => {
+ btnCancel.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
};
@@ -1907,7 +2004,8 @@
//渚嬶細鍙充笅鍦嗚 澶у皬涓�50
int mRectCornerID = HDLUtils.RectCornerBottomRight;
btnComplete.SetCornerWithSameRadius((uint)Application.GetRealWidth(14), mRectCornerID);
- btnComplete.MouseUpEventHandler = (sender, e) => {
+ btnComplete.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
trait.value = rgbString;
btn.BackgroundColor = (uint)(0xFF000000 + tempLight.GetRGBcolor(rgbString));
@@ -2102,14 +2200,14 @@
/// <summary>
/// 鍔犺浇鍔熻兘灞炴�ф暟鎹�夋嫨寮圭獥
/// </summary>
- void LoadEditDialog_FunctionPar(SceneFunctionStatus trait, Button btn,List<string> statusList)
+ void LoadEditDialog_FunctionPar(SceneFunctionStatus trait, Button btn, List<string> statusList)
{
Button lastButton = new Button();
var lastData = trait.value;
var lastText = btn.Text;
Dialog dialog = new Dialog();
- if(DB_ResidenceData.Instance.GatewayType == 0)
+ if (DB_ResidenceData.Instance.GatewayType == 0)
{
if (SPK.AcSpkList().Contains(sceneFunction.localFunction.spk))
{
@@ -2278,7 +2376,8 @@
};
row.AddChidren(btnPropertyTitle);
- btnPropertyTitle.MouseUpEventHandler = (sender, e) => {
+ btnPropertyTitle.MouseUpEventHandler = (sender, e) =>
+ {
btnChoose.IsSelected = true;
if (lastButton != null)
{
@@ -2295,14 +2394,17 @@
dialog.Show();
- pView.MouseUpEventHandler = (sender, e) => {
+ pView.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
};
- btnCancel.MouseUpEventHandler = (sender, e) => {
+ btnCancel.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
};
- btnConfrim.MouseUpEventHandler = (sender, e) => {
+ btnConfrim.MouseUpEventHandler = (sender, e) =>
+ {
dialog.Close();
trait.value = lastData;
//sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = trait.curValue.ToString() ;
@@ -2311,8 +2413,88 @@
}
- #endregion
+ /// <summary>
+ /// 鐧惧垎姣�
+ /// </summary>
+ /// <param name="oldStateValue">鏃х姸鎬佸��</param>
+ /// <param name="titleName">鏍囬</param>
+ /// <param name="action">鍥炶皟</param>
+ void BrightnessView(string oldStateValue, string titleName, Action<string, string> action)
+ {
+ #region 鐣岄潰
+ var brightness = new UI2.Intelligence.Automation.LogicView.BrightnessView();
+ brightness.FLayoutView(this, titleName, oldStateValue, action);
+ #endregion
+
+ }
+ /// <summary>
+ /// 鍒楄〃鐣岄潰
+ /// </summary>
+ /// <param name="list">鐣岄潰鏄剧ず鏁版嵁婧�</param>
+ /// <param name="oldStateValue">鏃х姸鎬佸��</param>
+ /// <param name="titleName">鏍囬</param>
+ /// <param name="action">鍥炶皟</param>
+ void ListView(List<string> list, string oldStateValue, string titleName, Action<string> action)
+ {
+ var pif = new UI2.Intelligence.Automation.PublicInterface();
+ pif.SingleSelectionShow(this, list, titleName, oldStateValue, action);
+ }
+
+ /// <summary>
+ /// 闊充箰鍒楄〃鐣岄潰
+ /// </summary>
+ /// <param name="oldStateValue">鏃х姸鎬佸��</param>
+ /// <param name="action">鍥炶皟</param>
+ void MusicListView(string oldStateValue, Action<string, Music.SongInfo> action)
+ {
+ Loading loading = new Loading();
+ this.AddChidren(loading);
+ loading.Start();
+ System.Threading.Tasks.Task.Run(() =>
+ {
+ try
+ {
+ var palyList = Music.SendMethod.Current.GetSingleSongList(new Function { sid = sceneFunction.sid }, "hdl_special", "");
+ List<string> songNameList = new List<string>();
+ for (int i = 0; i < palyList.songs.Count; i++)
+ {
+ var song = palyList.songs[i];
+ songNameList.Add(song.name);
+ }
+ Application.RunOnMainThread(() =>
+ {
+ loading.Hide();
+ var publicInterface = new UI2.Intelligence.Automation.PublicInterface();
+ publicInterface.FrameOrVv(this, songNameList, new List<string> { oldStateValue }, palyList.group, (index) =>
+ {
+ if (index > palyList.songs.Count)
+ {
+ index = 0;
+ }
+ var song = palyList.songs[index];
+ action?.Invoke(palyList.group, song);
+
+ //鐣岄潰鏄剧ず閫変腑鍊�
+ //funTypeView.btnState.Text = songSelecetd.name;
+ ////鏁版嵁灏佽
+ //AddDictionary("playlist_name", palyList.group);//鍒楄〃鍚�
+ //AddDictionary("song_name", songSelecetd.name);//姝屾洸鍚�
+ //if (!string.IsNullOrEmpty(songSelecetd.url))
+ //{
+ // //瀛樺湪url灏变竴璧峰彂閫佽繃鍘�
+ // AddDictionary("url", songSelecetd.url);
+ //}
+
+ }, false);
+
+ });
+ }
+ catch { }
+
+ });
+ }
+ #endregion
}
}
--
Gitblit v1.8.0