using System;
|
using System.Collections.Generic;
|
using System.Text;
|
|
namespace Shared.Phone.UserCenter.HideOption
|
{
|
public class AndroidBluetoothTestForm2 : EditorCommonForm
|
{
|
#region ■ 变量声明___________________________
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
/// </summary>
|
public void ShowForm()
|
{
|
//设置头部信息
|
base.SetTitleText("自定义发送内容");
|
|
//初始化中部信息
|
this.InitMiddleFrame();
|
}
|
|
/// <summary>
|
/// 初始化中部信息
|
/// </summary>
|
private void InitMiddleFrame()
|
{
|
//清空bodyFrame
|
this.ClearBodyFrame();
|
|
var txtInput = new EditTextView();
|
txtInput.Width = bodyFrameLayout.Width - ControlCommonResourse.XXLeft * 2;
|
txtInput.Height = Application.GetRealHeight(470);
|
txtInput.Y = Application.GetRealHeight(32);
|
txtInput.TextAlignment = TextAlignment.TopLeft;
|
txtInput.Gravity = Gravity.CenterHorizontal;
|
txtInput.TextColor = UserCenterColor.Current.TextColor1;
|
bodyFrameLayout.AddChidren(txtInput);
|
|
var mySendData = new SendData();
|
mySendData.ssid = HdlWifiLogic.Current.SSID;
|
txtInput.Text = Newtonsoft.Json.JsonConvert.SerializeObject(mySendData);
|
|
var btnSend = new BottomClickButton();
|
btnSend.Text = "发送";
|
bodyFrameLayout.AddChidren(btnSend);
|
btnSend.ButtonClickEvent += (sender, e) =>
|
{
|
btnSend.CanClick = false;
|
string sendData = txtInput.Text.Trim();
|
HdlThreadLogic.Current.RunThread(() =>
|
{
|
if (HdlAndroidBluetoothLogic.Current.SendData(sendData, 1) == true)
|
{
|
this.ShowMassage(ShowMsgType.Tip, "发送成功");
|
}
|
else
|
{
|
this.ShowMassage(ShowMsgType.Tip, "发送失败");
|
}
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
btnSend.CanClick = true;
|
});
|
});
|
|
};
|
}
|
|
#endregion
|
|
#region ■ 界面关闭___________________________
|
|
public override void CloseFormBefore()
|
{
|
HdlAndroidBluetoothLogic.Current.DisContectBluetooth();
|
|
base.CloseFormBefore();
|
}
|
|
#endregion
|
|
#region ■ 结构体_____________________________
|
|
private class SendData
|
{
|
public string id = "id010203";
|
public string ssid = string.Empty;
|
public string password = "hdl1985..";
|
public string gatewayIp = "172.16.2.209";
|
public int port = 8888;
|
}
|
|
#endregion
|
}
|
}
|