changed the UpdateAPI and set animation easeinout

This commit is contained in:
WeeXnes 2022-11-11 10:54:30 +01:00
parent dfc72ed8c7
commit dbc99c429c
7 changed files with 78 additions and 50 deletions

View file

@ -2,6 +2,8 @@
using System.Windows;
using WeeXnes.Core;
using System.IO;
using System.Reflection;
using WeeXnes.Misc;
using Application = System.Windows.Forms.Application;
namespace WeeXnes

View file

@ -1,30 +1,37 @@
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;
}
using System.Collections;
using System.Collections.Generic;
namespace WeeXnes.Core
{
public class GithubApiResponse
{
public string tag_name { get; set; }
public IList<GithubAsset> assets { get; set; }
public GithubApiResponse(string tag_name, IList<GithubAsset> assets)
{
this.tag_name = tag_name;
this.assets = assets;
}
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;
return this.tag_name + " with " + this.assets.Count;
}
}
public class GithubAsset
{
public string browser_download_url { get; set; }
public string name { get; set; }
public GithubAsset(string browser_download_url, string name)
{
this.browser_download_url = browser_download_url;
this.name = name;
}
public override string ToString()
{
return this.name;
}
}
}

View file

@ -16,10 +16,10 @@ namespace WeeXnes.Core
public static string encryptionKey = "8zf5#RdyQ]$4x4_";
public static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WeeXnes");
public static string SettingsFileName = "settings.ini";
public static string version = "3.6.6";
public static string version = "3.6.7";
public static bool info_isRpcRunning = false;
public static bool info_RpcAutoStart;
public static string apiUrl = "http://weexnes.com:5169/";
public static string apiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
public static UpdateVar<bool> settings_alwaysOnTop = new UpdateVar<bool>();
public static UpdateVar<bool> settings_osxStyleControlls = new UpdateVar<bool>();

View file

@ -282,15 +282,18 @@ 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)
using(WebClient webClient = new WebClient())
{;
webClient.Headers.Add("Authorization", "Basic :x-oauth-basic");
webClient.Headers.Add("User-Agent","lk-github-clien");
var downloadString = webClient.DownloadString(Globals.apiUrl);
GithubApiResponse ApiResponseData = JsonConvert.DeserializeObject<GithubApiResponse>(downloadString);
if (ApiResponseData.tag_name != Globals.version)
{
Misc.UpdateMessage updateMessage = new UpdateMessage(
GitHub,
ApiResponseData,
"Update Found");
updateMessage.Show();
}
@ -300,12 +303,17 @@ namespace WeeXnes.MVVM.View
msg.Show();
}
}
}
catch (Exception ex)
{
Misc.Message error = new Misc.Message(ex.ToString());
error.Show();
}
WebClient client = new WebClient();
}

View file

@ -72,7 +72,12 @@
Storyboard.TargetName="NavigationBorder"
Storyboard.TargetProperty="(Border.Width)"
To="200" Duration="0:0:00.4" AutoReverse="False"
/>
>
<DoubleAnimation.EasingFunction>
<CircleEase EasingMode="EaseInOut"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
@ -83,7 +88,12 @@
Storyboard.TargetName="NavigationBorder"
Storyboard.TargetProperty="(Border.Width)"
To="50" Duration="0:0:00.4" AutoReverse="False"
/>
>
<DoubleAnimation.EasingFunction>
<CircleEase EasingMode="EaseInOut"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>

View file

@ -11,8 +11,8 @@ namespace WeeXnes.Misc
{
public partial class UpdateMessage : Window
{
public static ApiResponse GitHub;
public UpdateMessage(ApiResponse _GitHub, string _title = "Message")
public static GithubApiResponse GitHub;
public UpdateMessage(GithubApiResponse _GitHub, string _title = "Message")
{
InitializeComponent();
string content = "Your Version: " + Globals.version + "\n" +
@ -26,13 +26,14 @@ namespace WeeXnes.Misc
{
checkForFile();
WebClient client = new WebClient();
client.DownloadFile(GitHub.download_url, GitHub.file_name);
client.DownloadFile(GitHub.assets[0].browser_download_url, GitHub.assets[0].name);
client.Dispose();
}
private static void checkForFile()
{
if (File.Exists(GitHub.file_name))
if (File.Exists(GitHub.assets[0].name))
{
File.Delete(GitHub.file_name);
File.Delete(GitHub.assets[0].name);
}
}
private void OkButton_OnClick(object sender, RoutedEventArgs e)
@ -43,7 +44,7 @@ namespace WeeXnes.Misc
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 + "\"");
Process updateProc = Process.Start("Update.exe", "\"" + path + "\"" + " " + "\"" + fileName + "\"" + " " + "\"" + pid + "\"" + " " + "\"" + GitHub.assets[0].name + "\"");
}
catch (Exception ex)
{

View file

@ -4,7 +4,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<Version>3.6.6</Version>
<Version>3.6.7</Version>
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>WeeXnes</RootNamespace>