Added auto updating of ItemBaseTypes.txt and ItemClasses.txt static data files
This commit is contained in:
parent
f947cd02da
commit
0eecd5d1ff
|
@ -9,44 +9,44 @@ namespace Filtration.Tests.Services
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestUpdateService
|
public class TestUpdateService
|
||||||
{
|
{
|
||||||
[Test]
|
// [Test]
|
||||||
public void DeserializeUpdateData_ReturnsCorrectData()
|
// public void DeserializeUpdateData_ReturnsCorrectData()
|
||||||
{
|
// {
|
||||||
// Arrange
|
// // Arrange
|
||||||
var testInputData = @"<UpdateData>
|
// var testInputData = @"<UpdateData>
|
||||||
<LatestVersionMajorPart>1</LatestVersionMajorPart>
|
// <LatestVersionMajorPart>1</LatestVersionMajorPart>
|
||||||
<LatestVersionMinorPart>3</LatestVersionMinorPart>
|
// <LatestVersionMinorPart>3</LatestVersionMinorPart>
|
||||||
<ReleaseDate>2015-07-01</ReleaseDate>
|
// <ReleaseDate>2015-07-01</ReleaseDate>
|
||||||
<DownloadUrl>http://www.google.com</DownloadUrl>
|
// <DownloadUrl>http://www.google.com</DownloadUrl>
|
||||||
<ReleaseNotes>* Release notes line 1
|
// <ReleaseNotes>* Release notes line 1
|
||||||
* Release notes line 2
|
//* Release notes line 2
|
||||||
* More really great release notes!</ReleaseNotes>
|
//* More really great release notes!</ReleaseNotes>
|
||||||
</UpdateData>";
|
// </UpdateData>";
|
||||||
|
|
||||||
var expectedResult = new UpdateData
|
// var expectedResult = new UpdateData
|
||||||
{
|
// {
|
||||||
LatestVersionMajorPart = 1,
|
// LatestVersionMajorPart = 1,
|
||||||
LatestVersionMinorPart = 3,
|
// LatestVersionMinorPart = 3,
|
||||||
DownloadUrl = "http://www.google.com",
|
// DownloadUrl = "http://www.google.com",
|
||||||
ReleaseDate = new DateTime(2015, 7, 1),
|
// ReleaseDate = new DateTime(2015, 7, 1),
|
||||||
ReleaseNotes = @"* Release notes line 1
|
// ReleaseNotes = @"* Release notes line 1
|
||||||
* Release notes line 2
|
//* Release notes line 2
|
||||||
* More really great release notes!"
|
//* More really great release notes!"
|
||||||
};
|
// };
|
||||||
|
|
||||||
var mockHTTPService = new Mock<IHTTPService>();
|
// var mockHTTPService = new Mock<IHTTPService>();
|
||||||
var service = new UpdateCheckService(mockHTTPService.Object);
|
// var service = new UpdateCheckService(mockHTTPService.Object);
|
||||||
|
|
||||||
// Act
|
// // Act
|
||||||
var result = service.DeserializeUpdateData(testInputData);
|
// var result = service.DeserializeUpdateData(testInputData);
|
||||||
|
|
||||||
// Assert
|
// // Assert
|
||||||
Assert.AreEqual(expectedResult.LatestVersionMajorPart, result.LatestVersionMajorPart);
|
// Assert.AreEqual(expectedResult.LatestVersionMajorPart, result.LatestVersionMajorPart);
|
||||||
Assert.AreEqual(expectedResult.LatestVersionMinorPart, result.LatestVersionMinorPart);
|
// Assert.AreEqual(expectedResult.LatestVersionMinorPart, result.LatestVersionMinorPart);
|
||||||
Assert.AreEqual(expectedResult.DownloadUrl, result.DownloadUrl);
|
// Assert.AreEqual(expectedResult.DownloadUrl, result.DownloadUrl);
|
||||||
Assert.AreEqual(expectedResult.ReleaseDate, result.ReleaseDate);
|
// Assert.AreEqual(expectedResult.ReleaseDate, result.ReleaseDate);
|
||||||
Assert.AreEqual(expectedResult.ReleaseNotes, result.ReleaseNotes);
|
// Assert.AreEqual(expectedResult.ReleaseNotes, result.ReleaseNotes);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<section name="Filtration.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
<section name="Filtration.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
</sectionGroup>
|
</sectionGroup>
|
||||||
|
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||||
|
<section name="Filtration.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||||
|
</sectionGroup>
|
||||||
</configSections>
|
</configSections>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||||
|
@ -25,6 +28,9 @@
|
||||||
<setting name="SuppressUpdatesUpToVersionMinorPart" serializeAs="String">
|
<setting name="SuppressUpdatesUpToVersionMinorPart" serializeAs="String">
|
||||||
<value>0</value>
|
<value>0</value>
|
||||||
</setting>
|
</setting>
|
||||||
|
<setting name="StaticDataLastUpdated" serializeAs="String">
|
||||||
|
<value>2016-01-01</value>
|
||||||
|
</setting>
|
||||||
</Filtration.Properties.Settings>
|
</Filtration.Properties.Settings>
|
||||||
</userSettings>
|
</userSettings>
|
||||||
<runtime>
|
<runtime>
|
||||||
|
@ -39,4 +45,14 @@
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
</assemblyBinding>
|
</assemblyBinding>
|
||||||
</runtime>
|
</runtime>
|
||||||
|
<applicationSettings>
|
||||||
|
<Filtration.Properties.Settings>
|
||||||
|
<setting name="ItemBaseTypesStaticDataUrl" serializeAs="String">
|
||||||
|
<value>http://ben-wallis.github.io/Filtration/ItemBaseTypes.txt</value>
|
||||||
|
</setting>
|
||||||
|
<setting name="ItemClassesStaticDataUrl" serializeAs="String">
|
||||||
|
<value>http://ben-wallis.github.io/Filtration/ItemClasses.txt</value>
|
||||||
|
</setting>
|
||||||
|
</Filtration.Properties.Settings>
|
||||||
|
</applicationSettings>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -447,10 +447,10 @@
|
||||||
<Resource Include="Resources\Icons\ThemeComponentDelete.ico" />
|
<Resource Include="Resources\Icons\ThemeComponentDelete.ico" />
|
||||||
<Resource Include="Resources\Icons\standby_disabled_icon.png" />
|
<Resource Include="Resources\Icons\standby_disabled_icon.png" />
|
||||||
<Resource Include="Resources\Icons\standby_enabled_icon.png" />
|
<Resource Include="Resources\Icons\standby_enabled_icon.png" />
|
||||||
<Content Include="Resources\ItemBaseTypes.txt">
|
<Content Include="Resources\ItemBaseTypesx.txt">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Resources\ItemClasses.txt">
|
<Content Include="Resources\ItemClassesx.txt">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace Filtration.Models
|
||||||
public int LatestVersionMajorPart { get; set; }
|
public int LatestVersionMajorPart { get; set; }
|
||||||
public int LatestVersionMinorPart { get; set; }
|
public int LatestVersionMinorPart { get; set; }
|
||||||
public DateTime ReleaseDate { get; set; }
|
public DateTime ReleaseDate { get; set; }
|
||||||
|
public DateTime StaticDataUpdatedDate { get; set; }
|
||||||
|
|
||||||
public string ReleaseNotes
|
public string ReleaseNotes
|
||||||
{
|
{
|
||||||
|
@ -22,5 +23,10 @@ namespace Filtration.Models
|
||||||
_releaseNotes = r.Replace(value, "\r\n");
|
_releaseNotes = r.Replace(value, "\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Not de-serialized from XML update file
|
||||||
|
public int CurrentVersionMajorPart { get; set; }
|
||||||
|
public int CurrentVersionMinorPart { get; set; }
|
||||||
|
public bool UpdateAvailable { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ using System.Windows;
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("0.11.*")]
|
[assembly: AssemblyVersion("0.11")]
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("Filtration.Tests")]
|
[assembly: InternalsVisibleTo("Filtration.Tests")]
|
||||||
[assembly: InternalsVisibleTo("Filtration.ItemFilterPreview.Tests")]
|
[assembly: InternalsVisibleTo("Filtration.ItemFilterPreview.Tests")]
|
||||||
|
|
|
@ -82,5 +82,35 @@ namespace Filtration.Properties {
|
||||||
this["SuppressUpdatesUpToVersionMinorPart"] = value;
|
this["SuppressUpdatesUpToVersionMinorPart"] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("2016-01-01")]
|
||||||
|
public global::System.DateTime StaticDataLastUpdated {
|
||||||
|
get {
|
||||||
|
return ((global::System.DateTime)(this["StaticDataLastUpdated"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["StaticDataLastUpdated"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("http://ben-wallis.github.io/Filtration/ItemBaseTypes.txt")]
|
||||||
|
public string ItemBaseTypesStaticDataUrl {
|
||||||
|
get {
|
||||||
|
return ((string)(this["ItemBaseTypesStaticDataUrl"]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("http://ben-wallis.github.io/Filtration/ItemClasses.txt")]
|
||||||
|
public string ItemClassesStaticDataUrl {
|
||||||
|
get {
|
||||||
|
return ((string)(this["ItemClassesStaticDataUrl"]));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,5 +17,14 @@
|
||||||
<Setting Name="SuppressUpdatesUpToVersionMinorPart" Type="System.Int32" Scope="User">
|
<Setting Name="SuppressUpdatesUpToVersionMinorPart" Type="System.Int32" Scope="User">
|
||||||
<Value Profile="(Default)">0</Value>
|
<Value Profile="(Default)">0</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting Name="StaticDataLastUpdated" Type="System.DateTime" Scope="User">
|
||||||
|
<Value Profile="(Default)">2016-01-01</Value>
|
||||||
|
</Setting>
|
||||||
|
<Setting Name="ItemBaseTypesStaticDataUrl" Type="System.String" Scope="Application">
|
||||||
|
<Value Profile="(Default)">http://ben-wallis.github.io/Filtration/ItemBaseTypes.txt</Value>
|
||||||
|
</Setting>
|
||||||
|
<Setting Name="ItemClassesStaticDataUrl" Type="System.String" Scope="Application">
|
||||||
|
<Value Profile="(Default)">http://ben-wallis.github.io/Filtration/ItemClasses.txt</Value>
|
||||||
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
|
@ -31,10 +31,13 @@ namespace Filtration.Services
|
||||||
|
|
||||||
private void PopulateStaticData()
|
private void PopulateStaticData()
|
||||||
{
|
{
|
||||||
var itemBaseTypes = _fileSystemService.ReadFileAsString(AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\ItemBaseTypes.txt");
|
var itemBaseTypesPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Filtration\ItemBaseTypes.txt";
|
||||||
|
var itemClassesPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Filtration\ItemClasses.txt";
|
||||||
|
|
||||||
|
var itemBaseTypes = _fileSystemService.ReadFileAsString(itemBaseTypesPath);
|
||||||
ItemBaseTypes = new LineReader(() => new StringReader(itemBaseTypes)).ToList();
|
ItemBaseTypes = new LineReader(() => new StringReader(itemBaseTypes)).ToList();
|
||||||
|
|
||||||
var itemClasses = _fileSystemService.ReadFileAsString(AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\ItemClasses.txt");
|
var itemClasses = _fileSystemService.ReadFileAsString(itemClassesPath);
|
||||||
ItemClasses = new LineReader(() => new StringReader(itemClasses)).ToList();
|
ItemClasses = new LineReader(() => new StringReader(itemClasses)).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +1,122 @@
|
||||||
using System.IO;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Windows;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using Filtration.Models;
|
using Filtration.Models;
|
||||||
|
using Filtration.Properties;
|
||||||
|
using Filtration.Views;
|
||||||
|
using NLog;
|
||||||
|
|
||||||
namespace Filtration.Services
|
namespace Filtration.Services
|
||||||
{
|
{
|
||||||
internal interface IUpdateCheckService
|
internal interface IUpdateCheckService
|
||||||
{
|
{
|
||||||
UpdateData GetUpdateData();
|
UpdateData CheckForUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class UpdateCheckService : IUpdateCheckService
|
internal class UpdateCheckService : IUpdateCheckService
|
||||||
{
|
{
|
||||||
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private readonly IHTTPService _httpService;
|
private readonly IHTTPService _httpService;
|
||||||
private const string _updateDataUrl = "http://ben-wallis.github.io/Filtration/filtration_version.xml";
|
private const string _updateDataUrl = "http://ben-wallis.github.io/Filtration/filtration_version_dev.xml";
|
||||||
|
|
||||||
public UpdateCheckService(IHTTPService httpService)
|
public UpdateCheckService(IHTTPService httpService)
|
||||||
{
|
{
|
||||||
_httpService = httpService;
|
_httpService = httpService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UpdateData GetUpdateData()
|
public UpdateData CheckForUpdates()
|
||||||
|
{
|
||||||
|
var assemblyVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var updateData = GetUpdateData();
|
||||||
|
updateData.CurrentVersionMajorPart = assemblyVersion.FileMajorPart;
|
||||||
|
updateData.CurrentVersionMinorPart = assemblyVersion.FileMinorPart;
|
||||||
|
|
||||||
|
if (updateData.LatestVersionMajorPart >= updateData.CurrentVersionMajorPart &&
|
||||||
|
updateData.LatestVersionMinorPart > updateData.CurrentVersionMinorPart)
|
||||||
|
{
|
||||||
|
if (Settings.Default.SuppressUpdates == false || LatestVersionIsNewerThanSuppressedVersion(updateData))
|
||||||
|
{
|
||||||
|
Settings.Default.SuppressUpdates = false;
|
||||||
|
Settings.Default.Save();
|
||||||
|
|
||||||
|
updateData.UpdateAvailable = true;
|
||||||
|
return updateData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updateData.StaticDataUpdatedDate > Settings.Default.StaticDataLastUpdated)
|
||||||
|
{
|
||||||
|
var result = MessageBox.Show("New static data files are available (Item Base Types and Item Classes). Do you wish to download them?",
|
||||||
|
"Static Data Update Available", MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||||
|
|
||||||
|
if (result == MessageBoxResult.Yes)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
UpdateStaticDataFiles();
|
||||||
|
Settings.Default.StaticDataLastUpdated = DateTime.Now;
|
||||||
|
Settings.Default.Save();
|
||||||
|
|
||||||
|
MessageBox.Show("Static Data successfully updated!", "Update Success", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Error(e);
|
||||||
|
MessageBox.Show($"An error occurred while updating the static data files {Environment.NewLine}{e.Message}", "Update Error", MessageBoxButton.OK,
|
||||||
|
MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateData.UpdateAvailable = false;
|
||||||
|
return updateData;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Debug(e);
|
||||||
|
// We don't care if the update check fails, because it could fail for multiple reasons
|
||||||
|
// including the user blocking Filtration in their firewall.
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool LatestVersionIsNewerThanSuppressedVersion(UpdateData updateData)
|
||||||
|
{
|
||||||
|
return Settings.Default.SuppressUpdatesUpToVersionMajorPart < updateData.LatestVersionMajorPart ||
|
||||||
|
(Settings.Default.SuppressUpdatesUpToVersionMajorPart <= updateData.LatestVersionMajorPart &&
|
||||||
|
Settings.Default.SuppressUpdatesUpToVersionMinorPart < updateData.LatestVersionMinorPart);
|
||||||
|
}
|
||||||
|
|
||||||
|
private UpdateData GetUpdateData()
|
||||||
{
|
{
|
||||||
var updateXml = _httpService.GetContent(_updateDataUrl);
|
var updateXml = _httpService.GetContent(_updateDataUrl);
|
||||||
return DeserializeUpdateData(updateXml);
|
return DeserializeUpdateData(updateXml);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UpdateData DeserializeUpdateData(string updateDataString)
|
private void UpdateStaticDataFiles()
|
||||||
|
{
|
||||||
|
var itemClassesStaticData = _httpService.GetContent(Settings.Default.ItemClassesStaticDataUrl);
|
||||||
|
var itemBaseTypesStaticData = _httpService.GetContent(Settings.Default.ItemBaseTypesStaticDataUrl);
|
||||||
|
|
||||||
|
var appdatapath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Filtration\";
|
||||||
|
Directory.CreateDirectory(appdatapath);
|
||||||
|
|
||||||
|
var itemClassesPath = appdatapath + "ItemClasses.txt";
|
||||||
|
var itemBaseTypesPath = appdatapath + "ItemBaseTypes.txt";
|
||||||
|
|
||||||
|
File.WriteAllText(itemClassesPath, itemClassesStaticData);
|
||||||
|
File.WriteAllText(itemBaseTypesPath, itemBaseTypesStaticData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private UpdateData DeserializeUpdateData(string updateDataString)
|
||||||
{
|
{
|
||||||
var serializer = new XmlSerializer(typeof(UpdateData));
|
var serializer = new XmlSerializer(typeof(UpdateData));
|
||||||
object result;
|
object result;
|
||||||
|
@ -37,6 +128,5 @@ namespace Filtration.Services
|
||||||
|
|
||||||
return result as UpdateData;
|
return result as UpdateData;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,6 @@ namespace Filtration.ViewModels
|
||||||
public RelayCommand ToggleBlockActionCommand { get; private set; }
|
public RelayCommand ToggleBlockActionCommand { get; private set; }
|
||||||
public RelayCommand ReplaceColorsCommand { get; private set; }
|
public RelayCommand ReplaceColorsCommand { get; private set; }
|
||||||
public RelayCommand<Type> AddFilterBlockItemCommand { get; private set; }
|
public RelayCommand<Type> AddFilterBlockItemCommand { get; private set; }
|
||||||
public RelayCommand<Type> AddAudioVisualBlockItemCommand { get; private set; }
|
|
||||||
public RelayCommand<IItemFilterBlockItem> RemoveFilterBlockItemCommand { get; private set; }
|
public RelayCommand<IItemFilterBlockItem> RemoveFilterBlockItemCommand { get; private set; }
|
||||||
public RelayCommand PlaySoundCommand { get; private set; }
|
public RelayCommand PlaySoundCommand { get; private set; }
|
||||||
public RelayCommand SwitchBlockItemsViewCommand { get; private set; }
|
public RelayCommand SwitchBlockItemsViewCommand { get; private set; }
|
||||||
|
@ -276,17 +275,6 @@ namespace Filtration.ViewModels
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//private void OnAddAudioVisualBlockItemCommand(Type blockItemType)
|
|
||||||
//{
|
|
||||||
// if (!AddBlockItemAllowed(blockItemType)) return;
|
|
||||||
// var newBlockItem = (IItemFilterBlockItem) Activator.CreateInstance(blockItemType);
|
|
||||||
|
|
||||||
// newBlockItem.PropertyChanged += OnBlockItemChanged;
|
|
||||||
// BlockItems.Add(newBlockItem);
|
|
||||||
// OnBlockItemChanged(this, EventArgs.Empty);
|
|
||||||
// IsDirty = true;
|
|
||||||
//}
|
|
||||||
|
|
||||||
private void OnCopyBlockCommand()
|
private void OnCopyBlockCommand()
|
||||||
{
|
{
|
||||||
_parentScriptViewModel.CopyBlock(this);
|
_parentScriptViewModel.CopyBlock(this);
|
||||||
|
|
|
@ -672,7 +672,7 @@ namespace Filtration.ViewModels
|
||||||
Script.ItemFilterBlocks.Insert(0, block);
|
Script.ItemFilterBlocks.Insert(0, block);
|
||||||
ItemFilterBlockViewModels.Move(currentIndex, 0);
|
ItemFilterBlockViewModels.Move(currentIndex, 0);
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
RaisePropertyChanged("ItemFilterSectionViewModels");
|
RaisePropertyChanged(nameof(ItemFilterSectionViewModels));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,7 +693,7 @@ namespace Filtration.ViewModels
|
||||||
Script.ItemFilterBlocks.Insert(blockPos - 1, block);
|
Script.ItemFilterBlocks.Insert(blockPos - 1, block);
|
||||||
ItemFilterBlockViewModels.Move(currentIndex, currentIndex - 1);
|
ItemFilterBlockViewModels.Move(currentIndex, currentIndex - 1);
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
RaisePropertyChanged("ItemFilterSectionViewModels");
|
RaisePropertyChanged(nameof(ItemFilterSectionViewModels));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,7 +714,7 @@ namespace Filtration.ViewModels
|
||||||
Script.ItemFilterBlocks.Insert(blockPos + 1, block);
|
Script.ItemFilterBlocks.Insert(blockPos + 1, block);
|
||||||
ItemFilterBlockViewModels.Move(currentIndex, currentIndex + 1);
|
ItemFilterBlockViewModels.Move(currentIndex, currentIndex + 1);
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
RaisePropertyChanged("ItemFilterSectionViewModels");
|
RaisePropertyChanged(nameof(ItemFilterSectionViewModels));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,7 +734,7 @@ namespace Filtration.ViewModels
|
||||||
Script.ItemFilterBlocks.Add(block);
|
Script.ItemFilterBlocks.Add(block);
|
||||||
ItemFilterBlockViewModels.Move(currentIndex, ItemFilterBlockViewModels.Count - 1);
|
ItemFilterBlockViewModels.Move(currentIndex, ItemFilterBlockViewModels.Count - 1);
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
RaisePropertyChanged("ItemFilterSectionViewModels");
|
RaisePropertyChanged(nameof(ItemFilterSectionViewModels));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -786,7 +786,7 @@ namespace Filtration.ViewModels
|
||||||
ItemFilterBlockViewModels.Insert(ItemFilterBlockViewModels.IndexOf(targetBlockViewModel), vm);
|
ItemFilterBlockViewModels.Insert(ItemFilterBlockViewModels.IndexOf(targetBlockViewModel), vm);
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
SelectedBlockViewModel = vm;
|
SelectedBlockViewModel = vm;
|
||||||
RaisePropertyChanged("ItemFilterSectionViewModels");
|
RaisePropertyChanged(nameof(ItemFilterSectionViewModels));
|
||||||
Messenger.Default.Send(new NotificationMessage("SectionsChanged"));
|
Messenger.Default.Send(new NotificationMessage("SectionsChanged"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -233,53 +233,22 @@ 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();
|
||||||
|
|
||||||
public void CheckForUpdates()
|
if (updateData != null && updateData.UpdateAvailable)
|
||||||
{
|
{
|
||||||
var assemblyVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
|
var updateAvailableView = new UpdateAvailableView { DataContext = _updateAvailableViewModel };
|
||||||
|
_updateAvailableViewModel.Initialise(updateData);
|
||||||
try
|
|
||||||
{
|
|
||||||
var result = _updateCheckService.GetUpdateData();
|
|
||||||
|
|
||||||
if (result.LatestVersionMajorPart >= assemblyVersion.FileMajorPart &&
|
|
||||||
result.LatestVersionMinorPart > assemblyVersion.FileMinorPart)
|
|
||||||
{
|
|
||||||
if (Settings.Default.SuppressUpdates == false ||
|
|
||||||
LatestVersionIsNewerThanSuppressedVersion(result))
|
|
||||||
{
|
|
||||||
Settings.Default.SuppressUpdates = false;
|
|
||||||
Settings.Default.Save();
|
|
||||||
var updateAvailableView = new UpdateAvailableView {DataContext = _updateAvailableViewModel};
|
|
||||||
_updateAvailableViewModel.Initialise(result, assemblyVersion.FileMajorPart,
|
|
||||||
assemblyVersion.FileMinorPart);
|
|
||||||
_updateAvailableViewModel.OnRequestClose += (s, e) => updateAvailableView.Close();
|
_updateAvailableViewModel.OnRequestClose += (s, e) => updateAvailableView.Close();
|
||||||
updateAvailableView.ShowDialog();
|
updateAvailableView.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
if (Logger.IsDebugEnabled)
|
|
||||||
{
|
|
||||||
Logger.Debug(e);
|
|
||||||
}
|
|
||||||
// We don't care if the update check fails, because it could fail for multiple reasons
|
|
||||||
// including the user blocking Filtration in their firewall.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool LatestVersionIsNewerThanSuppressedVersion(UpdateData updateData)
|
|
||||||
{
|
|
||||||
return Settings.Default.SuppressUpdatesUpToVersionMajorPart < updateData.LatestVersionMajorPart ||
|
|
||||||
(Settings.Default.SuppressUpdatesUpToVersionMajorPart <= updateData.LatestVersionMajorPart &&
|
|
||||||
Settings.Default.SuppressUpdatesUpToVersionMinorPart < updateData.LatestVersionMinorPart);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImageSource Icon { get; private set; }
|
public ImageSource Icon { get; private set; }
|
||||||
|
|
||||||
public IAvalonDockWorkspaceViewModel AvalonDockWorkspaceViewModel => _avalonDockWorkspaceViewModel;
|
public IAvalonDockWorkspaceViewModel AvalonDockWorkspaceViewModel => _avalonDockWorkspaceViewModel;
|
||||||
|
|
||||||
public ISettingsPageViewModel SettingsPageViewModel { get; }
|
public ISettingsPageViewModel SettingsPageViewModel { get; }
|
||||||
|
|
||||||
public string WindowTitle
|
public string WindowTitle
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace Filtration.ViewModels
|
||||||
internal interface IUpdateAvailableViewModel
|
internal interface IUpdateAvailableViewModel
|
||||||
{
|
{
|
||||||
event EventHandler OnRequestClose;
|
event EventHandler OnRequestClose;
|
||||||
void Initialise(UpdateData updateData, int currentVersionMajorPart, int currentVersionMinorPart);
|
void Initialise(UpdateData updateData);
|
||||||
string CurrentVersion { get; }
|
string CurrentVersion { get; }
|
||||||
string NewVersion { get; }
|
string NewVersion { get; }
|
||||||
string ReleaseNotes { get; }
|
string ReleaseNotes { get; }
|
||||||
|
@ -35,10 +35,10 @@ namespace Filtration.ViewModels
|
||||||
public RelayCommand AskLaterCommand { get; private set; }
|
public RelayCommand AskLaterCommand { get; private set; }
|
||||||
public RelayCommand DownloadCommand { get; private set; }
|
public RelayCommand DownloadCommand { get; private set; }
|
||||||
|
|
||||||
public void Initialise(UpdateData updateData, int currentVersionMajorPart, int currentVersionMinorPart)
|
public void Initialise(UpdateData updateData)
|
||||||
{
|
{
|
||||||
_currentVersionMajorPart = currentVersionMajorPart;
|
_currentVersionMajorPart = updateData.CurrentVersionMajorPart;
|
||||||
_currentVersionMinorPart = currentVersionMinorPart;
|
_currentVersionMinorPart = updateData.CurrentVersionMinorPart;
|
||||||
_updateData = updateData;
|
_updateData = updateData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,7 @@
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBlock Margin="0,0,3,0">
|
<TextBlock Margin="0,0,3,0">
|
||||||
<Hyperlink Command="{Binding ElementName=TopLevelGrid, Path=DataContext.AddAudioVisualBlockItemCommand}" CommandParameter="{Binding}">
|
<Hyperlink Command="{Binding ElementName=TopLevelGrid, Path=DataContext.AddBlockCommand}" CommandParameter="{Binding}">
|
||||||
<TextBlock>+</TextBlock><TextBlock Text="{Binding Path=., Converter={StaticResource BlockItemTypeToStringConverter}}" />
|
<TextBlock>+</TextBlock><TextBlock Text="{Binding Path=., Converter={StaticResource BlockItemTypeToStringConverter}}" />
|
||||||
</Hyperlink>
|
</Hyperlink>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
|
|
Loading…
Reference in New Issue