📄 frmmain.cs
字号:
// Build by Jaffy Chan
// Date: 23 Jan 2007
#region Using directives
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
#endregion
namespace UI
{
/// <summary>
/// Summary description for form.
/// </summary>
public class frmMain : System.Windows.Forms.Form
{
private MenuItem menuItemQuit;
private MenuItem menuItemMenu;
private int signalSent;
private PictureBox pictureBox1;
private MenuItem menuItemRemote;
private MenuItem menuItemDisconnected;
private MenuItem menuItemBrowse;
private MainMenu mainMenuForDisconnected;
private MenuItem menuItem1;
private MenuItem menuItem2;
private MenuItem menuItemNew;
private MenuItem menuItemProfile;
bool isConnected;
/// <summary>
/// Main menu for the form.
/// </summary>
private System.Windows.Forms.MainMenu mainMenuForConnected;
//internal System.Windows.Forms.ImageList ImageList1;
BTHWrapper.BTHConnector _connector;
private MenuItem menuItem3;
Profile.ProfileList _lstProfile;
public frmMain()
{
_connector = new BTHWrapper.BTHConnector();
_lstProfile = new Profile.ProfileList();
//_connector.InitialiseBluetooth();
_connector.InitialiseSocket();
InitializeComponent();
// In the constructor of the form, wire the
// KeyPressEventHandler to the KeyPress event.
//this.KeyPress += new KeyPressEventHandler(OnKeyPress);
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
this.mainMenuForConnected = new System.Windows.Forms.MainMenu();
this.menuItemQuit = new System.Windows.Forms.MenuItem();
this.menuItemMenu = new System.Windows.Forms.MenuItem();
this.menuItemRemote = new System.Windows.Forms.MenuItem();
this.menuItemDisconnected = new System.Windows.Forms.MenuItem();
this.menuItemBrowse = new System.Windows.Forms.MenuItem();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.mainMenuForDisconnected = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItemNew = new System.Windows.Forms.MenuItem();
this.menuItemProfile = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
//
// mainMenuForConnected
//
this.mainMenuForConnected.MenuItems.Add(this.menuItemQuit);
this.mainMenuForConnected.MenuItems.Add(this.menuItemMenu);
//
// menuItemQuit
//
this.menuItemQuit.Enabled = ((bool)(resources.GetObject("menuItemQuit.Enabled")));
this.menuItemQuit.Text = resources.GetString("menuItemQuit.Text");
this.menuItemQuit.Click += new System.EventHandler(this.menuItemQuit_Click);
//
// menuItemMenu
//
this.menuItemMenu.Enabled = ((bool)(resources.GetObject("menuItemMenu.Enabled")));
this.menuItemMenu.MenuItems.Add(this.menuItemRemote);
this.menuItemMenu.MenuItems.Add(this.menuItemDisconnected);
this.menuItemMenu.MenuItems.Add(this.menuItemBrowse);
this.menuItemMenu.Text = resources.GetString("menuItemMenu.Text");
//
// menuItemRemote
//
this.menuItemRemote.Enabled = ((bool)(resources.GetObject("menuItemRemote.Enabled")));
this.menuItemRemote.Text = resources.GetString("menuItemRemote.Text");
this.menuItemRemote.Click += new System.EventHandler(this.menuItem1_Click);
//
// menuItemDisconnected
//
this.menuItemDisconnected.Enabled = ((bool)(resources.GetObject("menuItemDisconnected.Enabled")));
this.menuItemDisconnected.Text = resources.GetString("menuItemDisconnected.Text");
this.menuItemDisconnected.Click += new System.EventHandler(this.menuItemDisconnected_Click);
//
// menuItemBrowse
//
this.menuItemBrowse.Enabled = ((bool)(resources.GetObject("menuItemBrowse.Enabled")));
this.menuItemBrowse.Text = resources.GetString("menuItemBrowse.Text");
this.menuItemBrowse.Click += new System.EventHandler(this.menuItem3_Click);
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.SystemColors.Highlight;
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = ((System.Drawing.Point)(resources.GetObject("pictureBox1.Location")));
this.pictureBox1.Size = ((System.Drawing.Size)(resources.GetObject("pictureBox1.Size")));
this.pictureBox1.SizeMode = ((System.Windows.Forms.PictureBoxSizeMode)(resources.GetObject("pictureBox1.SizeMode")));
this.pictureBox1.Visible = ((bool)(resources.GetObject("pictureBox1.Visible")));
//
// mainMenuForDisconnected
//
this.mainMenuForDisconnected.MenuItems.Add(this.menuItem1);
this.mainMenuForDisconnected.MenuItems.Add(this.menuItem2);
//
// menuItem1
//
this.menuItem1.Enabled = ((bool)(resources.GetObject("menuItem1.Enabled")));
this.menuItem1.Text = resources.GetString("menuItem1.Text");
this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click_1);
//
// menuItem2
//
this.menuItem2.Enabled = ((bool)(resources.GetObject("menuItem2.Enabled")));
this.menuItem2.MenuItems.Add(this.menuItemNew);
this.menuItem2.MenuItems.Add(this.menuItemProfile);
this.menuItem2.MenuItems.Add(this.menuItem3);
this.menuItem2.Text = resources.GetString("menuItem2.Text");
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// menuItemNew
//
this.menuItemNew.Enabled = ((bool)(resources.GetObject("menuItemNew.Enabled")));
this.menuItemNew.Text = resources.GetString("menuItemNew.Text");
this.menuItemNew.Click += new System.EventHandler(this.menuItemNew_Click);
//
// menuItemProfile
//
this.menuItemProfile.Enabled = ((bool)(resources.GetObject("menuItemProfile.Enabled")));
this.menuItemProfile.Text = resources.GetString("menuItemProfile.Text");
this.menuItemProfile.Click += new System.EventHandler(this.menuItemProfile_Click);
//
// menuItem3
//
this.menuItem3.Enabled = ((bool)(resources.GetObject("menuItem3.Enabled")));
this.menuItem3.Text = resources.GetString("menuItem3.Text");
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click_1);
//
// frmMain
//
this.BackColor = System.Drawing.SystemColors.Highlight;
this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize")));
this.Controls.Add(this.pictureBox1);
this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font")));
this.Location = ((System.Drawing.Point)(resources.GetObject("$this.Location")));
this.Menu = this.mainMenuForDisconnected;
this.Text = resources.GetString("$this.Text");
this.GotFocus += new System.EventHandler(this.frmMain_GotFocus);
this.Load += new System.EventHandler(this.frmMain_Load);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
Application.Run(new frmMain());
}
private void frmMain_Load(object sender, EventArgs e)
{
System.Reflection.Assembly exAs = System.Reflection.Assembly.GetExecutingAssembly();
//if (isConnected == true)
//{
// // Invisible Remote Controller MenuItem
// menuItemRemote.Enabled = false;
//}else menuItemRemote.Enabled = true;
isConnected = false;
}
private void frmMain_GotFocus(object sender, EventArgs e) {
//if (isConnected == true)
//{
// Menu = mainMenuForConnected;
//}
//else {
// Menu = mainMenuForDisconnected;
//}
}
private void menuItemQuit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void SignalOut(int _signalSent, string _menuChoiceStr) {
MessageBox.Show("SignalSent: " + _signalSent.ToString() + "\n" + "Item Selected: "+_menuChoiceStr);
}
private void subMenu1_Click(object sender, EventArgs e)
{
frmCreateProfile1 fNS = new frmCreateProfile1(_connector, _lstProfile);
fNS.Show();
//TODO: Ensure Ehome Appeared
this.Text = "Bluetooth Remote";
}
private void menuItem1_Click(object sender, EventArgs e)
{
//Application.Exit();
frmRemoteControl frmB = new frmRemoteControl(_connector);
frmB.Show();
}
private void menuItem3_Click(object sender, EventArgs e)
{
}
private void menuItem1_Click_1(object sender, EventArgs e)
{
Application.Exit();
}
private void menuItemDisconnected_Click(object sender, EventArgs e)
{
///TODO:
/// Add disconnect method here;
///
this.isConnected = false;
this.Menu = this.mainMenuForDisconnected;
}
private void menuItemProfile_Click(object sender, EventArgs e)
{
frmConnectProfile frmCP = new frmConnectProfile(_connector, _lstProfile);
frmCP.Show();
}
private void menuItemNew_Click(object sender, EventArgs e)
{
frmCreateProfile1 frmCreateProfile = new frmCreateProfile1(_connector,_lstProfile);
frmCreateProfile.Show();
}
private void menuItem2_Click(object sender, EventArgs e)
{
//Temp assignment for switching mainMenuConnected and mainMenuDisconnected
this.isConnected = true;
}
private void menuItem3_Click_1(object sender, EventArgs e)
{
frmEditProfile frmEP = new frmEditProfile(_lstProfile);
frmEP.Show();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -