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