📄 frmcreateprofile1.cs
字号:
this.label4.Font = new System.Drawing.Font("Nina", 9F, System.Drawing.FontStyle.Bold);
this.label4.Location = new System.Drawing.Point(148, 222);
this.label4.Size = new System.Drawing.Size(3, 30);
this.label4.Text = ":";
this.label4.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.label4.Visible = false;
//
// txtBTAddr5
//
this.txtBTAddr5.Enabled = false;
this.txtBTAddr5.Font = new System.Drawing.Font("Nina", 9F, System.Drawing.FontStyle.Regular);
this.txtBTAddr5.Location = new System.Drawing.Point(157, 222);
this.txtBTAddr5.MaxLength = 2;
this.txtBTAddr5.Size = new System.Drawing.Size(21, 28);
//
// label5
//
this.label5.Font = new System.Drawing.Font("Nina", 9F, System.Drawing.FontStyle.Bold);
this.label5.Location = new System.Drawing.Point(184, 222);
this.label5.Size = new System.Drawing.Size(3, 30);
this.label5.Text = ":";
this.label5.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.label5.Visible = false;
//
// txtBTAddr6
//
this.txtBTAddr6.Enabled = false;
this.txtBTAddr6.Font = new System.Drawing.Font("Nina", 9F, System.Drawing.FontStyle.Regular);
this.txtBTAddr6.Location = new System.Drawing.Point(193, 222);
this.txtBTAddr6.MaxLength = 2;
this.txtBTAddr6.Size = new System.Drawing.Size(21, 28);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(12, 42);
this.textBox1.Size = new System.Drawing.Size(207, 33);
//
// label6
//
this.label6.Location = new System.Drawing.Point(12, 9);
this.label6.Size = new System.Drawing.Size(207, 30);
this.label6.Text = "Profile Name:";
//
// label7
//
this.label7.Location = new System.Drawing.Point(12, 114);
this.label7.Size = new System.Drawing.Size(207, 30);
this.label7.Text = "Device:";
//
// frmConnectNew
//
this.ClientSize = new System.Drawing.Size(240, 266);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.checkBoxConnectManually);
this.Controls.Add(this.label1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label3);
this.Controls.Add(this.label4);
this.Controls.Add(this.label5);
this.Controls.Add(this.txtBTAddr1);
this.Controls.Add(this.txtBTAddr2);
this.Controls.Add(this.txtBTAddr3);
this.Controls.Add(this.txtBTAddr4);
this.Controls.Add(this.txtBTAddr5);
this.Controls.Add(this.txtBTAddr6);
this.Controls.Add(this.label6);
this.Controls.Add(this.label7);
this.Menu = this.mainMenu1;
this.Text = "New Search";
}
#endregion
private void menuItemCreateProfile_Click(object sender, EventArgs e)
{
_profileList.LoadFile(Global.PROFILE_PATH);
string strAddr = "";
if (!_profileList.IsProfileExists(textBox1.Text))
{
if (checkBoxConnectManually.Checked == true)
{
strAddr = txtBTAddr1.Text + ":" + txtBTAddr2.Text + ":" + txtBTAddr3.Text + ":" + txtBTAddr4.Text + ":" + txtBTAddr5.Text + ":" + txtBTAddr6.Text;
}
else
{
strAddr = comboBox1.SelectedValue.ToString();
}
if (strAddr.Equals(""))
{
Global.ShowCaution("Please enter a adderss", "Invaild Address");
}
if (!BTHWrapper.BTHUtil.IsAddressVaild(strAddr))
{
Global.ShowCaution("Invaild Address", "Invaild Address");
}
else
{
BTHWrapper.DeviceItem p = new BTHWrapper.DeviceItem();
if (comboBox1.Items.Count == 0)
{
p.DeviceName = "<unknown>";
}
else
{
p = (BTHWrapper.DeviceItem)comboBox1.SelectedItem;
}
Profile.Profile newProfile = new Profile.Profile(textBox1.Text, strAddr, p.DeviceName, "", "");
//_profileList.AddProfile(textBox1.Text, strAddr, p.DeviceName, "", "");
//_profileList.SaveFile(Global.PROFILE_PATH);
frmCreateProfile2 frmCreateProfile = new frmCreateProfile2(_connector, _profileList, newProfile);
frmCreateProfile.Show();
this.Dispose();
//Profile p = new Profile(textBox1.Text, strAddr, comboBox1.SelectedItem.ToString(), "", "");
/*
frmConnectProfile frmCP = new frmConnectProfile(_connector,_profileList);
frmCP.Show();
this.Dispose();*/
}
}
else
{
Global.ShowCaution("Profile name already exists.\nPlease choose another name.","Invalid Data");
}
}
private void checkBox1_CheckStateChanged(object sender, EventArgs e)
{
if (checkBoxConnectManually.Checked == false){
//txtBTAddr1.Text = "";
comboBox1.Enabled = true;
SetLbAddr(false);
SetTbAddr(false);
}
else {
//txtBTAddr1.Enabled = true;
//txtBTAddr1.Focus();
comboBox1.Enabled = false;
SetLbAddr(true);
SetTbAddr(true);
}
}
private void SetTbAddr(bool b)
{
txtBTAddr1.Enabled = b;
txtBTAddr2.Enabled = b;
txtBTAddr3.Enabled = b;
txtBTAddr4.Enabled = b;
txtBTAddr5.Enabled = b;
txtBTAddr6.Enabled = b;
}
private void SetLbAddr(bool b)
{
label1.Visible = b;
label2.Visible = b;
label3.Visible = b;
label4.Visible = b;
label5.Visible = b;
}
private void menuItemCancel_Click(object sender, EventArgs e)
{
this.Dispose();
}
private void menuItemSearch_Click(object sender, EventArgs e)
{
_deviceList = _connector.FindDevice();
if (_deviceList.Count >0)
{
comboBox1.DataSource = _deviceList;
comboBox1.DisplayMember = "DeviceName";
comboBox1.ValueMember = "Address";
}
else
{
Global.ShowCaution("No devices found", "Search error");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -