diff --git a/RetroBar/Controls/InputLanguage.xaml b/RetroBar/Controls/InputLanguage.xaml index 770c7529..5f7f07f0 100644 --- a/RetroBar/Controls/InputLanguage.xaml +++ b/RetroBar/Controls/InputLanguage.xaml @@ -2,6 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:converters="clr-namespace:RetroBar.Converters" + MouseLeftButtonDown="UserControl_MouseLeftButtonDown" Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded"> @@ -24,7 +25,7 @@ Style="{DynamicResource LanguageBar}"> + Text="{Binding Path=LocaleIdentifier, Converter={StaticResource cultureInfoToLocaleNameConverter}, ConverterParameter=TwoLetterIsoLanguageName, Mode=OneWay}" HorizontalAlignment="Left"> diff --git a/RetroBar/Controls/InputLanguage.xaml.cs b/RetroBar/Controls/InputLanguage.xaml.cs index 90d97b27..ccf6a51a 100644 --- a/RetroBar/Controls/InputLanguage.xaml.cs +++ b/RetroBar/Controls/InputLanguage.xaml.cs @@ -3,14 +3,31 @@ using System.Globalization; using System.Windows; using System.Windows.Controls; +using System.Windows.Media; using System.Windows.Threading; using ManagedShell.Common.Helpers; using ManagedShell.Common.Logging; using RetroBar.Converters; using RetroBar.Utilities; +using WinForms = System.Windows.Forms; namespace RetroBar.Controls { + public static class InputMethodSwitcher + { + public static void Toggle() + { + var list = WinForms.InputLanguage.InstalledInputLanguages.Cast().ToList(); + if (list.Count < 2) + return; + + var current = WinForms.InputLanguage.CurrentInputLanguage; + int index = list.IndexOf(current); + int next = (index + 1) % list.Count; + + WinForms.InputLanguage.CurrentInputLanguage = list[next]; + } + } public partial class InputLanguage : UserControl { public static DependencyProperty LocaleIdentifierProperty = DependencyProperty.Register(nameof(LocaleIdentifier), typeof(CultureInfo), typeof(InputLanguage)); @@ -64,7 +81,7 @@ private void SetLocaleIdentifier() private void StartWatch() { SetLocaleIdentifier(); - + layoutWatch.Start(); Visibility = Visibility.Visible; @@ -84,7 +101,7 @@ private void JapaneseImeAdd() var NewControl = new JapaneseIme(); InputLanguageDockPanel.Children.Add(NewControl); } - + private void JapaneseImeRemove() { var DelControl = InputLanguageDockPanel.Children @@ -171,10 +188,71 @@ private void UserControl_Loaded(object sender, RoutedEventArgs e) private void UserControl_Unloaded(object sender, RoutedEventArgs e) { StopWatch(); - + Settings.Instance.PropertyChanged -= Settings_PropertyChanged; _isLoaded = false; } + + private void ShowLanguageMenu() + { + var menu = new ContextMenu(); + + foreach (WinForms.InputLanguage lang in WinForms.InputLanguage.InstalledInputLanguages) + { + string code = lang.Culture.TwoLetterISOLanguageName.ToUpperInvariant(); + + var panel = new StackPanel + { + Orientation = Orientation.Horizontal, + Margin = new Thickness(0, 0, 0, 0) + }; + + var badge = new Border + { + Background = (Brush)Application.Current.Resources["InputLanguageBackground"], + Padding = new Thickness(1, 1, 2, 3), + Margin = new Thickness(0, 0, 6, 0), + Child = new TextBlock + { + Text = code, + FontSize = 10, + FontWeight = FontWeights.UltraLight, + Foreground = (Brush)Application.Current.Resources["InputLanguageSelectorForeground"] + } + }; + + var text = new TextBlock + { + Text = lang.Culture.DisplayName + }; + + panel.Children.Add(badge); + panel.Children.Add(text); + + var item = new MenuItem + { + Header = panel, + Tag = lang, + IsCheckable = true, + IsChecked = lang.Equals(WinForms.InputLanguage.CurrentInputLanguage) + }; + + item.Click += (s, e) => + { + WinForms.InputLanguage.CurrentInputLanguage = (WinForms.InputLanguage)((MenuItem)s).Tag; + }; + + menu.Items.Add(item); + } + + menu.PlacementTarget = this; + menu.IsOpen = true; + } + + private void UserControl_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) + { + ShowLanguageMenu();//InputMethodSwitcher.Toggle(); + } }; } \ No newline at end of file diff --git a/RetroBar/Themes/System.xaml b/RetroBar/Themes/System.xaml index 5a2f3cb2..bc22c35c 100644 --- a/RetroBar/Themes/System.xaml +++ b/RetroBar/Themes/System.xaml @@ -24,6 +24,7 @@ + @@ -1060,7 +1061,6 @@ Width="3"> - diff --git a/RetroBar/Themes/Windows Longhorn Aero.xaml b/RetroBar/Themes/Windows Longhorn Aero.xaml index 6d09d153..7dc29b51 100644 --- a/RetroBar/Themes/Windows Longhorn Aero.xaml +++ b/RetroBar/Themes/Windows Longhorn Aero.xaml @@ -56,6 +56,7 @@ + diff --git a/RetroBar/Themes/Windows Vista Aero.xaml b/RetroBar/Themes/Windows Vista Aero.xaml index c98c74b3..3503e48e 100644 --- a/RetroBar/Themes/Windows Vista Aero.xaml +++ b/RetroBar/Themes/Windows Vista Aero.xaml @@ -44,6 +44,7 @@ + diff --git a/RetroBar/Themes/Windows Vista Basic.xaml b/RetroBar/Themes/Windows Vista Basic.xaml index c294ec39..3c3c175f 100644 --- a/RetroBar/Themes/Windows Vista Basic.xaml +++ b/RetroBar/Themes/Windows Vista Basic.xaml @@ -51,6 +51,7 @@ +