[go: up one dir, main page]

Menu

[5b1ca9]: / AppUpdate.cs  Maximize  Restore  History

Download this file

92 lines (85 with data), 3.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/***********************************************************************************
This file is part of Clock Alert.
Clock Alert is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as published by
the Free Software Foundation.
Clock Alert is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clock Alert. If not, see <http://www.gnu.org/licenses/>.
*************************************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace Clock_Alert
{
class AppUpdate
{
private Version newVersion, currentVersion;
private XmlTextReader reader;
private string url, elementName,xmlUrl;
public AppUpdate()
{
newVersion = null;
currentVersion = null;
reader = null;
url = string.Empty;
elementName = string.Empty;
xmlUrl = string.Empty;
}
private void getVersion()
{
xmlUrl="http://clockalert.sourceforge.net/version.xml";
try
{
reader=new XmlTextReader(xmlUrl);
reader.MoveToContent();
if(reader.NodeType==XmlNodeType.Element && reader.Name=="clockalert")
{
while(reader.Read())
{
if(reader.NodeType==XmlNodeType.Element)
elementName=reader.Name;
else
{
if(reader.NodeType==XmlNodeType.Text &&reader.HasValue)
{
switch(elementName)
{
case "version":
newVersion=new Version(reader.Value);
break;
case "url":
url=reader.Value;
break;
}
}
}
}
}
}
catch(Exception ex)
{
CrashReporterUI reporter=new CrashReporterUI(ex);
reporter.ShowDialog();
}
}
public void checkForUpdate()
{
getVersion();
currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
if (currentVersion.CompareTo(newVersion) < 0)
{
if (System.Windows.Forms.DialogResult.Yes == System.Windows.Forms.MessageBox.Show("A new version of Clock alert is available do you want to download the new version?", "New Update available", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question))
{
System.Diagnostics.Process.Start(url);
}
}
else
System.Windows.Forms.MessageBox.Show("This is already the latest version", "No new update", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
}
}
}