mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Avoid new CultureInfo every second
This commit is contained in:
parent
9051e3ead3
commit
0e6fbf236a
1 changed files with 14 additions and 4 deletions
|
|
@ -67,7 +67,14 @@ namespace Flow.Launcher.ViewModel
|
|||
{
|
||||
if (args.PropertyName == nameof(Settings.WindowSize))
|
||||
{
|
||||
OnPropertyChanged(nameof(MainWindowWidth));
|
||||
}
|
||||
switch (args.PropertyName) {
|
||||
case nameof(Settings.WindowSize):
|
||||
OnPropertyChanged(nameof(MainWindowWidth));
|
||||
break;
|
||||
case nameof(Settings.Language):
|
||||
Culture = new CultureInfo(Settings.Language);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -99,6 +106,8 @@ namespace Flow.Launcher.ViewModel
|
|||
RegisterClockAndDateUpdateAsync();
|
||||
|
||||
SetOpenResultModifiers();
|
||||
|
||||
Culture = new CultureInfo(Settings.Language);
|
||||
}
|
||||
|
||||
private void RegisterViewUpdate()
|
||||
|
|
@ -334,8 +343,8 @@ namespace Flow.Launcher.ViewModel
|
|||
public Settings Settings { get; }
|
||||
public string ClockText { get; private set; }
|
||||
public string DateText { get; private set; }
|
||||
public CultureInfo Culture { get; set; }
|
||||
|
||||
public CultureInfo cultureInfo => new CultureInfo(Settings.Language);
|
||||
private async Task RegisterClockAndDateUpdateAsync()
|
||||
{
|
||||
var timer = new PeriodicTimer(TimeSpan.FromSeconds(1));
|
||||
|
|
@ -343,11 +352,12 @@ namespace Flow.Launcher.ViewModel
|
|||
while (await timer.WaitForNextTickAsync().ConfigureAwait(false))
|
||||
{
|
||||
if (Settings.UseClock)
|
||||
ClockText = DateTime.Now.ToString(Settings.TimeFormat, cultureInfo);
|
||||
ClockText = DateTime.Now.ToString(Settings.TimeFormat, Culture);
|
||||
if (Settings.UseDate)
|
||||
DateText = DateTime.Now.ToString(Settings.DateFormat, cultureInfo);
|
||||
DateText = DateTime.Now.ToString(Settings.DateFormat, Culture);
|
||||
}
|
||||
}
|
||||
|
||||
public ResultsViewModel Results { get; private set; }
|
||||
|
||||
public ResultsViewModel ContextMenu { get; private set; }
|
||||
|
|
|
|||
Loading…
Reference in a new issue