using System;
|
using System.Collections.Generic;
|
using Shared.Common;
|
using Shared.Phone.UserCenter.Device;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.UserCenter.SmartSound
|
{
|
//智能音箱列表界面
|
public class SmartSoundListForm : EditorCommonForm
|
{
|
public SmartSoundListForm()
|
{
|
}
|
|
private List<SmartSound> smartSoundList = null;
|
|
/// <summary>
|
/// 列表控件
|
/// </summary>
|
private VerticalListRefreshControl listView = null;
|
/// <summary>
|
/// 前一次显示出左滑菜单的RowLayout
|
/// </summary>
|
private RowLayoutControl oldShowRightMuneRow = null;
|
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
/// </summary>
|
public void ShowForm()
|
{
|
iniData();//先加载模拟数据
|
|
this.ScrollEnabled = false;
|
|
//设置标题信息
|
base.SetTitleText("智能音箱");
|
Dictionary<string, string> floorDictionary = Config.Instance.Home.FloorDics;//楼层列表
|
|
var helpBtn = new MyButton();
|
//helpBtn.TextSize = 15;
|
helpBtn.TextColor = UserCenterColor.Current.TextOrangeColor;
|
helpBtn.Text = "帮助";
|
helpBtn.Gravity = Gravity.CenterRight;
|
helpBtn.TextAlignment = TextAlignment.CenterRight;
|
//helpBtn.BackgroundColor = UserCenterColor.Current.BlackBackGround;
|
topFrameLayout.AddChidren(helpBtn);
|
helpBtn.X -= Application.GetRealWidth(58);
|
|
//初始化中部控件
|
this.InitMiddleFrame();
|
|
helpBtn.MouseUpEventHandler += (sernder, e) =>
|
{
|
//这里是加载帮组的界面
|
};
|
|
string room_id = Common.Config.Instance.Home.Id;//住宅 ID
|
string gu_id = Common.Config.Instance.Guid;
|
|
Console.WriteLine("room_id =" + room_id);
|
Console.WriteLine("gu_id =" + gu_id);
|
|
}
|
|
/// <summary>
|
/// 初始化中部控件(外部可以调用)
|
/// </summary>
|
/// <param name="i_reGetDeviceOnlineStatu">重新获取设备的在线状态</param>
|
public void InitMiddleFrame()
|
{
|
// show出没有设备的图标文字提示
|
this.ShowNotDataImage(bodyFrameLayout, new string[] { "还没有音箱哦,", "绑定智能音箱请前往第三方 APP 进行操作" });
|
|
var frame = new FrameLayout();
|
this.bodyFrameLayout.AddChidren(frame);
|
frame.BackgroundColor = UserCenterColor.Current.White;
|
frame.Y = 0;
|
frame.Height = this.bodyFrameLayout.Height;
|
|
// 初始化 lisetView
|
listView = new VerticalListRefreshControl(29);
|
listView.Y = 0;
|
listView.Height = bodyFrameLayout.Height;
|
frame.AddChidren(listView);
|
listView.BeginHeaderRefreshingAction += () =>
|
{
|
HdlThreadLogic.Current.RunThread(() =>
|
{
|
//下拉刷新
|
iniView();
|
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
//隐藏下拉刷新特效
|
listView.EndHeaderRefreshing();
|
});
|
|
});
|
};
|
|
iniView();
|
}
|
|
private void iniView()
|
{
|
//
|
listView.RemoveAll();
|
|
if (smartSoundList == null)
|
return;
|
|
for (int i = 0; i < smartSoundList.Count; i++)
|
{
|
//
|
var smartSound = smartSoundList[i];
|
var row = new SoundRowLayout();
|
listView.AddChidren(row);
|
|
switch (smartSound.Type)
|
{
|
case SmartSound.SMARTSOUND_XIAODU:
|
row.Account = "小度:" + smartSound.UserName;
|
row.ImagePath = "SmartSound/Xiaodu.png";
|
row.Remark = smartSound.Remark;
|
break;
|
case SmartSound.SMARTSOUND_XIAOAI:
|
row.Account = "小爱:" + smartSound.UserName;
|
row.ImagePath = "SmartSound/Xiaoai.png";
|
row.Remark = smartSound.Remark;
|
break;
|
case SmartSound.SMARTSOUND_TIANMAO:
|
row.Account = "天猫精灵:" + smartSound.UserName;
|
row.ImagePath = "SmartSound/Tianmao.png";
|
row.Remark = smartSound.Remark;
|
break;
|
}
|
|
row.InitControl();
|
row.btnDelect.AddTag("index", i);
|
row.btnRename.AddTag("index", i);
|
|
//重命名
|
row.btnRename.ButtonClickEvent += (sender, e) =>
|
{
|
//
|
int index = (int)(((NormalViewControl)sender).GetTagByKey("index"));
|
var smartSound = smartSoundList[index];
|
ShowRenameDialog(row, smartSound);
|
|
};
|
|
// 解除绑定
|
row.btnDelect.ButtonClickEvent += (sender, e) =>
|
{
|
//
|
int index = (int)(((NormalViewControl)sender).GetTagByKey("index"));
|
ShowDelectDialog(index);
|
};
|
|
//跳转到控制内容界面
|
row.frameTable.ButtonClickEvent += (sender, e) =>
|
{
|
var smartSoundControlForm = new SmartSoundControlForm();
|
smartSoundControlForm.AddForm();
|
};
|
}
|
}
|
|
/// <summary>
|
/// 解除绑定弹窗
|
/// </summary>
|
private void ShowDelectDialog(int index)
|
{
|
this.ShowMassage(ShowMsgType.Confirm, "接触绑定需要第三方 APP 进行操作", () =>
|
{
|
//
|
smartSoundList.RemoveAt(index);
|
listView.RemoveAt(index);
|
},"跳转至小度 APP");
|
}
|
|
/// <summary>
|
/// 重命名弹窗
|
/// </summary>
|
/// <returns></returns>
|
private void ShowRenameDialog(SoundRowLayout soundRowLayout, SmartSound smartSound)
|
{
|
//生成一个弹窗画面
|
var dialogForm = new DialogInputControl();
|
//添加备份
|
dialogForm.SetTitleText("重命名");
|
//请输入备份名称
|
dialogForm.SetTipText(smartSound.Remark);
|
|
//按下确认按钮
|
dialogForm.ComfirmClickEvent += ((textValue) =>
|
{
|
|
//画面关闭
|
dialogForm.CloseDialog();
|
|
//上传备份
|
smartSound.Remark = textValue;
|
soundRowLayout.btnRemark.Text= textValue;
|
});
|
}
|
|
/// <summary>
|
/// 初始化模拟一些数据,用来加载界面用的
|
/// </summary>
|
private void iniData()
|
{
|
smartSoundList = new List<SmartSound>();
|
|
// 增加小度音箱
|
SmartSound smartSound = new SmartSound();
|
smartSound.Remark = "我的音箱";
|
smartSound.UserName = "123456@qq.com";
|
smartSound.Type = SmartSound.SMARTSOUND_XIAODU;
|
smartSoundList.Add(smartSound);
|
|
// 增加小爱音箱
|
smartSound = new SmartSound();
|
smartSound.Remark = "我的音箱";
|
smartSound.UserName = "234567@qq.com";
|
smartSound.Type = SmartSound.SMARTSOUND_XIAOAI;
|
smartSoundList.Add(smartSound);
|
|
// 增加天猫精灵
|
smartSound = new SmartSound();
|
smartSound.Remark = "我的音箱";
|
smartSound.UserName = "345678@qq.com";
|
smartSound.Type = SmartSound.SMARTSOUND_TIANMAO;
|
smartSoundList.Add(smartSound);
|
}
|
|
#endregion
|
|
|
#region ■ 界面重新激活事件___________________
|
|
/// <summary>
|
/// 自身的上层界面关闭后,它自身处于最上层时,触发的事件
|
/// </summary>
|
public override int FormActionAgainEvent()
|
{
|
return 1;
|
}
|
|
#endregion
|
|
#region ■ 关闭界面___________________________
|
|
/// <summary>
|
/// 画面关闭
|
/// </summary>
|
public override void CloseFormBefore()
|
{
|
base.CloseFormBefore();
|
}
|
|
#endregion
|
|
}
|
}
|