Fixed #33 - Update check window buttons erroneously shut down application
This commit is contained in:
parent
43bc1410ae
commit
0b791f5747
|
@ -12,6 +12,7 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
||||||
{
|
{
|
||||||
class serializationtest
|
class serializationtest
|
||||||
{
|
{
|
||||||
|
[Ignore("")]
|
||||||
[Test]
|
[Test]
|
||||||
public void test_serialization()
|
public void test_serialization()
|
||||||
{
|
{
|
||||||
|
|
BIN
Filtration.db
BIN
Filtration.db
Binary file not shown.
|
@ -1,18 +1,16 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using Castle.Facilities.TypedFactory;
|
using Castle.Facilities.TypedFactory;
|
||||||
using Castle.MicroKernel.ModelBuilder.Inspectors;
|
using Castle.MicroKernel.ModelBuilder.Inspectors;
|
||||||
using Castle.MicroKernel.Registration;
|
|
||||||
using Castle.Windsor;
|
using Castle.Windsor;
|
||||||
using Castle.Windsor.Installer;
|
using Castle.Windsor.Installer;
|
||||||
using Filtration.ObjectModel;
|
using Filtration.ObjectModel;
|
||||||
using Filtration.ObjectModel.ThemeEditor;
|
using Filtration.ObjectModel.ThemeEditor;
|
||||||
using Filtration.Properties;
|
using Filtration.Properties;
|
||||||
|
using Filtration.Services;
|
||||||
using Filtration.ThemeEditor.ViewModels;
|
using Filtration.ThemeEditor.ViewModels;
|
||||||
using Filtration.ViewModels;
|
using Filtration.ViewModels;
|
||||||
using Filtration.Views;
|
using Filtration.Views;
|
||||||
|
@ -71,6 +69,9 @@ namespace Filtration
|
||||||
|
|
||||||
var mainWindow = _container.Resolve<IMainWindow>();
|
var mainWindow = _container.Resolve<IMainWindow>();
|
||||||
mainWindow.Show();
|
mainWindow.Show();
|
||||||
|
|
||||||
|
var updateCheckService = _container.Resolve<IUpdateCheckService>();
|
||||||
|
updateCheckService.CheckForUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
private static void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||||
|
|
|
@ -6,13 +6,15 @@ using System.Windows;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using Filtration.Models;
|
using Filtration.Models;
|
||||||
using Filtration.Properties;
|
using Filtration.Properties;
|
||||||
|
using Filtration.ViewModels;
|
||||||
|
using Filtration.Views;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
namespace Filtration.Services
|
namespace Filtration.Services
|
||||||
{
|
{
|
||||||
internal interface IUpdateCheckService
|
internal interface IUpdateCheckService
|
||||||
{
|
{
|
||||||
UpdateData CheckForUpdates();
|
void CheckForUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class UpdateCheckService : IUpdateCheckService
|
internal class UpdateCheckService : IUpdateCheckService
|
||||||
|
@ -20,13 +22,16 @@ namespace Filtration.Services
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private readonly IHTTPService _httpService;
|
private readonly IHTTPService _httpService;
|
||||||
|
private readonly IUpdateAvailableViewModel _updateAvailableViewModel;
|
||||||
|
|
||||||
public UpdateCheckService(IHTTPService httpService)
|
public UpdateCheckService(IHTTPService httpService,
|
||||||
|
IUpdateAvailableViewModel updateAvailableViewModel)
|
||||||
{
|
{
|
||||||
_httpService = httpService;
|
_httpService = httpService;
|
||||||
|
_updateAvailableViewModel = updateAvailableViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UpdateData CheckForUpdates()
|
public void CheckForUpdates()
|
||||||
{
|
{
|
||||||
var assemblyVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
|
var assemblyVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
|
||||||
|
|
||||||
|
@ -45,7 +50,6 @@ namespace Filtration.Services
|
||||||
Settings.Default.Save();
|
Settings.Default.Save();
|
||||||
|
|
||||||
updateData.UpdateAvailable = true;
|
updateData.UpdateAvailable = true;
|
||||||
return updateData;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,8 +77,13 @@ namespace Filtration.Services
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateData.UpdateAvailable = false;
|
if (updateData.UpdateAvailable)
|
||||||
return updateData;
|
{
|
||||||
|
var updateAvailableView = new UpdateAvailableView { DataContext = _updateAvailableViewModel };
|
||||||
|
_updateAvailableViewModel.Initialise(updateData);
|
||||||
|
_updateAvailableViewModel.OnRequestClose += (s, e) => updateAvailableView.Close();
|
||||||
|
updateAvailableView.ShowDialog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -82,8 +91,6 @@ namespace Filtration.Services
|
||||||
// We don't care if the update check fails, because it could fail for multiple reasons
|
// We don't care if the update check fails, because it could fail for multiple reasons
|
||||||
// including the user blocking Filtration in their firewall.
|
// including the user blocking Filtration in their firewall.
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool LatestVersionIsNewerThanSuppressedVersion(UpdateData updateData)
|
private static bool LatestVersionIsNewerThanSuppressedVersion(UpdateData updateData)
|
||||||
|
|
|
@ -10,13 +10,10 @@ using System.Windows.Forms;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using Filtration.Common.Services;
|
using Filtration.Common.Services;
|
||||||
using Filtration.Common.ViewModels;
|
|
||||||
using Filtration.Interface;
|
using Filtration.Interface;
|
||||||
using Filtration.Models;
|
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
using Filtration.ObjectModel.ThemeEditor;
|
using Filtration.ObjectModel.ThemeEditor;
|
||||||
using Filtration.Parser.Interface.Services;
|
using Filtration.Parser.Interface.Services;
|
||||||
using Filtration.Properties;
|
|
||||||
using Filtration.Repositories;
|
using Filtration.Repositories;
|
||||||
using Filtration.Services;
|
using Filtration.Services;
|
||||||
using Filtration.ThemeEditor.Messages;
|
using Filtration.ThemeEditor.Messages;
|
||||||
|
@ -50,8 +47,6 @@ namespace Filtration.ViewModels
|
||||||
private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel;
|
private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel;
|
||||||
private readonly IThemeProvider _themeProvider;
|
private readonly IThemeProvider _themeProvider;
|
||||||
private readonly IThemeService _themeService;
|
private readonly IThemeService _themeService;
|
||||||
private readonly IUpdateCheckService _updateCheckService;
|
|
||||||
private readonly IUpdateAvailableViewModel _updateAvailableViewModel;
|
|
||||||
private readonly IMessageBoxService _messageBoxService;
|
private readonly IMessageBoxService _messageBoxService;
|
||||||
private readonly IClipboardService _clipboardService;
|
private readonly IClipboardService _clipboardService;
|
||||||
private bool _showLoadingBanner;
|
private bool _showLoadingBanner;
|
||||||
|
@ -63,8 +58,6 @@ namespace Filtration.ViewModels
|
||||||
ISettingsPageViewModel settingsPageViewModel,
|
ISettingsPageViewModel settingsPageViewModel,
|
||||||
IThemeProvider themeProvider,
|
IThemeProvider themeProvider,
|
||||||
IThemeService themeService,
|
IThemeService themeService,
|
||||||
IUpdateCheckService updateCheckService,
|
|
||||||
IUpdateAvailableViewModel updateAvailableViewModel,
|
|
||||||
IMessageBoxService messageBoxService,
|
IMessageBoxService messageBoxService,
|
||||||
IClipboardService clipboardService)
|
IClipboardService clipboardService)
|
||||||
{
|
{
|
||||||
|
@ -75,8 +68,6 @@ namespace Filtration.ViewModels
|
||||||
SettingsPageViewModel = settingsPageViewModel;
|
SettingsPageViewModel = settingsPageViewModel;
|
||||||
_themeProvider = themeProvider;
|
_themeProvider = themeProvider;
|
||||||
_themeService = themeService;
|
_themeService = themeService;
|
||||||
_updateCheckService = updateCheckService;
|
|
||||||
_updateAvailableViewModel = updateAvailableViewModel;
|
|
||||||
_messageBoxService = messageBoxService;
|
_messageBoxService = messageBoxService;
|
||||||
_clipboardService = clipboardService;
|
_clipboardService = clipboardService;
|
||||||
|
|
||||||
|
@ -102,10 +93,8 @@ namespace Filtration.ViewModels
|
||||||
AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => ActiveDocumentIsScript);
|
AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => ActiveDocumentIsScript);
|
||||||
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => ActiveDocumentIsScript);
|
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => ActiveDocumentIsScript);
|
||||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand,
|
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedEnabledBlock);
|
||||||
() => ActiveDocumentIsScript && ActiveScriptHasSelectedEnabledBlock);
|
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedDisabledBlock);
|
||||||
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand,
|
|
||||||
() => ActiveDocumentIsScript && ActiveScriptHasSelectedDisabledBlock);
|
|
||||||
OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand);
|
OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand);
|
||||||
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => ActiveDocumentIsScript);
|
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => ActiveDocumentIsScript);
|
||||||
|
|
||||||
|
@ -116,10 +105,7 @@ namespace Filtration.ViewModels
|
||||||
AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||||
AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||||
AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||||
DeleteThemeComponentCommand = new RelayCommand(OnDeleteThemeComponentCommand,
|
DeleteThemeComponentCommand = new RelayCommand(OnDeleteThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable && _avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent != null);
|
||||||
() =>
|
|
||||||
ActiveDocumentIsTheme && ActiveThemeIsEditable &&
|
|
||||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent != null);
|
|
||||||
|
|
||||||
ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript);
|
ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript);
|
||||||
CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => ActiveDocumentIsScript);
|
CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => ActiveDocumentIsScript);
|
||||||
|
@ -189,8 +175,6 @@ namespace Filtration.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
CheckForUpdates();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayCommand OpenScriptCommand { get; }
|
public RelayCommand OpenScriptCommand { get; }
|
||||||
|
@ -233,19 +217,6 @@ namespace Filtration.ViewModels
|
||||||
public RelayCommand<bool> ToggleShowAdvancedCommand { get; }
|
public RelayCommand<bool> ToggleShowAdvancedCommand { get; }
|
||||||
public RelayCommand ClearFiltersCommand { get; }
|
public RelayCommand ClearFiltersCommand { get; }
|
||||||
|
|
||||||
private void CheckForUpdates()
|
|
||||||
{
|
|
||||||
var updateData = _updateCheckService.CheckForUpdates();
|
|
||||||
|
|
||||||
if (updateData != null && updateData.UpdateAvailable)
|
|
||||||
{
|
|
||||||
var updateAvailableView = new UpdateAvailableView { DataContext = _updateAvailableViewModel };
|
|
||||||
_updateAvailableViewModel.Initialise(updateData);
|
|
||||||
_updateAvailableViewModel.OnRequestClose += (s, e) => updateAvailableView.Close();
|
|
||||||
updateAvailableView.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImageSource Icon { get; private set; }
|
public ImageSource Icon { get; private set; }
|
||||||
|
|
||||||
public IAvalonDockWorkspaceViewModel AvalonDockWorkspaceViewModel => _avalonDockWorkspaceViewModel;
|
public IAvalonDockWorkspaceViewModel AvalonDockWorkspaceViewModel => _avalonDockWorkspaceViewModel;
|
||||||
|
|
Loading…
Reference in New Issue