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:
var info = new StringBuilder(EnvironmentInfo.EnvironmentToString(true));
var screenboundsSize = DisplayInfo.ScreenBounds.Size;
info.AppendLine();
info.AppendFormat("Screen: {0} at {1}%", $"{screenboundsSize.Width} x {screenboundsSize.Height}", FormDpiHandler.ScaleWithCurrentDpi(100));
MessageBox.Show(info.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
break;

View file

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

View file

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

View file

@ -20,13 +20,16 @@
using System;
using System.Collections.Generic;
using System.Reactive.Disposables;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using Autofac.Features.OwnedInstances;
using Dapplo.CaliburnMicro;
using Dapplo.CaliburnMicro.Configuration;
using Dapplo.CaliburnMicro.Extensions;
using Dapplo.Config.Language;
using Greenshot.Addons;
using Greenshot.Addons.Core;
using Greenshot.Configuration;
using Greenshot.Ui.Notifications.ViewModels;
using MahApps.Metro.IconPacks;
@ -60,9 +63,11 @@ namespace Greenshot.Ui.Configuration.ViewModels
public IConfigTranslations ConfigTranslations { get; }
public ConfigViewModel(
ICoreConfiguration coreConfiguration,
IEnumerable<Lazy<IConfigScreen>> configScreens,
IGreenshotLanguage greenshotLanguage,
IConfigTranslations configTranslations,
LanguageContainer languageContainer,
Func<Owned<UpdateNotificationViewModel>> updateNotificationViewModelFactory
)
{
@ -73,9 +78,8 @@ namespace Greenshot.Ui.Configuration.ViewModels
// automatically update the DisplayName
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 = demoConfiguration.Language;
//Task.Run(async () => await LanguageLoader.Current.ChangeLanguageAsync(lang).ConfigureAwait(false));
var lang = coreConfiguration.Language;
Task.Run(async () => await languageContainer.ChangeLanguageAsync(lang).ConfigureAwait(false));
}
/// <summary>

View file

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