added update checker in settings
This commit is contained in:
parent
3cf1146803
commit
9a8bf18265
13 changed files with 370 additions and 16 deletions
|
@ -105,6 +105,7 @@ namespace Release_Tool
|
||||||
files.Add(new file(@"WeeXnes\bin\Release\DiscordRPC.dll", "DiscordRPC.dll"));
|
files.Add(new file(@"WeeXnes\bin\Release\DiscordRPC.dll", "DiscordRPC.dll"));
|
||||||
files.Add(new file(@"WeeXnes\bin\Release\Newtonsoft.Json.dll", "Newtonsoft.Json.dll"));
|
files.Add(new file(@"WeeXnes\bin\Release\Newtonsoft.Json.dll", "Newtonsoft.Json.dll"));
|
||||||
files.Add(new file(@"Autostart\bin\Release\Autostart.exe", "Autostart.exe"));
|
files.Add(new file(@"Autostart\bin\Release\Autostart.exe", "Autostart.exe"));
|
||||||
|
files.Add(new file(@"Update\bin\Release\Update.exe", "Update.exe"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
65
Update/Program.cs
Normal file
65
Update/Program.cs
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
|
|
||||||
|
namespace Update
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Path: " + args[0]);
|
||||||
|
Console.WriteLine("FileName: " + args[1]);
|
||||||
|
Console.WriteLine("PID: " + args[2]);
|
||||||
|
Console.WriteLine("New File: " + args[3]);
|
||||||
|
Process p = Process.GetProcessById(Convert.ToInt32(args[2]));
|
||||||
|
p.Kill();
|
||||||
|
p.WaitForExit();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ZipArchiveHelper.ExtractToDirectory(args[3], args[0], true);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.ToString());
|
||||||
|
ZipArchiveHelper.ExtractToDirectory(args[3], args[0], true);
|
||||||
|
}
|
||||||
|
Process.Start(args[0] + "\\" + args[1]);
|
||||||
|
if (File.Exists(args[3]))
|
||||||
|
{
|
||||||
|
File.Delete(args[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static class ZipArchiveHelper
|
||||||
|
{
|
||||||
|
public static void ExtractToDirectory(string archiveFileName, string destinationDirectoryName, bool overwrite)
|
||||||
|
{
|
||||||
|
if (!overwrite)
|
||||||
|
{
|
||||||
|
ZipFile.ExtractToDirectory(archiveFileName, destinationDirectoryName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
using (var archive = ZipFile.OpenRead(archiveFileName))
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach (var file in archive.Entries)
|
||||||
|
{
|
||||||
|
var completeFileName = Path.Combine(destinationDirectoryName, file.FullName);
|
||||||
|
var directory = Path.GetDirectoryName(completeFileName);
|
||||||
|
|
||||||
|
if (!Directory.Exists(directory) && !string.IsNullOrEmpty(directory))
|
||||||
|
Directory.CreateDirectory(directory);
|
||||||
|
|
||||||
|
if (file.Name != "")
|
||||||
|
file.ExtractToFile(completeFileName, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
35
Update/Properties/AssemblyInfo.cs
Normal file
35
Update/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("Update")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Update")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("6F2F689B-F4E3-4204-BA72-624BE46020AD")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
56
Update/Update.csproj
Normal file
56
Update/Update.csproj
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{6F2F689B-F4E3-4204-BA72-624BE46020AD}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Update</RootNamespace>
|
||||||
|
<AssemblyName>Update</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.IO.Compression" />
|
||||||
|
<Reference Include="System.IO.Compression.FileSystem" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
|
||||||
|
</Project>
|
|
@ -8,6 +8,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeeXnes_UAC", "WeeXnes_UAC\
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Release_Tool", "Release_Tool\Release_Tool.csproj", "{4C09AD12-B48E-40ED-B418-CF868889E317}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Release_Tool", "Release_Tool\Release_Tool.csproj", "{4C09AD12-B48E-40ED-B418-CF868889E317}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Update", "Update\Update.csproj", "{6F2F689B-F4E3-4204-BA72-624BE46020AD}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -30,5 +32,9 @@ Global
|
||||||
{4C09AD12-B48E-40ED-B418-CF868889E317}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{4C09AD12-B48E-40ED-B418-CF868889E317}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{4C09AD12-B48E-40ED-B418-CF868889E317}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{4C09AD12-B48E-40ED-B418-CF868889E317}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{4C09AD12-B48E-40ED-B418-CF868889E317}.Release|Any CPU.Build.0 = Release|Any CPU
|
{4C09AD12-B48E-40ED-B418-CF868889E317}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{6F2F689B-F4E3-4204-BA72-624BE46020AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6F2F689B-F4E3-4204-BA72-624BE46020AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6F2F689B-F4E3-4204-BA72-624BE46020AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6F2F689B-F4E3-4204-BA72-624BE46020AD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
30
WeeXnes/Core/ApiResponse.cs
Normal file
30
WeeXnes/Core/ApiResponse.cs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
namespace WeeXnes.Core
|
||||||
|
{
|
||||||
|
public class ApiResponse
|
||||||
|
{
|
||||||
|
public string download_url { get; set; }
|
||||||
|
public string file_name { get; set; }
|
||||||
|
public string tag_name { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public string description { get; set; }
|
||||||
|
public ApiResponse(string _download_url, string _file_name, string _tag_name, string _name, string _description)
|
||||||
|
{
|
||||||
|
this.download_url = _download_url;
|
||||||
|
this.file_name = _file_name;
|
||||||
|
this.tag_name = _tag_name;
|
||||||
|
this.name = _name;
|
||||||
|
this.description = _description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string returnval =
|
||||||
|
"download_url: " + this.download_url + "\n" +
|
||||||
|
"file_name: " + this.file_name + "\n" +
|
||||||
|
"tag_name: " + this.tag_name + "\n" +
|
||||||
|
"name: " + this.name + "\n" +
|
||||||
|
"description: " + this.description;
|
||||||
|
return returnval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,9 +15,10 @@ namespace WeeXnes.Core
|
||||||
public static string encryptionKey = "8zf5#RdyQ]$4x4_";
|
public static string encryptionKey = "8zf5#RdyQ]$4x4_";
|
||||||
public static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WeeXnes");
|
public static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WeeXnes");
|
||||||
public static string SettingsFileName = "settings.ini";
|
public static string SettingsFileName = "settings.ini";
|
||||||
public static string version = "2.6";
|
public static string version = "2.7";
|
||||||
public static bool info_isRpcRunning = false;
|
public static bool info_isRpcRunning = false;
|
||||||
public static bool info_RpcAutoStart;
|
public static bool info_RpcAutoStart;
|
||||||
|
public static string apiUrl = "http://www.weexnes.com:5169/";
|
||||||
|
|
||||||
public static UpdateVar<bool> settings_alwaysOnTop = new UpdateVar<bool>();
|
public static UpdateVar<bool> settings_alwaysOnTop = new UpdateVar<bool>();
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ namespace WeeXnes.Core
|
||||||
}
|
}
|
||||||
public static class SettingsManager
|
public static class SettingsManager
|
||||||
{
|
{
|
||||||
private static INIFile SettingsFile = new INIFile(
|
public static INIFile SettingsFile = new INIFile(
|
||||||
Globals.AppDataPath + "\\" + Globals.SettingsFileName,
|
Globals.AppDataPath + "\\" + Globals.SettingsFileName,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
|
@ -36,22 +36,36 @@
|
||||||
Background="#22202f"
|
Background="#22202f"
|
||||||
CornerRadius="10"
|
CornerRadius="10"
|
||||||
Margin="10,40,10,10">
|
Margin="10,40,10,10">
|
||||||
|
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
|
|
||||||
|
<CheckBox VerticalAlignment="Top"
|
||||||
|
VerticalContentAlignment="Center"
|
||||||
|
HorizontalContentAlignment="Center"
|
||||||
|
Name="AlwaysOnTopSwitch"
|
||||||
|
Checked="AlwaysOnTopSwitch_Checked"
|
||||||
|
Unchecked="AlwaysOnTopSwitch_Unchecked"
|
||||||
|
Margin="10,10,0,0">
|
||||||
|
<TextBlock
|
||||||
|
Text="Always On Top"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
FontSize="15"
|
||||||
|
Foreground="White"/>
|
||||||
|
</CheckBox>
|
||||||
|
|
||||||
<CheckBox VerticalAlignment="Top"
|
|
||||||
VerticalContentAlignment="Center"
|
<Button Name="CheckForUpdateBtn"
|
||||||
HorizontalContentAlignment="Center"
|
Style="{StaticResource UniversalMaterialButton}"
|
||||||
Name="AlwaysOnTopSwitch"
|
Content="Check for Updates"
|
||||||
Checked="AlwaysOnTopSwitch_Checked"
|
Background="#353340"
|
||||||
Unchecked="AlwaysOnTopSwitch_Unchecked"
|
Height="25"
|
||||||
Margin="10,10,0,0">
|
Click="CheckForUpdateBtn_OnClick"
|
||||||
<TextBlock
|
Margin="4,10,4,0"/>
|
||||||
Text="Always On Top"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
FontSize="15"
|
|
||||||
Foreground="White"/>
|
|
||||||
</CheckBox>
|
|
||||||
|
|
||||||
|
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
</Border>
|
</Border>
|
||||||
<Border Grid.Column="2"
|
<Border Grid.Column="2"
|
||||||
Background="#22202f"
|
Background="#22202f"
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
@ -14,9 +15,13 @@ using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Nocksoft.IO.ConfigFiles;
|
using Nocksoft.IO.ConfigFiles;
|
||||||
using WeeXnes.Core;
|
using WeeXnes.Core;
|
||||||
|
using WeeXnes.Misc;
|
||||||
|
using Application = System.Windows.Forms.Application;
|
||||||
using MessageBox = System.Windows.MessageBox;
|
using MessageBox = System.Windows.MessageBox;
|
||||||
|
using Path = System.IO.Path;
|
||||||
using UserControl = System.Windows.Controls.UserControl;
|
using UserControl = System.Windows.Controls.UserControl;
|
||||||
|
|
||||||
namespace WeeXnes.MVVM.View
|
namespace WeeXnes.MVVM.View
|
||||||
|
@ -261,5 +266,34 @@ namespace WeeXnes.MVVM.View
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CheckForUpdateBtn_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
WebClient client = new WebClient();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string downloadString = client.DownloadString(Globals.apiUrl);
|
||||||
|
ApiResponse GitHub = JsonConvert.DeserializeObject<ApiResponse>(downloadString);
|
||||||
|
if (GitHub.tag_name != Globals.version)
|
||||||
|
{
|
||||||
|
Misc.UpdateMessage updateMessage = new UpdateMessage(
|
||||||
|
GitHub,
|
||||||
|
"Update Found");
|
||||||
|
updateMessage.Show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Misc.Message msg = new Misc.Message("No Updates found");
|
||||||
|
msg.Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Misc.Message error = new Misc.Message(ex.ToString());
|
||||||
|
error.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,11 @@ namespace WeeXnes.Misc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class Message : Window
|
public partial class Message : Window
|
||||||
{
|
{
|
||||||
public Message(string _message)
|
public Message(string _message, string _title = "Message")
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
MessageLabel.Content = _message;
|
MessageLabel.Content = _message;
|
||||||
|
this.Title = _title;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void okButton_Click(object sender, RoutedEventArgs e)
|
private void okButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
|
45
WeeXnes/Misc/UpdateMessage.xaml
Normal file
45
WeeXnes/Misc/UpdateMessage.xaml
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<Window x:Class="WeeXnes.Misc.UpdateMessage"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:WeeXnes.Misc"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Message" Height="150" Width="300"
|
||||||
|
ResizeMode="NoResize"
|
||||||
|
Background="#272537"
|
||||||
|
WindowStartupLocation="CenterScreen"
|
||||||
|
SizeToContent="WidthAndHeight">
|
||||||
|
<Grid>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Label Content="Placeholder"
|
||||||
|
Name="MessageLabel"
|
||||||
|
Foreground="White"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Center"/>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center">
|
||||||
|
<Button Grid.Row="1"
|
||||||
|
Style="{StaticResource UniversalMaterialButton}"
|
||||||
|
Content="OK"
|
||||||
|
Width="140"
|
||||||
|
Height="40"
|
||||||
|
Background="#353340"
|
||||||
|
Name="okButton"
|
||||||
|
Click="OkButton_OnClick"/>
|
||||||
|
<Button Grid.Row="1"
|
||||||
|
Style="{StaticResource UniversalMaterialButton}"
|
||||||
|
Content="CANCEL"
|
||||||
|
Width="140"
|
||||||
|
Height="40"
|
||||||
|
Background="#353340"
|
||||||
|
Name="cancelButton"
|
||||||
|
Click="CancelButton_OnClick"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
61
WeeXnes/Misc/UpdateMessage.xaml.cs
Normal file
61
WeeXnes/Misc/UpdateMessage.xaml.cs
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using WeeXnes.Core;
|
||||||
|
using Application = System.Windows.Forms.Application;
|
||||||
|
|
||||||
|
namespace WeeXnes.Misc
|
||||||
|
{
|
||||||
|
public partial class UpdateMessage : Window
|
||||||
|
{
|
||||||
|
public static ApiResponse GitHub;
|
||||||
|
public UpdateMessage(ApiResponse _GitHub, string _title = "Message")
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
string content = "Your Version: " + Globals.version + "\n" +
|
||||||
|
"Current Version: " + _GitHub.tag_name;
|
||||||
|
MessageLabel.Content = content;
|
||||||
|
this.Title = _title;
|
||||||
|
GitHub = _GitHub;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void downloadAssets()
|
||||||
|
{
|
||||||
|
checkForFile();
|
||||||
|
WebClient client = new WebClient();
|
||||||
|
client.DownloadFile(GitHub.download_url, GitHub.file_name);
|
||||||
|
}
|
||||||
|
private static void checkForFile()
|
||||||
|
{
|
||||||
|
if (File.Exists(GitHub.file_name))
|
||||||
|
{
|
||||||
|
File.Delete(GitHub.file_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void OkButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
downloadAssets();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string path = Application.StartupPath;
|
||||||
|
string fileName = Path.GetFileName(Application.ExecutablePath);
|
||||||
|
string pid = Process.GetCurrentProcess().Id.ToString();
|
||||||
|
Process updateProc = Process.Start("Update.exe", "\"" + path + "\"" + " " + "\"" + fileName + "\"" + " " + "\"" + pid + "\"" + " " + "\"" + GitHub.file_name + "\"");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Misc.Message message = new Misc.Message(ex.ToString());
|
||||||
|
message.Show();
|
||||||
|
|
||||||
|
}
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CancelButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -59,6 +59,10 @@
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
|
<Compile Include="Core\ApiResponse.cs" />
|
||||||
|
<Compile Include="Misc\UpdateMessage.xaml.cs">
|
||||||
|
<DependentUpon>UpdateMessage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="RPC\Game.cs" />
|
<Compile Include="RPC\Game.cs" />
|
||||||
<Page Include="MainWindow.xaml">
|
<Page Include="MainWindow.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
@ -78,6 +82,7 @@
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Page Include="Misc\Message.xaml" />
|
<Page Include="Misc\Message.xaml" />
|
||||||
|
<Page Include="Misc\UpdateMessage.xaml" />
|
||||||
<Page Include="MVVM\View\DiscordRpcView.xaml" />
|
<Page Include="MVVM\View\DiscordRpcView.xaml" />
|
||||||
<Page Include="MVVM\View\HomeView.xaml" />
|
<Page Include="MVVM\View\HomeView.xaml" />
|
||||||
<Page Include="MVVM\View\KeyManagerView.xaml" />
|
<Page Include="MVVM\View\KeyManagerView.xaml" />
|
||||||
|
|
Loading…
Add table
Reference in a new issue