summaryrefslogtreecommitdiffstats
path: root/win/C#/frmUpdater.cs
blob: 7d56c587efc0e1e673f9d6fbb96db97f41f4d8ac (plain)
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
92
93
94
95
96
97
98
99
100
101
102
103
/*  frmUpdater.cs $
    This file is part of the HandBrake source code.
    Homepage: <http://handbrake.fr>.
    It may be used under the terms of the GNU General Public License. */

namespace Handbrake
{
    using System;
    using System.Windows.Forms;
    using Functions;

    /// <summary>
    /// A window to display update information.
    /// </summary>
    public partial class frmUpdater : Form
    {
        /// <summary>
        /// An instance of the Appcast Reader
        /// </summary>
        private readonly AppcastReader appcast;

        /// <summary>
        /// Initializes a new instance of the <see cref="frmUpdater"/> class.
        /// </summary>
        /// <param name="reader">
        /// The appcast reader.
        /// </param>
        public frmUpdater(AppcastReader reader)
        {
            InitializeComponent();

            appcast = reader;
            GetRss();
            SetVersions();
        }

        /// <summary>
        /// Get the RSS feed
        /// </summary>
        private void GetRss()
        {
            wBrowser.Url = appcast.DescriptionUrl;
        }

        /// <summary>
        /// Set the versions
        /// </summary>
        private void SetVersions()
        {
            string old = "(You have: " + Properties.Settings.Default.hb_version.Trim() + " / " +
                         Properties.Settings.Default.hb_build.ToString().Trim() + ")";
            string newBuild = appcast.Version.Trim() + " (" + appcast.Build + ")";
            lbl_update_text.Text = "HandBrake " + newBuild + " is now available. " + old;
        }

        /// <summary>
        /// Handle the Install Update button click event.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The EventArgs.
        /// </param>
        private void BtnInstallUpdateClick(object sender, EventArgs e)
        {
            frmDownload download = new frmDownload(appcast.DownloadFile);
            download.ShowDialog();
            this.Close();
        }

        /// <summary>
        /// Handle the Remind Later button click event
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The EventArgs.
        /// </param>
        private void BtnRemindLaterClick(object sender, EventArgs e)
        {
            this.Close();
        }

        /// <summary>
        /// Handle the Skip update button click event
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void BtnSkipClick(object sender, EventArgs e)
        {
            Properties.Settings.Default.skipversion = int.Parse(appcast.Build);
            Properties.Settings.Default.Save();

            this.Close();
        }
    }
}