root / trunk / NetSparkle / NetSparkleForm.cs @ 7153da40
History | View | Annotate | Download (3.3 kB)
1 |
using System; |
---|---|
2 |
using System.Diagnostics; |
3 |
using System.Drawing; |
4 |
using System.Net; |
5 |
using System.Windows.Forms; |
6 |
|
7 |
namespace AppLimit.NetSparkle |
8 |
{ |
9 |
public partial class NetSparkleForm : Form |
10 |
{ |
11 |
NetSparkleAppCastItem _currentItem; |
12 |
|
13 |
public NetSparkleForm(NetSparkleAppCastItem item, Image appIcon, Icon windowIcon) |
14 |
{ |
15 |
InitializeComponent(); |
16 |
|
17 |
// init ui |
18 |
try |
19 |
{ |
20 |
NetSparkleBrowser.AllowWebBrowserDrop = false; |
21 |
NetSparkleBrowser.AllowNavigation = false; |
22 |
} |
23 |
catch (Exception) |
24 |
{ } |
25 |
|
26 |
_currentItem = item; |
27 |
|
28 |
lblHeader.Text = lblHeader.Text.Replace("APP", item.AppName); |
29 |
lblInfoText.Text = lblInfoText.Text.Replace("APP", item.AppName + " " + item.Version); |
30 |
lblInfoText.Text = lblInfoText.Text.Replace("OLDVERSION", item.AppVersionInstalled); |
31 |
|
32 |
if (!String.IsNullOrWhiteSpace(item.Summary)) |
33 |
{ |
34 |
NetSparkleBrowser.DocumentText = "<html><body>" + item.Summary + "</html></body>"; |
35 |
} |
36 |
else |
37 |
{ |
38 |
if (item.ReleaseNotesLink != null && item.ReleaseNotesLink.Length > 0) |
39 |
{ |
40 |
using (var client = new WebClient()) |
41 |
{ |
42 |
//Download the content instead of navigating to it, to bypass |
43 |
//the Content-Disposition header |
44 |
string notes = client.DownloadString(item.ReleaseNotesLink); |
45 |
NetSparkleBrowser.DocumentText = notes; |
46 |
} |
47 |
} |
48 |
else |
49 |
RemoveReleaseNotesControls(); |
50 |
} |
51 |
|
52 |
if (appIcon != null) |
53 |
imgAppIcon.Image = appIcon; |
54 |
|
55 |
if (windowIcon != null) |
56 |
Icon = windowIcon; |
57 |
} |
58 |
|
59 |
public void RemoveReleaseNotesControls() |
60 |
{ |
61 |
if (label3.Parent == null) |
62 |
return; |
63 |
|
64 |
// calc new size |
65 |
Size newSize = new Size(this.Size.Width, this.Size.Height - label3.Height - panel1.Height); |
66 |
|
67 |
// remove the no more needed controls |
68 |
label3.Parent.Controls.Remove(label3); |
69 |
NetSparkleBrowser.Parent.Controls.Remove(NetSparkleBrowser); |
70 |
panel1.Parent.Controls.Remove(panel1); |
71 |
|
72 |
// resize the window |
73 |
/*this.MinimumSize = newSize; |
74 |
this.Size = this.MinimumSize; |
75 |
this.MaximumSize = this.MinimumSize;*/ |
76 |
this.Size = newSize; |
77 |
} |
78 |
|
79 |
private void skipButton_Click(object sender, EventArgs e) |
80 |
{ |
81 |
// set the dialog result to no |
82 |
this.DialogResult = DialogResult.No; |
83 |
|
84 |
// close the windows |
85 |
Close(); |
86 |
} |
87 |
|
88 |
private void buttonRemind_Click(object sender, EventArgs e) |
89 |
{ |
90 |
// set the dialog result ot retry |
91 |
this.DialogResult = DialogResult.Retry; |
92 |
|
93 |
// close the window |
94 |
Close(); |
95 |
} |
96 |
|
97 |
private void updateButton_Click(object sender, EventArgs e) |
98 |
{ |
99 |
// set the result to yes |
100 |
DialogResult = DialogResult.Yes; |
101 |
|
102 |
// close the dialog |
103 |
Close(); |
104 |
} |
105 |
} |
106 |
} |