void TranslateMainFormInputLanguageChanged(object sender, InputLanguageChangedEventArgs e) { UpdateCurrentInputLanguage(); if(!TranslateOptions.Instance.GuessingOptions.SwitchDirectionBasedOnLayout) return; if(skipChangeLayout) return; if(languageSelector.Selection == null) return; if(!InputLanguageManager.IsLanguageSupported(languageSelector.Selection.From)) { bool default_selected = currentProfile == TranslateOptions.Instance.DefaultProfile; UserTranslateProfile upf; //step 0. seek in current if not default upf = currentProfile as UserTranslateProfile; if(upf != null) { if(upf.TranslationDirection.From == Language.Any || InputLanguageManager.IsLanguageSupported(upf.TranslationDirection.From)) { tbFrom.Focus(); return; } foreach(LanguagePair lp in languageSelector.History) { if(InputLanguageManager.IsLanguageSupported(lp.From)) { try { skipChangeInput = true; languageSelector.Selection = lp; UpdateCaption(); } finally { skipChangeInput = false; } tbFrom.Focus(); return; } } } //step 1. seek in history ProfilesHistory ph_to_delete = new ProfilesHistory(); bool found = false; foreach(ProfilesHistoryData phd in TranslateOptions.Instance.ProfilesHistory) { if(InputLanguageManager.IsLanguageSupported(phd.Language)) { TranslateProfile pf = TranslateOptions.Instance.Profiles.GetByName(phd.Name); if(pf == null) { //here we should not to be, but ph_to_delete.Add(phd); continue; } upf = pf as UserTranslateProfile; if(upf != null && (upf.TranslationDirection.From == Language.Any || InputLanguageManager.IsLanguageSupported(upf.TranslationDirection.From)) && !upf.ShowLanguages ) { skipChangeInput = true; ActivateProfile(upf); tbFrom.Focus(); found = true; break; } foreach(LanguagePair lp in pf.History) { if(InputLanguageManager.IsLanguageSupported(lp.From)) { try { skipChangeInput = true; ActivateProfile(pf); languageSelector.Selection = lp; UpdateCaption(); } finally { skipChangeInput = false; } tbFrom.Focus(); found = true; break; } } if(!found) ph_to_delete.Add(phd); else break; } } //remove unsupported profiles from history foreach(ProfilesHistoryData phd in ph_to_delete) TranslateOptions.Instance.ProfilesHistory.DeleteProfile(phd.Name); if(found) return; //step 2. Generate list of profiles. default - last TranslateProfilesCollection profiles = new TranslateProfilesCollection(); foreach(TranslateProfile pf in TranslateOptions.Instance.Profiles) { if(pf == TranslateOptions.Instance.DefaultProfile) continue; if(pf == currentProfile) continue; profiles.Add(pf); } profiles.Add(TranslateOptions.Instance.DefaultProfile); //step 2. seek in other not default profiles foreach(TranslateProfile pf in profiles) { foreach(LanguagePair lp in pf.History) { if(InputLanguageManager.IsLanguageSupported(lp.From)) { try { skipChangeInput = true; ActivateProfile(pf); languageSelector.Selection = lp; UpdateCaption(); } finally { skipChangeInput = false; } tbFrom.Focus(); return; } } upf = pf as UserTranslateProfile; if(upf != null) { if(InputLanguageManager.IsLanguageSupported(upf.TranslationDirection.From)) { skipChangeInput = true; ActivateProfile(upf); tbFrom.Focus(); return; } } } //switch auto upf = currentProfile as UserTranslateProfile; if((default_selected || (upf != null && upf.ShowLanguages)) && (currentProfile.SelectedLanguagePair.From != Language.Autodetect) ) { CultureInfo inputCulture = e.Culture; CultureInfo systemCulture = System.Threading.Thread.CurrentThread.CurrentUICulture; if(inputCulture.EnglishName == systemCulture.EnglishName || inputCulture.Parent.EnglishName == systemCulture.Parent.EnglishName ) { Language targetLanguage = Language.English; foreach(InputLanguage il in InputLanguage.InstalledInputLanguages) { if(inputCulture.EnglishName != il.Culture.EnglishName && inputCulture.Parent.EnglishName != il.Culture.Parent.EnglishName) { for(int i = 0; i < (int)Language.Last; i++) { if(InputLanguageManager.IsLanguageSupported(il, (Language)i)) { targetLanguage = (Language)i; goto EndDetect; } } } } EndDetect: foreach(LanguagePair lp in currentProfile.GetLanguagePairs()) { if(LanguageHelper.IsLanguageSupported(inputCulture, lp.From) && lp.To == targetLanguage ) { languageSelector.Selection = lp; tbFrom.Focus(); return; } } } else { foreach(LanguagePair lp in currentProfile.GetLanguagePairs()) { if(lp.From != Language.Any && LanguageHelper.IsLanguageSupported(inputCulture, lp.From) && LanguageHelper.IsLanguageSupported(systemCulture, lp.To) ) { languageSelector.Selection = lp; tbFrom.Focus(); return; } } } } } tbFrom.Focus(); }
protected virtual void OnInputLanguageChanged(InputLanguageChangedEventArgs e) { InputLanguageChangedEventHandler eh = (InputLanguageChangedEventHandler)(Events [InputLanguageChangedEvent]); if (eh != null) eh (this, e); }
protected virtual void OnInputLanguageChanged(InputLanguageChangedEventArgs e) { InputLanguageChangedEventHandler handler = (InputLanguageChangedEventHandler)Events[EVENT_INPUTLANGCHANGE]; if (handler != null) handler(this,e); }
/// <devdoc> /// Simulates a InputLanguageChanged event. Used by Control to forward events /// to the parent form. /// </devdoc> /// <internalonly/> internal void PerformOnInputLanguageChanged(InputLanguageChangedEventArgs iplevent) { OnInputLanguageChanged(iplevent); }
protected virtual void OnInputLanguageChanged(InputLanguageChangedEventArgs e);
/// <summary> /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed. /// <example> /// inputlanguagechangedeventhandler.BeginInvoke(sender, e, callback); /// </example> /// </summary> public static IAsyncResult BeginInvoke(this InputLanguageChangedEventHandler inputlanguagechangedeventhandler, Object sender, InputLanguageChangedEventArgs e, AsyncCallback callback) { if(inputlanguagechangedeventhandler == null) throw new ArgumentNullException("inputlanguagechangedeventhandler"); return inputlanguagechangedeventhandler.BeginInvoke(sender, e, callback, null); }
// The WinKeyboardAdaptor will subscribe to the Form's InputLanguageChanged event // only if TSF is not available. Otherwise this code won't be executed. private void OnWindowsMessageInputLanguageChanged(object sender, InputLanguageChangedEventArgs inputLanguageChangedEventArgs) { Debug.Assert(_keyboardAdaptor._profileNotifySinkCookie == 0); KeyboardDescription winKeyboard = _keyboardAdaptor.GetKeyboardForInputLanguage( inputLanguageChangedEventArgs.InputLanguage.Interface()); _keyboardAdaptor._windowsLanguageProfileSinks.ForEach( sink => sink.OnInputLanguageChanged(Keyboard.Controller.ActiveKeyboard, winKeyboard)); }
/// ----------------------------------------------------------------------------------- /// <summary> /// The system keyboard has changed. Determine the corresponding codepage to use when /// processing characters. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks>Because .NET uses only Unicode characters, there is no need to set a code /// page</remarks> /// ----------------------------------------------------------------------------------- protected virtual void OnInputLangChanged(object sender, InputLanguageChangedEventArgs e) { if (IsDisposed || m_rootb == null || DataUpdateMonitor.IsUpdateInProgress(DataAccess)) return; //Debug.WriteLine(string.Format("OnInputLangChanged: Handle={2}, g_focusRootSite={0}, culture={1}", // g_focusRootSite, e.InputLanguage.Culture.ToString(), Handle)); // JT: apparently this comes to all the views, but only the active keyboard // needs to handle it. // SMc: furthermore, this is not really focused until OnGotFocus() has run. // Responding before that causes a nasty bug in language/keyboard selection. // SMc: also, we trust the lcid derived from vwsel more than we trust the one // passed in as e.CultureInfo.LCID. if (this.Focused && g_focusRootSite == this) { // If possible, adjust the language of the selection to be one that matches // the keyboard just selected. IVwSelection vwsel = m_rootb.Selection; int lcid = LcidHelper.LangIdFromLCID(e.Culture.LCID); // Since we're being told it changed, assume this really is current, as opposed // to whatever we last set it to. m_editingHelper.ActiveLanguageId = lcid; if (m_fHandlingOnGotFocus) { int wsSel = SelectionHelper.GetFirstWsOfSelection(vwsel); if (wsSel != 0) { IWritingSystem qws = WritingSystemFactory.get_EngineOrNull(wsSel); if (qws != null) lcid = qws.Locale; } } HandleKeyboardChange(vwsel, (short)lcid); // The following line is needed to get Chinese IMEs to fully initialize. // This causes Text Services to set its focus, which is the crucial bit // of behavior. See LT-7488 and LT-5345. Activate(VwSelectionState.vssEnabled); RestoreKeyboardStatus(lcid); //Debug.WriteLine("End SimpleRootSite.OnInputLangChanged(" + lcid + // ") [hwnd = " + this.Handle + "] -> HandleKeyBoardChange(vwsel, " + lcid + // ")"); } //else //{ // Debug.WriteLine("End SimpleRootSite.OnInputLangChanged(" + LcidHelper.LangIdFromLCID(e.Culture.LCID).ToString() + // ") [hwnd = " + this.Handle + "] -> no action"); //} }
/// ----------------------------------------------------------------------------------- /// <summary> /// The system keyboard has changed. Determine the corresponding codepage to use when /// processing characters. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks>Because .NET uses only Unicode characters, there is no need to set a code /// page</remarks> /// ----------------------------------------------------------------------------------- protected virtual void OnInputLangChanged(object sender, InputLanguageChangedEventArgs e) { if (IsDisposed || m_rootb == null || DataUpdateMonitor.IsUpdateInProgress()) return; var manager = WritingSystemFactory as PalasoWritingSystemManager; if (manager == null) return; //Debug.WriteLine(string.Format("OnInputLangChanged: Handle={2}, g_focusRootSite={0}, culture={1}", // g_focusRootSite.Target, e.InputLanguage.Culture.ToString(), Handle)); // JT: apparently this comes to all the views, but only the active keyboard // needs to handle it. // SMc: furthermore, this is not really focused until OnGotFocus() has run. // Responding before that causes a nasty bug in language/keyboard selection. // SMc: also, we trust the lcid derived from vwsel more than we trust the one // passed in as e.CultureInfo.LCID. var wsRepo = manager.LocalWritingSystemStore; if (this.Focused && g_focusRootSite.Target == this && wsRepo != null) { // If possible, adjust the language of the selection to be one that matches // the keyboard just selected. IVwSelection vwsel = m_rootb.Selection; // may be null int wsSel = SelectionHelper.GetFirstWsOfSelection(vwsel); // may be zero IWritingSystemDefinition wsSelDefn = null; if (wsSel != 0) wsSelDefn = manager.Get(wsSel) as IWritingSystemDefinition; var wsNewDefn = wsRepo.GetWsForInputLanguage(e.InputLanguage.LayoutName, e.InputLanguage.Culture, wsSelDefn, PlausibleWritingSystems); if (wsNewDefn == null || wsNewDefn.Equals(wsSelDefn)) return; HandleKeyboardChange(vwsel, ((PalasoWritingSystem)wsNewDefn).Handle); // The following line is needed to get Chinese IMEs to fully initialize. // This causes Text Services to set its focus, which is the crucial bit // of behavior. See LT-7488 and LT-5345. Activate(VwSelectionState.vssEnabled); //Debug.WriteLine("End SimpleRootSite.OnInputLangChanged(" + lcid + // ") [hwnd = " + this.Handle + "] -> HandleKeyBoardChange(vwsel, " + lcid + // ")"); } //else //{ // Debug.WriteLine("End SimpleRootSite.OnInputLangChanged(" + LcidHelper.LangIdFromLCID(e.Culture.LCID).ToString() + // ") [hwnd = " + this.Handle + "] -> no action"); //} }
public void InputLanguage_Handler (object sender,InputLanguageChangedEventArgs e) { eventhandled = true; }
private void languageChange(Object sender, InputLanguageChangedEventArgs e) { // If the input language is Japanese. if (e.InputLanguage.Culture.TwoLetterISOLanguageName.Equals("ja")) { tbxStaff_Code.ImeMode = System.Windows.Forms.ImeMode.Off; } }
private void FrmExpense_InputLanguageChanged(object sender, InputLanguageChangedEventArgs e) { //if (InputLanguage.CurrentInputLanguage != null) // lblKeyboardLayout.Text = InputLanguage.CurrentInputLanguage.Culture.TwoLetterISOLanguageName; //lblKeyboardLayout.Visible = true; }
// Emit the "InputLanguageChanged" event. protected virtual void OnInputLanguageChanged (InputLanguageChangedEventArgs e) { InputLanguageChangedEventHandler handler; handler = (InputLanguageChangedEventHandler) (GetHandler(EventId.InputLanguageChanged)); if(handler != null) { handler(this, e); } }
void LookupFormInputLanguageChanged(object sender, InputLanguageChangedEventArgs e) { if (targetCulture != null && targetCulture.Equals(e.InputLanguage.Culture)) { SearchMode = SearchMode.Backward; } else if (sourceCulture != null && sourceCulture.Equals(e.InputLanguage.Culture)) { SearchMode = SearchMode.Forward; } }
private void ActiveFormOnInputLanguageChanged(object sender, InputLanguageChangedEventArgs inputLanguageChangedEventArgs) { RestoreImeConversionStatus(GetKeyboardDescription(inputLanguageChangedEventArgs.InputLanguage.Interface())); }
void ParentForm_InputLanguageChanged(object sender, InputLanguageChangedEventArgs e) { RepresentInputLanguage(e.Culture); }