using System;
|
using System.Collections.Generic;
|
using Shared.Common;
|
using Shared.Phone.Device.CommonForm;
|
|
namespace Shared.Phone.Device.Category
|
{
|
public class SelectDelayTime : FrameLayout
|
{
|
#region ◆ 变量____________________________
|
/// <summary>
|
/// bodyFrameLayout
|
/// </summary>
|
private FrameLayout bodyFrameLayout;
|
/// <summary>
|
/// totalSecond
|
/// </summary>
|
public int totalSecond;
|
/// <summary>
|
/// selectedTimeAction
|
/// </summary>
|
public Action<SceneTargetDeviceUI> selectedTimeAction;
|
|
#endregion
|
|
/// <summary>
|
/// SelectDelayTime
|
/// </summary>
|
public SelectDelayTime()
|
{
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
|
//Tag = "categoryAddScene";
|
}
|
/// <summary>
|
/// RemoveFromParent
|
/// </summary>
|
public override void RemoveFromParent()
|
{
|
base.RemoveFromParent();
|
}
|
/// <summary>
|
/// sceneTargetDevice
|
/// </summary>
|
public SceneTargetDeviceUI sceneTargetDevice;
|
|
/// <summary>
|
/// Show
|
/// </summary>
|
public void Show()
|
{
|
if (sceneTargetDevice == null)
|
{
|
sceneTargetDevice = new SceneTargetDeviceUI { Type = 2 };
|
}
|
AddTop();
|
|
AddBodyView();
|
}
|
|
|
#region Add____________________________________
|
/// <summary>
|
/// AddTop
|
/// </summary>
|
private void AddTop()
|
{
|
var top = new TopFrameLayout();
|
AddChidren(top);
|
top.InitTopview();
|
top.SetTopTitle(R.MyInternationalizationString.AddScence);
|
top.backButton.MouseUpEventHandler += (sender, e) =>
|
{
|
RemoveFromParent();
|
};
|
}
|
|
/// <summary>
|
/// AddBodyView
|
/// </summary>
|
private void AddBodyView()
|
{
|
bodyFrameLayout = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(184),
|
Height = Application.GetRealHeight(1737),
|
BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor,
|
};
|
AddChidren(bodyFrameLayout);
|
|
var bg1 = new FrameLayout
|
{
|
Y = Application.GetRealHeight(118),
|
Height = Application.GetMinRealAverage(207),
|
Width = Application.GetMinRealAverage(207),
|
Gravity = Gravity.CenterHorizontal,
|
Radius = (uint)Application.GetMinRealAverage(207 / 2),
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
};
|
bodyFrameLayout.AddChidren(bg1);
|
|
var bg2 = new FrameLayout
|
{
|
Height = Application.GetMinRealAverage(184),
|
Width = Application.GetMinRealAverage(184),
|
Gravity = Gravity.Center,
|
Radius = (uint)Application.GetMinRealAverage(184 / 2),
|
BackgroundColor = ZigbeeColor.Current.GXCSelectedBackgroundColor,
|
};
|
bg1.AddChidren(bg2);
|
|
var timeImg = new Button
|
{
|
Height = Application.GetMinRealAverage(124),
|
Width = Application.GetMinRealAverage(124),
|
Gravity = Gravity.Center,
|
Radius = (uint)Application.GetRealHeight(124 / 2),
|
UnSelectedImagePath = "Item/Timer.png"
|
};
|
bg1.AddChidren(timeImg);
|
|
var tip = new Button
|
{
|
Y = Application.GetRealHeight(350),
|
Width = Application.GetRealWidth(700),
|
Height = Application.GetRealHeight(120),
|
Gravity = Gravity.CenterHorizontal,
|
TextID = R.MyInternationalizationString.SelectTimeForAction,
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
IsMoreLines = true
|
};
|
bodyFrameLayout.AddChidren(tip);
|
|
var midFL = new FrameLayout
|
{
|
Y = Application.GetRealHeight(611),
|
Height = Application.GetRealHeight(1126),
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
Radius = (uint)Application.GetRealHeight(17),
|
};
|
bodyFrameLayout.AddChidren(midFL);
|
|
var timeFL = new FrameLayout
|
{
|
Y = Application.GetRealHeight(127),
|
Height = Application.GetRealHeight(1126 - 127),
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
|
};
|
midFL.AddChidren(timeFL);
|
|
var pickView = new UIPickerView
|
{
|
Height = Application.GetRealHeight(153 * 3),
|
};
|
timeFL.AddChidren(pickView);
|
|
var minuList = new List<int> { };
|
var secList = new List<int> { };
|
var minuStrList = new List<string> { };
|
var secStrList = new List<string> { };
|
for (int i = 0; i < 60; i++)
|
{
|
minuList.Add(i);
|
minuStrList.Add($"{i}{Language.StringByID(R.MyInternationalizationString.Minute)}");
|
secList.Add(i);
|
secStrList.Add($"{i}{Language.StringByID(R.MyInternationalizationString.Second)}");
|
}
|
|
pickView.setNPicker(minuStrList, secStrList, null);
|
|
pickView.setCurrentItems(totalSecond / 60, totalSecond % 60, 0);
|
|
pickView.OnSelectChangeEvent += (l1, l2, l3) =>
|
{
|
totalSecond = minuList[l1] * 60 + secList[l2];
|
};
|
|
var confirmBtn = new CommonForm.CompleteButton(1656, 907, 127);
|
AddChidren(confirmBtn);
|
confirmBtn.SetTitle(R.MyInternationalizationString.Save);
|
confirmBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
if (totalSecond == 0)
|
{
|
RemoveFromParent();
|
}
|
else
|
{
|
sceneTargetDevice.DelayTime = totalSecond;
|
selectedTimeAction?.Invoke(sceneTargetDevice);
|
RemoveFromParent();
|
}
|
};
|
}
|
|
#endregion
|
|
}
|
}
|