using System;
using System.Collections.Generic;
using Shared.Common;
using Shared.Phone.Device.Light;
using Shared.Phone.UserCenter.Device;
using ZigBee.Device;
using static ZigBee.Device.BindObj;
using static ZigBee.Device.Panel;
namespace Shared.Phone.UserCenter.Bind
{
public class PanelBindPage : FrameLayout, ZigBee.Common.IStatus
{
///
/// 按键模式接收
///
/// Common.
public void Changed(CommonDevice common)
{
if (common.Type != ZigBee.Device.DeviceType.OnOffSwitch)
{
return;
}
Shared.Application.RunOnMainThread(() =>
{
var dev = common as Panel;
});
}
///
/// 加载绑定界面
///
/// Gateway.
/// Key.
public void Show(ZigBee.Device.ZbGateway gateway, Panel key)
{
currentKey = key;
curGateway = gateway;
InitConfigurePage(gateway);
}
#region 绑定变量
//显示被绑定设备或场景的view
VerticalScrolViewLayout midVerticalScrolViewLayout;
int currentClusterID = 0;
int currentMode = 0;
Panel currentKey;
ZbGateway curGateway;
Action> action;//按键绑定表通知
RowSecondRightTextView btnMode;//当前模式显示控件
FrameLayout inVerticalscrolView;//加场景或设备的view
bool isBindScene = false;
//本地设备列表
public static System.Collections.Generic.List localDeviceList = new System.Collections.Generic.List();
//本地场景列表
public static System.Collections.Generic.List scList = new System.Collections.Generic.List { };
//按键支持的私有模式列表
//private static System.Collections.Generic.List priFunList = new System.Collections.Generic.List { };
//按键配置的目标列表
private List targetList = new List();
#endregion
///
/// 按键配置
///
/// Gateway.
/// Key.
async void InitConfigurePage(ZigBee.Device.ZbGateway gateway)
{
currentKey.bindList.Clear();
#region topFrameLayout (只有UI,无数据处理)
var topFrameLayout = new FrameLayout()
{
Height = Application.GetRealHeight(220),
BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor,
};
this.AddChidren(topFrameLayout);
var titleFrameLayout = new FrameLayout()
{
Y = Application.GetRealHeight(80),
Height = Application.GetRealHeight(140),
BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor,
};
topFrameLayout.AddChidren(titleFrameLayout);
var title = new Button()
{
TextAlignment = TextAlignment.Center,
Text = currentKey.DeviceEpointName,
TextColor = Shared.Common.ZigbeeColor.Current.GXCTextBlackColor,
Width = Application.GetRealWidth(1080 - 500),
Gravity = Gravity.CenterHorizontal,
};
titleFrameLayout.AddChidren(title);
var back = new Button()
{
X = Application.GetRealWidth(50),
Height = Application.GetRealHeight(100),
Width = Application.GetRealWidth(100),
UnSelectedImagePath = "Item/Back.png",
SelectedImagePath = "Item/BackOn.png",
Gravity = Gravity.CenterVertical,
};
titleFrameLayout.AddChidren(back);
#endregion
#region middleFrameLayout (只有UI,无数据处理)
#region modeFrameLayout
var midFrameLayout = new FrameLayout()
{
Width = LayoutParams.MatchParent,
Height = Application.GetRealHeight(1920 - 220),
Y = topFrameLayout.Bottom,
BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCBackgroundColor,
};
this.AddChidren(midFrameLayout);
var modeFrameLayout = new FrameLayout()
{
Width = LayoutParams.MatchParent,
Height = Application.GetRealHeight(170),
BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCBackgroundColor,
};
midFrameLayout.AddChidren(modeFrameLayout);
var btnModeText = new Button()
{
X = Application.GetRealWidth(50),
Width = Application.GetRealWidth(700),
Height = Application.GetRealHeight(110),
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
Text = Language.StringByID(R.MyInternationalizationString.ModeType),
TextAlignment = TextAlignment.CenterLeft,
TextSize = 16,
Gravity = Gravity.CenterVertical,
};
modeFrameLayout.AddChidren(btnModeText);
btnMode = new RowSecondRightTextView();
btnMode.TextID = R.MyInternationalizationString.uNotHadSettion;
btnMode.TextColor = UserCenterColor.Current.Gray;
modeFrameLayout.AddChidren(btnMode);
var btnRight = new RowRightIconView();
modeFrameLayout.AddChidren(btnRight);
var line = new Button()
{
Y = modeFrameLayout.Bottom,
Height = 1,
BackgroundColor = ZigbeeColor.Current.GXCLineColor,
};
midFrameLayout.AddChidren(line);
#endregion
#region addBindDevice FrameLayout (只有UI,无数据处理)
var addBindDeviceFrameLayout = new FrameLayout()
{
Width = LayoutParams.MatchParent,
Height = Application.GetRealHeight(170),
Y = line.Bottom,
BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCBackgroundColor,
};
midFrameLayout.AddChidren(addBindDeviceFrameLayout);
var btnAddBindText = new Button()
{
X = Application.GetRealWidth(50),
Width = Application.GetRealWidth(700),
Height = Application.GetRealHeight(110),
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
TextID = R.MyInternationalizationString.AddBindTargets,
TextAlignment = TextAlignment.CenterLeft,
TextSize = 16,
Gravity = Gravity.CenterVertical
};
addBindDeviceFrameLayout.AddChidren(btnAddBindText);
var btnAddBind = new Button()
{
X = Application.CurrentWidth - Application.GetRealWidth(150),
Width = Application.GetMinRealAverage(110),
Height = Application.GetMinRealAverage(110),
UnSelectedImagePath = "Bind/BindAdd.png",
SelectedImagePath = "Bind/BindAddOn.png",
Gravity = Gravity.CenterVertical
};
addBindDeviceFrameLayout.AddChidren(btnAddBind);
var line1 = new Button()
{
Y = addBindDeviceFrameLayout.Bottom,
Height = 1,
BackgroundColor = ZigbeeColor.Current.GXCLineColor,
};
midFrameLayout.AddChidren(line1);
midVerticalScrolViewLayout = new VerticalScrolViewLayout()
{
Y = line1.Bottom,
Height = Application.GetRealHeight(1920 - 620),
};
midFrameLayout.AddChidren(midVerticalScrolViewLayout);
#endregion
#endregion
#region 处理事件 (数据处理)
back.MouseUpEventHandler += (sender, e) =>
{
localDeviceList.Clear();
scList.Clear();
this.RemoveFromParent();
};
EventHandler hander = async (sender, e) =>
{
var oldCluster = currentClusterID;
if (currentKey. priFunList == null)
{
try
{
CommonPage.Loading.Start();
KeyModeList(currentKey);
}
catch { }
finally
{
CommonPage.Loading.Hide();
}
}
if (currentKey.priFunList != null)
{
PickerView.Show(currentKey.priFunList, ModeSelectAction);
}
else
{
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.NoModeSupport), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnMode);
}
currentKey.ReSave();
};
btnMode.MouseUpEventHandler += hander;
btnRight.MouseUpEventHandler += hander;
btnModeText.MouseUpEventHandler += hander;
modeFrameLayout.MouseUpEventHandler += hander;
btnAddBind.MouseUpEventHandler += (sender, e) =>
{
if (currentClusterID == 0)
{
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.KeyConfiguration), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnAddBind);
return;
}
if (currentMode != 1)
{
var selectDeviceList = new List();
foreach (var dev in currentKey.bindList)
{
string mainkey = Common.LocalDevice.Current.GetDeviceMainKeys(dev.BindMacAddr, dev.BindEpoint);
selectDeviceList.Add(mainkey);
}
var listShowDevice = new List();
foreach (var device in localDeviceList)
{
if (SupportDevice(device, currentClusterID) == false)
{
continue;
}
//如果已经被绑定过了的设备,则不在列表中进行显示
string mainkey = Common.LocalDevice.Current.GetDeviceMainKeys(device);
if (selectDeviceList.Contains(mainkey) == true)
{
continue;
}
listShowDevice.Add(device);
}
var form = new SelectDeviceForm();
form.AddForm(form, listShowDevice, selectDeviceList, false);
form.SetTitleText(Language.StringByID(R.MyInternationalizationString.AddBindTargets));
form.ActionSelectDevice += (async (devList) =>
{
try
{
if (devList == null || devList.Count == 0)
{
return;
}
CommonPage.Loading.Start();
//执行目标绑定
var result = await Common.LocalDevice.Current.BindDeviceTarget(currentKey, devList, currentClusterID);
if (result != null && result.Count > 0)
{
currentKey.bindList.Clear();
var getBindList = await currentKey.GetDeviceBindAsync();
var bindDeviceListTemp = new System.Collections.Generic.List { };
var bindSceneListTemp = new System.Collections.Generic.List { };
if (getBindList != null)
{
if (getBindList.getAllBindResponseData != null)
{
foreach (var b in getBindList.getAllBindResponseData.BindList)
{
if (b.BindCluster == currentClusterID)
{
if (b.BindCluster == 6)
{
if (b.BindType == 2)
{
bindSceneListTemp.Add(b);
}
else
{
bindDeviceListTemp.Add(b);
}
}
else
{
currentKey.bindList.Add(b);
}
}
}
}
}
if (currentKey.panelMode == 1)
{
currentKey.bindList = bindSceneListTemp;
}
else if (currentKey.panelMode == 100 || currentKey.panelMode == 101 || currentKey.panelMode == 102)
{
currentKey.bindList = bindDeviceListTemp;
}
}
}catch { }
finally
{
//绑定表刷新
RefreshList(gateway, currentKey);
CommonPage.Loading.Hide();
}
});
}
else
{
if (currentKey.bindList.Count != 0)
{
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.SneneModeExistTargets), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnAddBind);
}
else
{
var addBindTargetsPage = new Shared.Phone.UserCenter.Bind.AddBindTargetsPage();
Shared.Phone.UserView.HomePage.Instance.AddChidren(addBindTargetsPage);
Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
addBindTargetsPage.Show(currentKey, currentClusterID, false);
Action> action = (obj) =>
{
currentKey.bindList = obj;
RefreshList(curGateway, currentKey);
};
addBindTargetsPage.action += action;
}
}
currentKey.ReSave();
};
//绑定表数据初始化(被绑定的设备列表,场景列表和设备列表)
try
{
localDeviceList.Clear();
scList.Clear();
foreach (var dev in Shared.Common.LocalDevice.Current.listAllDevice)
{
localDeviceList.Add(dev);
}
scList = Shared.Common.Room.AllRoomSceneUIList;
KeyModeList(currentKey);
}
catch { }
#endregion
}
///
/// 按键绑定表显示
///
/// Gateway.
/// Key.
void RefreshList(ZigBee.Device.ZbGateway gateway, Panel key)
{
midVerticalScrolViewLayout.RemoveAll();
foreach (var bindDevice in key.bindList)
{
#region 绑定表UI显(无数据处理)
var rowLayout = new RowLayout()
{
Height = Application.GetRealHeight(170),
};
midVerticalScrolViewLayout.AddChidren(rowLayout);
var devicePic = new Button()
{
X = Application.GetRealWidth(50),
Width = Application.GetMinRealAverage(110),
Height = Application.GetMinRealAverage(110),
Gravity = Gravity.CenterVertical,
};
rowLayout.AddChidren(devicePic);
var btnBindName = new Button()
{
Width = Application.GetRealWidth(500 - 120),
X = devicePic.Right + Application.GetRealWidth(20),
TextColor = Shared.Common.ZigbeeColor.Current.TextBlack,
TextAlignment = TextAlignment.CenterLeft,
};
rowLayout.AddChidren(btnBindName);
var btnDel = new Button()
{
TextColor = Shared.Common.ZigbeeColor.Current.GXCTextWhiteColor,
X = btnBindName.Right,
TextID = R.MyInternationalizationString.Delete,
BackgroundColor = Shared.Common.ZigbeeColor.Current.DelRowLayout,
};
rowLayout.AddRightView(btnDel);
#endregion
#region 绑定数据处理
bool isExistScene = false;
foreach (var sc in key.bindList)
{
if (sc.BindType == 2)
{
isExistScene = true;
}
}
if (isExistScene)
{
devicePic.UnSelectedImagePath = "Item/Scene.png";
devicePic.Width = Application.GetMinRealAverage(110);
if (bindDevice.ESName == "")
{
btnBindName.Text = bindDevice.BindScenesId.ToString();
}
else
{
btnBindName.Text = bindDevice.ESName;
}
}
else
{
//被绑定设备图片
foreach (var dev in localDeviceList)
{
var tempDev = localDeviceList.Find(obj => obj.DeviceAddr == bindDevice.BindMacAddr && obj.DeviceEpoint == bindDevice.BindEpoint);
if (tempDev != null)
{
var deviceUi = Common.LocalDevice.Current.GetDeviceUI(tempDev);
devicePic.UnSelectedImagePath = deviceUi.IconPath;
devicePic.Width = Application.GetRealWidth(110);
devicePic.Text = "";
if (tempDev.DeviceEpointName == "")
{
btnBindName.Text = tempDev.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit);
}
else
{
btnBindName.Text = tempDev.DeviceEpointName;
}
}
else
{
btnBindName.Text = bindDevice.BindMacAddr + "_" + bindDevice.BindEpoint;
devicePic.Width = Application.GetMinRealAverage(200);
devicePic.TextAlignment = TextAlignment.CenterLeft;
devicePic.TextColor = UserCenterColor.Current.Gray;
devicePic.Text = Language.StringByID(R.MyInternationalizationString.uOffLine);
}
}
}
//删除事件处理
btnDel.MouseUpEventHandler += async (sender, e) =>
{
var delDevice = new DelDeviceBindData();
delDevice.DeviceAddr = key.DeviceAddr;
delDevice.Epoint = key.DeviceEpoint;
if (bindDevice.BindType == 0 || bindDevice.BindType == 1)
{
var removeDevice = new RemoveBindListObj();
removeDevice.BindCluster = bindDevice.BindCluster;
removeDevice.BindType = 0;
removeDevice.BindMacAddr = bindDevice.BindMacAddr;
removeDevice.BindEpoint = bindDevice.BindEpoint;
delDevice.RemoveBindList.Add(removeDevice);
}
else if (bindDevice.BindType == 2)
{
var removeDevice = new RemoveBindListObj();
removeDevice.BindCluster = bindDevice.BindCluster;
removeDevice.BindType = 1;
removeDevice.BindScenesId = bindDevice.BindScenesId;
delDevice.RemoveBindList.Add(removeDevice);
}
try
{
CommonPage.Loading.Start();
var delResult = new DelDeviceBindResponseAllData();
delResult = await key.DelDeviceBindAsync(delDevice);
if (delResult.delDeviceBindResponseData?.RemoveBindList != null)
{
foreach (var re in delResult.delDeviceBindResponseData.RemoveBindList)
{
switch (re.Result)
{
case 0:
key.bindList.Remove(bindDevice);
RefreshList(gateway, key);
break;
case 1:
key.bindList.Clear();
try
{
CommonPage.Loading.Start();
var getBindList = await key.GetDeviceBindAsync();
var bindDeviceListTemp = new System.Collections.Generic.List { };
var bindSceneListTemp = new System.Collections.Generic.List { };
if (getBindList != null)
{
if (getBindList.getAllBindResponseData != null)
{
foreach (var b in getBindList.getAllBindResponseData.BindList)
{
if (b.BindCluster == currentClusterID)
{
if (b.BindCluster == 6)
{
if (b.BindType == 2)
{
bindSceneListTemp.Add(b);
}
else
{
bindDeviceListTemp.Add(b);
}
}
else
{
key.bindList.Add(b);
}
}
}
}
}
if (key.panelMode == 1)
{
key.bindList = bindSceneListTemp;
}
else if (key.panelMode == 100 || key.panelMode == 101 || key.panelMode == 102)
{
key.bindList = bindDeviceListTemp;
}
}
catch { }
finally
{
CommonPage.Loading.Hide();
RefreshList(gateway, key);
}
break;
case 4:
if (delResult.removeBindResultResponseData != null)
{
if (delResult.removeBindResultResponseData.Result == 0)
{
key.bindList.Remove(bindDevice);
RefreshList(gateway, key);
}
else
{
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel);
}
}
break;
default:
break;
}
}
}
else
{
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel);
}
}
catch { }
finally
{
CommonPage.Loading.Hide();
}
};
#endregion
}
}
///
/// 选择需要绑定的设备和场景
///
/// Gateway.
/// Key.
/// Action.
void BindDevice(ZigBee.Device.ZbGateway gateway, Panel key)
{
#region 绑定的设备和场景Dialog UI
var dialog = new Dialog();
var dialogBodyView = new FrameLayout()
{
Width = Application.GetRealWidth(753),
Height = Application.GetRealHeight(946 - 50),
BackgroundColor = ZigbeeColor.Current.DialogColor,
Radius = 5,
BorderWidth = 0,
Gravity = Gravity.Center
};
dialog.AddChidren(dialogBodyView);
var btnTitle = new Button()
{
Height = Application.GetRealHeight(119),
TextAlignment = TextAlignment.Center,
TextID = R.MyInternationalizationString.BindDevice,
BackgroundColor = ZigbeeColor.Current.DialogTitleColor,
TextSize = 20,
};
dialogBodyView.AddChidren(btnTitle);
var BindTypeView = new FrameLayout()
{
Height = Application.GetRealHeight(110),
BackgroundColor = ZigbeeColor.Current.DialogSubTitleColor,
Y = btnTitle.Bottom,
};
dialogBodyView.AddChidren(BindTypeView);
var bindVerticalScrolView = new VerticalScrolViewLayout()
{
Height = Application.GetRealHeight(946 - 240 - 180),
Width = Application.GetRealWidth(753),
Y = BindTypeView.Bottom,
};
dialogBodyView.AddChidren(bindVerticalScrolView);
inVerticalscrolView = new FrameLayout();
bindVerticalScrolView.AddChidren(inVerticalscrolView);
var btnDevice = new Button()
{
Width = Application.GetRealWidth(376),
TextSize = 16,
SelectedTextColor = Shared.Common.ZigbeeColor.Current.SelectedTextColor,
TextColor = Shared.Common.ZigbeeColor.Current.TextColor,
TextID = R.MyInternationalizationString.BindDevice,
IsSelected = !isBindScene,
};
BindTypeView.AddChidren(btnDevice);
var btnScene = new Button()
{
Width = Application.GetRealWidth(376),
X = btnDevice.Right,
TextSize = 16,
SelectedTextColor = Shared.Common.ZigbeeColor.Current.SelectedTextColor,
TextColor = Shared.Common.ZigbeeColor.Current.TextColor,
TextID = R.MyInternationalizationString.BindScene,
IsSelected = isBindScene,
};
BindTypeView.AddChidren(btnScene);
var btnLine = new Button()
{
Width = 1,
Height = Application.GetRealHeight(119) - 1,
BackgroundColor = Shared.Common.ZigbeeColor.Current.DialogTitleLine,
X = btnDevice.Right,
Y = 1,
};
BindTypeView.AddChidren(btnLine);
var bottomView = new FrameLayout()
{
Y = dialogBodyView.Height - Application.GetRealHeight(119),
Height = Application.GetRealHeight(119),
BackgroundColor = Shared.Common.ZigbeeColor.Current.DialogTitleColor,
};
dialogBodyView.AddChidren(bottomView);
var btnBack = new Button()
{
Width = Application.GetRealWidth(119),
Height = Application.GetRealHeight(119),
UnSelectedImagePath = "Bind/DialogBack.png",
SelectedImagePath = "Bind/DialogBackOn.png",
};
bottomView.AddChidren(btnBack);
btnBack.MouseUpEventHandler += (sender1, e1) =>
{
dialog.Close();
};
var btnLineH = new Button()
{
Width = 1,
Height = LayoutParams.MatchParent,
X = btnBack.Right,
BackgroundColor = Shared.Common.ZigbeeColor.Current.DialogColor,
};
bottomView.AddChidren(btnLineH);
var btnConfigureSave = new Button()
{
Width = Application.GetRealWidth(753 - 120),
X = btnLineH.Right,
TextID = R.MyInternationalizationString.Save,
BackgroundColor = ZigbeeColor.Current.DialogTitleColor,
TextAlignment = TextAlignment.Center,
TextSize = 16,
};
bottomView.AddChidren(btnConfigureSave);
InitDeviceOrSceneView(true, key, inVerticalscrolView, (obj) =>
{
Refresh();
});
dialog.Show();
#endregion
#region 事件和数据处理
//保存处理事件(添加场景和设备)
btnConfigureSave.MouseUpEventHandler += async (sender, e) =>
{
var addBindeDev = new AddBindData();
addBindeDev.DeviceAddr = key.DeviceAddr;
addBindeDev.Epoint = key.DeviceEpoint;
foreach (var de in targetList)
{
if (de.DeviceAddr != null)
{
var addBindInfo = new AddBindListObj();
addBindInfo.BindType = 0;
addBindInfo.BindCluster = currentClusterID;
addBindInfo.BindMacAddr = de.DeviceAddr;
addBindInfo.BindEpoint = de.DeviceEpoint;
addBindeDev.BindList.Add(addBindInfo);
}
else
{
var addBindInfo = new AddBindListObj();
addBindInfo.BindType = 1;
addBindInfo.BindCluster = currentClusterID;
var sc1 = (SceneUI)de;
addBindInfo.BindScenesId = sc1.Id;
addBindeDev.BindList.Add(addBindInfo);
}
}
try
{
CommonPage.Loading.Start();
var dev = new AddedDeviceBindResponseAllData();
dev = await key.AddDeviceBindAsync(addBindeDev);
foreach (var ab in dev.addedDeviceBindResponseData?.BindList)
{
switch (ab.Result)
{
case 0:
key.bindList.Add((BindListResponseObj)ab);
for (int i = 0; i < targetList.Count; i++)
{
var de = targetList[i];
var sc1 = new SceneUI();
if (de.DeviceAddr == null)
{
sc1 = (SceneUI)de;
if (sc1.Id == ab.BindScenesId)
{
targetList.RemoveAt(i);
i--;
}
}
}
RefreshList(gateway, key);
break;
case 1:
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindErrorAbsence), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnConfigureSave);
break;
case 2:
switch (dev.addBindResultResponseData?.Result)
{
case 0:
key.bindList.Add((BindListResponseObj)ab);
for (int i = 0; i < targetList.Count; i++)
{
var de = targetList[i];
if (de.DeviceAddr == ab.BindMacAddr && de.DeviceEpoint == ab.BindEpoint)
{
targetList.RemoveAt(i);
i--;
}
}
RefreshList(gateway, key);
break;
case 140:
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFull), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnConfigureSave);
break;
default:
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnConfigureSave);
break;
}
break;
case 3:
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindErrorExisted), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnConfigureSave);
break;
case 4:
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnConfigureSave);
break;
default:
break;
}
}
}
catch { }
finally
{
CommonPage.Loading.Hide();
}
};
//设备事件
btnDevice.MouseUpEventHandler += (sender, e) =>
{
btnDevice.IsSelected = true;
btnScene.IsSelected = false;
isBindScene = false;
InitDeviceOrSceneView(true, key, inVerticalscrolView, (obj) =>
{
Refresh();
});
};
//场景事件
btnScene.MouseUpEventHandler += (sender, e) =>
{
btnScene.IsSelected = true;
btnDevice.IsSelected = false;
isBindScene = false;
InitDeviceOrSceneView(false, key, inVerticalscrolView, (obj) =>
{
Refresh();
});
};
#endregion
}
///
/// 匹配当前模式的设备和场景,并选择绑定
///
/// If set to true is device.
/// Hdl button.
/// In verticalscrol view.
/// Action.
async void InitDeviceOrSceneView(bool isDevice, Panel key, FrameLayout inVerticalscrolView, Action