Skip to content

Commit

Permalink
Merge branch 'issue-151'
Browse files Browse the repository at this point in the history
  • Loading branch information
david-poindexter committed Mar 5, 2018
2 parents 55d6b64 + 6e89ea6 commit 2d59bb9
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 2 deletions.
27 changes: 27 additions & 0 deletions Controllers/VersionController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Net;

namespace nvQuickSite.Controllers
{
public class VersionController
{
public static string GetRemoteLatestVersion()
{
WebClient client = new WebClient();
try
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var url = "https://raw.githubusercontent.com/nvisionative/nvQuickSite/master/data/latestVersion.json";
string result = client.DownloadString(url);
Models.Version res = Newtonsoft.Json.JsonConvert.DeserializeObject<Models.Version>(result);
return res.latestVersion;
}
catch (Exception ex)
{
}
return "";
}

}
}
22 changes: 20 additions & 2 deletions Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using MetroFramework.Forms;
using Segment;
using JCS;
using nvQuickSite.Controllers;

namespace nvQuickSite
{
Expand All @@ -39,6 +40,13 @@ public Main()
});

lblVersion.Text = "v" + Application.ProductVersion;

var latestVersion = VersionController.GetRemoteLatestVersion();
if (Version.Parse(latestVersion) > Version.Parse(Application.ProductVersion))
{
tileGetNewVersion.Visible = true;
}

Start control = new Start();
control.Dock = DockStyle.Fill;
Controls.Add(control);
Expand All @@ -48,5 +56,10 @@ private void pictureBox1_Click(object sender, EventArgs e)
{
Process.Start("http://www.nvisionative.com");
}

private void tileGetNewVersion_Click(object sender, EventArgs e)
{
Process.Start("https://github.com/nvisionative/nvQuickSite/releases/latest");
}
}
}
13 changes: 13 additions & 0 deletions Models/Version.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace nvQuickSite.Models
{
class Version
{
public string latestVersion { get; set; }
}
}
3 changes: 3 additions & 0 deletions data/latestVersion.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"latestVersion": "1.2.0"
}
3 changes: 3 additions & 0 deletions nvQuickSite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@
<ItemGroup>
<Compile Include="CodePlexRSS.cs" />
<Compile Include="ComboItem.cs" />
<Compile Include="Controllers\VersionController.cs" />
<Compile Include="Models\Version.cs" />
<Compile Include="MsgBoxYesNoIgnore.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -174,6 +176,7 @@
</Compile>
<None Include=".gitignore" />
<None Include="app.config" />
<None Include="data\latestVersion.json" />
<None Include="LICENSE.md" />
<None Include="packages.config">
<SubType>Designer</SubType>
Expand Down

0 comments on commit 2d59bb9

Please sign in to comment.