Skip to content

Commit

Permalink
Updater Added
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Jun 8, 2020
1 parent d36b157 commit 00ab472
Show file tree
Hide file tree
Showing 10 changed files with 355 additions and 76 deletions.
134 changes: 63 additions & 71 deletions RsMapper/Form1.Designer.cs

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion RsMapper/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,12 @@ private Image Rotate(Image img) {
return img;

}


private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
{
UpdateCheck uc = new UpdateCheck();
uc.ShowDialog();
uc.Dispose();
}
}
}
2 changes: 1 addition & 1 deletion RsMapper/Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADg
CgAAAk1TRnQBSQFMAgEBDAEAAQgBAQEIAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CgAAAk1TRnQBSQFMAgEBDAEAASABAQEgAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAAUADAAEBAQABCAYAARAYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
Expand Down
2 changes: 1 addition & 1 deletion RsMapper/Forms/DownloadProgress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private void DownloadProgress_Load(object sender, EventArgs e)
try
{
// Reinstall the file if the user clicks yes.
wc.DownloadFileAsync(new Uri(source), AppDomain.CurrentDomain.BaseDirectory + "Components.json");
wc.DownloadFileAsync(new Uri(source), AppDomain.CurrentDomain.BaseDirectory + local);
wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
wc.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
}
Expand Down
69 changes: 69 additions & 0 deletions RsMapper/Forms/UpdateCheck.Designer.cs

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

77 changes: 77 additions & 0 deletions RsMapper/Forms/UpdateCheck.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RsMapper.Properties;
using System.Windows.Forms;
using System.Net;
using Octokit;
using System.Reflection;
using System.Diagnostics;

namespace RsMapper.Forms
{
public partial class UpdateCheck : Form
{


public UpdateCheck()
{
InitializeComponent();

}

private void UpdateCheck_Load(object sender, EventArgs e)
{

// The the update void.
CheckUpdates();
}

private async void CheckUpdates()
{
// About box to get current version.
AboutBox1 abt = new AboutBox1();

// Create a new client.
var client = new GitHubClient(new ProductHeaderValue("RsMapper"));
try
{
// Get all of the releases on the repo.
var releases = await client.Repository.Release.GetAll("GreenJamesDev", "RsMapper");
var latest = releases[0]; // Get the latest release.

// Compare versions.
if (latest.TagName != abt.AssemblyVersion)
{
// Is a new update.
if (MessageBox.Show("An update for RsMapper is available! Would you like to download it?", "Update Found", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
{
Process.Start(latest.HtmlUrl);
System.Windows.Forms.Application.Exit();
}
// Isn't a new update.
else
{
this.Dispose();
}
}
else
{
this.Dispose();
}


} catch (Exception e)
{
this.Dispose();
}
this.Dispose();

}
}
}
120 changes: 120 additions & 0 deletions RsMapper/Forms/UpdateCheck.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
7 changes: 5 additions & 2 deletions RsMapper/PrgmSelfCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ public class PrgmSelfCheck
/// </summary>
public void CheckAll()
{
if(File.Exists(ComponentsJson) == false)
UpdateCheck uc = new UpdateCheck();
uc.ShowDialog();

if (File.Exists(ComponentsJson) == false)
{

// Check for components settings file.
Expand All @@ -44,7 +47,7 @@ public void CheckAll()

}


uc.Dispose();

}

Expand Down
12 changes: 12 additions & 0 deletions RsMapper/RsMapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Octokit, Version=0.48.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Octokit.0.48.0\lib\net46\Octokit.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -91,6 +94,12 @@
<Compile Include="Forms\UnsavedDialog.Designer.cs">
<DependentUpon>UnsavedDialog.cs</DependentUpon>
</Compile>
<Compile Include="Forms\UpdateCheck.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\UpdateCheck.Designer.cs">
<DependentUpon>UpdateCheck.cs</DependentUpon>
</Compile>
<Compile Include="imgs.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
Expand All @@ -115,6 +124,9 @@
<EmbeddedResource Include="Forms\UnsavedDialog.resx">
<DependentUpon>UnsavedDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\UpdateCheck.resx">
<DependentUpon>UpdateCheck.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="imgs.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>imgs.Designer.cs</LastGenOutput>
Expand Down
1 change: 1 addition & 0 deletions RsMapper/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
<package id="Octokit" version="0.48.0" targetFramework="net472" />
</packages>

0 comments on commit 00ab472

Please sign in to comment.