using System;
|
using System.Collections.Generic;
|
using System.Net;
|
using System.Net.Sockets;
|
using System.Text;
|
using Shared;
|
using Shared.SimpleControl;
|
using Shared.SimpleControl.Phone.Music;
|
using Shared.SimpleControl.R;
|
|
namespace SmartHome
|
{
|
class WiFiSet : FrameLayout
|
{
|
public static Action refreshView;
|
FrameLayout middle;
|
|
|
public void Show ()
|
{
|
|
AddChidren (new Button {
|
Height = Application.GetRealHeight (36),
|
BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
|
});
|
|
var topFrameLayout = new FrameLayout {
|
Height = Application.GetRealHeight (100),
|
Y = Application.GetRealHeight (36),
|
BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
|
};
|
AddChidren (topFrameLayout);
|
|
var btnset = new Button {
|
TextID = MyInternationalizationString.Setting,
|
TextColor = SkinStyle.Current.MusicTextColor,
|
//Text = "设置",
|
};
|
topFrameLayout.AddChidren (btnset);
|
|
var hdl = new Button {
|
Width = Application.GetRealWidth (154),
|
Height = Application.GetRealHeight (90),
|
X = Application.GetRealWidth (486),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = MainPage.LogoString,
|
};
|
topFrameLayout.AddChidren (hdl);
|
var back = new Button {
|
Width = Application.GetRealWidth (82),
|
Height = Application.GetRealHeight (89),
|
X = Application.GetRealWidth (10),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "MusicIcon/HomepageBack.png",
|
};
|
topFrameLayout.AddChidren (back);
|
back.MouseDownEventHandler += (sender, e) => {
|
RemoveFromParent ();
|
refreshView = null;
|
};
|
|
middle = new FrameLayout ();
|
middle.Y = topFrameLayout.Bottom;
|
middle.Height = Application.GetRealHeight (Application.DesignHeight - 136);
|
middle.BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout;
|
AddChidren (middle);
|
|
refreshView += () => {
|
refreshView = null;
|
RemoveFromParent ();
|
var wifiSet = new WiFiSet ();
|
MainPage.MainFrameLayout.AddChidren (wifiSet);
|
wifiSet.Show ();
|
MainPage.Loading.Start (Language.StringByID (MyInternationalizationString.load));
|
System.Threading.Tasks.Task.Run (() => {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
wifiSet.Init ();
|
});
|
});
|
};
|
|
}
|
|
public void Init ()
|
{
|
var radius = new Button {
|
Width = Application.GetRealWidth (50),
|
Height = Application.GetRealHeight (50),
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (30),
|
UnSelectedImagePath = "MusicIcon/radius.png",
|
Y = Application.GetRealHeight (73),
|
};
|
middle.AddChidren (radius);
|
|
|
var btnnulltxet1 = new Button {
|
Height = Application.GetRealHeight (50),
|
Width = Application.GetRealWidth (560),
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (70),
|
Y = Application.GetRealHeight (70),
|
TextColor = SkinStyle.Current.MusicTextColor,
|
};
|
middle.AddChidren (btnnulltxet1);
|
|
var btnnulltxet2 = new Button {
|
Height = Application.GetRealHeight (50),
|
Width = Application.GetRealWidth (500),
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (70),
|
Y = Application.GetRealHeight (120),
|
TextColor = SkinStyle.Current.MusicTextColor,
|
};
|
middle.AddChidren (btnnulltxet2);
|
|
|
var btntxet1 = new Button {
|
Height = Application.GetRealHeight (50),
|
Width = Application.GetRealWidth (560),
|
TextAlignment = TextAlignment.CenterLeft,
|
Y = Application.GetRealHeight (70),
|
X = Application.GetRealWidth (70),
|
TextColor = SkinStyle.Current.MusicTextColor,
|
};
|
middle.AddChidren (btntxet1);
|
|
var btntxet2 = new Button {
|
Height = Application.GetRealHeight (50),
|
Width = Application.GetRealWidth (560),
|
TextAlignment = TextAlignment.CenterLeft,
|
Y = Application.GetRealHeight (120),
|
X = Application.GetRealWidth (70),
|
TextColor = SkinStyle.Current.MusicTextColor,
|
};
|
middle.AddChidren (btntxet2);
|
|
var btntxet3 = new Button {
|
Height = Application.GetRealHeight (50),
|
Width = Application.GetRealWidth (560),
|
TextAlignment = TextAlignment.CenterLeft,
|
Y = Application.GetRealHeight (170),
|
X = Application.GetRealWidth (70),//
|
TextColor = SkinStyle.Current.MusicTextColor,
|
};
|
middle.AddChidren (btntxet3);
|
|
var btnicon = new Button {
|
Height = Application.GetRealHeight (537),
|
Width = Application.GetRealWidth (535),
|
// TextAlignment = TextAlignment.CenterLeft,
|
Y = Application.GetRealHeight (200),
|
X = Application.GetRealWidth (45),
|
TextColor = SkinStyle.Current.MusicTextColor,
|
};
|
middle.AddChidren (btnicon);
|
///引导图片的Button
|
if (Application.DeviceType == Device.Android) {
|
btnicon.UnSelectedImagePath = "MusicIcon/androidwifi.png";
|
} else {
|
btnicon.UnSelectedImagePath = "MusicIcon/iossetwifi.png";
|
}
|
|
var btnwifiset = new Button {
|
Width = Application.GetRealWidth (580),
|
Height = Application.GetRealHeight (80),
|
Text = Language.StringByID (MyInternationalizationString.Setting) + "Wi-Fi",
|
TextSize = 20,
|
X = Application.GetRealWidth (30),
|
Y = Application.GetRealHeight (820),
|
BackgroundColor = 0xff656565,
|
Radius = (uint)Application.GetRealHeight (16),
|
};
|
middle.AddChidren(btnwifiset);
|
///调用手机设置界面的点击事件
|
btnwifiset.MouseUpEventHandler += (sen, e) => {
|
//RemoveFromParent ();
|
if (Application.DeviceType == Device.Android) {
|
///打开设置界面
|
//CommonClass.OpenAction ("android.settings.SETTINGS");
|
///打开WI-IF界面
|
CommonClass.OpenAction ("android.settings.WIFI_SETTINGS");
|
} else {
|
CommonClass.OpenAction ("App-Prefs:root=WIFI");
|
}
|
};
|
|
try {
|
///判断手机当前连接WI-IF是以HDL开头
|
if (WiimuUPnP.SSID != null && WiimuUPnP.SSID.StartsWith ("HDL")) {
|
refreshView = null;
|
RemoveFromParent ();
|
var a31wifi = new A31Wifi ();
|
MainPage.MainFrameLayout.AddChidren (a31wifi);
|
a31wifi.Show ();
|
|
MainPage.Loading.Start (Language.StringByID (MyInternationalizationString.load));
|
System.Threading.Tasks.Task.Run (() => {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
a31wifi.Init ();
|
});
|
});
|
} else if (WiimuUPnP.SSID == null) {
|
if (Language.CurrentLanguage == "English") {
|
btnnulltxet1.Text = "Your cellphone hasn't open the Wi-Fi yet,";
|
btnnulltxet2.Text = "please open it and search again .";
|
}else{
|
btnnulltxet1.TextID = MyInternationalizationString.searchwifi;
|
}
|
} else {
|
if (Language.CurrentLanguage == "English") {
|
btntxet1.Text = "Go to the wireless LAN interface of cellphone.";
|
btntxet2.Text = "Select the Wi-Fi which is named HDL*** as";
|
btntxet3.Text = "beginning to connect.";
|
} else {
|
btntxet1.TextID = MyInternationalizationString.WirelessLANinterface;
|
btntxet2.TextID = MyInternationalizationString.Makeconnection;
|
}
|
|
}
|
} catch { }
|
|
|
}
|
|
}
|
}
|