using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace InputLanguageSwitch
{
/// <summary>
/// 獲取系統所有的輸入法,並可以程序改變當前輸入法;打開關閉軟鍵盤。
/// 程序:房客
/// QQ:83849123
/// Blog:http://www.cnblogs.com/sxlfybb
/// </summary>
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.InputLanguageChanged += new InputLanguageChangedEventHandler(Form1_InputLanguageChanged);
}
void Form1_InputLanguageChanged(object sender, InputLanguageChangedEventArgs e)
{
//throw new Exception("The method or Operation is not implemented.");
for( int i=0;i<comboBox1.Items.Count;i++)
{
if (InputLanguage.CurrentInputLanguage.LayoutName == comboBox1.Items[i].ToString())
{
comboBox1.SelectedIndex = i;
}
}
}
private void comboBox1_SelectedIndExchanged(object sender, EventArgs e)
{
string strTemp = comboBox1.Items[comboBox1.SelectedIndex].ToString();
InputLanguageCollection collects = InputLanguage.InstalledInputLanguages;
for (int i = 0; i < collects.Count; i++)
{
if (collects[i].LayoutName == strTemp)
InputLanguage.CurrentInputLanguage = collects[i];
}
}
private void Form1_Load(object sender, EventArgs e)
{
InputLanguageCo