-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.Updates.cs
More file actions
59 lines (52 loc) · 2.6 KB
/
Copy pathMainWindow.Updates.cs
File metadata and controls
59 lines (52 loc) · 2.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
using System;
using System.Windows;
namespace JL_Monitor_Brightness
{
/// <summary>
/// Проверка обновлений из окна настроек.
///
/// Вынесено из MainWindow.xaml.cs 25.08.2026 вместе с горячими клавишами.
/// </summary>
public partial class MainWindow
{
private void CheckForUpdatesCheckBox_Changed(object sender, RoutedEventArgs e)
{
if (_isInitializing) return;
// Нет необходимости делать что-то здесь, настройка будет сохранена при нажатии кнопки "Сохранить"
}
private async void CheckForUpdatesButton_Click(object sender, RoutedEventArgs e)
{
try
{
CheckForUpdatesButton.IsEnabled = false;
CheckForUpdatesButton.Content = "Проверка...";
var updateInfo = await _updateService.CheckForUpdatesAsync();
CheckForUpdatesButton.IsEnabled = true;
CheckForUpdatesButton.Content = "Проверить обновления сейчас";
if (updateInfo == null)
{
MessageBox.Show("Не удалось проверить наличие обновлений. Проверьте подключение к интернету.",
"Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if (_updateService.IsUpdateAvailable(updateInfo, _settings.CurrentVersion))
{
var updateWindow = new UpdateWindow(updateInfo, _settings, _updateService);
updateWindow.ShowDialog();
}
else
{
MessageBox.Show("У вас установлена последняя версия программы.",
"Обновлений нет", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
catch (Exception ex)
{
CheckForUpdatesButton.IsEnabled = true;
CheckForUpdatesButton.Content = "Проверить обновления сейчас";
MessageBox.Show($"Произошла ошибка при проверке обновлений: {ex.Message}",
"Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}