[QuickAccent]Multi-language selection (#35539)
* PowerAccent with multi-language selection - Updated Language enum, method signatures, and settings to support multiple language selections. - Remove ALL language and added special characters language instead. - Modified UI to use ListView with checkboxes for language selection, including a "Select All" option. - Adjusted ViewModel and code-behind to handle multi-selection logic. - Updated Resources.resw and PowerAccentViewModel.cs to reflect these changes. * Changes Language selection UI - Groups languages into two groups - Sort them by localized language name - Remove unneeded looping when no languages selected
This commit is contained in:
Родитель
db23992aac
Коммит
54aab5d109
|
@ -10,7 +10,7 @@ namespace PowerAccent.Core
|
|||
{
|
||||
public enum Language
|
||||
{
|
||||
ALL,
|
||||
SPECIAL,
|
||||
BG,
|
||||
CA,
|
||||
CRH,
|
||||
|
@ -54,52 +54,68 @@ namespace PowerAccent.Core
|
|||
|
||||
internal sealed class Languages
|
||||
{
|
||||
public static string[] GetDefaultLetterKey(LetterKey letter, Language lang)
|
||||
public static string[] GetDefaultLetterKey(LetterKey letter, Language[] langs)
|
||||
{
|
||||
return lang switch
|
||||
if (langs.Length == Enum.GetValues(typeof(Language)).Length)
|
||||
{
|
||||
Language.ALL => GetDefaultLetterKeyALL(letter), // All
|
||||
Language.BG => GetDefaultLetterKeyBG(letter), // Bulgarian
|
||||
Language.CA => GetDefaultLetterKeyCA(letter), // Catalan
|
||||
Language.CRH => GetDefaultLetterKeyCRH(letter), // Crimean Tatar
|
||||
Language.CUR => GetDefaultLetterKeyCUR(letter), // Currency
|
||||
Language.CY => GetDefaultLetterKeyCY(letter), // Welsh
|
||||
Language.CZ => GetDefaultLetterKeyCZ(letter), // Czech
|
||||
Language.DK => GetDefaultLetterKeyDK(letter), // Danish
|
||||
Language.GA => GetDefaultLetterKeyGA(letter), // Gaeilge (Irish)
|
||||
Language.GD => GetDefaultLetterKeyGD(letter), // Gàidhlig (Scottish Gaelic)
|
||||
Language.DE => GetDefaultLetterKeyDE(letter), // German
|
||||
Language.EL => GetDefaultLetterKeyEL(letter), // Greek
|
||||
Language.EST => GetDefaultLetterKeyEST(letter), // Estonian
|
||||
Language.EPO => GetDefaultLetterKeyEPO(letter), // Esperanto
|
||||
Language.FI => GetDefaultLetterKeyFI(letter), // Finnish
|
||||
Language.FR => GetDefaultLetterKeyFR(letter), // French
|
||||
Language.HR => GetDefaultLetterKeyHR(letter), // Croatian
|
||||
Language.HE => GetDefaultLetterKeyHE(letter), // Hebrew
|
||||
Language.HU => GetDefaultLetterKeyHU(letter), // Hungarian
|
||||
Language.IS => GetDefaultLetterKeyIS(letter), // Iceland
|
||||
Language.IPA => GetDefaultLetterKeyIPA(letter), // IPA (International phonetic alphabet)
|
||||
Language.IT => GetDefaultLetterKeyIT(letter), // Italian
|
||||
Language.KU => GetDefaultLetterKeyKU(letter), // Kurdish
|
||||
Language.LT => GetDefaultLetterKeyLT(letter), // Lithuanian
|
||||
Language.MK => GetDefaultLetterKeyMK(letter), // Macedonian
|
||||
Language.MI => GetDefaultLetterKeyMI(letter), // Maori
|
||||
Language.NL => GetDefaultLetterKeyNL(letter), // Dutch
|
||||
Language.NO => GetDefaultLetterKeyNO(letter), // Norwegian
|
||||
Language.PI => GetDefaultLetterKeyPI(letter), // Pinyin
|
||||
Language.PL => GetDefaultLetterKeyPL(letter), // Polish
|
||||
Language.PT => GetDefaultLetterKeyPT(letter), // Portuguese
|
||||
Language.RO => GetDefaultLetterKeyRO(letter), // Romanian
|
||||
Language.ROM => GetDefaultLetterKeyROM(letter), // Middle Eastern Romanization
|
||||
Language.SK => GetDefaultLetterKeySK(letter), // Slovak
|
||||
Language.SL => GetDefaultLetterKeySL(letter), // Slovenian
|
||||
Language.SP => GetDefaultLetterKeySP(letter), // Spain
|
||||
Language.SR => GetDefaultLetterKeySR(letter), // Serbian
|
||||
Language.SR_CYRL => GetDefaultLetterKeySRCyrillic(letter), // Serbian Cyrillic
|
||||
Language.SV => GetDefaultLetterKeySV(letter), // Swedish
|
||||
Language.TK => GetDefaultLetterKeyTK(letter), // Turkish
|
||||
_ => throw new ArgumentException("The language {0} is not known in this context", lang.ToString()),
|
||||
};
|
||||
return GetDefaultLetterKeyALL(letter);
|
||||
}
|
||||
|
||||
if (langs.Length == 0)
|
||||
{
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
|
||||
var characters = new List<string>();
|
||||
foreach (var lang in langs)
|
||||
{
|
||||
characters.AddRange(lang switch
|
||||
{
|
||||
Language.SPECIAL => GetDefaultLetterKeySPECIAL(letter), // Special Characters
|
||||
Language.BG => GetDefaultLetterKeyBG(letter), // Bulgarian
|
||||
Language.CA => GetDefaultLetterKeyCA(letter), // Catalan
|
||||
Language.CRH => GetDefaultLetterKeyCRH(letter), // Crimean Tatar
|
||||
Language.CUR => GetDefaultLetterKeyCUR(letter), // Currency
|
||||
Language.CY => GetDefaultLetterKeyCY(letter), // Welsh
|
||||
Language.CZ => GetDefaultLetterKeyCZ(letter), // Czech
|
||||
Language.DK => GetDefaultLetterKeyDK(letter), // Danish
|
||||
Language.GA => GetDefaultLetterKeyGA(letter), // Gaeilge (Irish)
|
||||
Language.GD => GetDefaultLetterKeyGD(letter), // Gàidhlig (Scottish Gaelic)
|
||||
Language.DE => GetDefaultLetterKeyDE(letter), // German
|
||||
Language.EL => GetDefaultLetterKeyEL(letter), // Greek
|
||||
Language.EST => GetDefaultLetterKeyEST(letter), // Estonian
|
||||
Language.EPO => GetDefaultLetterKeyEPO(letter), // Esperanto
|
||||
Language.FI => GetDefaultLetterKeyFI(letter), // Finnish
|
||||
Language.FR => GetDefaultLetterKeyFR(letter), // French
|
||||
Language.HR => GetDefaultLetterKeyHR(letter), // Croatian
|
||||
Language.HE => GetDefaultLetterKeyHE(letter), // Hebrew
|
||||
Language.HU => GetDefaultLetterKeyHU(letter), // Hungarian
|
||||
Language.IS => GetDefaultLetterKeyIS(letter), // Iceland
|
||||
Language.IPA => GetDefaultLetterKeyIPA(letter), // IPA (International phonetic alphabet)
|
||||
Language.IT => GetDefaultLetterKeyIT(letter), // Italian
|
||||
Language.KU => GetDefaultLetterKeyKU(letter), // Kurdish
|
||||
Language.LT => GetDefaultLetterKeyLT(letter), // Lithuanian
|
||||
Language.MK => GetDefaultLetterKeyMK(letter), // Macedonian
|
||||
Language.MI => GetDefaultLetterKeyMI(letter), // Maori
|
||||
Language.NL => GetDefaultLetterKeyNL(letter), // Dutch
|
||||
Language.NO => GetDefaultLetterKeyNO(letter), // Norwegian
|
||||
Language.PI => GetDefaultLetterKeyPI(letter), // Pinyin
|
||||
Language.PL => GetDefaultLetterKeyPL(letter), // Polish
|
||||
Language.PT => GetDefaultLetterKeyPT(letter), // Portuguese
|
||||
Language.RO => GetDefaultLetterKeyRO(letter), // Romanian
|
||||
Language.ROM => GetDefaultLetterKeyROM(letter), // Middle Eastern Romanization
|
||||
Language.SK => GetDefaultLetterKeySK(letter), // Slovak
|
||||
Language.SL => GetDefaultLetterKeySL(letter), // Slovenian
|
||||
Language.SP => GetDefaultLetterKeySP(letter), // Spain
|
||||
Language.SR => GetDefaultLetterKeySR(letter), // Serbian
|
||||
Language.SR_CYRL => GetDefaultLetterKeySRCyrillic(letter), // Serbian Cyrillic
|
||||
Language.SV => GetDefaultLetterKeySV(letter), // Swedish
|
||||
Language.TK => GetDefaultLetterKeyTK(letter), // Turkish
|
||||
_ => throw new ArgumentException("The language {0} is not known in this context", lang.ToString()),
|
||||
});
|
||||
}
|
||||
|
||||
return characters.Distinct().ToArray();
|
||||
}
|
||||
|
||||
// Store the computed letters for each key, so that subsequent calls don't take as long.
|
||||
|
@ -149,7 +165,7 @@ namespace PowerAccent.Core
|
|||
.Union(GetDefaultLetterKeySRCyrillic(letter))
|
||||
.Union(GetDefaultLetterKeySV(letter))
|
||||
.Union(GetDefaultLetterKeyTK(letter))
|
||||
.Union(GetDefaultLetterKeyAllLanguagesOnly(letter))
|
||||
.Union(GetDefaultLetterKeySPECIAL(letter))
|
||||
.ToArray();
|
||||
|
||||
_allLanguagesCache[letter] = cachedValue;
|
||||
|
@ -160,7 +176,7 @@ namespace PowerAccent.Core
|
|||
|
||||
// Contains all characters that should be shown in all languages but currently don't belong to any of the single languages available for that letter.
|
||||
// These characters can be removed from this list after they've been added to one of the other languages for that specific letter.
|
||||
private static string[] GetDefaultLetterKeyAllLanguagesOnly(LetterKey letter)
|
||||
private static string[] GetDefaultLetterKeySPECIAL(LetterKey letter)
|
||||
{
|
||||
return letter switch
|
||||
{
|
||||
|
|
|
@ -66,7 +66,10 @@ public class SettingsService
|
|||
ExcludedApps = settings.Properties.ExcludedApps.Value;
|
||||
_keyboardListener.UpdateExcludedApps(ExcludedApps);
|
||||
|
||||
SelectedLang = Enum.TryParse(settings.Properties.SelectedLang.Value, out Language selectedLangValue) ? selectedLangValue : Language.ALL;
|
||||
SelectedLang = settings.Properties.SelectedLang.Value
|
||||
.Split(',', StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(lang => Enum.TryParse(lang, out Language selectedLangValue) ? selectedLangValue : Language.SPECIAL)
|
||||
.ToArray();
|
||||
|
||||
switch (settings.Properties.ToolbarPosition.Value)
|
||||
{
|
||||
|
@ -187,9 +190,9 @@ public class SettingsService
|
|||
}
|
||||
}
|
||||
|
||||
private Language _selectedLang;
|
||||
private Language[] _selectedLang;
|
||||
|
||||
public Language SelectedLang
|
||||
public Language[] SelectedLang
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
{
|
||||
public class PowerAccentLanguageGroupModel : List<PowerAccentLanguageModel>
|
||||
{
|
||||
public PowerAccentLanguageGroupModel(List<PowerAccentLanguageModel> languages, string group)
|
||||
: base(languages)
|
||||
{
|
||||
this.Group = group;
|
||||
}
|
||||
|
||||
public string Group { get; init; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
{
|
||||
public record PowerAccentLanguageModel(string LanguageCode, string LanguageResourceID, string GroupResourceID)
|
||||
{
|
||||
public string Language { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
<Page
|
||||
<Page
|
||||
x:Class="Microsoft.PowerToys.Settings.UI.Views.PowerAccentPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Lib="using:Microsoft.PowerToys.Settings.UI.Library"
|
||||
xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
|
@ -9,6 +10,15 @@
|
|||
xmlns:ui="using:CommunityToolkit.WinUI"
|
||||
AutomationProperties.LandmarkType="Main"
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
<CollectionViewSource
|
||||
x:Name="LanguagesCustomViewSource"
|
||||
IsSourceGrouped="True"
|
||||
Source="{x:Bind ViewModel.LanguageGroups, Mode=OneWay}" />
|
||||
<DataTemplate x:Key="LanguageViewTemplate" x:DataType="Lib:PowerAccentLanguageModel">
|
||||
<TextBlock Text="{x:Bind Language}" />
|
||||
</DataTemplate>
|
||||
</Page.Resources>
|
||||
|
||||
<controls:SettingsPageControl
|
||||
x:Uid="QuickAccent"
|
||||
|
@ -48,52 +58,98 @@
|
|||
</tkcontrols:SettingsExpander>
|
||||
</controls:SettingsGroup>
|
||||
|
||||
<controls:SettingsGroup x:Uid="QuickAccent_Language" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
|
||||
<tkcontrols:SettingsCard x:Uid="QuickAccent_SelectedLanguage" HeaderIcon="{ui:FontIcon Glyph=}">
|
||||
<ComboBox MinWidth="{StaticResource SettingActionControlMinWidth}" SelectedIndex="{x:Bind Path=ViewModel.SelectedLangIndex, Mode=TwoWay}">
|
||||
<!-- These should be in the same order as the array items in PowerAccentViewModel.cs -->
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_All" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Bulgarian" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Catalan" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Crimean" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Currency" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Croatian" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Czech" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Danish" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Gaeilge" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Gaidhlig" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Dutch" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Greek" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Estonian" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Esperanto" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Finnish" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_French" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_German" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Hebrew" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Hungarian" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Icelandic" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_IPA" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Italian" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Kurdish" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Lithuanian" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Macedonian" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Maori" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Norwegian" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Pinyin" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Polish" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Portuguese" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Romanian" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Romanization" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Slovak" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Slovenian" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Spanish" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Serbian" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Serbian_Cyrillic" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Swedish" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Turkish" />
|
||||
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Welsh" />
|
||||
</ComboBox>
|
||||
</tkcontrols:SettingsCard>
|
||||
<controls:SettingsGroup
|
||||
x:Name="QuickAccent_Language"
|
||||
x:Uid="QuickAccent_Language"
|
||||
IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
|
||||
<tkcontrols:SettingsExpander
|
||||
x:Uid="QuickAccent_SelectedLanguage"
|
||||
HeaderIcon="{ui:FontIcon Glyph=}"
|
||||
IsExpanded="False">
|
||||
<CheckBox
|
||||
x:Name="QuickAccent_SelectedLanguage_All"
|
||||
x:Uid="QuickAccent_SelectedLanguage_All"
|
||||
Checked="QuickAccent_SelectedLanguage_SelectAll"
|
||||
IsThreeState="True"
|
||||
Unchecked="QuickAccent_SelectedLanguage_UnselectAll" />
|
||||
<tkcontrols:SettingsExpander.Items>
|
||||
<tkcontrols:SettingsCard>
|
||||
<ListView
|
||||
x:Name="QuickAccent_Language_Select"
|
||||
MinWidth="{StaticResource SettingActionControlMinWidth}"
|
||||
MinHeight="{StaticResource SettingActionControlMinWidth}"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalContentAlignment="Stretch"
|
||||
ItemTemplate="{StaticResource LanguageViewTemplate}"
|
||||
ItemsSource="{x:Bind LanguagesCustomViewSource.View, Mode=OneWay}"
|
||||
Loaded="QuickAccent_Language_Select_Loaded"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Visible"
|
||||
ScrollViewer.HorizontalScrollMode="Enabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Visible"
|
||||
ScrollViewer.VerticalScrollMode="Enabled"
|
||||
SelectionChanged="QuickAccent_SelectedLanguage_SelectionChanged"
|
||||
SelectionMode="Multiple">
|
||||
<ListView.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<ItemsWrapGrid
|
||||
MaxWidth="{Binding ElementName=QuickAccent_Language, Path=ActualWidth}"
|
||||
ItemWidth="280"
|
||||
Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ListView.ItemsPanel>
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListViewItem">
|
||||
<ListViewItemPresenter
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
CheckBoxBorderBrush="{ThemeResource CheckBoxBorderThemeBrush}"
|
||||
CheckBoxBrush="{ThemeResource CheckBoxCheckBackgroundFillUnchecked}"
|
||||
CheckBoxCornerRadius="{ThemeResource ControlCornerRadius}"
|
||||
CheckBoxDisabledBorderBrush="{ThemeResource CheckBoxDisabledBorderThemeBrush}"
|
||||
CheckBoxDisabledBrush="{ThemeResource CheckBoxCheckBackgroundFillUncheckedDisabled}"
|
||||
CheckBoxPointerOverBorderBrush="{ThemeResource CheckBoxPointerOverBorderThemeBrush}"
|
||||
CheckBoxPointerOverBrush="{ThemeResource CheckBoxCheckBackgroundFillUncheckedPointerOver}"
|
||||
CheckBoxPressedBorderBrush="{ThemeResource CheckBoxPressedBorderThemeBrush}"
|
||||
CheckBoxPressedBrush="{ThemeResource CheckBoxCheckBackgroundFillUncheckedPressed}"
|
||||
CheckBoxSelectedBrush="{ThemeResource CheckBoxCheckBackgroundFillChecked}"
|
||||
CheckBoxSelectedDisabledBrush="{ThemeResource CheckBoxCheckBackgroundFillCheckedDisabled}"
|
||||
CheckBoxSelectedPointerOverBrush="{ThemeResource CheckBoxCheckBackgroundFillCheckedPointerOver}"
|
||||
CheckBoxSelectedPressedBrush="{ThemeResource CheckBoxCheckBackgroundFillCheckedPressed}"
|
||||
CheckBrush="{ThemeResource CheckBoxCheckGlyphForegroundChecked}"
|
||||
CheckDisabledBrush="{ThemeResource CheckBoxCheckGlyphForegroundCheckedDisabled}"
|
||||
CheckMode="Inline"
|
||||
CheckPressedBrush="{ThemeResource CheckBoxCheckGlyphForegroundUncheckedPressed}"
|
||||
ContentMargin="{TemplateBinding Padding}"
|
||||
ContentTransitions="{TemplateBinding ContentTransitions}"
|
||||
DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}"
|
||||
ReorderHintOffset="{ThemeResource ListViewItemReorderHintThemeOffset}"
|
||||
SelectionCheckMarkVisualEnabled="True" />
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
<ListView.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.HeaderTemplate>
|
||||
<DataTemplate x:DataType="Lib:PowerAccentLanguageGroupModel">
|
||||
<Border AutomationProperties.AccessibilityView="Raw">
|
||||
<TextBlock
|
||||
AutomationProperties.AccessibilityView="Raw"
|
||||
Style="{ThemeResource SubtitleTextBlockStyle}"
|
||||
Text="{x:Bind Group}" />
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</GroupStyle.HeaderTemplate>
|
||||
</GroupStyle>
|
||||
</ListView.GroupStyle>
|
||||
</ListView>
|
||||
</tkcontrols:SettingsCard>
|
||||
</tkcontrols:SettingsExpander.Items>
|
||||
</tkcontrols:SettingsExpander>
|
||||
</controls:SettingsGroup>
|
||||
|
||||
<controls:SettingsGroup x:Uid="QuickAccent_Toolbar" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Linq;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.ViewModels;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
|
@ -19,11 +21,65 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||
ViewModel = new PowerAccentViewModel(settingsUtils, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage);
|
||||
DataContext = ViewModel;
|
||||
this.InitializeComponent();
|
||||
this.InitializeControlsStates();
|
||||
}
|
||||
|
||||
public void RefreshEnabledState()
|
||||
{
|
||||
ViewModel.RefreshEnabledState();
|
||||
}
|
||||
|
||||
private void InitializeControlsStates()
|
||||
{
|
||||
SetCheckBoxStatus();
|
||||
}
|
||||
|
||||
private void SetCheckBoxStatus()
|
||||
{
|
||||
if (ViewModel.SelectedLanguageOptions.Length == 0)
|
||||
{
|
||||
this.QuickAccent_SelectedLanguage_All.IsChecked = false;
|
||||
this.QuickAccent_SelectedLanguage_All.IsThreeState = false;
|
||||
}
|
||||
else if (ViewModel.AllSelected)
|
||||
{
|
||||
this.QuickAccent_SelectedLanguage_All.IsChecked = true;
|
||||
this.QuickAccent_SelectedLanguage_All.IsThreeState = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.QuickAccent_SelectedLanguage_All.IsThreeState = true;
|
||||
this.QuickAccent_SelectedLanguage_All.IsChecked = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void QuickAccent_SelectedLanguage_SelectAll(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.QuickAccent_Language_Select.SelectAllSafe();
|
||||
}
|
||||
|
||||
private void QuickAccent_SelectedLanguage_UnselectAll(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.QuickAccent_Language_Select.DeselectAll();
|
||||
}
|
||||
|
||||
private void QuickAccent_SelectedLanguage_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
var listView = sender as ListView;
|
||||
|
||||
ViewModel.SelectedLanguageOptions = listView.SelectedItems
|
||||
.Select(item => item as PowerAccentLanguageModel)
|
||||
.ToArray();
|
||||
|
||||
SetCheckBoxStatus();
|
||||
}
|
||||
|
||||
private void QuickAccent_Language_Select_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
foreach (var languageOption in ViewModel.SelectedLanguageOptions)
|
||||
{
|
||||
this.QuickAccent_Language_Select.SelectedItems.Add(languageOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
@ -3585,124 +3585,133 @@ Activate by holding the key for the character you want to add an accent to, then
|
|||
<data name="QuickAccent_SelectedLanguage_All.Content" xml:space="preserve">
|
||||
<value>All available</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Bulgarian.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_Group_Special" xml:space="preserve">
|
||||
<value>Special sets</value>
|
||||
</data>
|
||||
<data name="QuickAccent_Group_Language" xml:space="preserve">
|
||||
<value>Language sets</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Special" xml:space="preserve">
|
||||
<value>Special Characters</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Bulgarian" xml:space="preserve">
|
||||
<value>Bulgarian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Catalan.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Catalan" xml:space="preserve">
|
||||
<value>Catalan</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Crimean.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Crimean" xml:space="preserve">
|
||||
<value>Crimean Tatar</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Currency.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Currency" xml:space="preserve">
|
||||
<value>Currency</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Croatian.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Croatian" xml:space="preserve">
|
||||
<value>Croatian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Czech.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Czech" xml:space="preserve">
|
||||
<value>Czech</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Danish.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Danish" xml:space="preserve">
|
||||
<value>Danish</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Gaeilge.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Gaeilge" xml:space="preserve">
|
||||
<value>Gaeilge</value>
|
||||
<comment>Gaelic language spoken in Ireland</comment>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Gaidhlig.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Gaidhlig" xml:space="preserve">
|
||||
<value>Gàidhlig</value>
|
||||
<comment>Scottish Gaelic</comment>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_German.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_German" xml:space="preserve">
|
||||
<value>German</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Greek.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Greek" xml:space="preserve">
|
||||
<value>Greek</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Hebrew.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Hebrew" xml:space="preserve">
|
||||
<value>Hebrew</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_French.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_French" xml:space="preserve">
|
||||
<value>French</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Finnish.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Finnish" xml:space="preserve">
|
||||
<value>Finnish</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Estonian.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Estonian" xml:space="preserve">
|
||||
<value>Estonian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Esperanto.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Esperanto" xml:space="preserve">
|
||||
<value>Esperanto</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_IPA.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_IPA" xml:space="preserve">
|
||||
<value>IPA</value>
|
||||
<comment>International Phonetic Alphabet</comment>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Lithuanian.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Lithuanian" xml:space="preserve">
|
||||
<value>Lithuanian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Macedonian.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Macedonian" xml:space="preserve">
|
||||
<value>Macedonian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Maori.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Maori" xml:space="preserve">
|
||||
<value>Maori</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Romanization.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Romanization" xml:space="preserve">
|
||||
<value>Middle Eastern Romanization</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Dutch.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Dutch" xml:space="preserve">
|
||||
<value>Dutch</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Norwegian.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Norwegian" xml:space="preserve">
|
||||
<value>Norwegian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Pinyin.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Pinyin" xml:space="preserve">
|
||||
<value>Pinyin</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Polish.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Polish" xml:space="preserve">
|
||||
<value>Polish</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Portuguese.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Portuguese" xml:space="preserve">
|
||||
<value>Portuguese</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Slovak.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Slovak" xml:space="preserve">
|
||||
<value>Slovak</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Slovenian.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Slovenian" xml:space="preserve">
|
||||
<value>Slovenian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Spanish.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Spanish" xml:space="preserve">
|
||||
<value>Spanish</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Swedish.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Swedish" xml:space="preserve">
|
||||
<value>Swedish</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Turkish.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Turkish" xml:space="preserve">
|
||||
<value>Turkish</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Icelandic.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Icelandic" xml:space="preserve">
|
||||
<value>Icelandic</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Romanian.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Romanian" xml:space="preserve">
|
||||
<value>Romanian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Serbian.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Serbian" xml:space="preserve">
|
||||
<value>Serbian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Serbian_Cyrillic.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Serbian_Cyrillic" xml:space="preserve">
|
||||
<value>Serbian Cyrillic</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Hungarian.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Hungarian" xml:space="preserve">
|
||||
<value>Hungarian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Italian.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Italian" xml:space="preserve">
|
||||
<value>Italian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Kurdish.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Kurdish" xml:space="preserve">
|
||||
<value>Kurdish</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Welsh.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Welsh" xml:space="preserve">
|
||||
<value>Welsh</value>
|
||||
</data>
|
||||
<data name="Hosts.ModuleDescription" xml:space="preserve">
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using global::PowerToys.GPOWrapper;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
|
||||
|
@ -21,50 +23,53 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
|
||||
private readonly ISettingsUtils _settingsUtils;
|
||||
|
||||
// These should be in the same order as the ComboBoxItems in PowerAccentPage.xaml
|
||||
private readonly string[] _languageOptions =
|
||||
{
|
||||
"ALL",
|
||||
"BG",
|
||||
"CA",
|
||||
"CRH",
|
||||
"CUR",
|
||||
"HR",
|
||||
"CZ",
|
||||
"DK",
|
||||
"GA",
|
||||
"GD",
|
||||
"NL",
|
||||
"EL",
|
||||
"EST",
|
||||
"EPO",
|
||||
"FI",
|
||||
"FR",
|
||||
"DE",
|
||||
"HE",
|
||||
"HU",
|
||||
"IS",
|
||||
"IPA",
|
||||
"IT",
|
||||
"KU",
|
||||
"LT",
|
||||
"MK",
|
||||
"MI",
|
||||
"NO",
|
||||
"PI",
|
||||
"PL",
|
||||
"PT",
|
||||
"RO",
|
||||
"ROM",
|
||||
"SK",
|
||||
"SL",
|
||||
"SP",
|
||||
"SR",
|
||||
"SR_CYRL",
|
||||
"SV",
|
||||
"TK",
|
||||
"CY",
|
||||
};
|
||||
private const string SpecialGroup = "QuickAccent_Group_Special";
|
||||
private const string LanguageGroup = "QuickAccent_Group_Language";
|
||||
|
||||
public List<PowerAccentLanguageModel> Languages { get; } = [
|
||||
new PowerAccentLanguageModel("SPECIAL", "QuickAccent_SelectedLanguage_Special", SpecialGroup),
|
||||
new PowerAccentLanguageModel("BG", "QuickAccent_SelectedLanguage_Bulgarian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("CA", "QuickAccent_SelectedLanguage_Catalan", LanguageGroup),
|
||||
new PowerAccentLanguageModel("CRH", "QuickAccent_SelectedLanguage_Crimean", LanguageGroup),
|
||||
new PowerAccentLanguageModel("CUR", "QuickAccent_SelectedLanguage_Currency", SpecialGroup),
|
||||
new PowerAccentLanguageModel("HR", "QuickAccent_SelectedLanguage_Croatian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("CZ", "QuickAccent_SelectedLanguage_Czech", LanguageGroup),
|
||||
new PowerAccentLanguageModel("DK", "QuickAccent_SelectedLanguage_Danish", LanguageGroup),
|
||||
new PowerAccentLanguageModel("GA", "QuickAccent_SelectedLanguage_Gaeilge", LanguageGroup),
|
||||
new PowerAccentLanguageModel("GD", "QuickAccent_SelectedLanguage_Gaidhlig", LanguageGroup),
|
||||
new PowerAccentLanguageModel("NL", "QuickAccent_SelectedLanguage_Dutch", LanguageGroup),
|
||||
new PowerAccentLanguageModel("EL", "QuickAccent_SelectedLanguage_Greek", LanguageGroup),
|
||||
new PowerAccentLanguageModel("EST", "QuickAccent_SelectedLanguage_Estonian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("EPO", "QuickAccent_SelectedLanguage_Esperanto", LanguageGroup),
|
||||
new PowerAccentLanguageModel("FI", "QuickAccent_SelectedLanguage_Finnish", LanguageGroup),
|
||||
new PowerAccentLanguageModel("FR", "QuickAccent_SelectedLanguage_French", LanguageGroup),
|
||||
new PowerAccentLanguageModel("DE", "QuickAccent_SelectedLanguage_German", LanguageGroup),
|
||||
new PowerAccentLanguageModel("HE", "QuickAccent_SelectedLanguage_Hebrew", LanguageGroup),
|
||||
new PowerAccentLanguageModel("HU", "QuickAccent_SelectedLanguage_Hungarian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("IS", "QuickAccent_SelectedLanguage_Icelandic", LanguageGroup),
|
||||
new PowerAccentLanguageModel("IPA", "QuickAccent_SelectedLanguage_IPA", SpecialGroup),
|
||||
new PowerAccentLanguageModel("IT", "QuickAccent_SelectedLanguage_Italian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("KU", "QuickAccent_SelectedLanguage_Kurdish", LanguageGroup),
|
||||
new PowerAccentLanguageModel("LT", "QuickAccent_SelectedLanguage_Lithuanian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("MK", "QuickAccent_SelectedLanguage_Macedonian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("MI", "QuickAccent_SelectedLanguage_Maori", LanguageGroup),
|
||||
new PowerAccentLanguageModel("NO", "QuickAccent_SelectedLanguage_Norwegian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("PI", "QuickAccent_SelectedLanguage_Pinyin", LanguageGroup),
|
||||
new PowerAccentLanguageModel("PL", "QuickAccent_SelectedLanguage_Polish", LanguageGroup),
|
||||
new PowerAccentLanguageModel("PT", "QuickAccent_SelectedLanguage_Portuguese", LanguageGroup),
|
||||
new PowerAccentLanguageModel("RO", "QuickAccent_SelectedLanguage_Romanian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("ROM", "QuickAccent_SelectedLanguage_Romanization", SpecialGroup),
|
||||
new PowerAccentLanguageModel("SK", "QuickAccent_SelectedLanguage_Slovak", LanguageGroup),
|
||||
new PowerAccentLanguageModel("SL", "QuickAccent_SelectedLanguage_Slovenian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("SP", "QuickAccent_SelectedLanguage_Spanish", LanguageGroup),
|
||||
new PowerAccentLanguageModel("SR", "QuickAccent_SelectedLanguage_Serbian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("SR_CYRL", "QuickAccent_SelectedLanguage_Serbian_Cyrillic", LanguageGroup),
|
||||
new PowerAccentLanguageModel("SV", "QuickAccent_SelectedLanguage_Swedish", LanguageGroup),
|
||||
new PowerAccentLanguageModel("TK", "QuickAccent_SelectedLanguage_Turkish", LanguageGroup),
|
||||
new PowerAccentLanguageModel("CY", "QuickAccent_SelectedLanguage_Welsh", LanguageGroup),
|
||||
];
|
||||
|
||||
public PowerAccentLanguageGroupModel[] LanguageGroups { get; private set; }
|
||||
|
||||
private readonly string[] _toolbarOptions =
|
||||
{
|
||||
|
@ -90,6 +95,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
GeneralSettingsConfig = settingsRepository.SettingsConfig;
|
||||
|
||||
InitializeEnabledValue();
|
||||
InitializeLanguages();
|
||||
|
||||
if (_settingsUtils.SettingsExists(PowerAccentSettings.ModuleName))
|
||||
{
|
||||
|
@ -104,7 +110,20 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
|
||||
_excludedApps = _powerAccentSettings.Properties.ExcludedApps.Value;
|
||||
|
||||
_selectedLangIndex = Array.IndexOf(_languageOptions, _powerAccentSettings.Properties.SelectedLang.Value);
|
||||
if (!string.IsNullOrWhiteSpace(_powerAccentSettings.Properties.SelectedLang.Value) && !_powerAccentSettings.Properties.SelectedLang.Value.Contains("ALL"))
|
||||
{
|
||||
SelectedLanguageOptions = _powerAccentSettings.Properties.SelectedLang.Value.Split(',')
|
||||
.Select(l => Languages.Find(lang => lang.LanguageCode == l))
|
||||
.ToArray();
|
||||
}
|
||||
else if (_powerAccentSettings.Properties.SelectedLang.Value.Contains("ALL"))
|
||||
{
|
||||
SelectedLanguageOptions = Languages.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedLanguageOptions = Array.Empty<PowerAccentLanguageModel>();
|
||||
}
|
||||
|
||||
_toolbarPositionIndex = Array.IndexOf(_toolbarOptions, _powerAccentSettings.Properties.ToolbarPosition.Value);
|
||||
|
||||
|
@ -127,6 +146,23 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds Localized Language Name, sorts by it and splits languages into two groups.
|
||||
/// </summary>
|
||||
private void InitializeLanguages()
|
||||
{
|
||||
foreach (var item in Languages)
|
||||
{
|
||||
item.Language = ResourceLoaderInstance.ResourceLoader.GetString(item.LanguageResourceID);
|
||||
}
|
||||
|
||||
Languages.Sort((x, y) => string.Compare(x.Language, y.Language, StringComparison.Ordinal));
|
||||
LanguageGroups = Languages
|
||||
.GroupBy(language => language.GroupResourceID)
|
||||
.Select(grp => new PowerAccentLanguageGroupModel(grp.ToList(), ResourceLoaderInstance.ResourceLoader.GetString(grp.Key)))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
|
@ -253,23 +289,18 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
private int _selectedLangIndex;
|
||||
public bool AllSelected => _selectedLanguageOptions.Length == Languages.Count;
|
||||
|
||||
public int SelectedLangIndex
|
||||
private PowerAccentLanguageModel[] _selectedLanguageOptions;
|
||||
|
||||
public PowerAccentLanguageModel[] SelectedLanguageOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
return _selectedLangIndex;
|
||||
}
|
||||
|
||||
get => _selectedLanguageOptions;
|
||||
set
|
||||
{
|
||||
if (_selectedLangIndex != value)
|
||||
{
|
||||
_selectedLangIndex = value;
|
||||
_powerAccentSettings.Properties.SelectedLang.Value = _languageOptions[value];
|
||||
RaisePropertyChanged(nameof(SelectedLangIndex));
|
||||
}
|
||||
_selectedLanguageOptions = value;
|
||||
_powerAccentSettings.Properties.SelectedLang.Value = string.Join(',', _selectedLanguageOptions.Select(l => l.LanguageCode));
|
||||
RaisePropertyChanged(nameof(SelectedLanguageOptions));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче