mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
Add About Page.
This commit is contained in:
@@ -309,5 +309,26 @@
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
<TabItem Header="About">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80"></ColumnDefinition>
|
||||
<ColumnDefinition></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"></RowDefinition>
|
||||
<RowDefinition Height="30"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" Margin="6">Website:</TextBlock>
|
||||
<TextBlock Grid.Column="1" Grid.Row="0" Margin="6" HorizontalAlignment="Left" Cursor="Hand" MouseUp="tbWebsite_MouseUp" x:Name="tbWebsite" Foreground="Blue" Text="http://www.getwox.com"></TextBlock>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="1" Margin="6">Version:</TextBlock>
|
||||
<StackPanel Grid.Column="1" Grid.Row="1" Orientation="Horizontal">
|
||||
<TextBlock Margin="6" HorizontalAlignment="Left" x:Name="tbVersion" Text="1.0.0"></TextBlock>
|
||||
<TextBlock Margin="6" HorizontalAlignment="Left" Cursor="Hand" MouseUp="tbNewVersionAvailable_MouseUp" x:Name="tbNewVersionAvailable" Foreground="Blue" Text="1.1.0 Available"></TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Window>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -15,6 +16,7 @@ using Wox.Plugin;
|
||||
using Wox.Helper;
|
||||
using Wox.Plugin.SystemPlugins;
|
||||
using Wox.PluginLoader;
|
||||
using Wox.Update;
|
||||
using Application = System.Windows.Forms.Application;
|
||||
using File = System.IO.File;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
@@ -221,6 +223,21 @@ namespace Wox
|
||||
|
||||
#endregion
|
||||
|
||||
#region About
|
||||
|
||||
tbVersion.Text = ConfigurationManager.AppSettings["version"];
|
||||
Release newRelease = new UpdateChecker().CheckUpgrade();
|
||||
if (newRelease == null)
|
||||
{
|
||||
tbNewVersionAvailable.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
tbNewVersionAvailable.Text = newRelease.version + " available";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
settingsLoaded = true;
|
||||
}
|
||||
|
||||
@@ -698,5 +715,19 @@ namespace Wox
|
||||
MessageBox.Show("Proxy connect failed.");
|
||||
}
|
||||
}
|
||||
|
||||
private void tbWebsite_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Process.Start("http://www.getwox.com");
|
||||
}
|
||||
|
||||
private void tbNewVersionAvailable_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Release newRelease = new UpdateChecker().CheckUpgrade();
|
||||
if (newRelease != null)
|
||||
{
|
||||
Process.Start("http://www.getwox.com/release/" + newRelease.version);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,16 +13,19 @@ namespace Wox.Update
|
||||
{
|
||||
public class UpdateChecker
|
||||
{
|
||||
private string updateURL = "https://api.getwox.com/release/latest/";
|
||||
private const string updateURL = "https://api.getwox.com/release/latest/";
|
||||
private static Release newRelease;
|
||||
private static bool checkedUpdate = false;
|
||||
|
||||
/// <summary>
|
||||
/// If new release is available, then return the new release
|
||||
/// otherwise, return null
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Release CheckUpgrade()
|
||||
public Release CheckUpgrade(bool forceCheck = false)
|
||||
{
|
||||
Release release = null;
|
||||
if (checkedUpdate && !forceCheck) return newRelease;
|
||||
|
||||
HttpWebResponse response = HttpRequest.CreateGetHttpResponse(updateURL, HttpProxy.Instance);
|
||||
Stream s = response.GetResponseStream();
|
||||
if (s != null)
|
||||
@@ -31,20 +34,20 @@ namespace Wox.Update
|
||||
string json = reader.ReadToEnd();
|
||||
try
|
||||
{
|
||||
release = JsonConvert.DeserializeObject<Release>(json);
|
||||
newRelease = JsonConvert.DeserializeObject<Release>(json);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsNewerThanCurrent(release))
|
||||
if (!IsNewerThanCurrent(newRelease))
|
||||
{
|
||||
return null;
|
||||
newRelease = null;
|
||||
}
|
||||
|
||||
return release;
|
||||
checkedUpdate = true;
|
||||
return newRelease;
|
||||
}
|
||||
|
||||
private bool IsNewerThanCurrent(Release release)
|
||||
|
||||
Reference in New Issue
Block a user