using System;
using System.Collections.Generic;
using Shared.Common;
using Shared.Phone.Device.CommonForm;
namespace Shared.Phone.Device.Category
{
public class SelectDelayTime : FrameLayout
{
#region ◆ 变量____________________________
///
/// bodyFrameLayout
///
private FrameLayout bodyFrameLayout;
///
/// totalSecond
///
public int totalSecond;
///
/// selectedTimeAction
///
public Action selectedTimeAction;
#endregion
///
/// SelectDelayTime
///
public SelectDelayTime()
{
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
//Tag = "categoryAddScene";
}
///
/// RemoveFromParent
///
public override void RemoveFromParent()
{
base.RemoveFromParent();
}
///
/// sceneTargetDevice
///
public SceneTargetDeviceUI sceneTargetDevice;
///
/// Show
///
public void Show()
{
if (sceneTargetDevice == null)
{
sceneTargetDevice = new SceneTargetDeviceUI { Type = 2 };
}
AddTop();
AddBodyView();
}
#region Add____________________________________
///
/// AddTop
///
private void AddTop()
{
var top = new TopFrameLayout();
AddChidren(top);
top.InitTopview();
top.SetTopTitle(R.MyInternationalizationString.AddDelayTime);
top.backButton.MouseUpEventHandler += (sender, e) =>
{
RemoveFromParent();
};
}
///
/// AddBodyView
///
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(58),
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,
TextSize=15,
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(58),
};
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 { };
var secList = new List { };
var minuStrList = new List { };
var secStrList = new List { };
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
}
}