Skip to content

Commit

Permalink
Add check update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeric-X committed May 22, 2017
1 parent bcf8772 commit f9b83d1
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 13 deletions.
3 changes: 3 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v1.0.3
- Add check update

v1.0.2
- Add deployment
- Fix bugs
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
> - [x] NextCloud
## Client-Windows
下载最新的[Release](https://github.com/Jeric-X/SyncClipboard/releases/)
下载最新的[Release](https://github.com/Jeric-X/SyncClipboard/releases/),自备梯子
或者clone or下载源码,VS2013及以上编译
## Client-IOS
使用[Workflow](https://appsto.re/cn/2IzJ2.i)提供的`Get Contents of URL`功能发送HTTP协议
导入这个[Workflow](https://workflow.is/workflows/6da4c1de8b1446cda56e336b1ed50b25)
Expand Down
26 changes: 18 additions & 8 deletions SyncClipboard/MainForm.Designer.cs

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

6 changes: 6 additions & 0 deletions SyncClipboard/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,11 @@ private void 下载远程ToolStripMenuItem_Click(object sender, EventArgs e)
Config.IfPull = this.下载远程ToolStripMenuItem.Checked;
Config.Save();
}

private void 检查更新ToolStripMenuItem_Click(object sender, EventArgs e)
{
UpdateChecker updateChecker = new UpdateChecker();
updateChecker.Check();
}
}
}
3 changes: 1 addition & 2 deletions SyncClipboard/Properties/Settings.Designer.cs

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

5 changes: 4 additions & 1 deletion SyncClipboard/SyncClipboard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@
</Compile>
<EmbeddedResource Include="SettingsForm.resx">
<DependentUpon>SettingsForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<None Include="app.config" />
<None Include="app.config">
<SubType>Designer</SubType>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down
44 changes: 43 additions & 1 deletion SyncClipboard/UpdateChecker.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,55 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows.Forms;

namespace SyncClipboard
{
class UpdateChecker
{
public const string Version = "1.0.2";
public const string Version = "1.0.3";
public const string UpdateUrl = "https://api.github.com/repos/Jeric-X/SyncClipboard/releases/latest";
public const string ReleaseUrl = "https://github.com/Jeric-X/SyncClipboard/releases/latest";

public bool Check()
{
HttpWebResponse httpWebResponse = null;
try
{
httpWebResponse = HttpWebResponseUtility.CreateGetHttpResponse(UpdateUrl, Config.TimeOut, null, null, null);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
return false;
}
StreamReader objStrmReader = new StreamReader(httpWebResponse.GetResponseStream());
String strReply = objStrmReader.ReadToEnd();
JavaScriptSerializer serializer = new JavaScriptSerializer();
UpdateConvertJson p1 = null;
try
{
p1 = serializer.Deserialize<UpdateConvertJson>(strReply);
if (String.Compare(p1.name, "v" + Version) > 0)
if (MessageBox.Show("v" + Version + " -> " + p1.name + "\n\n是否更新", "检测到新版本", MessageBoxButtons.OKCancel) == DialogResult.OK)
System.Diagnostics.Process.Start(UpdateChecker.ReleaseUrl);
}
catch (Exception e)
{
MessageBox.Show(e.Message.ToString());
}
return false;
}
}
class UpdateConvertJson
{
public String name { get; set; }

public String rowser_download_url { get; set; }
}
}

0 comments on commit f9b83d1

Please sign in to comment.