示例#1
0
        public MainWindow()
        {
            InitializeComponent();
            if (Resources[nameof(InputMethodCollection)] is InputMethodCollection collec)
            {
                InputProcessorProfiles inputProcessorProfiles = new InputProcessorProfiles();

                //var kk = inputProcessorProfiles.GetInputProcessorInfo();

                foreach (var id in inputProcessorProfiles.LanguageIDs)
                {
                    var    profiles = inputProcessorProfiles.GetLanguageProfiles(id);
                    string langName = inputProcessorProfiles.GetLanguageName(id);
                    foreach (var profile in profiles)
                    {
                        if (inputProcessorProfiles.IsEnabledLanguageProfile(profile))
                        {
                            collec.Add(new InputMethod()
                            {
                                Profile     = profile,
                                Description = $"{langName} - {inputProcessorProfiles.GetLanguageProfileDescription(profile)}"
                            });
                        }
                    }
                }
            }
        }
示例#2
0
 private void CurrentInputMethod_Click(object sender, RoutedEventArgs e)
 {
     if (sender is Button button)
     {
         using (InputProcessorProfiles inputProcessorProfiles = new InputProcessorProfiles()) {
             button.Content = inputProcessorProfiles.GetCurrentLanguageProfileName();
         }
     }
 }
示例#3
0
        private void SelectInputMethod_Click(object sender, RoutedEventArgs e)
        {
            int i = InputMethodListBox.SelectedIndex;

            if (i >= 0)
            {
                var im = InputMethodListBox.SelectedValue as InputMethod;
                using (InputProcessorProfiles inputProcessorProfiles = new InputProcessorProfiles()) {
                    try {
                        inputProcessorProfiles.ActivateLanguageProfile(im.Profile);
                    } catch (Exception) {
                    }
                }
            }
        }
示例#4
0
 private void SetDefaultInputMethod_Click(object sender, RoutedEventArgs e)
 {
     if (sender is Button button)
     {
         int i = InputMethodListBox.SelectedIndex;
         if (i >= 0)
         {
             var im = InputMethodListBox.SelectedValue as InputMethod;
             using (InputProcessorProfiles inputProcessorProfiles = new InputProcessorProfiles()) {
                 try {
                     inputProcessorProfiles.SetDefaultLanguageProfile(im.Profile);
                     button.Content = "設定預設輸入法";
                 } catch (Exception ex) {
                     button.Content = ex.Message;
                 }
             }
         }
     }
 }