Repository navigation
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
60 lines (53 loc) · 2.46 KB
/
Copy pathMainWindow.xaml.cs
File metadata and controls
60 lines (53 loc) · 2.46 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
using System.Reflection;
using System.Windows;
using CodeDead.UpdateManager.Classes;
namespace UpdateManager.Sample.WPF
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
/// <summary>
/// Initialize a new MainWindow
/// </summary>
public MainWindow()
{
InitializeComponent();
}
/// <summary>
/// Method that is called when the Update button is clicked
/// </summary>
/// <param name="sender">The sender that initiated this method</param>
/// <param name="e">The RoutedEventArgs</param>
private async void UpdateButton_Click(object sender, RoutedEventArgs e)
{
// Initialize a new UpdateManager object
CodeDead.UpdateManager.Classes.UpdateManager updateManager = new CodeDead.UpdateManager.Classes.UpdateManager();
// Initialize and set the StringVariables that can be used by the dialog functionality
StringVariables stringVariables = new StringVariables
{
CancelButtonText = "Cancel",
DownloadButtonText = "Download",
InformationButtonText = "Information",
NoNewVersionText = "You are running the latest version!",
TitleText = "UpdateManager Sample",
UpdateNowText = "Would you like to update to the latest version now?"
};
// Automatically get the current application's version by utilizing
updateManager.ApplicationVersion = Assembly.GetExecutingAssembly().GetName().Version;
// Set the data type of the remote Update object representation
updateManager.DataType = DataType.Json;
// Set the remote address where the Update object representation is located
updateManager.UpdateUrl = "https://codedead.com/Software/PK%20Finder/update.json";
// Set that a message should be displayed if no updates are available
updateManager.ShowNoUpdates = true;
// Set the StringVariables object
updateManager.StringVariables = stringVariables;
// Retrieve the latest Update object from the remote location asynchronously
Update update = await updateManager.GetLatestVersionAsync();
// Display an update dialog, if applicable
updateManager.DisplayUpdateDialog(update);
}
}
}