Changing system language, settings page finished

Before running a game, the app will try to force a new UI language to
make the app run in another language.

Also finished the new settings page.
UWPTest
Brian Lima 8 years ago
parent 2aaea481f7
commit 70ed581c9b

@ -16,6 +16,9 @@
<setting name="TargetLanguage" serializeAs="String"> <setting name="TargetLanguage" serializeAs="String">
<value /> <value />
</setting> </setting>
<setting name="Seconds" serializeAs="String">
<value>5</value>
</setting>
</UWPHook.Properties.Settings> </UWPHook.Properties.Settings>
</userSettings> </userSettings>
</configuration> </configuration>

@ -70,9 +70,7 @@ namespace UWPHook
{ {
using (StreamReader reader = new StreamReader(stream)) using (StreamReader reader = new StreamReader(stream))
{ {
ScriptManager script = new ScriptManager(); result = ScriptManager.RunScript(reader.ReadToEnd()).Split(';').ToList<string>();
result = script.RunScript(reader.ReadToEnd()).Split(';').ToList<string>();
} }
} }

@ -23,17 +23,6 @@ namespace UWPHook
Apps = new AppEntryModel(); Apps = new AppEntryModel();
listGames.ItemsSource = Apps.Entries; listGames.ItemsSource = Apps.Entries;
if (Properties.Settings.Default.ChangeLanguage)
{
this.Title = "true ";
}
else
{
this.Title = "false ";
}
this.Title += Properties.Settings.Default.TargetLanguage;
//If null or 1, the app was launched normally //If null or 1, the app was launched normally
if (Environment.GetCommandLineArgs() == null) if (Environment.GetCommandLineArgs() == null)
{ {
@ -50,8 +39,14 @@ namespace UWPHook
this.Title = "UWPHook: Playing a game"; this.Title = "UWPHook: Playing a game";
//Hide the window so the app is launched seamless //Hide the window so the app is launched seamless
this.Hide(); this.Hide();
string currentLanguage = CultureInfo.CurrentCulture.ToString();
try try
{ {
if (Properties.Settings.Default.ChangeLanguage && !String.IsNullOrEmpty(Properties.Settings.Default.TargetLanguage))
{
string script = "";
ScriptManager.RunScript("Set - WinUILanguageOverride " + Properties.Settings.Default.TargetLanguage);
}
//The only other parameter Steam will send is the app AUMID //The only other parameter Steam will send is the app AUMID
AppManager.LaunchUWPApp(Environment.GetCommandLineArgs()[1]); AppManager.LaunchUWPApp(Environment.GetCommandLineArgs()[1]);
while (AppManager.IsRunning()) while (AppManager.IsRunning())
@ -64,6 +59,13 @@ namespace UWPHook
this.Show(); this.Show();
MessageBox.Show(e.Message, "UWPHook", MessageBoxButton.OK, MessageBoxImage.Warning); MessageBox.Show(e.Message, "UWPHook", MessageBoxButton.OK, MessageBoxImage.Warning);
} }
finally
{
if (Properties.Settings.Default.ChangeLanguage && !String.IsNullOrEmpty(Properties.Settings.Default.TargetLanguage))
{
ScriptManager.RunScript("Set - WinUILanguageOverride " + currentLanguage);
}
}
} }
private void ExportButton_Click(object sender, RoutedEventArgs e) private void ExportButton_Click(object sender, RoutedEventArgs e)

@ -46,5 +46,17 @@ namespace UWPHook.Properties {
this["TargetLanguage"] = value; this["TargetLanguage"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("5")]
public int Seconds {
get {
return ((int)(this["Seconds"]));
}
set {
this["Seconds"] = value;
}
}
} }
} }

@ -8,5 +8,8 @@
<Setting Name="TargetLanguage" Type="System.String" Scope="User"> <Setting Name="TargetLanguage" Type="System.String" Scope="User">
<Value Profile="(Default)" /> <Value Profile="(Default)" />
</Setting> </Setting>
<Setting Name="Seconds" Type="System.Int32" Scope="User">
<Value Profile="(Default)">5</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

@ -5,9 +5,9 @@ using System.Text;
namespace UWPHook namespace UWPHook
{ {
class ScriptManager static class ScriptManager
{ {
public string RunScript(string scriptText) public static string RunScript(string scriptText)
{ {
// create Powershell runspace // create Powershell runspace
Runspace runspace = RunspaceFactory.CreateRunspace(); Runspace runspace = RunspaceFactory.CreateRunspace();

@ -11,7 +11,7 @@
TextElement.FontWeight="Medium" TextElement.FontWeight="Medium"
TextElement.FontSize="14" TextElement.FontSize="14"
FontFamily="Segoe UI Light" FontFamily="Segoe UI Light"
Title="SettingsWindow" Height="600" Width="800"> Title="Settings" Height="600" Width="800">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="27*"/> <ColumnDefinition Width="27*"/>
@ -33,32 +33,47 @@
<ColumnDefinition Width="301*"/> <ColumnDefinition Width="301*"/>
<ColumnDefinition Width="113*"/> <ColumnDefinition Width="113*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<GroupBox x:Name="groupBox" Header="Settings" Grid.ColumnSpan="3" Grid.RowSpan="2"/> <materialDesign:ColorZone Padding="16" materialDesign:ShadowAssist.ShadowDepth="Depth2" Mode="PrimaryMid" VerticalAlignment="Top" Height="27" Grid.ColumnSpan="3">
<ToggleButton x:Name="language_toggle" Style="{StaticResource MaterialDesignSwitchToggleButton}" VerticalAlignment="Top" Margin="4,56,0,0" ToolTip="MaterialDesignSwitchToggleButton" IsChecked="False" Checked="ToggleButton_Checked" Height="18" HorizontalAlignment="Left" Width="46" /> <Label Content="Settings" HorizontalAlignment="Left" Margin="-10,-15,0,-17" VerticalAlignment="Top" FontFamily="Segoe UI Semibold" FontSize="14" Height="32" Foreground="#DDFFFFFF"/>
</materialDesign:ColorZone>
<ToggleButton x:Name="language_toggle" Style="{StaticResource MaterialDesignSwitchToggleButton}" VerticalAlignment="Top" Margin="4,56,0,0" ToolTip="MaterialDesignSwitchToggleButton" IsChecked="False" Height="18" HorizontalAlignment="Left" Width="46" />
<Label ToolTip="Some apps use the system language to choose what language to display, this setting will store your current language, change it so you can play in another language and then revert your system back to your default display language." x:Name="label1" Content="Set system language when launching an app*" Margin="5,48,0,0" VerticalAlignment="Top" Height="29" Grid.Column="1"/> <Label ToolTip="Some apps use the system language to choose what language to display, this setting will store your current language, change it so you can play in another language and then revert your system back to your default display language." x:Name="label1" Content="Set system language when launching an app*" Margin="5,48,0,0" VerticalAlignment="Top" Height="29" Grid.Column="1"/>
<ComboBox ToolTip="Some apps use the system language to choose what language to display, this setting will store your current language, change it so you can play in another language and then revert your system back to your default display language." x:Name="cultures_comboBox" Margin="0,48,10,0" VerticalAlignment="Top" Height="31" Grid.Column="2" HorizontalAlignment="Right" Width="93"/> <ComboBox ToolTip="Some apps use the system language to choose what language to display, this setting will store your current language, change it so you can play in another language and then revert your system back to your default display language." x:Name="cultures_comboBox" Margin="0,48,10,0" VerticalAlignment="Top" Height="31" Grid.Column="2" HorizontalAlignment="Right" Width="93"/>
<Button x:Name="save_button" Content="Save" HorizontalAlignment="Right" Margin="0,15,10,0" VerticalAlignment="Top" Width="93" Click="saveButton_Click" Grid.Column="2" Grid.Row="1"/> <Button x:Name="save_button" Content="Save" HorizontalAlignment="Right" Margin="0,95,10,0" VerticalAlignment="Top" Width="93" Click="saveButton_Click" Grid.Column="2" Grid.Row="1"/>
<Label x:Name="label3" Content="Check if the launched app is running every" Margin="5,0,0,0" VerticalAlignment="Top" Height="29" Grid.Column="1" Grid.Row="1"/>
<ComboBox x:Name="seconds_comboBox" Margin="0,10,10,0" VerticalAlignment="Top" Height="31" Grid.Column="2" HorizontalAlignment="Right" Width="93" Grid.Row="1"/>
<Button x:Name="update_button" Click="update_button_Click" Content="Check for updates" Grid.Column="1" Margin="96,0,45,10" Grid.Row="1" VerticalAlignment="Bottom"/>
</Grid>
<Grid Margin="10,10,10,0" Grid.Column="1" Grid.Row="1">
<materialDesign:Chip Content="Projects @ GitHub"
IconBackground="{DynamicResource PrimaryHueDarkBrush}"
IconForeground="{DynamicResource PrimaryHueDarkForegroundBrush}"
Margin="75,299,59,149" Click="Chip1_Click" HorizontalAlignment="Stretch">
<materialDesign:Chip.Icon>
<materialDesign:PackIcon Kind="GithubCircle"></materialDesign:PackIcon>
</materialDesign:Chip.Icon>
</materialDesign:Chip>
<materialDesign:Chip Content="Paypal donate"
IconBackground="{DynamicResource PrimaryHueDarkBrush}"
IconForeground="{DynamicResource PrimaryHueDarkForegroundBrush}"
Margin="75,337,81,111" Click="Chip2_Click" HorizontalAlignment="Stretch">
<materialDesign:Chip.Icon>
<materialDesign:PackIcon Kind="Coffee"></materialDesign:PackIcon>
</materialDesign:Chip.Icon>
</materialDesign:Chip>
<materialDesign:Chip Content="@brianostorm"
IconBackground="{DynamicResource PrimaryHueDarkBrush}"
IconForeground="{DynamicResource PrimaryHueDarkForegroundBrush}"
Margin="75,263,81,185" Click="Chip_Click" HorizontalAlignment="Stretch">
<materialDesign:Chip.Icon>
<materialDesign:PackIcon Kind="Twitter" />
</materialDesign:Chip.Icon>
</materialDesign:Chip>
<TextBlock TextWrapping="WrapWithOverflow" x:Name="textBlock" Margin="0,185,0,0" VerticalAlignment="Top" Height="120" Text="Developed by Brian Lima, @brianostorm, if you like my work cheer me up at my Twitter or pay me a coffee via Paypal, this way i can keep building amazing open-source tools for you!" HorizontalAlignment="Left" Width="286" TextAlignment="Justify"/>
<materialDesign:ColorZone Padding="16" materialDesign:ShadowAssist.ShadowDepth="Depth2" Mode="PrimaryMid" VerticalAlignment="Top" Height="27">
<Label Content="About" HorizontalAlignment="Left" Margin="-10,-15,0,-17" VerticalAlignment="Top" FontFamily="Segoe UI Semibold" FontSize="14" Height="32" Foreground="#DDFFFFFF"/>
</materialDesign:ColorZone>
<Image x:Name="image2" Height="150" VerticalAlignment="Top" Source="Resources/briano.png" Stretch="UniformToFill" Margin="71,32,65,0"/>
</Grid> </Grid>
<GroupBox Header="About" Grid.Column="1" Margin="10" Grid.Row="1" materialDesign:ColorZoneAssist.Mode="Accent">
<Grid Margin="0,0,0,2" Width="270">
<Button Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}"
Margin="0,0,116,10" HorizontalAlignment="Right"
ToolTip="My Twitter" Height="40" VerticalAlignment="Bottom">
<materialDesign:PackIcon Kind="Twitter" Height="24" Width="24" />
</Button>
<Button Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}"
Margin="0,0,0,10" HorizontalAlignment="Right"
ToolTip="Donate on Paypal" Height="40" VerticalAlignment="Bottom">
<materialDesign:PackIcon Kind="Cash" Height="24" Width="24" />
</Button>
<Button Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}"
Margin="0,0,0,10"
ToolTip="My GitHub" Width="40" Height="40" VerticalAlignment="Bottom" HorizontalAlignment="Left">
<materialDesign:PackIcon Kind="GithubCircle" Height="24" Width="24" />
</Button>
<TextBlock TextWrapping="WrapWithOverflow" x:Name="textBlock" Margin="0,166,0,0" VerticalAlignment="Top" Height="120" Text="Developed by Brian Lima, @brianostorm, if you like my work cheer me up at my Twitter or pay me a coffee via Paypal, this way i can keep building amazing open-source tools for you!" HorizontalAlignment="Left" Width="270"/>
</Grid>
</GroupBox>
<Image x:Name="image1" Source="Resources/briano.jpg" Margin="82,57,0,283" HorizontalAlignment="Left" Width="152" Grid.Column="1" Grid.Row="1"/>
</Grid> </Grid>
</Window> </Window>

@ -1,18 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace UWPHook namespace UWPHook
{ {
@ -25,24 +13,53 @@ namespace UWPHook
{ {
InitializeComponent(); InitializeComponent();
Properties.Settings.Default.ChangeLanguage = true; this.Title = "UWPHook version " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
foreach (var culture in CultureInfo.GetCultures(CultureTypes.AllCultures)) foreach (var culture in CultureInfo.GetCultures(CultureTypes.AllCultures))
{ {
cultures_comboBox.Items.Add(culture.TextInfo.CultureName); cultures_comboBox.Items.Add(culture.TextInfo.CultureName);
} }
}
private void ToggleButton_Checked(object sender, RoutedEventArgs e) for (int i = 1; i < 10; i++)
{ {
seconds_comboBox.Items.Add(i + " seconds");
if (i == Properties.Settings.Default.Seconds)
{
seconds_comboBox.SelectedIndex = i - 1;
}
}
cultures_comboBox.SelectedItem = Properties.Settings.Default.TargetLanguage;
language_toggle.IsChecked = Properties.Settings.Default.ChangeLanguage;
} }
private void saveButton_Click(object sender, RoutedEventArgs e) private void saveButton_Click(object sender, RoutedEventArgs e)
{ {
Properties.Settings.Default.ChangeLanguage = (bool)language_toggle.IsChecked; Properties.Settings.Default.ChangeLanguage = (bool)language_toggle.IsChecked;
Properties.Settings.Default.TargetLanguage = cultures_comboBox.SelectedItem.ToString(); Properties.Settings.Default.TargetLanguage = cultures_comboBox.SelectedItem.ToString();
Properties.Settings.Default.Seconds = Int32.Parse(seconds_comboBox.SelectedItem.ToString().Substring(0, 1));
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
this.Close();
}
private void Chip_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start("http://twitter.com/brianostorm");
}
private void Chip1_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start("http://github.com/brianlima");
}
private void Chip2_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9YPV3FHEFRAUQ");
}
private void update_button_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start("https://github.com/BrianLima/UWPHook/releases");
} }
} }
} }

@ -186,7 +186,7 @@
</COMReference> </COMReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Resources\briano.jpg" /> <Resource Include="Resources\briano.png" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

Loading…
Cancel
Save