[Settings] Temporary string showing the latest available version (#6254)

This commit is contained in:
Seraphima Zykova
2020-09-04 11:56:52 +03:00
committed by GitHub
parent e84a293642
commit 570065175c
12 changed files with 127 additions and 15 deletions

View File

@@ -723,4 +723,10 @@
<data name="FancyZones_MoveWindowsBasedOnPositionCheckBoxControl.Content" xml:space="preserve">
<value>Move windows based on their position</value>
</data>
<data name="GeneralSettings_NewVersionIsAvailable" xml:space="preserve">
<value>New update available</value>
</data>
<data name="GeneralSettings_VersionIsLatest" xml:space="preserve">
<value>You have the latest available version.</value>
</data>
</root>

View File

@@ -116,6 +116,9 @@
<HyperlinkButton NavigateUri="https://github.com/microsoft/PowerToys/releases" Margin="4,-6,0,0">
<TextBlock Text="{x:Bind ViewModel.PowerToysVersion }" />
</HyperlinkButton>
<TextBlock Text="{x:Bind ViewModel.LatestAvailableVersion, Mode=OneWay}"
Foreground="{ThemeResource SystemControlErrorTextForegroundBrush}"
Margin="16,0,0,0" />
</StackPanel>

View File

@@ -2,8 +2,10 @@
// 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;
using Microsoft.PowerToys.Settings.UI.Lib.ViewModels;
using Windows.ApplicationModel.Resources;
using Windows.Data.Json;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
@@ -40,6 +42,34 @@ namespace Microsoft.PowerToys.Settings.UI.Views
ShellPage.SendRestartAdminIPCMessage,
ShellPage.SendCheckForUpdatesIPCMessage);
ShellPage.ShellHandler.IPCResponseHandleList.Add((JsonObject json) =>
{
try
{
string version = json.GetNamedString("version");
bool isLatest = json.GetNamedBoolean("isVersionLatest");
var str = string.Empty;
if (isLatest)
{
str = ResourceLoader.GetForCurrentView().GetString("GeneralSettings_VersionIsLatest");
}
else if (version != string.Empty)
{
str = ResourceLoader.GetForCurrentView().GetString("GeneralSettings_NewVersionIsAvailable");
if (str != string.Empty)
{
str += ": " + version;
}
}
ViewModel.LatestAvailableVersion = string.Format(str);
}
catch (Exception)
{
}
});
DataContext = ViewModel;
}

View File

@@ -2,7 +2,9 @@
// 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;
using Microsoft.PowerToys.Settings.UI.ViewModels;
using Windows.Data.Json;
using Windows.UI.Xaml.Controls;
namespace Microsoft.PowerToys.Settings.UI.Views
@@ -43,6 +45,11 @@ namespace Microsoft.PowerToys.Settings.UI.Views
/// </summary>
public ShellViewModel ViewModel { get; } = new ShellViewModel();
/// <summary>
/// Gets a collection of functions that handle IPC responses.
/// </summary>
public List<System.Action<JsonObject>> IPCResponseHandleList { get; } = new List<System.Action<JsonObject>>();
public static bool IsElevated { get; set; }
public static bool IsUserAnAdmin { get; set; }