using System;
|
using System.Collections.Generic;
|
using HDL_ON.Entity;
|
using HDL_ON.UI.CSS;
|
using Shared;
|
namespace HDL_ON.UI
|
{
|
public class SetSceneRgbColorfulModePage : FrameLayout
|
{
|
FrameLayout bodyView;
|
VerticalScrolViewLayout contentView;
|
Button btnSelected;
|
Function selectedFunction;
|
string status = "off";
|
|
public Action<Function,string> backAction;
|
|
public SetSceneRgbColorfulModePage()
|
{
|
bodyView = this;
|
}
|
|
public void LoadPage(string oid)
|
{
|
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
|
|
new TopViewDiv(bodyView, Language.StringByID( StringId.ColorfulFunction)).LoadTopView();
|
contentView = new VerticalScrolViewLayout()
|
{
|
Y = Application.GetRealHeight(64),
|
Height = Application.GetRealHeight(520),
|
ScrollEnabled = false,
|
};
|
bodyView.AddChidren(contentView);
|
|
var sequenceList = FunctionList.List.GetSeries();
|
|
if (btnSelected == null)
|
{
|
btnSelected = new Button()
|
{
|
Width = Application.GetRealWidth(330),
|
TextAlignment = TextAlignment.CenterRight,
|
TextColor = CSS_Color.PromptingColor1,
|
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
|
};
|
}
|
|
|
LoadFunctionRow();
|
contentView.AddChidren(new Button() { X = Application.GetRealWidth(16), Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor });
|
|
foreach (var sequence in sequenceList)
|
{
|
if (sequence.sid.StartsWith(oid))
|
{
|
LoadFunctionRow(sequence);
|
contentView.AddChidren(new Button() { X = Application.GetRealWidth(16), Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor });
|
|
}
|
}
|
|
|
|
var bottomView = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(591),
|
Height = Application.GetRealHeight(106),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
Radius = (uint)Application.GetRealWidth(16),
|
};
|
bodyView.AddChidren(bottomView);
|
|
var btnConfrim = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(12),
|
Width = Application.GetRealWidth(220),
|
Height = Application.GetRealWidth(44),
|
TextAlignment = TextAlignment.Center,
|
TextColor = CSS_Color.MainBackgroundColor,
|
BackgroundColor = CSS_Color.MainColor,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
IsBold = true,
|
Radius = (uint)Application.GetRealWidth(22),
|
TextID = StringId.Complete
|
};
|
bottomView.AddChidren(btnConfrim);
|
|
btnConfrim.MouseUpEventHandler = (sender, e) => {
|
backAction?.Invoke(selectedFunction,status);
|
this.RemoveFromParent();
|
};
|
}
|
|
|
/// <summary>
|
/// 加载功能Row
|
/// </summary>
|
void LoadFunctionRow(Function function)
|
{
|
try
|
{
|
#region Row code
|
var row = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(50),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
//Tag = sceneStatus.key,
|
};
|
contentView.AddChidren(row);
|
|
|
Button btnRight = new Button()
|
{
|
X = Application.GetRealWidth(339),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage(16),
|
Height = Application.GetMinRealAverage(16),
|
UnSelectedImagePath = "Public/Right.png",
|
};
|
row.AddChidren(btnRight);
|
|
//if()
|
//row.AddChidren(btnFunctionText);
|
|
|
|
var btnFunctionName = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
Text = function.name
|
};
|
row.AddChidren(btnFunctionName);
|
btnFunctionName.MouseUpEventHandler = (sender, e) =>
|
{
|
LoadEditDialog_OnOff(row,function);
|
};
|
|
#endregion
|
}
|
catch (Exception ex)
|
{
|
MainPage.Log($"场景加载设备属性异常:{ex.Message}");
|
}
|
}
|
|
void LoadFunctionRow()
|
{
|
try
|
{
|
#region Row code
|
var row = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(50),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
//Tag = sceneStatus.key,
|
};
|
contentView.AddChidren(row);
|
|
|
Button btnRight = new Button()
|
{
|
X = Application.GetRealWidth(339),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage(16),
|
Height = Application.GetMinRealAverage(16),
|
UnSelectedImagePath = "Public/Right.png",
|
};
|
row.AddChidren(btnRight);
|
|
//if()
|
//row.AddChidren(btnFunctionText);
|
|
|
|
var btnFunctionName = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextID = StringId.AutomaticColoring,
|
};
|
row.AddChidren(btnFunctionName);
|
btnFunctionName.MouseUpEventHandler = (sender, e) =>
|
{
|
LoadEditDialog_OnOff(row,null);
|
};
|
|
#endregion
|
}
|
catch (Exception ex)
|
{
|
MainPage.Log($"场景加载设备属性异常:{ex.Message}");
|
}
|
}
|
|
|
/// <summary>
|
/// 加载开关选择弹窗
|
/// </summary>
|
/// <param name="function"></param>
|
/// <param name="btn"></param>
|
void LoadEditDialog_OnOff(FrameLayout row,Function function)
|
{
|
Dialog dialog = new Dialog();
|
|
var pView = new FrameLayout()
|
{
|
BackgroundColor = CSS_Color.DialogTransparentColor1,
|
};
|
dialog.AddChidren(pView);
|
|
var optionBaseView = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(500),
|
Height = Application.GetRealHeight(160),
|
AnimateSpeed = 0.3f,
|
Animate = Animate.DownToUp,
|
};
|
pView.AddChidren(optionBaseView);
|
|
var optionView = new VerticalScrolViewLayout()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(343),
|
Height = Application.GetRealHeight(100),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
Radius = (uint)Application.GetRealWidth(12),
|
ScrollEnabled = false,
|
};
|
optionBaseView.AddChidren(optionView);
|
|
var btnOn = new Button()
|
{
|
Height = Application.GetRealHeight(50),
|
TextAlignment = TextAlignment.Center,
|
TextColor = CSS_Color.TextualColor,
|
SelectedTextColor = CSS_Color.MainColor,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextID = StringId.On,
|
IsSelected = true
|
};
|
optionView.AddChidren(btnOn);
|
|
optionView.AddChidren(new Button() { Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.DividingLineColor });
|
|
var btnOff = new Button()
|
{
|
Height = Application.GetRealHeight(50),
|
TextAlignment = TextAlignment.Center,
|
TextColor = CSS_Color.TextualColor,
|
SelectedTextColor = CSS_Color.MainColor,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextID = StringId.OFF,
|
};
|
optionView.AddChidren(btnOff);
|
|
var btnCancel = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(8) + optionView.Bottom,
|
Width = Application.GetRealWidth(343),
|
Height = Application.GetRealHeight(50),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
Radius = (uint)Application.GetRealWidth(12),
|
TextID = StringId.Cancel,
|
TextColor = CSS_Color.WarningColor,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
};
|
optionBaseView.AddChidren(btnCancel);
|
|
dialog.Show();
|
|
pView.MouseUpEventHandler = (sender, e) => {
|
dialog.Close();
|
};
|
|
btnCancel.MouseUpEventHandler = (sender, e) => {
|
dialog.Close();
|
};
|
btnOn.MouseUpEventHandler = (sender, e) =>
|
{
|
dialog.Close();
|
btnSelected.TextID = StringId.On;
|
status = "on";
|
selectedFunction = function;
|
row.AddChidren(btnSelected);
|
};
|
btnOff.MouseUpEventHandler = (sender, e) => {
|
dialog.Close();
|
btnSelected.TextID = StringId.OFF;
|
status = "off";
|
selectedFunction = function;
|
row.AddChidren(btnSelected);
|
};
|
|
}
|
|
|
}
|
}
|