using System;
using System.Collections.Generic;
using Shared.Phone.UserCenter;
using Shared.Phone.UserCenter.SmartSound.Forms;
namespace Shared.Phone.SmartSound.Forms
{
public class AddSmartSound : EditorCommonForm
{
/// 列表控件
///
private VerticalListControl listView = null;
private FrameLayout contentLayout = null;
///
/// 当前楼层的索引
///
public int CurrentIndex = 0;
private BottomClickButton bottomClickButton = null;
private RoomRowLayout xiaoduRowLayout = null;//小度
private RoomRowLayout sbcRowLayout = null;
///
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
///
public void ShowForm()
{
this.ScrollEnabled = false;
base.SetTitleText("添加音箱");//设置标题信息
contentLayout = new FrameLayout();
this.bodyFrameLayout.AddChidren(contentLayout);
IniAllDataView();
}
#region 加载本地所有数据,生成供用户选择房间的界面
private void IniAllDataView()
{
contentLayout.RemoveAll();
if (listView == null)
{
listView = new VerticalListControl();
contentLayout.AddChidren(listView);
listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(173);
}
Sound sound = new Sound();
//添加小度音箱
sound.Checked = false;
sound.Name = "小度";
sound.type = 0;
xiaoduRowLayout = new RoomRowLayout(sound);
listView.AddChidren(xiaoduRowLayout);
xiaoduRowLayout.InitControl();
xiaoduRowLayout.Right_icon.IsSelected = true;
xiaoduRowLayout.ButtonClickEvent += (sender, e) =>
{
xiaoduRowLayout.Right_icon.IsSelected = true;
sbcRowLayout.Right_icon.IsSelected = false;
CurrentIndex = 0;
};
//添加思必驰音箱
sound.Checked = false;
sound.Name = "思必驰";
sound.type = 1 ;
sbcRowLayout = new RoomRowLayout(sound);
listView.AddChidren(sbcRowLayout);
sbcRowLayout.InitControl();
sbcRowLayout.Right_icon.IsSelected = false;
sbcRowLayout.ButtonClickEvent += (sender, e) =>
{
xiaoduRowLayout.Right_icon.IsSelected = false;
sbcRowLayout.Right_icon.IsSelected = true;
CurrentIndex = 1;
};
//跳转至第三方下载按钮
bottomClickButton = new BottomClickButton();
this.bodyFrameLayout.AddChidren(bottomClickButton);
bottomClickButton.Text = "跳转至第三方APP";
bottomClickButton.ButtonClickEvent += (sender, e) =>
{
//
if (CurrentIndex == 0)
{
OpenXiaoDuAPP();
}
else if (CurrentIndex == 1)
{
OpenSBCAPP();
}
};
//bottomClickButton.Visible = false;
}
///
/// 小度
///
private void OpenXiaoDuAPP()
{
bool bol = false;
try
{
#if Android
bol = HDLUtils.OpenAppWithPackageName("com.baidu.duer.superapp");
#else
bol=HDLUtils.OpenApp("xiaoduapp://");
#endif
if (!bol)
{
#if Android
HDLUtils.OpenUrl("market://details?id=com.baidu.duer.superapp");
#else
HDLUtils.OpenUrl("https://apps.apple.com/cn/app/%E5%B0%8F%E5%BA%A6/id1437733193");
#endif
}
}
catch (Exception e)
{
string error = e.Message;
bol = false;
}
}
///
/// 思必驰
///
private void OpenSBCAPP()
{
bool bol = false;
try
{
#if Android
bol = HDLUtils.OpenAppWithPackageName("com.aispeech.companionapp");
#else
bol=HDLUtils.OpenApp("AispeechMobile://");
#endif
if (!bol)
{
#if Android
HDLUtils.OpenUrl("market://details?id=com.aispeech.companionapp");
#else
HDLUtils.OpenUrl("https://apps.apple.com/cn/app/id1460767442");
#endif
}
}
catch (Exception e)
{
string error = e.Message;
bol = false;
}
}
#endregion
#region ■ 自定义房间选择控件_____________________
///
/// 房间列表行
///
private class RoomRowLayout : FrameRowControl
{
///
/// 房间名称
///
private NormalViewControl btnName = null;
///
///
///
private Sound sound=null;
public MostRightIconControl Right_icon = null;
private IconViewControl iconViewControl = null;
private NormalViewControl bottomLine = null;
///
/// 房间列表行
///
public RoomRowLayout(Sound _sound)
{
this.sound = _sound;
this.UseClickStatu = false;
this.BackgroundColor = UserCenterColor.Current.White;
this.Height = Application.GetRealHeight(170);
}
///
/// 初始化控件
///
public void InitControl()
{
//图标
if (sound.type == 0)
{
iconViewControl = this.AddLeftIcon(81, "SmartSound/Xiaodu.png");
}
else
{
iconViewControl = this.AddLeftIcon(81, "SmartSound/Sibici.png");
}
//显示文本
btnName = this.AddLeftCaption(string.Empty, 2000);
btnName.Height = Application.GetRealHeight(60);
btnName.TextSize = 14;
btnName.Y = Application.GetRealHeight(57);
btnName.Text = sound.Name;
//btnName.X = iconViewControl.X + iconViewControl.Width ;
Right_icon = this.AddMostRightEmptyIcon(58, 58);
Right_icon.Gravity = Gravity.CenterVertical;
Right_icon.SelectedImagePath = "Item/ItemSelected.png";
Right_icon.UnSelectedImagePath = "Item/ItemUnSelected.png";
bottomLine = AddBottomLine();
bottomLine.X = btnName.X;
}
}
#endregion
private class Sound
{
public int type = 0;
public string Name="";
public bool Checked = false;
}
}
}