Fixed language selection.

This commit is contained in:
Robin Krom 2019-04-30 23:20:38 +02:00
commit 669dce1b12
5 changed files with 26 additions and 18 deletions

View file

@ -359,6 +359,7 @@ namespace Greenshot.Forms
case Keys.E: case Keys.E:
var info = new StringBuilder(EnvironmentInfo.EnvironmentToString(true)); var info = new StringBuilder(EnvironmentInfo.EnvironmentToString(true));
var screenboundsSize = DisplayInfo.ScreenBounds.Size; var screenboundsSize = DisplayInfo.ScreenBounds.Size;
info.AppendLine();
info.AppendFormat("Screen: {0} at {1}%", $"{screenboundsSize.Width} x {screenboundsSize.Height}", FormDpiHandler.ScaleWithCurrentDpi(100)); info.AppendFormat("Screen: {0} at {1}%", $"{screenboundsSize.Width} x {screenboundsSize.Height}", FormDpiHandler.ScaleWithCurrentDpi(100));
MessageBox.Show(info.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show(info.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
break; break;

View file

@ -819,12 +819,17 @@ namespace Greenshot.Forms
/// </summary> /// </summary>
public void ShowSetting() public void ShowSetting()
{ {
var lang = _coreConfiguration.Language;
using (var ownedConfigViewModel = _configViewModelFactory()) using (var ownedConfigViewModel = _configViewModelFactory())
{ {
_windowManager.ShowDialog(ownedConfigViewModel.Value); _windowManager.ShowDialog(ownedConfigViewModel.Value);
} }
if (!Equals(lang, _coreConfiguration.Language))
{
ApplyLanguage();
InitializeQuickSettingsMenu(); InitializeQuickSettingsMenu();
} }
}
/// <summary> /// <summary>
/// The "About Greenshot" entry is clicked /// The "About Greenshot" entry is clicked

View file

@ -156,13 +156,6 @@ namespace Greenshot.Helpers
{ {
environment.AppendLine(); environment.AppendLine();
} }
else
{
environment.Append(", ");
}
// TODO: Is this needed?
// environment.AppendFormat("Surface count: {0}", Surface.Count);
return environment.ToString(); return environment.ToString();
} }

View file

@ -20,13 +20,16 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reactive.Disposables; using System.Reactive.Disposables;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using Autofac.Features.OwnedInstances; using Autofac.Features.OwnedInstances;
using Dapplo.CaliburnMicro; using Dapplo.CaliburnMicro;
using Dapplo.CaliburnMicro.Configuration; using Dapplo.CaliburnMicro.Configuration;
using Dapplo.CaliburnMicro.Extensions; using Dapplo.CaliburnMicro.Extensions;
using Dapplo.Config.Language;
using Greenshot.Addons; using Greenshot.Addons;
using Greenshot.Addons.Core;
using Greenshot.Configuration; using Greenshot.Configuration;
using Greenshot.Ui.Notifications.ViewModels; using Greenshot.Ui.Notifications.ViewModels;
using MahApps.Metro.IconPacks; using MahApps.Metro.IconPacks;
@ -60,9 +63,11 @@ namespace Greenshot.Ui.Configuration.ViewModels
public IConfigTranslations ConfigTranslations { get; } public IConfigTranslations ConfigTranslations { get; }
public ConfigViewModel( public ConfigViewModel(
ICoreConfiguration coreConfiguration,
IEnumerable<Lazy<IConfigScreen>> configScreens, IEnumerable<Lazy<IConfigScreen>> configScreens,
IGreenshotLanguage greenshotLanguage, IGreenshotLanguage greenshotLanguage,
IConfigTranslations configTranslations, IConfigTranslations configTranslations,
LanguageContainer languageContainer,
Func<Owned<UpdateNotificationViewModel>> updateNotificationViewModelFactory Func<Owned<UpdateNotificationViewModel>> updateNotificationViewModelFactory
) )
{ {
@ -73,9 +78,8 @@ namespace Greenshot.Ui.Configuration.ViewModels
// automatically update the DisplayName // automatically update the DisplayName
GreenshotLanguage.CreateDisplayNameBinding(this, nameof(IGreenshotLanguage.SettingsTitle)); GreenshotLanguage.CreateDisplayNameBinding(this, nameof(IGreenshotLanguage.SettingsTitle));
// TODO: Check if we need to set the current language (this should update all registered OnPropertyChanged anyway, so it can run in the background var lang = coreConfiguration.Language;
//var lang = demoConfiguration.Language; Task.Run(async () => await languageContainer.ChangeLanguageAsync(lang).ConfigureAwait(false));
//Task.Run(async () => await LanguageLoader.Current.ChangeLanguageAsync(lang).ConfigureAwait(false));
} }
/// <summary> /// <summary>

View file

@ -21,10 +21,12 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Reactive.Disposables; using System.Reactive.Disposables;
using Caliburn.Micro;
using Dapplo.CaliburnMicro.Configuration; using Dapplo.CaliburnMicro.Configuration;
using Dapplo.CaliburnMicro.Extensions; using Dapplo.CaliburnMicro.Extensions;
using Dapplo.CaliburnMicro.Metro; using Dapplo.CaliburnMicro.Metro;
using Dapplo.Config.Intercepting; using Dapplo.Config.Intercepting;
using Dapplo.Config.Language;
using Dapplo.Utils.Extensions; using Dapplo.Utils.Extensions;
using Greenshot.Addons; using Greenshot.Addons;
using Greenshot.Addons.Core; using Greenshot.Addons.Core;
@ -36,6 +38,7 @@ namespace Greenshot.Ui.Configuration.ViewModels
public sealed class UiConfigViewModel : SimpleConfigScreen public sealed class UiConfigViewModel : SimpleConfigScreen
{ {
private readonly MetroThemeManager _metroThemeManager; private readonly MetroThemeManager _metroThemeManager;
private readonly LanguageContainer _languageContainer;
/// <summary> /// <summary>
/// Here all disposables are registered, so we can clean the up /// Here all disposables are registered, so we can clean the up
@ -57,17 +60,16 @@ namespace Greenshot.Ui.Configuration.ViewModels
/// </summary> /// </summary>
// ReSharper disable once UnusedMember.Global // ReSharper disable once UnusedMember.Global
// TODO: Fix // TODO: Fix
public IDictionary<string, string> AvailableLanguages => new Dictionary<string, string>();//LanguageLoader.Current.AvailableLanguages; public IDictionary<string, string> AvailableLanguages { get; }
/// <summary> /// <summary>
/// Can the login button be pressed? /// Can the login button be pressed?
/// </summary> /// </summary>
// TODO: Fix // TODO: Fix
public bool CanChangeLanguage public bool CanChangeLanguage
=> !string.IsNullOrWhiteSpace(CoreConfiguration.Language); // && CoreConfiguration.Language != LanguageLoader.Current.CurrentLanguage; => !string.IsNullOrWhiteSpace(CoreConfiguration.Language) && CoreConfiguration.Language != _languageContainer.CurrentLanguage;
public IMetroConfiguration MetroConfiguration { get; } public IMetroConfiguration MetroConfiguration { get; }
public IConfigTranslations ConfigTranslations { get; } public IConfigTranslations ConfigTranslations { get; }
public ICoreConfiguration CoreConfiguration { get; } public ICoreConfiguration CoreConfiguration { get; }
@ -87,10 +89,13 @@ namespace Greenshot.Ui.Configuration.ViewModels
IGreenshotLanguage greenshotLanguage, IGreenshotLanguage greenshotLanguage,
IConfigTranslations configTranslations, IConfigTranslations configTranslations,
IMetroConfiguration metroConfiguration, IMetroConfiguration metroConfiguration,
MetroThemeManager metroThemeManager MetroThemeManager metroThemeManager,
LanguageContainer languageContainer
) )
{ {
AvailableLanguages = languageContainer.AvailableLanguages;
_metroThemeManager = metroThemeManager; _metroThemeManager = metroThemeManager;
_languageContainer = languageContainer;
CoreConfiguration = coreConfiguration; CoreConfiguration = coreConfiguration;
GreenshotLanguage = greenshotLanguage; GreenshotLanguage = greenshotLanguage;
ConfigTranslations = configTranslations; ConfigTranslations = configTranslations;
@ -105,8 +110,8 @@ namespace Greenshot.Ui.Configuration.ViewModels
MetroConfiguration.CommitTransaction(); MetroConfiguration.CommitTransaction();
CoreConfiguration.CommitTransaction(); CoreConfiguration.CommitTransaction();
// TODO: Fix Execute.OnUIThread(async () => {
//Execute.OnUIThread(async () => { await LanguageLoader.Current.ChangeLanguageAsync(CoreConfiguration.Language).ConfigureAwait(false); }); await _languageContainer.ChangeLanguageAsync(CoreConfiguration.Language).ConfigureAwait(false); });
} }