Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37258e563a | ||
|
|
71e1f2bf78 | ||
|
|
b2b412a73c | ||
|
|
ae948c83a5 | ||
|
|
3727166a44 | ||
|
|
32b0a0199f | ||
|
|
e54730d693 | ||
|
|
d11eefaeab | ||
|
|
da5b2c73a0 | ||
|
|
2ff1373c6b | ||
|
|
1882687601 | ||
|
|
3ba25b8f07 | ||
|
|
e80295cb69 | ||
|
|
f3ed386845 | ||
|
|
89e0c717e8 | ||
|
|
8924637b98 | ||
|
|
b0b912c676 | ||
|
|
92ebc51e7b | ||
|
|
95e7581a5b | ||
|
|
9cb854b584 | ||
|
|
61c2902f0c | ||
|
|
dc157713f3 | ||
|
|
16fe837544 | ||
|
|
58de6f06b9 | ||
|
|
af2dace29a | ||
|
|
59cf604430 | ||
|
|
93a51e7829 | ||
|
|
9d928a374a | ||
|
|
b5788504cb | ||
|
|
6e71005e93 | ||
|
|
56e163e3e0 | ||
|
|
c856bbcee7 | ||
|
|
490496f2f7 | ||
|
|
9fcb609a51 | ||
|
|
1b63f68eee | ||
|
|
a496ab9b42 | ||
|
|
cbbc7c25fa | ||
|
|
d6bd1678b4 | ||
|
|
bfa2341ab8 | ||
|
|
511f503e88 | ||
|
|
3ea0530c01 | ||
|
|
aad34b1407 | ||
|
|
544b931477 |
@@ -2,7 +2,7 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Filtration.Converters
|
||||
namespace Filtration.Common.Converters
|
||||
{
|
||||
internal class BoolInverterConverter : IValueConverter
|
||||
{
|
||||
@@ -3,9 +3,9 @@ using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Filtration.Converters
|
||||
namespace Filtration.Common.Converters
|
||||
{
|
||||
internal class BooleanVisibilityConverterCopy : IValueConverter
|
||||
public class BooleanVisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Filtration.Converters
|
||||
namespace Filtration.Common.Converters
|
||||
{
|
||||
public class ColorToSolidColorBrushConverter : IValueConverter
|
||||
{
|
||||
@@ -3,9 +3,9 @@ using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Filtration.Converters
|
||||
namespace Filtration.Common.Converters
|
||||
{
|
||||
internal class BooleanVisibilityConverter : IValueConverter
|
||||
internal class InverseBooleanVisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
@@ -14,25 +14,24 @@ namespace Filtration.Converters
|
||||
var val = (bool) value;
|
||||
if (val)
|
||||
{
|
||||
return Visibility.Visible;
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
if (parameter is Visibility)
|
||||
{
|
||||
return parameter;
|
||||
}
|
||||
return Visibility.Collapsed;
|
||||
return Visibility.Visible;
|
||||
}
|
||||
if (value != null)
|
||||
{
|
||||
return Visibility.Visible;
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
|
||||
|
||||
if (parameter is Visibility)
|
||||
{
|
||||
return parameter;
|
||||
}
|
||||
return Visibility.Collapsed;
|
||||
return Visibility.Visible;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
@@ -3,7 +3,7 @@ using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Filtration.Converters
|
||||
namespace Filtration.Common.Converters
|
||||
{
|
||||
internal class StringToVisibilityConverter : IValueConverter
|
||||
{
|
||||
@@ -64,6 +64,12 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Converters\BooleanInverterConverter.cs" />
|
||||
<Compile Include="Converters\BooleanVisibilityConverter.cs" />
|
||||
<Compile Include="Converters\ColorToSolidColorBrushConverter.cs" />
|
||||
<Compile Include="Converters\InverseBooleanVisibilityConverter.cs" />
|
||||
<Compile Include="Converters\StringToVisibilityConverter.cs" />
|
||||
<Compile Include="Messages\ThemeClosedMessage.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Services\FileSystemService.cs" />
|
||||
<Compile Include="Services\MessageBoxService.cs" />
|
||||
@@ -80,6 +86,12 @@
|
||||
<Name>Filtration.ObjectModel</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="Styles\SharedResourcesDictionary.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
12
Filtration.Common/Messages/ThemeClosedMessage.cs
Normal file
12
Filtration.Common/Messages/ThemeClosedMessage.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Filtration.Common.Messages
|
||||
{
|
||||
class ThemeClosedMessage
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Filtration.Common.Services
|
||||
{
|
||||
@@ -20,7 +21,7 @@ namespace Filtration.Common.Services
|
||||
|
||||
public void WriteFileFromString(string filePath, string inputString)
|
||||
{
|
||||
File.WriteAllText(filePath, inputString);
|
||||
File.WriteAllText(filePath, inputString, Encoding.UTF8);
|
||||
}
|
||||
|
||||
public bool DirectoryExists(string directoryPath)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:converters="clr-namespace:Filtration.Converters"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:converters="clr-namespace:Filtration.Common.Converters"
|
||||
mc:Ignorable="d" >
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary>
|
||||
@@ -31,17 +31,19 @@
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<converters:IntToItemRarityConverter x:Key="IntToItemRarityConverter" />
|
||||
<Style TargetType="{x:Type Border}" x:Key="BlockItemBorder">
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="BorderBrush" Value="Black" />
|
||||
<Setter Property="CornerRadius" Value="3" />
|
||||
<Setter Property="Margin" Value="0,0,5,5" />
|
||||
</Style>
|
||||
<converters:StringToVisibilityConverter x:Key="StringToVisibilityConverter" />
|
||||
<converters:BoolInverterConverter x:Key="BoolInverterConverter" />
|
||||
<converters:ColorToSolidColorBrushConverter x:Key="ColorToSolidColorBrushConverter" />
|
||||
<converters:BooleanToBlockActionConverter x:Key="BooleanToBlockActionConverter" />
|
||||
<converters:BooleanToBlockActionInverseConverter x:Key="BooleanToBlockActionInverseConverter" />
|
||||
<converters:BlockItemTypeToStringConverter x:Key="BlockItemTypeToStringConverter" />
|
||||
<converters:BooleanVisibilityConverter x:Key="BooleanVisibilityConverter" />
|
||||
<converters:InverseBooleanVisibilityConverter x:Key="InverseBooleanVisibilityConverter" />
|
||||
<converters:BlockItemToRemoveEnabledVisibilityConverter x:Key="BlockItemToRemoveEnabledVisibilityConverter" />
|
||||
|
||||
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary Source="ExpanderStyle.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
@@ -1,9 +1,11 @@
|
||||
namespace Filtration.Interface
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Filtration.Interface
|
||||
{
|
||||
public interface IDocument
|
||||
{
|
||||
bool IsScript { get; }
|
||||
bool IsTheme { get; }
|
||||
void Close();
|
||||
Task Close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
namespace Filtration.Interface
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Filtration.Interface
|
||||
{
|
||||
public interface IEditableDocument : IDocument
|
||||
{
|
||||
bool IsDirty { get; }
|
||||
void Save();
|
||||
void SaveAs();
|
||||
Task SaveAsync();
|
||||
Task SaveAsAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
<Compile Include="TestItemFilterBlock.cs" />
|
||||
<Compile Include="TestItemFilterBlockGroup.cs" />
|
||||
<Compile Include="TestItemFilterScript.cs" />
|
||||
<Compile Include="ThemeEditor\TestThemeComponentCollection.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
|
||||
@@ -60,6 +61,7 @@
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Filtration.ObjectModel.Tests.ThemeEditor
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestThemeComponentCollection
|
||||
{
|
||||
[Test]
|
||||
public void AddComponent_ReturnsFirstAddedComponent_WhenComponentAddedTwice()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
var testInputTargetType = ThemeComponentType.TextColor;
|
||||
var testInputComponentName = "testComponent";
|
||||
var testInputColor = new Color();
|
||||
|
||||
var componentCollection = new ThemeComponentCollection();
|
||||
|
||||
// Act
|
||||
var firstResult = componentCollection.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
|
||||
var secondResult = componentCollection.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
|
||||
|
||||
// Assert
|
||||
Assert.AreSame(firstResult, secondResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Windows.Media;
|
||||
using System;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
@@ -6,6 +7,7 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
public abstract class ColorBlockItem : BlockItemBase, IAudioVisualBlockItem
|
||||
{
|
||||
private Color _color;
|
||||
private ThemeComponent _themeComponent;
|
||||
|
||||
protected ColorBlockItem()
|
||||
{
|
||||
@@ -31,7 +33,28 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
get { return string.Empty; }
|
||||
}
|
||||
|
||||
public ThemeComponent ThemeComponent { get; set; }
|
||||
public ThemeComponent ThemeComponent
|
||||
{
|
||||
get { return _themeComponent; }
|
||||
set
|
||||
{
|
||||
if (_themeComponent == value){ return;}
|
||||
|
||||
if (_themeComponent != null)
|
||||
{
|
||||
_themeComponent.ThemeComponentUpdated -= OnThemeComponentUpdated;
|
||||
_themeComponent.ThemeComponentDeleted -= OnThemeComponentDeleted;
|
||||
}
|
||||
if (value != null)
|
||||
{
|
||||
value.ThemeComponentUpdated += OnThemeComponentUpdated;
|
||||
value.ThemeComponentDeleted += OnThemeComponentDeleted;
|
||||
}
|
||||
|
||||
_themeComponent = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public override Color SummaryBackgroundColor { get { return Colors.Transparent; } }
|
||||
public override Color SummaryTextColor { get { return Colors.Transparent; } }
|
||||
@@ -45,5 +68,15 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnThemeComponentUpdated(object sender, EventArgs e)
|
||||
{
|
||||
Color = ((ThemeComponent) sender).Color;
|
||||
}
|
||||
|
||||
private void OnThemeComponentDeleted(object sender, EventArgs e)
|
||||
{
|
||||
ThemeComponent = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<Compile Include="ReplaceColorsParameterSet.cs" />
|
||||
<Compile Include="ThemeEditor\Theme.cs" />
|
||||
<Compile Include="ThemeEditor\ThemeComponent.cs" />
|
||||
<Compile Include="ThemeEditor\ThemeComponentCollection.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -13,8 +13,10 @@ namespace Filtration.ObjectModel
|
||||
public ItemFilterBlock()
|
||||
{
|
||||
BlockItems = new ObservableCollection<IItemFilterBlockItem> {new ActionBlockItem(BlockAction.Show)};
|
||||
Enabled = true;
|
||||
}
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
public ItemFilterBlockGroup BlockGroup
|
||||
|
||||
@@ -16,13 +16,13 @@ namespace Filtration.ObjectModel
|
||||
{
|
||||
new ItemFilterBlockGroup("Root", null)
|
||||
};
|
||||
ThemeComponents = new List<ThemeComponent>();
|
||||
ThemeComponents = new ThemeComponentCollection { IsMasterCollection = true};
|
||||
}
|
||||
|
||||
public ObservableCollection<ItemFilterBlock> ItemFilterBlocks { get; private set; }
|
||||
public ObservableCollection<ItemFilterBlockGroup> ItemFilterBlockGroups { get; private set; }
|
||||
|
||||
public List<ThemeComponent> ThemeComponents { get; set; }
|
||||
public ThemeComponentCollection ThemeComponents { get; set; }
|
||||
|
||||
public string FilePath { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using System.Xml.Serialization;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
|
||||
namespace Filtration.ObjectModel.ThemeEditor
|
||||
@@ -8,24 +10,28 @@ namespace Filtration.ObjectModel.ThemeEditor
|
||||
[Serializable]
|
||||
public class Theme
|
||||
{
|
||||
private readonly List<ThemeComponent> _components;
|
||||
private readonly ThemeComponentCollection _components;
|
||||
|
||||
public Theme()
|
||||
{
|
||||
_components = new List<ThemeComponent>();
|
||||
_components = new ThemeComponentCollection { IsMasterCollection = false};
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
[XmlIgnore]
|
||||
public string FilePath { get; set; }
|
||||
|
||||
public List<ThemeComponent> Components
|
||||
public ThemeComponentCollection Components
|
||||
{
|
||||
get { return _components; }
|
||||
}
|
||||
|
||||
public bool ComponentExists(ThemeComponentType componentType, string componentName)
|
||||
{
|
||||
return _components.Exists(c => c.ComponentName == componentName && c.ComponentType == componentType);
|
||||
var componentCount =
|
||||
_components.Count(c => c.ComponentName == componentName && c.ComponentType == componentType);
|
||||
return componentCount > 0;
|
||||
}
|
||||
|
||||
public void AddComponent(ThemeComponentType componentType, string componentName, Color componentColor)
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows.Media;
|
||||
using System.Xml.Serialization;
|
||||
using Filtration.ObjectModel.Annotations;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
|
||||
namespace Filtration.ObjectModel.ThemeEditor
|
||||
{
|
||||
[Serializable]
|
||||
public class ThemeComponent
|
||||
public class ThemeComponent : INotifyPropertyChanged
|
||||
{
|
||||
private Color _color;
|
||||
private EventHandler _themeComponentUpdatedEventHandler;
|
||||
private readonly object _eventLock = new object();
|
||||
|
||||
public ThemeComponent()
|
||||
{
|
||||
|
||||
@@ -24,8 +32,75 @@ namespace Filtration.ObjectModel.ThemeEditor
|
||||
ComponentName = componentName;
|
||||
}
|
||||
|
||||
// By implementing a custom event accessor here we can keep the UsageCount up to date.
|
||||
public event EventHandler ThemeComponentUpdated
|
||||
{
|
||||
add
|
||||
{
|
||||
lock (_eventLock)
|
||||
{
|
||||
_themeComponentUpdatedEventHandler += value;
|
||||
OnPropertyChanged("UsageCount");
|
||||
}
|
||||
}
|
||||
remove
|
||||
{
|
||||
lock (_eventLock)
|
||||
{
|
||||
// ReSharper disable once DelegateSubtraction
|
||||
_themeComponentUpdatedEventHandler -= value;
|
||||
OnPropertyChanged("UsageCount");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler ThemeComponentDeleted;
|
||||
|
||||
public string ComponentName { get; set; }
|
||||
public ThemeComponentType ComponentType{ get; set; }
|
||||
public Color Color { get; set; }
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get { return _color; }
|
||||
set
|
||||
{
|
||||
_color = value;
|
||||
OnPropertyChanged();
|
||||
if (_themeComponentUpdatedEventHandler != null)
|
||||
{
|
||||
_themeComponentUpdatedEventHandler.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int UsageCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_themeComponentUpdatedEventHandler == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return _themeComponentUpdatedEventHandler.GetInvocationList().Length;
|
||||
}
|
||||
}
|
||||
|
||||
public void TerminateComponent()
|
||||
{
|
||||
if (ThemeComponentDeleted != null)
|
||||
{
|
||||
ThemeComponentDeleted.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
var handler = PropertyChanged;
|
||||
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
|
||||
namespace Filtration.ObjectModel.ThemeEditor
|
||||
{
|
||||
public class ThemeComponentCollection : ObservableCollection<ThemeComponent>
|
||||
{
|
||||
public bool IsMasterCollection { get; set; }
|
||||
|
||||
public ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, Color componentColor)
|
||||
{
|
||||
if (ComponentExists(componentType, componentName))
|
||||
{
|
||||
return Items.FirstOrDefault(t => t.ComponentName == componentName && t.ComponentType == componentType);
|
||||
}
|
||||
|
||||
var component = new ThemeComponent(componentType, componentName, componentColor);
|
||||
Items.Add(component);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
private bool ComponentExists(ThemeComponentType componentType, string componentName)
|
||||
{
|
||||
var componentCount =
|
||||
Items.Count(c => c.ComponentName == componentName && c.ComponentType == componentType);
|
||||
return componentCount > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,6 @@
|
||||
<Compile Include="Translators\TestBlockGroupHierarchyBuilder.cs" />
|
||||
<Compile Include="Translators\TestItemFilterBlockTranslator.cs" />
|
||||
<Compile Include="Translators\TestItemFilterScriptTranslator.cs" />
|
||||
<Compile Include="Translators\TestThemeComponentListBuilder.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Filtration.Tests.Repositories
|
||||
|
||||
|
||||
var mockPersistenceService = new Mock<IItemFilterPersistenceService>();
|
||||
mockPersistenceService.Setup(p => p.LoadItemFilterScript(testInputPath)).Verifiable();
|
||||
mockPersistenceService.Setup(p => p.LoadItemFilterScriptAsync(testInputPath)).Verifiable();
|
||||
|
||||
var mockItemFilterScriptViewModel = new Mock<IItemFilterScriptViewModel>();
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Filtration.Tests.Repositories
|
||||
var repository = new ItemFilterScriptRepository(mockPersistenceService.Object, mockItemFilterScriptViewModelFactory.Object);
|
||||
|
||||
// Act
|
||||
var result = repository.LoadScriptFromFile(testInputPath);
|
||||
var result = repository.LoadScriptFromFileAsync(testInputPath);
|
||||
|
||||
// Assert
|
||||
mockPersistenceService.Verify();
|
||||
@@ -42,7 +42,7 @@ namespace Filtration.Tests.Repositories
|
||||
var testInputPath = "C:\\TestPath.filter";
|
||||
|
||||
var mockPersistenceService = new Mock<IItemFilterPersistenceService>();
|
||||
mockPersistenceService.Setup(p => p.LoadItemFilterScript(testInputPath)).Throws<IOException>();
|
||||
mockPersistenceService.Setup(p => p.LoadItemFilterScriptAsync(testInputPath)).Throws<IOException>();
|
||||
|
||||
var mockItemFilterScriptViewModelFactory = new Mock<IItemFilterScriptViewModelFactory>();
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Filtration.Tests.Repositories
|
||||
// Act
|
||||
|
||||
// Assert
|
||||
Assert.Throws<IOException>(() => repository.LoadScriptFromFile(testInputPath));
|
||||
Assert.Throws<IOException>(() => repository.LoadScriptFromFileAsync(testInputPath));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Filtration.Tests.Services
|
||||
var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object);
|
||||
|
||||
// Act
|
||||
var script = service.LoadItemFilterScript(TestInputPath);
|
||||
var script = service.LoadItemFilterScriptAsync(TestInputPath);
|
||||
|
||||
// Assert
|
||||
mockFileSystemService.Verify();
|
||||
@@ -53,7 +53,7 @@ namespace Filtration.Tests.Services
|
||||
var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object);
|
||||
|
||||
// Act
|
||||
service.SaveItemFilterScript(testScript);
|
||||
service.SaveItemFilterScriptAsync(testScript);
|
||||
|
||||
// Assert
|
||||
mockFileSystemService.Verify();
|
||||
|
||||
@@ -25,6 +25,36 @@ namespace Filtration.Tests.Translators
|
||||
_testUtility = new ItemFilterBlockTranslatorTestUtility();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterBlock_NotDisabled_SetsBlockEnabledTrue()
|
||||
{
|
||||
// Arrange
|
||||
var inputString = "Show" + Environment.NewLine +
|
||||
" ItemLevel >= 55";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(true, result.Enabled);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterBlock_DisabledBlock_SetsBlockEnabledFalse()
|
||||
{
|
||||
// Arrange
|
||||
var inputString = "HideDisabled" + Environment.NewLine +
|
||||
" ItemLevel >= 55";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(2, result.BlockItems.Count);
|
||||
Assert.AreEqual(BlockAction.Hide, result.Action);
|
||||
Assert.AreEqual(false, result.Enabled);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterBlock_NoDescriptionComment_ReturnsCorrectObject()
|
||||
{
|
||||
@@ -33,7 +63,7 @@ namespace Filtration.Tests.Translators
|
||||
" ItemLevel >= 55";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is ItemLevelBlockItem));
|
||||
@@ -51,7 +81,7 @@ namespace Filtration.Tests.Translators
|
||||
|
||||
// Act
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Verify();
|
||||
@@ -66,7 +96,7 @@ namespace Filtration.Tests.Translators
|
||||
|
||||
// Act
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(true, inputBlockGroup.IsChecked);
|
||||
@@ -81,7 +111,7 @@ namespace Filtration.Tests.Translators
|
||||
|
||||
// Act
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(false, inputBlockGroup.IsChecked);
|
||||
@@ -95,7 +125,7 @@ namespace Filtration.Tests.Translators
|
||||
|
||||
// Act
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable();
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never);
|
||||
@@ -109,7 +139,7 @@ namespace Filtration.Tests.Translators
|
||||
|
||||
// Act
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable();
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never);
|
||||
@@ -124,7 +154,7 @@ namespace Filtration.Tests.Translators
|
||||
|
||||
// Act
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(testBlockGroup).Verifiable();
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(testBlockGroup, result.BlockGroup);
|
||||
@@ -138,7 +168,7 @@ namespace Filtration.Tests.Translators
|
||||
var inputString = "Hide" + Environment.NewLine;
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is ActionBlockItem));
|
||||
@@ -154,7 +184,7 @@ namespace Filtration.Tests.Translators
|
||||
" ItemLevel >= 55";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("This is a test Block", result.Description);
|
||||
@@ -174,7 +204,7 @@ namespace Filtration.Tests.Translators
|
||||
" ItemLevel >= 55";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Second Line", result.Description);
|
||||
@@ -192,7 +222,7 @@ namespace Filtration.Tests.Translators
|
||||
" DropLevel = 40";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
|
||||
@@ -210,7 +240,7 @@ namespace Filtration.Tests.Translators
|
||||
" Quality < 18";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
|
||||
@@ -228,7 +258,7 @@ namespace Filtration.Tests.Translators
|
||||
" Rarity > Normal";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
|
||||
@@ -246,7 +276,7 @@ namespace Filtration.Tests.Translators
|
||||
" Rarity Normal";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is RarityBlockItem));
|
||||
@@ -263,7 +293,7 @@ namespace Filtration.Tests.Translators
|
||||
@" Class ""Test Class 1"" ""TestOneWordClassInQuotes"" TestOneWordClassNotInQuotes ""Test Class 2""";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is ClassBlockItem));
|
||||
@@ -282,7 +312,7 @@ namespace Filtration.Tests.Translators
|
||||
@" BaseType ""Test Base Type 1"" ""TestOneWordBaseTypeInQuotes"" TestOneWordBaseTypeNotInQuotes ""Test BaseType 2""";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BaseTypeBlockItem));
|
||||
@@ -301,7 +331,7 @@ namespace Filtration.Tests.Translators
|
||||
" Sockets > 2";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
|
||||
@@ -319,7 +349,7 @@ namespace Filtration.Tests.Translators
|
||||
" LinkedSockets != 1";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
|
||||
@@ -337,7 +367,7 @@ namespace Filtration.Tests.Translators
|
||||
" Width != 1";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
|
||||
@@ -355,7 +385,7 @@ namespace Filtration.Tests.Translators
|
||||
" Height <= 3";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
|
||||
@@ -373,7 +403,7 @@ namespace Filtration.Tests.Translators
|
||||
" Height <=3";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is HeightBlockItem));
|
||||
@@ -390,7 +420,7 @@ namespace Filtration.Tests.Translators
|
||||
" SocketGroup RRGB";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is SocketGroupBlockItem));
|
||||
@@ -408,7 +438,7 @@ namespace Filtration.Tests.Translators
|
||||
" SetTextColor 255 20 100";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
|
||||
@@ -426,7 +456,7 @@ namespace Filtration.Tests.Translators
|
||||
" SetTextColor 65 0 255 12";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
|
||||
@@ -445,7 +475,7 @@ namespace Filtration.Tests.Translators
|
||||
" SetBackgroundColor 255 20 100";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem));
|
||||
@@ -464,7 +494,7 @@ namespace Filtration.Tests.Translators
|
||||
" SetBorderColor 255 20 100";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
|
||||
@@ -483,8 +513,8 @@ namespace Filtration.Tests.Translators
|
||||
|
||||
// Act
|
||||
|
||||
Assert.DoesNotThrow(() => _testUtility.Translator.TranslateStringToItemFilterBlock(inputString));
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
Assert.DoesNotThrow(() => _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null));
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
|
||||
@@ -500,21 +530,17 @@ namespace Filtration.Tests.Translators
|
||||
// Arrange
|
||||
var inputString = "Show" + Environment.NewLine +
|
||||
" SetTextColor 255 20 100 # Rare Item Text";
|
||||
var testComponent = new ThemeComponent(ThemeComponentType.TextColor, "testComponent", new Color());
|
||||
|
||||
_testUtility.MockThemeComponentListBuilder.Setup(
|
||||
t =>
|
||||
t.AddComponent(ThemeComponentType.TextColor, "Rare Item Text",
|
||||
new Color {A = 255, R = 255, G = 20, B = 100})).Returns(testComponent).Verifiable();
|
||||
_testUtility.MockThemeComponentListBuilder.SetupGet(t => t.IsInitialised).Returns(true);
|
||||
var testComponent = new ThemeComponent(ThemeComponentType.TextColor, "Rare Item Text", new Color { R = 255, G = 20, B = 100});
|
||||
var testInputThemeComponentCollection = new ThemeComponentCollection { testComponent };
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, testInputThemeComponentCollection);
|
||||
|
||||
// Assert
|
||||
var blockItem = result.BlockItems.OfType<TextColorBlockItem>().First();
|
||||
Assert.AreSame(testComponent, blockItem.ThemeComponent);
|
||||
_testUtility.MockThemeComponentListBuilder.Verify();
|
||||
var firstComponent = testInputThemeComponentCollection.First();
|
||||
Assert.AreEqual("Rare Item Text", firstComponent.ComponentName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -526,7 +552,7 @@ namespace Filtration.Tests.Translators
|
||||
" SetFontSize 15";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem));
|
||||
@@ -543,7 +569,7 @@ namespace Filtration.Tests.Translators
|
||||
" PlayAlertSound 4";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
|
||||
@@ -561,7 +587,7 @@ namespace Filtration.Tests.Translators
|
||||
" PlayAlertSound 2 95";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
|
||||
@@ -578,7 +604,7 @@ namespace Filtration.Tests.Translators
|
||||
var inputString = "# Section: " + TestInputSectionDescription;
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.IsInstanceOf<ItemFilterSection>(result);
|
||||
@@ -611,7 +637,7 @@ namespace Filtration.Tests.Translators
|
||||
" PlayAlertSound 3";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Test filter with everything", result.Description);
|
||||
@@ -693,7 +719,7 @@ namespace Filtration.Tests.Translators
|
||||
" Quality < 17";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(2, result.BlockItems.Count(b => b is ItemLevelBlockItem));
|
||||
@@ -722,7 +748,7 @@ namespace Filtration.Tests.Translators
|
||||
" SetTextColor 255 20 100";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
|
||||
@@ -743,7 +769,7 @@ namespace Filtration.Tests.Translators
|
||||
" SetFontSize 27" + Environment.NewLine;
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem));
|
||||
@@ -762,7 +788,7 @@ namespace Filtration.Tests.Translators
|
||||
" PlayAlertSound 2" + Environment.NewLine;
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
|
||||
@@ -780,7 +806,7 @@ namespace Filtration.Tests.Translators
|
||||
" SetBackgroundColor 255 20 100";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem));
|
||||
@@ -799,7 +825,7 @@ namespace Filtration.Tests.Translators
|
||||
" SetBorderColor 255 20 100";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
|
||||
@@ -1268,6 +1294,26 @@ namespace Filtration.Tests.Translators
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateItemFilterBlockToString_DisabledBlock_ReturnsCorrectString()
|
||||
{
|
||||
// Arrange
|
||||
var expectedResult = "#Disabled Block Start" + Environment.NewLine +
|
||||
"#Show" + Environment.NewLine +
|
||||
"# Width = 4" + Environment.NewLine +
|
||||
"#Disabled Block End";
|
||||
|
||||
|
||||
_testUtility.TestBlock.Enabled = false;
|
||||
_testUtility.TestBlock.BlockItems.Add(new WidthBlockItem(FilterPredicateOperator.Equal, 4));
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateItemFilterBlockToString_Everything_ReturnsCorrectString()
|
||||
{
|
||||
@@ -1347,6 +1393,26 @@ namespace Filtration.Tests.Translators
|
||||
Assert.AreEqual(new Color { R = 240, G = 200, B = 150, A = 255}, textColorBlockItem.Color);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReplaceColorBlockItemsFromString_SingleLine_ReplacesColorBlockBugTest()
|
||||
{
|
||||
// Arrange
|
||||
var testInputString = "SetBackgroundColor 70 0 0 255";
|
||||
|
||||
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
|
||||
var testInputBlockItem = new BackgroundColorBlockItem(new Color { R = 70, G = 0, B = 1, A = 255});
|
||||
testInputBlockItems.Add(testInputBlockItem);
|
||||
|
||||
// Act
|
||||
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
|
||||
|
||||
// Assert
|
||||
var backgroundColorBlockItem = testInputBlockItems.First(b => b is BackgroundColorBlockItem) as BackgroundColorBlockItem;
|
||||
Assert.IsNotNull(backgroundColorBlockItem);
|
||||
Assert.AreNotSame(testInputBlockItem, backgroundColorBlockItem);
|
||||
Assert.AreEqual(new Color { R = 70, G = 0, B = 0, A = 255 }, backgroundColorBlockItem.Color);
|
||||
}
|
||||
|
||||
[Ignore("Not currently possible - will not be necessary once commanding (to enable undo history) is implemented anyway")]
|
||||
[Test]
|
||||
public void ReplaceColorBlockItemsFromString_MalformedLine_DoesNothing()
|
||||
@@ -1461,6 +1527,7 @@ namespace Filtration.Tests.Translators
|
||||
Assert.AreEqual(0, testInputBlockItems.Count(b => b is BorderColorBlockItem));
|
||||
}
|
||||
|
||||
[Ignore("ThemeComponentBuilder deprecated")]
|
||||
[Test]
|
||||
public void ReplaceColorBlockItemsFromString_ThemeComponentBuilderNotInitialised_DoesNotCallAddComponent()
|
||||
{
|
||||
@@ -1470,13 +1537,12 @@ namespace Filtration.Tests.Translators
|
||||
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
|
||||
var testInputBlockItem = new TextColorBlockItem(Colors.Red);
|
||||
testInputBlockItems.Add(testInputBlockItem);
|
||||
_testUtility.MockThemeComponentListBuilder.Setup(t => t.AddComponent(It.IsAny<ThemeComponentType>(), It.IsAny<string>(), It.IsAny<Color>())).Verifiable();
|
||||
|
||||
// Act
|
||||
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
|
||||
|
||||
// Assert
|
||||
_testUtility.MockThemeComponentListBuilder.Verify(t => t.AddComponent(It.IsAny<ThemeComponentType>(), It.IsAny<string>(), It.IsAny<Color>()), Times.Never);
|
||||
|
||||
}
|
||||
private class ItemFilterBlockTranslatorTestUtility
|
||||
{
|
||||
@@ -1487,16 +1553,13 @@ namespace Filtration.Tests.Translators
|
||||
|
||||
// Mock setups
|
||||
MockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();
|
||||
MockThemeComponentListBuilder = new Mock<IThemeComponentListBuilder>();
|
||||
|
||||
// Class under test instantiation
|
||||
Translator = new ItemFilterBlockTranslator(MockBlockGroupHierarchyBuilder.Object,
|
||||
MockThemeComponentListBuilder.Object);
|
||||
Translator = new ItemFilterBlockTranslator(MockBlockGroupHierarchyBuilder.Object);
|
||||
}
|
||||
|
||||
public ItemFilterBlock TestBlock { get; set; }
|
||||
public Mock<IBlockGroupHierarchyBuilder> MockBlockGroupHierarchyBuilder { get; private set; }
|
||||
public Mock<IThemeComponentListBuilder> MockThemeComponentListBuilder { get; private set; }
|
||||
public ItemFilterBlockTranslator Translator { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Filtration.Tests.Translators
|
||||
// Arrange
|
||||
var testInput = File.ReadAllText(@"Resources/testscript.txt");
|
||||
|
||||
_testUtility.MockItemFilterBlockTranslator.Setup(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>())).Verifiable();
|
||||
_testUtility.MockItemFilterBlockTranslator.Setup(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>(), It.IsAny<ThemeComponentCollection>())).Verifiable();
|
||||
|
||||
// Act
|
||||
var script = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
|
||||
@@ -54,7 +54,7 @@ namespace Filtration.Tests.Translators
|
||||
"End Script Description";
|
||||
|
||||
var mockItemFilterBlockTranslator = new Mock<IItemFilterBlockTranslator>();
|
||||
mockItemFilterBlockTranslator.Setup(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>())).Verifiable();
|
||||
mockItemFilterBlockTranslator.Setup(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>(), It.IsAny<ThemeComponentCollection>())).Verifiable();
|
||||
|
||||
// Act
|
||||
var script = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
|
||||
@@ -63,37 +63,6 @@ namespace Filtration.Tests.Translators
|
||||
Assert.AreEqual(expectedDescription, script.Description);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterScript_CallsThemeComponentListBuilderInitialise()
|
||||
{
|
||||
// Arrange
|
||||
var testInput = File.ReadAllText(@"Resources/testscript.txt");
|
||||
|
||||
_testUtility.MockThemeComponentListBuilder.Setup(t => t.Initialise()).Verifiable();
|
||||
// Act
|
||||
_testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
|
||||
|
||||
// Assert
|
||||
_testUtility.MockThemeComponentListBuilder.Verify();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterScript_SetsScriptThemeComponentsToComponentListBuilderResult()
|
||||
{
|
||||
// Arrange
|
||||
var testInput = File.ReadAllText(@"Resources/testscript.txt");
|
||||
List<ThemeComponent> testThemeComponents = new List<ThemeComponent>();
|
||||
|
||||
_testUtility.MockThemeComponentListBuilder.Setup(t => t.GetComponents()).Returns(testThemeComponents).Verifiable();
|
||||
// Act
|
||||
var result = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
|
||||
|
||||
// Assert
|
||||
_testUtility.MockThemeComponentListBuilder.Verify();
|
||||
Assert.AreSame(testThemeComponents, result.ThemeComponents);
|
||||
}
|
||||
|
||||
[Ignore("Integration Test")]
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterScript_ThioleItemFilterTest()
|
||||
@@ -101,10 +70,9 @@ namespace Filtration.Tests.Translators
|
||||
// Arrange
|
||||
var testInput = File.ReadAllText(@"Resources/ThioleItemFilter.txt");
|
||||
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
|
||||
_testUtility.MockThemeComponentListBuilder.Object);
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
translator.TranslateStringToItemFilterScript(testInput);
|
||||
@@ -161,10 +129,9 @@ namespace Filtration.Tests.Translators
|
||||
" Width = 3" + Environment.NewLine +
|
||||
" SetFontSize 7" + Environment.NewLine;
|
||||
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
|
||||
_testUtility.MockThemeComponentListBuilder.Object);
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
var result = translator.TranslateItemFilterScriptToString(script);
|
||||
@@ -207,10 +174,9 @@ namespace Filtration.Tests.Translators
|
||||
" Width = 3" + Environment.NewLine +
|
||||
" SetFontSize 7" + Environment.NewLine + Environment.NewLine;
|
||||
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
|
||||
_testUtility.MockThemeComponentListBuilder.Object);
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
var result = translator.TranslateItemFilterScriptToString(script);
|
||||
@@ -251,10 +217,9 @@ namespace Filtration.Tests.Translators
|
||||
" SetBorderColor 255 0 255" + Environment.NewLine +
|
||||
" SetFontSize 25";
|
||||
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
|
||||
_testUtility.MockThemeComponentListBuilder.Object);
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
var result = translator.TranslateStringToItemFilterScript(testInputScript);
|
||||
@@ -275,10 +240,9 @@ namespace Filtration.Tests.Translators
|
||||
Environment.NewLine +
|
||||
"Show" + Environment.NewLine +
|
||||
"BaseType \"Maelström Staff\"" + Environment.NewLine + Environment.NewLine;
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
|
||||
_testUtility.MockThemeComponentListBuilder.Object);
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
var result = translator.TranslateStringToItemFilterScript(testInputScript);
|
||||
@@ -289,6 +253,139 @@ namespace Filtration.Tests.Translators
|
||||
Assert.IsNullOrEmpty(firstBlock.Description);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterScript_DisabledBlock_ReturnsCorrectBlockCount()
|
||||
{
|
||||
// Arrange
|
||||
var testInputScript = "Show" + Environment.NewLine +
|
||||
" ItemLevel > 2" + Environment.NewLine +
|
||||
" SetTextColor 255 40 0" + Environment.NewLine +
|
||||
Environment.NewLine +
|
||||
"#Disabled Block Start" + Environment.NewLine +
|
||||
"#Show" + Environment.NewLine +
|
||||
"# ItemLevel > 2" + Environment.NewLine +
|
||||
"# SetTextColor 255 215 0" + Environment.NewLine +
|
||||
"# SetBorderColor 255 105 180" + Environment.NewLine +
|
||||
"# SetFontSize 32" + Environment.NewLine +
|
||||
"#Disabled Block End" + Environment.NewLine +
|
||||
Environment.NewLine +
|
||||
"Show" + Environment.NewLine +
|
||||
" ItemLevel > 20" + Environment.NewLine +
|
||||
" SetTextColor 255 255 0";
|
||||
|
||||
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
var result = translator.TranslateStringToItemFilterScript(testInputScript);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(3, result.ItemFilterBlocks.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterScript_DisabledBlock_ReturnsCorrectBlocks()
|
||||
{
|
||||
// Arrange
|
||||
var testInputScript = "Show" + Environment.NewLine +
|
||||
" ItemLevel > 2" + Environment.NewLine +
|
||||
" SetTextColor 255 40 0" + Environment.NewLine +
|
||||
Environment.NewLine +
|
||||
"#Disabled Block Start" + Environment.NewLine +
|
||||
"#Show" + Environment.NewLine +
|
||||
"# ItemLevel > 2" + Environment.NewLine +
|
||||
"# SetTextColor 255 215 0" + Environment.NewLine +
|
||||
"# SetBorderColor 255 105 180" + Environment.NewLine +
|
||||
"# SetFontSize 32" + Environment.NewLine +
|
||||
"#Disabled Block End" + Environment.NewLine +
|
||||
Environment.NewLine +
|
||||
"Show" + Environment.NewLine +
|
||||
" ItemLevel > 20" + Environment.NewLine +
|
||||
" SetTextColor 255 255 0";
|
||||
|
||||
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
var result = translator.TranslateStringToItemFilterScript(testInputScript);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(3, result.ItemFilterBlocks.Count);
|
||||
|
||||
var firstBlock = result.ItemFilterBlocks.First();
|
||||
var secondBlock = result.ItemFilterBlocks.Skip(1).First();
|
||||
var thirdBlock = result.ItemFilterBlocks.Skip(2).First();
|
||||
|
||||
Assert.AreEqual(3, firstBlock.BlockItems.Count);
|
||||
Assert.AreEqual(5, secondBlock.BlockItems.Count);
|
||||
Assert.AreEqual(3, thirdBlock.BlockItems.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterScript_DisabledBlock_BlockDescriptionNotLost()
|
||||
{
|
||||
// Arrange
|
||||
var testInputScript = "Show" + Environment.NewLine +
|
||||
" ItemLevel > 2" + Environment.NewLine +
|
||||
" SetTextColor 255 40 0" + Environment.NewLine +
|
||||
Environment.NewLine +
|
||||
"#Disabled Block Start" + Environment.NewLine +
|
||||
"# This is a disabled block" + Environment.NewLine +
|
||||
"#Show" + Environment.NewLine +
|
||||
"# ItemLevel > 2" + Environment.NewLine +
|
||||
"#Disabled Block End";
|
||||
|
||||
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
var result = translator.TranslateStringToItemFilterScript(testInputScript);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(2, result.ItemFilterBlocks.Count);
|
||||
var secondBlock = result.ItemFilterBlocks.Skip(1).First();
|
||||
Assert.AreEqual("This is a disabled block", secondBlock.Description);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterScript_DisabledBlockWithBlockGroup_ReturnsCorrectBlock()
|
||||
{
|
||||
// Arrange
|
||||
var testInputScript = "Show" + Environment.NewLine +
|
||||
" ItemLevel > 2" + Environment.NewLine +
|
||||
" SetTextColor 255 40 0" + Environment.NewLine +
|
||||
Environment.NewLine +
|
||||
"#Disabled Block Start" + Environment.NewLine +
|
||||
"# This is a disabled block" + Environment.NewLine +
|
||||
"#Show#My Block Group" + Environment.NewLine +
|
||||
"# ItemLevel > 2" + Environment.NewLine +
|
||||
"#Disabled Block End";
|
||||
|
||||
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(
|
||||
b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()))
|
||||
.Returns(new ItemFilterBlockGroup("My Block Group", null));
|
||||
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
var result = translator.TranslateStringToItemFilterScript(testInputScript);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(2, result.ItemFilterBlocks.Count);
|
||||
var secondBlock = result.ItemFilterBlocks.Skip(1).First();
|
||||
Assert.AreEqual("This is a disabled block", secondBlock.Description);
|
||||
Assert.AreEqual("My Block Group", secondBlock.BlockGroup.GroupName);
|
||||
}
|
||||
|
||||
private class ItemFilterScriptTranslatorTestUtility
|
||||
{
|
||||
public ItemFilterScriptTranslatorTestUtility()
|
||||
@@ -296,16 +393,14 @@ namespace Filtration.Tests.Translators
|
||||
// Mock setups
|
||||
MockItemFilterBlockTranslator = new Mock<IItemFilterBlockTranslator>();
|
||||
MockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();
|
||||
MockThemeComponentListBuilder = new Mock<IThemeComponentListBuilder>();
|
||||
|
||||
// Class under test instantiation
|
||||
ScriptTranslator = new ItemFilterScriptTranslator(MockItemFilterBlockTranslator.Object, MockBlockGroupHierarchyBuilder.Object, MockThemeComponentListBuilder.Object);
|
||||
ScriptTranslator = new ItemFilterScriptTranslator(MockItemFilterBlockTranslator.Object, MockBlockGroupHierarchyBuilder.Object);
|
||||
}
|
||||
|
||||
public ItemFilterScriptTranslator ScriptTranslator { get; private set; }
|
||||
public Mock<IItemFilterBlockTranslator> MockItemFilterBlockTranslator { get; private set; }
|
||||
public Mock<IBlockGroupHierarchyBuilder> MockBlockGroupHierarchyBuilder { get; private set; }
|
||||
public Mock<IThemeComponentListBuilder> MockThemeComponentListBuilder { get; private set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
using System.Net.Mime;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.Translators;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Filtration.Tests.Translators
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestThemeComponentListBuilder
|
||||
{
|
||||
[Test]
|
||||
public void AddComponent_ReturnsFirstAddedComponent_WhenComponentAddedTwice()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
var testInputTargetType = ThemeComponentType.TextColor;
|
||||
var testInputComponentName = "testComponent";
|
||||
var testInputColor = new Color();
|
||||
|
||||
var builder = new ThemeComponentListBuilder();
|
||||
builder.Initialise();
|
||||
|
||||
// Act
|
||||
var firstResult = builder.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
|
||||
var secondResult = builder.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
|
||||
|
||||
// Assert
|
||||
Assert.AreSame(firstResult, secondResult);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsInitialised_NotInitialised_ReturnsFalse()
|
||||
{
|
||||
// Arrange
|
||||
var builder = new ThemeComponentListBuilder();
|
||||
|
||||
// Act
|
||||
var result = builder.IsInitialised;
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsInitialised_Initialised_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
var builder = new ThemeComponentListBuilder();
|
||||
builder.Initialise();
|
||||
|
||||
// Act
|
||||
var result = builder.IsInitialised;
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.Extensions;
|
||||
|
||||
@@ -18,6 +17,22 @@ namespace Filtration.ThemeEditor.Converters
|
||||
}
|
||||
var type = (ThemeComponentType) value;
|
||||
|
||||
switch (type.GetAttributeDescription())
|
||||
{
|
||||
case "Text":
|
||||
{
|
||||
return "Text Color Theme Components";
|
||||
}
|
||||
case "Border":
|
||||
{
|
||||
return "Border Color Theme Components";
|
||||
}
|
||||
case "Background":
|
||||
{
|
||||
return "Background Color Theme Components";
|
||||
}
|
||||
}
|
||||
|
||||
return type.GetAttributeDescription();
|
||||
|
||||
}
|
||||
|
||||
@@ -95,18 +95,19 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Converters\ThemeComponentTypeToStringConverter.cs" />
|
||||
<Compile Include="Messages\ThemeClosedMessage.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Providers\ThemeProvider.cs" />
|
||||
<Compile Include="Services\ThemePersistenceService.cs" />
|
||||
<Compile Include="Services\ThemeService.cs" />
|
||||
<Compile Include="ViewModels\IThemeViewModelFactory.cs" />
|
||||
<Compile Include="ViewModels\ThemeComponentViewModel.cs" />
|
||||
<Compile Include="ViewModels\ThemeViewModel.cs" />
|
||||
<Compile Include="ViewModels\ThemeEditorViewModel.cs" />
|
||||
<Compile Include="Views\ThemeComponentControl.xaml.cs">
|
||||
<DependentUpon>ThemeComponentControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\ThemeControl.xaml.cs">
|
||||
<DependentUpon>ThemeControl.xaml</DependentUpon>
|
||||
<Compile Include="Views\ThemeEditorView.xaml.cs">
|
||||
<DependentUpon>ThemeEditorView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WindsorInstallers\ProvidersInstaller.cs" />
|
||||
<Compile Include="WindsorInstallers\ServicesInstaller.cs" />
|
||||
@@ -132,7 +133,7 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\ThemeControl.xaml">
|
||||
<Page Include="Views\ThemeEditorView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
|
||||
9
Filtration.ThemeEditor/Messages/ThemeClosedMessage.cs
Normal file
9
Filtration.ThemeEditor/Messages/ThemeClosedMessage.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Filtration.ThemeEditor.ViewModels;
|
||||
|
||||
namespace Filtration.ThemeEditor.Messages
|
||||
{
|
||||
public class ThemeClosedMessage
|
||||
{
|
||||
public IThemeEditorViewModel ClosedViewModel { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
@@ -9,10 +12,11 @@ namespace Filtration.ThemeEditor.Providers
|
||||
{
|
||||
public interface IThemeProvider
|
||||
{
|
||||
IThemeViewModel NewThemeForScript(ItemFilterScript script);
|
||||
IThemeViewModel LoadThemeFromFile(string filePath);
|
||||
Theme LoadThemeModelFromFile(string filePath);
|
||||
void SaveTheme(IThemeViewModel themeViewModel, string filePath);
|
||||
IThemeEditorViewModel NewThemeForScript(ItemFilterScript script);
|
||||
IThemeEditorViewModel MasterThemeForScript(ItemFilterScript script);
|
||||
Task<IThemeEditorViewModel> LoadThemeFromFile(string filePath);
|
||||
Task<Theme> LoadThemeModelFromFile(string filePath);
|
||||
Task SaveThemeAsync(IThemeEditorViewModel themeEditorViewModel, string filePath);
|
||||
}
|
||||
|
||||
internal class ThemeProvider : IThemeProvider
|
||||
@@ -26,33 +30,51 @@ namespace Filtration.ThemeEditor.Providers
|
||||
_themePersistenceService = themePersistenceService;
|
||||
}
|
||||
|
||||
public IThemeViewModel NewThemeForScript(ItemFilterScript script)
|
||||
public IThemeEditorViewModel NewThemeForScript(ItemFilterScript script)
|
||||
{
|
||||
var themeComponentViewModels = Mapper.Map<ObservableCollection<ThemeComponentViewModel>>(script.ThemeComponents);
|
||||
var themeComponentCollection = script.ThemeComponents.Aggregate(new ThemeComponentCollection(),
|
||||
(c, component) =>
|
||||
{
|
||||
c.Add(new ThemeComponent(component.ComponentType, component.ComponentName, component.Color));
|
||||
return c;
|
||||
});
|
||||
|
||||
var themeViewModel = _themeViewModelFactory.Create();
|
||||
themeViewModel.Initialise(themeComponentViewModels, true);
|
||||
themeViewModel.InitialiseForNewTheme(themeComponentCollection);
|
||||
themeViewModel.FilePath = "Untitled.filtertheme";
|
||||
|
||||
return themeViewModel;
|
||||
}
|
||||
|
||||
public IThemeViewModel LoadThemeFromFile(string filePath)
|
||||
public IThemeEditorViewModel MasterThemeForScript(ItemFilterScript script)
|
||||
{
|
||||
var model = _themePersistenceService.LoadTheme(filePath);
|
||||
var viewModel = Mapper.Map<IThemeViewModel>(model);
|
||||
var themeViewModel = _themeViewModelFactory.Create();
|
||||
themeViewModel.InitialiseForMasterTheme(script);
|
||||
themeViewModel.FilePath = "<Master Theme> " + Path.GetFileName(script.FilePath);
|
||||
|
||||
return themeViewModel;
|
||||
}
|
||||
|
||||
public async Task<IThemeEditorViewModel> LoadThemeFromFile(string filePath)
|
||||
{
|
||||
var model = await _themePersistenceService.LoadThemeAsync(filePath);
|
||||
var viewModel = Mapper.Map<IThemeEditorViewModel>(model);
|
||||
viewModel.FilePath = filePath;
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
public Theme LoadThemeModelFromFile(string filePath)
|
||||
public async Task<Theme> LoadThemeModelFromFile(string filePath)
|
||||
{
|
||||
return _themePersistenceService.LoadTheme(filePath);
|
||||
return await _themePersistenceService.LoadThemeAsync(filePath);
|
||||
}
|
||||
|
||||
public void SaveTheme(IThemeViewModel themeViewModel, string filePath)
|
||||
public async Task SaveThemeAsync(IThemeEditorViewModel themeEditorViewModel, string filePath)
|
||||
{
|
||||
var theme = Mapper.Map<Theme>(themeViewModel);
|
||||
_themePersistenceService.SaveTheme(theme, filePath);
|
||||
await Task.Run(() =>
|
||||
{
|
||||
var theme = Mapper.Map<Theme>(themeEditorViewModel);
|
||||
_themePersistenceService.SaveThemeAsync(theme, filePath);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
|
||||
@@ -6,28 +7,34 @@ namespace Filtration.ThemeEditor.Services
|
||||
{
|
||||
internal interface IThemePersistenceService
|
||||
{
|
||||
Theme LoadTheme(string filePath);
|
||||
void SaveTheme(Theme theme, string filePath);
|
||||
Task<Theme> LoadThemeAsync(string filePath);
|
||||
Task SaveThemeAsync(Theme theme, string filePath);
|
||||
}
|
||||
|
||||
internal class ThemePersistenceService : IThemePersistenceService
|
||||
{
|
||||
public Theme LoadTheme(string filePath)
|
||||
public async Task<Theme> LoadThemeAsync(string filePath)
|
||||
{
|
||||
Theme loadedTheme = null;
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
var xmlSerializer = new XmlSerializer(typeof (Theme));
|
||||
|
||||
Theme loadedTheme;
|
||||
|
||||
using (Stream reader = new FileStream(filePath, FileMode.Open))
|
||||
{
|
||||
loadedTheme = (Theme) xmlSerializer.Deserialize(reader);
|
||||
}
|
||||
|
||||
loadedTheme.FilePath = filePath;
|
||||
});
|
||||
|
||||
return loadedTheme;
|
||||
}
|
||||
|
||||
public void SaveTheme(Theme theme, string filePath)
|
||||
public async Task SaveThemeAsync(Theme theme, string filePath)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
var xmlSerializer = new XmlSerializer(typeof (Theme));
|
||||
|
||||
@@ -35,6 +42,7 @@ namespace Filtration.ThemeEditor.Services
|
||||
{
|
||||
xmlSerializer.Serialize(writer, theme);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
public interface IThemeViewModelFactory
|
||||
{
|
||||
IThemeViewModel Create();
|
||||
void Release(IThemeViewModel themeViewModel);
|
||||
IThemeEditorViewModel Create();
|
||||
void Release(IThemeEditorViewModel themeEditorViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
215
Filtration.ThemeEditor/ViewModels/ThemeEditorViewModel.cs
Normal file
215
Filtration.ThemeEditor/ViewModels/ThemeEditorViewModel.cs
Normal file
@@ -0,0 +1,215 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Filtration.Common.Services;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.Interface;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
using Filtration.ThemeEditor.Messages;
|
||||
using Filtration.ThemeEditor.Providers;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
using NLog;
|
||||
|
||||
namespace Filtration.ThemeEditor.ViewModels
|
||||
{
|
||||
public interface IThemeEditorViewModel : IEditableDocument
|
||||
{
|
||||
RelayCommand<ThemeComponentType> AddThemeComponentCommand { get; }
|
||||
RelayCommand<ThemeComponent> DeleteThemeComponentCommand { get; }
|
||||
RelayCommand CloseCommand { get; }
|
||||
|
||||
void InitialiseForNewTheme(ThemeComponentCollection themeComponentCollection);
|
||||
void InitialiseForMasterTheme(ItemFilterScript script);
|
||||
bool IsMasterTheme { get; }
|
||||
ItemFilterScript IsMasterThemeForScript { get; }
|
||||
string Title { get; }
|
||||
string FilePath { get; set; }
|
||||
string Filename { get; }
|
||||
string Name { get; set; }
|
||||
ThemeComponentCollection Components { get; set; }
|
||||
ThemeComponent SelectedThemeComponent { get; }
|
||||
}
|
||||
|
||||
public class ThemeEditorViewModel : PaneViewModel, IThemeEditorViewModel
|
||||
{
|
||||
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private readonly IThemeProvider _themeProvider;
|
||||
private readonly IMessageBoxService _messageBoxService;
|
||||
private bool _filenameIsFake;
|
||||
private string _filePath;
|
||||
private ThemeComponent _selectedThemeComponent;
|
||||
|
||||
public ThemeEditorViewModel(IThemeProvider themeProvider,
|
||||
IMessageBoxService messageBoxService)
|
||||
{
|
||||
_themeProvider = themeProvider;
|
||||
_messageBoxService = messageBoxService;
|
||||
|
||||
AddThemeComponentCommand = new RelayCommand<ThemeComponentType>(OnAddThemeComponentCommand, t => IsMasterTheme);
|
||||
DeleteThemeComponentCommand = new RelayCommand<ThemeComponent>(OnDeleteThemeComponentCommand,
|
||||
t => IsMasterTheme && SelectedThemeComponent != null);
|
||||
CloseCommand = new RelayCommand(async () => await OnCloseCommand());
|
||||
|
||||
var icon = new BitmapImage();
|
||||
icon.BeginInit();
|
||||
icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/Theme.ico");
|
||||
icon.EndInit();
|
||||
IconSource = icon;
|
||||
|
||||
}
|
||||
|
||||
public RelayCommand<ThemeComponentType> AddThemeComponentCommand { get; private set; }
|
||||
public RelayCommand<ThemeComponent> DeleteThemeComponentCommand { get; private set; }
|
||||
public RelayCommand CloseCommand { get; private set; }
|
||||
|
||||
public bool IsMasterTheme
|
||||
{
|
||||
get { return Components.IsMasterCollection; }
|
||||
}
|
||||
|
||||
public ItemFilterScript IsMasterThemeForScript { get; private set; }
|
||||
|
||||
public void InitialiseForNewTheme(ThemeComponentCollection themeComponentCollection)
|
||||
{
|
||||
Components = themeComponentCollection;
|
||||
_filenameIsFake = true;
|
||||
}
|
||||
|
||||
public void InitialiseForMasterTheme(ItemFilterScript script)
|
||||
{
|
||||
Components = script.ThemeComponents;
|
||||
IsMasterThemeForScript = script;
|
||||
_filenameIsFake = true;
|
||||
|
||||
}
|
||||
|
||||
public bool IsScript { get { return false; } }
|
||||
public bool IsTheme { get { return true; } }
|
||||
public bool IsDirty { get; private set; }
|
||||
|
||||
public string FilePath
|
||||
{
|
||||
get { return _filePath; }
|
||||
set
|
||||
{
|
||||
_filePath = value;
|
||||
Title = Filename;
|
||||
}
|
||||
}
|
||||
|
||||
public string Filename
|
||||
{
|
||||
get { return _filenameIsFake ? FilePath : Path.GetFileName(FilePath); }
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public ThemeComponentCollection Components { get; set; }
|
||||
|
||||
public ThemeComponent SelectedThemeComponent
|
||||
{
|
||||
get { return _selectedThemeComponent; }
|
||||
set
|
||||
{
|
||||
_selectedThemeComponent = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SaveAsync()
|
||||
{
|
||||
if (IsMasterTheme) return;
|
||||
|
||||
if (_filenameIsFake)
|
||||
{
|
||||
await SaveAsAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await _themeProvider.SaveThemeAsync(this, FilePath);
|
||||
//RemoveDirtyFlag();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (_logger.IsErrorEnabled)
|
||||
{
|
||||
_logger.Error(e);
|
||||
}
|
||||
|
||||
_messageBoxService.Show("Save Error", "Error saving filter theme - " + e.Message, MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SaveAsAsync()
|
||||
{
|
||||
if (IsMasterTheme) return;
|
||||
|
||||
var saveDialog = new SaveFileDialog
|
||||
{
|
||||
DefaultExt = ".filter",
|
||||
Filter = @"Filter Theme Files (*.filtertheme)|*.filtertheme|All Files (*.*)|*.*"
|
||||
};
|
||||
|
||||
var result = saveDialog.ShowDialog();
|
||||
|
||||
if (result != DialogResult.OK) return;
|
||||
|
||||
var previousFilePath = FilePath;
|
||||
try
|
||||
{
|
||||
FilePath = saveDialog.FileName;
|
||||
await _themeProvider.SaveThemeAsync(this, FilePath);
|
||||
_filenameIsFake = false;
|
||||
Title = Filename;
|
||||
//RemoveDirtyFlag();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (_logger.IsErrorEnabled)
|
||||
{
|
||||
_logger.Error(e);
|
||||
}
|
||||
|
||||
_messageBoxService.Show("Save Error", "Error saving theme file - " + e.Message, MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
FilePath = previousFilePath;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task OnCloseCommand()
|
||||
{
|
||||
await Close();
|
||||
}
|
||||
|
||||
#pragma warning disable 1998
|
||||
public async Task Close()
|
||||
#pragma warning restore 1998
|
||||
{
|
||||
Messenger.Default.Send(new ThemeClosedMessage {ClosedViewModel = this});
|
||||
}
|
||||
|
||||
private void OnAddThemeComponentCommand(ThemeComponentType themeComponentType)
|
||||
{
|
||||
Components.Add(new ThemeComponent(themeComponentType, "Untitled Component",
|
||||
new Color {A = 255, R = 255, G = 255, B = 255}));
|
||||
}
|
||||
|
||||
private void OnDeleteThemeComponentCommand(ThemeComponent themeComponent)
|
||||
{
|
||||
if (themeComponent == null) return;
|
||||
|
||||
themeComponent.TerminateComponent();
|
||||
Components.Remove(themeComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Filtration.Common.Services;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.Interface;
|
||||
using Filtration.ThemeEditor.Providers;
|
||||
using NLog;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
|
||||
namespace Filtration.ThemeEditor.ViewModels
|
||||
{
|
||||
public interface IThemeViewModel : IEditableDocument
|
||||
{
|
||||
void Initialise(ObservableCollection<ThemeComponentViewModel> themeComponentViewModels, bool newTheme);
|
||||
string Title { get; }
|
||||
string FilePath { get; set; }
|
||||
string Filename { get; }
|
||||
string Name { get; set; }
|
||||
ObservableCollection<ThemeComponentViewModel> Components { get; set; }
|
||||
}
|
||||
|
||||
public class ThemeViewModel : PaneViewModel, IThemeViewModel
|
||||
{
|
||||
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private readonly IThemeProvider _themeProvider;
|
||||
private readonly IMessageBoxService _messageBoxService;
|
||||
private bool _filenameIsFake;
|
||||
private string _filePath;
|
||||
|
||||
public ThemeViewModel(IThemeProvider themeProvider,
|
||||
IMessageBoxService messageBoxService)
|
||||
{
|
||||
_themeProvider = themeProvider;
|
||||
_messageBoxService = messageBoxService;
|
||||
|
||||
Components = new ObservableCollection<ThemeComponentViewModel>();
|
||||
|
||||
|
||||
var icon = new BitmapImage();
|
||||
icon.BeginInit();
|
||||
icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/Theme.ico");
|
||||
icon.EndInit();
|
||||
IconSource = icon;
|
||||
}
|
||||
|
||||
public void Initialise(ObservableCollection<ThemeComponentViewModel> themeComponentViewModels, bool newTheme)
|
||||
{
|
||||
Components = themeComponentViewModels;
|
||||
_filenameIsFake = newTheme;
|
||||
}
|
||||
|
||||
public bool IsScript { get { return false; } }
|
||||
public bool IsTheme { get { return true; } }
|
||||
public bool IsDirty { get; private set; }
|
||||
|
||||
public string FilePath
|
||||
{
|
||||
get { return _filePath; }
|
||||
set
|
||||
{
|
||||
_filePath = value;
|
||||
Title = Filename;
|
||||
}
|
||||
}
|
||||
|
||||
public string Filename
|
||||
{
|
||||
get { return Path.GetFileName(FilePath); }
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public ObservableCollection<ThemeComponentViewModel> Components { get; set; }
|
||||
|
||||
public void Save()
|
||||
{
|
||||
if (_filenameIsFake)
|
||||
{
|
||||
SaveAs();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_themeProvider.SaveTheme(this, FilePath);
|
||||
//RemoveDirtyFlag();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (_logger.IsErrorEnabled)
|
||||
{
|
||||
_logger.Error(e);
|
||||
}
|
||||
|
||||
_messageBoxService.Show("Save Error", "Error saving filter theme - " + e.Message, MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveAs()
|
||||
{
|
||||
var saveDialog = new SaveFileDialog
|
||||
{
|
||||
DefaultExt = ".filter",
|
||||
Filter = @"Filter Theme Files (*.filtertheme)|*.filtertheme|All Files (*.*)|*.*"
|
||||
};
|
||||
|
||||
var result = saveDialog.ShowDialog();
|
||||
|
||||
if (result != DialogResult.OK) return;
|
||||
|
||||
var previousFilePath = FilePath;
|
||||
try
|
||||
{
|
||||
FilePath = saveDialog.FileName;
|
||||
_themeProvider.SaveTheme(this, FilePath);
|
||||
_filenameIsFake = false;
|
||||
//RemoveDirtyFlag();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (_logger.IsErrorEnabled)
|
||||
{
|
||||
_logger.Error(e);
|
||||
}
|
||||
|
||||
_messageBoxService.Show("Save Error", "Error saving theme file - " + e.Message, MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
FilePath = previousFilePath;
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,15 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:viewModels="clr-namespace:Filtration.ThemeEditor.ViewModels"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
xmlns:converters="clr-namespace:Filtration.ThemeEditor.Converters"
|
||||
xmlns:commonConverters="clr-namespace:Filtration.Common.Converters;assembly=Filtration.Common"
|
||||
xmlns:themeEditor="clr-namespace:Filtration.ObjectModel.ThemeEditor;assembly=Filtration.ObjectModel"
|
||||
xmlns:views="clr-namespace:Filtration.ThemeEditor.Views"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=viewModels:ThemeComponentViewModel}"
|
||||
d:DesignHeight="40" d:DesignWidth="200">
|
||||
d:DataContext="{d:DesignInstance Type=themeEditor:ThemeComponent}"
|
||||
d:DesignHeight="100" d:DesignWidth="200">
|
||||
<UserControl.Resources>
|
||||
<converters:ThemeComponentTypeToStringConverter x:Key="ThemeComponentTypeToStringConverter" />
|
||||
<commonConverters:BooleanVisibilityConverter x:Key="BooleanVisibilityConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid Width="200">
|
||||
<Grid.RowDefinitions>
|
||||
@@ -18,8 +19,45 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="25" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding ComponentType, Converter={StaticResource ThemeComponentTypeToStringConverter}}" Foreground="Red" FontSize="10" />
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="{Binding ComponentName}" ToolTip="{Binding ComponentName}" />
|
||||
<xctk:ColorPicker Grid.Row="2" Grid.Column="0" SelectedColor="{Binding Color}" />
|
||||
<Grid.Resources>
|
||||
<DataTemplate x:Key="EditableComponentNameTemplate">
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding UsageCount, StringFormat='Usages: {0}'}"
|
||||
FontSize="10"
|
||||
HorizontalAlignment="Right"
|
||||
Visibility="{Binding Path=DataContext.EditEnabled, RelativeSource={RelativeSource AncestorType={x:Type views:ThemeEditorView}}, Converter={StaticResource BooleanVisibilityConverter}}">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding UsageCount}" Value="0">
|
||||
<Setter Property="Foreground" Value="Red" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
<Setter Property="Foreground" Value="SteelBlue" />
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
<TextBox Text="{Binding ComponentName}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="ViewOnlyComponentNameTemplate">
|
||||
<TextBlock Text="{Binding ComponentName}" ToolTip="{Binding ComponentName}" />
|
||||
</DataTemplate>
|
||||
</Grid.Resources>
|
||||
<ContentControl Grid.Row="1" Content="{Binding}">
|
||||
<ContentControl.Style>
|
||||
<Style TargetType="ContentControl">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Path=DataContext.IsMasterTheme, RelativeSource={RelativeSource AncestorType={x:Type views:ThemeEditorView}}}" Value="true">
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource EditableComponentNameTemplate}" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Path=DataContext.IsMasterTheme, RelativeSource={RelativeSource AncestorType={x:Type views:ThemeEditorView}}}" Value="false">
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource ViewOnlyComponentNameTemplate}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ContentControl.Style>
|
||||
</ContentControl>
|
||||
<xctk:ColorPicker Grid.Row="2" SelectedColor="{Binding Color}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
<UserControl x:Class="Filtration.ThemeEditor.Views.ThemeControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:viewModels="clr-namespace:Filtration.ThemeEditor.ViewModels"
|
||||
xmlns:views="clr-namespace:Filtration.ThemeEditor.Views"
|
||||
xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=viewModels:ThemeViewModel}"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<UserControl.Resources>
|
||||
<CollectionViewSource Source="{Binding Components}" x:Key="ComponentsViewSource">
|
||||
<CollectionViewSource.GroupDescriptions>
|
||||
<PropertyGroupDescription PropertyName="ComponentType" />
|
||||
</CollectionViewSource.GroupDescriptions>
|
||||
<CollectionViewSource.SortDescriptions>
|
||||
<componentModel:SortDescription PropertyName="ComponentType" />
|
||||
</CollectionViewSource.SortDescriptions>
|
||||
</CollectionViewSource>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
|
||||
<ItemsControl ItemsSource="{Binding Source={StaticResource ComponentsViewSource}}" Margin="10">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock FontWeight="Bold" FontSize="15" Text="{Binding Path=Name}"/>
|
||||
</DataTemplate>
|
||||
</GroupStyle.HeaderTemplate>
|
||||
</GroupStyle>
|
||||
</ItemsControl.GroupStyle>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<views:ThemeComponentControl DataContext="{Binding}" Margin="10,5,10,5" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Filtration.ThemeEditor.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ThemeControl.xaml
|
||||
/// </summary>
|
||||
public partial class ThemeControl : UserControl
|
||||
{
|
||||
public ThemeControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
78
Filtration.ThemeEditor/Views/ThemeEditorView.xaml
Normal file
78
Filtration.ThemeEditor/Views/ThemeEditorView.xaml
Normal file
@@ -0,0 +1,78 @@
|
||||
<UserControl x:Class="Filtration.ThemeEditor.Views.ThemeEditorView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:viewModels="clr-namespace:Filtration.ThemeEditor.ViewModels"
|
||||
xmlns:views="clr-namespace:Filtration.ThemeEditor.Views"
|
||||
xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
|
||||
xmlns:converters="clr-namespace:Filtration.ThemeEditor.Converters"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=viewModels:ThemeEditorViewModel}"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary>
|
||||
<CollectionViewSource Source="{Binding Components}" x:Key="ComponentsViewSource">
|
||||
<CollectionViewSource.GroupDescriptions>
|
||||
<PropertyGroupDescription PropertyName="ComponentType" />
|
||||
</CollectionViewSource.GroupDescriptions>
|
||||
<CollectionViewSource.SortDescriptions>
|
||||
<componentModel:SortDescription PropertyName="ComponentType" />
|
||||
</CollectionViewSource.SortDescriptions>
|
||||
</CollectionViewSource>
|
||||
<converters:ThemeComponentTypeToStringConverter x:Key="ThemeComponentTypeToStringConverter" />
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary Source="pack://application:,,,/Filtration.Common;component/Styles/SharedResourcesDictionary.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid Margin="10">
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
|
||||
<ListView ItemsSource="{Binding Source={StaticResource ComponentsViewSource}}"
|
||||
SelectedItem="{Binding SelectedThemeComponent}"
|
||||
Margin="5"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
|
||||
<ListView.Resources>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListViewItem">
|
||||
<Border Name="Border" BorderBrush="Black" Background="White" BorderThickness="1" CornerRadius="3" Margin="2" SnapsToDevicePixels="true">
|
||||
<ContentPresenter />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsSelected" Value="true">
|
||||
<Setter TargetName="Border" Property="Background" Value="#A9BDD8"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ListView.Resources>
|
||||
<ListView.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel />
|
||||
</ItemsPanelTemplate>
|
||||
</ListView.ItemsPanel>
|
||||
<ListView.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Margin="7,5,0,0" FontWeight="Bold" FontSize="15" Text="{Binding Path=Name, Converter={StaticResource ThemeComponentTypeToStringConverter}}"/>
|
||||
</DataTemplate>
|
||||
</GroupStyle.HeaderTemplate>
|
||||
</GroupStyle>
|
||||
</ListView.GroupStyle>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<views:ThemeComponentControl DataContext="{Binding}" Margin="10,5,10,5" />
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
10
Filtration.ThemeEditor/Views/ThemeEditorView.xaml.cs
Normal file
10
Filtration.ThemeEditor/Views/ThemeEditorView.xaml.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Filtration.ThemeEditor.Views
|
||||
{
|
||||
public partial class ThemeEditorView
|
||||
{
|
||||
public ThemeEditorView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ namespace Filtration.ThemeEditor.WindsorInstallers
|
||||
public void Install(IWindsorContainer container, IConfigurationStore store)
|
||||
{
|
||||
container.Register(
|
||||
Component.For<IThemeViewModel>()
|
||||
.ImplementedBy<ThemeViewModel>()
|
||||
Component.For<IThemeEditorViewModel>()
|
||||
.ImplementedBy<ThemeEditorViewModel>()
|
||||
.LifeStyle.Transient);
|
||||
|
||||
container.Register(
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
<Application x:Class="Filtration.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:converters="clr-namespace:Filtration.Converters"
|
||||
Startup="Application_Startup">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/Filtration.Common;component/Styles/SharedResourcesDictionary.xaml" />
|
||||
|
||||
<ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Generic.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/Fluent;component/Themes/windows8/silver.xaml" />
|
||||
<ResourceDictionary Source="Views/Styles/Colours.xaml" />
|
||||
@@ -20,9 +23,11 @@
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.RadioButton.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Scrollbars.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.TextBox.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.ListView.xaml" />
|
||||
|
||||
<ResourceDictionary Source="Views/CrossButton.xaml" />
|
||||
<ResourceDictionary Source="Views/IconsDictionary.xaml" />
|
||||
<ResourceDictionary Source="Views/ExpanderStyle.xaml" />
|
||||
|
||||
<ResourceDictionary>
|
||||
<Style TargetType="ComboBox" BasedOn="{StaticResource MetroComboBox}" />
|
||||
@@ -30,6 +35,14 @@
|
||||
<Style TargetType="ScrollBar" BasedOn="{StaticResource MetroScrollBar}" />
|
||||
<Style TargetType="TextBox" BasedOn="{StaticResource MetroTextBox}" />
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary>
|
||||
<converters:BlockItemToRemoveEnabledVisibilityConverter x:Key="BlockItemToRemoveEnabledVisibilityConverter" />
|
||||
<converters:IntToItemRarityConverter x:Key="IntToItemRarityConverter" />
|
||||
<converters:BooleanToBlockActionConverter x:Key="BooleanToBlockActionConverter" />
|
||||
<converters:BlockItemTypeToStringConverter x:Key="BlockItemTypeToStringConverter" />
|
||||
<converters:BooleanToBlockActionInverseConverter x:Key="BooleanToBlockActionInverseConverter" />
|
||||
<converters:AvailableThemeComponentsConverter x:Key="AvailableThemeComponentsConverter" />
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
@@ -58,9 +57,9 @@ namespace Filtration
|
||||
.ForMember(dest => dest.IsExpanded,
|
||||
opts => opts.UseValue(false));
|
||||
|
||||
Mapper.CreateMap<Theme, IThemeViewModel>().ConstructUsingServiceLocator();
|
||||
Mapper.CreateMap<Theme, IThemeEditorViewModel>().ConstructUsingServiceLocator();
|
||||
Mapper.CreateMap<ThemeComponent, ThemeComponentViewModel>().ReverseMap();
|
||||
Mapper.CreateMap<IThemeViewModel, Theme>();
|
||||
Mapper.CreateMap<IThemeEditorViewModel, Theme>();
|
||||
|
||||
Mapper.AssertConfigurationIsValid();
|
||||
|
||||
|
||||
49
Filtration/Converters/AvailableThemeComponentsConverter.cs
Normal file
49
Filtration/Converters/AvailableThemeComponentsConverter.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows.Data;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
|
||||
namespace Filtration.Converters
|
||||
{
|
||||
public class AvailableThemeComponentsConverter :IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var themeComponentsList = values[0] as ThemeComponentCollection;
|
||||
if (themeComponentsList == null || themeComponentsList.Count == 0) return null;
|
||||
|
||||
var blockItem = values[1] as ColorBlockItem;
|
||||
if (blockItem == null) return null;
|
||||
|
||||
ThemeComponentType themeComponentType;
|
||||
|
||||
if (blockItem.GetType() == typeof(BackgroundColorBlockItem))
|
||||
{
|
||||
themeComponentType = ThemeComponentType.BackgroundColor;
|
||||
}
|
||||
else if (blockItem.GetType() == typeof(TextColorBlockItem))
|
||||
{
|
||||
themeComponentType = ThemeComponentType.TextColor;
|
||||
}
|
||||
else if (blockItem.GetType() == typeof(BorderColorBlockItem))
|
||||
{
|
||||
themeComponentType = ThemeComponentType.BorderColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return themeComponentsList.Where(t => t.ComponentType == themeComponentType).ToList();
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,6 +94,10 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="WpfAnimatedGif, Version=1.4.13.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\WpfAnimatedGif.1.4.13\lib\net\WpfAnimatedGif.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\WPFToolkit.3.5.50211.1\lib\WPFToolkit.dll</HintPath>
|
||||
@@ -129,27 +133,23 @@
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Converters\ActiveDocumentConverter.cs" />
|
||||
<Compile Include="Converters\AvailableThemeComponentsConverter.cs" />
|
||||
<Compile Include="Converters\BlockGroupAdvancedFillConverter.cs" />
|
||||
<Compile Include="Converters\BlockGroupAdvancedColorConverter.cs" />
|
||||
<Compile Include="Converters\BlockGroupVisibilityConverter.cs" />
|
||||
<Compile Include="Converters\BlockItemTypeToStringConverter.cs" />
|
||||
<Compile Include="Converters\BooleanInverterConverter.cs" />
|
||||
<Compile Include="Converters\BooleanToBlockActionInverseConverter.cs" />
|
||||
<Compile Include="Converters\BooleanToBlockActionConverter.cs" />
|
||||
<Compile Include="Converters\BooleanVisibilityConverter.cs" />
|
||||
<Compile Include="Converters\BooleanVisibilityConverterCopy.cs" />
|
||||
<Compile Include="Converters\BlockItemToRemoveEnabledVisibilityConverter.cs" />
|
||||
<Compile Include="Converters\ColorToSolidColorBrushConverter.cs" />
|
||||
<Compile Include="Converters\HashSignRemovalConverter.cs" />
|
||||
<Compile Include="Converters\ItemRarityConverter.cs" />
|
||||
<Compile Include="Converters\InverseBooleanVisibilityConverter.cs" />
|
||||
<Compile Include="Converters\StringToVisibilityConverter.cs" />
|
||||
<Compile Include="Converters\TreeViewMarginConverter.cs" />
|
||||
<Compile Include="Extensions\EnumerationExtension.cs" />
|
||||
<Compile Include="Extensions\HyperlinkExtensions.cs" />
|
||||
<Compile Include="Models\UpdateData.cs" />
|
||||
<Compile Include="Properties\Annotations.cs" />
|
||||
<Compile Include="Repositories\ItemFilterScriptRepository.cs" />
|
||||
<Compile Include="Services\ClipboardService.cs" />
|
||||
<Compile Include="Services\HTTPService.cs" />
|
||||
<Compile Include="Services\ItemFilterPersistenceService.cs" />
|
||||
<Compile Include="Services\StaticDataService.cs" />
|
||||
@@ -158,7 +158,6 @@
|
||||
<Compile Include="Translators\BlockGroupHierarchyBuilder.cs" />
|
||||
<Compile Include="Translators\ItemFilterBlockTranslator.cs" />
|
||||
<Compile Include="Translators\ItemFilterScriptTranslator.cs" />
|
||||
<Compile Include="Translators\ThemeComponentListBuilder.cs" />
|
||||
<Compile Include="UserControls\AutoScrollingListBox.cs" />
|
||||
<Compile Include="UserControls\BlockItemControl.xaml.cs">
|
||||
<DependentUpon>BlockItemControl.xaml</DependentUpon>
|
||||
@@ -170,6 +169,9 @@
|
||||
<Compile Include="UserControls\ItemPreviewControl.xaml.cs">
|
||||
<DependentUpon>ItemPreviewControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UserControls\ThemeComponentSelectionControl.xaml.cs">
|
||||
<DependentUpon>ThemeComponentSelectionControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Utilities\AutoMapperHelpers.cs" />
|
||||
<Compile Include="Utilities\BlockGroupMapper.cs" />
|
||||
<Compile Include="Utilities\LineReader.cs" />
|
||||
@@ -201,6 +203,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UserControls\ThemeComponentSelectionControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\Styles\ListBoxItem.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -242,7 +248,6 @@
|
||||
<Compile Include="Views\UpdateAvailableView.xaml.cs">
|
||||
<DependentUpon>UpdateAvailableView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WindsorInstallers\ModelsInstaller.cs" />
|
||||
<Compile Include="WindsorInstallers\RepositoriesInstaller.cs" />
|
||||
<Compile Include="WindsorInstallers\ServicesInstaller.cs" />
|
||||
<Compile Include="WindsorInstallers\TranslatorsInstaller.cs" />
|
||||
@@ -304,10 +309,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\SharedResourcesDictionary.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\ItemFilterScriptView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -368,10 +369,14 @@
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Resource Include="Resources\loading_spinner.gif" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<Content Include="LICENSE.txt">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="NLog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
@@ -427,6 +432,10 @@
|
||||
<Resource Include="Resources\Icons\ReplaceColors.ico" />
|
||||
<Resource Include="Resources\Icons\Theme.ico" />
|
||||
<Resource Include="Resources\Icons\filtration_icon.png" />
|
||||
<Resource Include="Resources\Icons\Add.ico" />
|
||||
<Resource Include="Resources\Icons\ThemeComponentDelete.ico" />
|
||||
<Resource Include="Resources\Icons\standby_disabled_icon.png" />
|
||||
<Resource Include="Resources\Icons\standby_enabled_icon.png" />
|
||||
<Content Include="Resources\ItemBaseTypes.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
||||
339
Filtration/LICENSE.txt
Normal file
339
Filtration/LICENSE.txt
Normal file
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{description}
|
||||
Copyright (C) {year} {fullname}
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
{signature of Ty Coon}, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -7,7 +7,7 @@ using System.Windows;
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Filtration")]
|
||||
[assembly: AssemblyDescription("An item filter script manager for Path of Exile")]
|
||||
[assembly: AssemblyDescription("An item filter script editor for Path of Exile")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("XVar Industries Inc.")]
|
||||
[assembly: AssemblyProduct("Filtration")]
|
||||
@@ -50,7 +50,7 @@ using System.Windows;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.6.*")]
|
||||
[assembly: AssemblyVersion("0.10.*")]
|
||||
|
||||
[assembly: InternalsVisibleTo("Filtration.Tests")]
|
||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.Services;
|
||||
using Filtration.ViewModels;
|
||||
@@ -8,7 +7,7 @@ namespace Filtration.Repositories
|
||||
{
|
||||
internal interface IItemFilterScriptRepository
|
||||
{
|
||||
IItemFilterScriptViewModel LoadScriptFromFile(string path);
|
||||
Task<IItemFilterScriptViewModel> LoadScriptFromFileAsync(string path);
|
||||
IItemFilterScriptViewModel NewScript();
|
||||
string GetItemFilterScriptDirectory();
|
||||
void SetItemFilterScriptDirectory(string path);
|
||||
@@ -26,9 +25,9 @@ namespace Filtration.Repositories
|
||||
_itemFilterScriptViewModelFactory = itemFilterScriptViewModelFactory;
|
||||
}
|
||||
|
||||
public IItemFilterScriptViewModel LoadScriptFromFile(string path)
|
||||
public async Task<IItemFilterScriptViewModel> LoadScriptFromFileAsync(string path)
|
||||
{
|
||||
var loadedScript = _itemFilterPersistenceService.LoadItemFilterScript(path);
|
||||
var loadedScript = await _itemFilterPersistenceService.LoadItemFilterScriptAsync(path);
|
||||
|
||||
var newViewModel = _itemFilterScriptViewModelFactory.Create();
|
||||
newViewModel.Initialise(loadedScript, false);
|
||||
|
||||
BIN
Filtration/Resources/Icons/Add.ico
Normal file
BIN
Filtration/Resources/Icons/Add.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
BIN
Filtration/Resources/Icons/ThemeComponentDelete.ico
Normal file
BIN
Filtration/Resources/Icons/ThemeComponentDelete.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
BIN
Filtration/Resources/Icons/standby_disabled_icon.png
Normal file
BIN
Filtration/Resources/Icons/standby_disabled_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
BIN
Filtration/Resources/Icons/standby_enabled_icon.png
Normal file
BIN
Filtration/Resources/Icons/standby_enabled_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
@@ -1069,3 +1069,54 @@ Sage Wand
|
||||
Serpent Wand
|
||||
Spiraled Wand
|
||||
Tornado Wand
|
||||
Abandoned Wealth
|
||||
The Avenger
|
||||
The Battle Born
|
||||
Birth of the Three
|
||||
The Brittle Emperor
|
||||
The Carrion Crow
|
||||
The Cataclysm
|
||||
The Celestial Justicar
|
||||
The Chains that Bind
|
||||
Chaotic Disposition
|
||||
Coveted Possession
|
||||
The Dark Mage
|
||||
The Doctor
|
||||
The Drunken Aristocrat
|
||||
Emperor's Luck
|
||||
The Explorer
|
||||
The Feast
|
||||
The Fiend
|
||||
The Gambler
|
||||
The Gemcutter
|
||||
Gemcutter's Promise
|
||||
The Gladiator
|
||||
The Hermit
|
||||
The Hoarder
|
||||
Hope
|
||||
The Hunger
|
||||
Humility
|
||||
The Incantation
|
||||
The Inventor
|
||||
Jack in the Box
|
||||
The King's Heart
|
||||
Lantador's Lost Love
|
||||
The Lover
|
||||
Lucky Connections
|
||||
The Metalsmith's Gift
|
||||
The Pact
|
||||
The Poet
|
||||
The Queen
|
||||
Rain of Chaos
|
||||
The Road to Power
|
||||
The Scarred Meadow
|
||||
The Scholar
|
||||
The Summoner
|
||||
The Sun
|
||||
Three Faces in the Dark
|
||||
Time-Lost Relic
|
||||
The Union
|
||||
Vinia's Token
|
||||
The Warden
|
||||
The Watcher
|
||||
The Wind
|
||||
@@ -34,3 +34,5 @@ Fishing Rods
|
||||
Map Fragments
|
||||
Hideout Doodads
|
||||
Microtransactions
|
||||
Divination Card
|
||||
Jewel
|
||||
BIN
Filtration/Resources/loading_spinner.gif
Normal file
BIN
Filtration/Resources/loading_spinner.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
43
Filtration/Services/ClipboardService.cs
Normal file
43
Filtration/Services/ClipboardService.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using NLog;
|
||||
|
||||
namespace Filtration.Services
|
||||
{
|
||||
internal interface IClipboardService
|
||||
{
|
||||
void SetClipboardText(string inputText);
|
||||
string GetClipboardText();
|
||||
}
|
||||
|
||||
internal class ClipboardService : IClipboardService
|
||||
{
|
||||
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public void SetClipboardText(string inputText)
|
||||
{
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(inputText);
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.Error(e);
|
||||
}
|
||||
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
throw new Exception("Failed to copy to clipboard");
|
||||
}
|
||||
|
||||
public string GetClipboardText()
|
||||
{
|
||||
return Clipboard.GetText();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Filtration.Common.Services;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.Properties;
|
||||
@@ -10,8 +11,8 @@ namespace Filtration.Services
|
||||
{
|
||||
void SetItemFilterScriptDirectory(string path);
|
||||
string ItemFilterScriptDirectory { get; }
|
||||
ItemFilterScript LoadItemFilterScript(string filePath);
|
||||
void SaveItemFilterScript(ItemFilterScript script);
|
||||
Task<ItemFilterScript> LoadItemFilterScriptAsync(string filePath);
|
||||
Task SaveItemFilterScriptAsync(ItemFilterScript script);
|
||||
string DefaultPathOfExileDirectory();
|
||||
}
|
||||
|
||||
@@ -58,20 +59,30 @@ namespace Filtration.Services
|
||||
Settings.Default.DefaultFilterDirectory = path;
|
||||
}
|
||||
|
||||
public ItemFilterScript LoadItemFilterScript(string filePath)
|
||||
public async Task<ItemFilterScript> LoadItemFilterScriptAsync(string filePath)
|
||||
{
|
||||
var script =
|
||||
_itemFilterScriptTranslator.TranslateStringToItemFilterScript(
|
||||
ItemFilterScript loadedScript = null;
|
||||
await Task.Run(() =>
|
||||
{
|
||||
loadedScript = _itemFilterScriptTranslator.TranslateStringToItemFilterScript(
|
||||
_fileSystemService.ReadFileAsString(filePath));
|
||||
});
|
||||
|
||||
script.FilePath = filePath;
|
||||
return script;
|
||||
if (loadedScript != null)
|
||||
{
|
||||
loadedScript.FilePath = filePath;
|
||||
}
|
||||
|
||||
public void SaveItemFilterScript(ItemFilterScript script)
|
||||
return loadedScript;
|
||||
}
|
||||
|
||||
public async Task SaveItemFilterScriptAsync(ItemFilterScript script)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
_fileSystemService.WriteFileFromString(script.FilePath,
|
||||
_itemFilterScriptTranslator.TranslateItemFilterScriptToString(script));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using Filtration.Common.Services;
|
||||
using Filtration.Utilities;
|
||||
|
||||
@@ -28,10 +30,10 @@ namespace Filtration.Services
|
||||
|
||||
private void PopulateStaticData()
|
||||
{
|
||||
var itemBaseTypes = _fileSystemService.ReadFileAsString("Resources\\ItemBaseTypes.txt");
|
||||
var itemBaseTypes = _fileSystemService.ReadFileAsString(AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\ItemBaseTypes.txt");
|
||||
ItemBaseTypes = new LineReader(() => new StringReader(itemBaseTypes)).ToList();
|
||||
|
||||
var itemClasses = _fileSystemService.ReadFileAsString("Resources\\ItemClasses.txt");
|
||||
var itemClasses = _fileSystemService.ReadFileAsString(AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\ItemClasses.txt");
|
||||
ItemClasses = new LineReader(() => new StringReader(itemClasses)).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,21 +7,20 @@ namespace Filtration.Services
|
||||
{
|
||||
internal interface IUpdateCheckService
|
||||
{
|
||||
Task<UpdateData> GetUpdateData();
|
||||
Task<UpdateData> GetUpdateDataAsync();
|
||||
}
|
||||
|
||||
internal class UpdateCheckService : IUpdateCheckService
|
||||
{
|
||||
private readonly IHTTPService _httpService;
|
||||
//private const string UpdateDataUrl = "http://ben-wallis.github.io/Filtration/filtration_version.xml";
|
||||
private const string UpdateDataUrl = "http://xvar.net/filtration_version.xml";
|
||||
private const string UpdateDataUrl = "http://ben-wallis.github.io/Filtration/filtration_version.xml";
|
||||
|
||||
public UpdateCheckService(IHTTPService httpService)
|
||||
{
|
||||
_httpService = httpService;
|
||||
}
|
||||
|
||||
public async Task<UpdateData> GetUpdateData()
|
||||
public async Task<UpdateData> GetUpdateDataAsync()
|
||||
{
|
||||
var updateXml = await _httpService.GetContentAsync(UpdateDataUrl);
|
||||
return (DeserializeUpdateData(updateXml));
|
||||
|
||||
@@ -10,14 +10,15 @@ using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.Extensions;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
using Filtration.Utilities;
|
||||
|
||||
namespace Filtration.Translators
|
||||
{
|
||||
internal interface IItemFilterBlockTranslator
|
||||
{
|
||||
void InitialiseForExistingScript(ItemFilterScript script);
|
||||
ItemFilterBlock TranslateStringToItemFilterBlock(string inputString);
|
||||
ItemFilterBlock TranslateStringToItemFilterBlock(string inputString,
|
||||
ThemeComponentCollection masterComponentCollection);
|
||||
string TranslateItemFilterBlockToString(ItemFilterBlock block);
|
||||
void ReplaceColorBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString);
|
||||
}
|
||||
@@ -25,28 +26,24 @@ namespace Filtration.Translators
|
||||
internal class ItemFilterBlockTranslator : IItemFilterBlockTranslator
|
||||
{
|
||||
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
|
||||
private readonly IThemeComponentListBuilder _themeComponentListBuilder;
|
||||
private const string Indent = " ";
|
||||
private readonly string _newLine = Environment.NewLine + Indent;
|
||||
private readonly string _disabledNewLine = Environment.NewLine + "#" + Indent;
|
||||
private ThemeComponentCollection _masterComponentCollection;
|
||||
|
||||
public ItemFilterBlockTranslator(IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder, IThemeComponentListBuilder themeComponentListBuilder)
|
||||
public ItemFilterBlockTranslator(IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
|
||||
{
|
||||
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
|
||||
_themeComponentListBuilder = themeComponentListBuilder;
|
||||
}
|
||||
|
||||
public void InitialiseForExistingScript(ItemFilterScript script)
|
||||
{
|
||||
_themeComponentListBuilder.Initialise(script.ThemeComponents);
|
||||
_blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First());
|
||||
}
|
||||
|
||||
// This method converts a string into a ItemFilterBlock. This is used for pasting ItemFilterBlocks
|
||||
// and reading ItemFilterScripts from a file.
|
||||
public ItemFilterBlock TranslateStringToItemFilterBlock(string inputString)
|
||||
public ItemFilterBlock TranslateStringToItemFilterBlock(string inputString, ThemeComponentCollection masterComponentCollection)
|
||||
{
|
||||
_masterComponentCollection = masterComponentCollection;
|
||||
var block = new ItemFilterBlock();
|
||||
var showHideFound = false;
|
||||
|
||||
foreach (var line in new LineReader(() => new StringReader(inputString)))
|
||||
{
|
||||
|
||||
@@ -67,6 +64,7 @@ namespace Filtration.Translators
|
||||
|
||||
var adjustedLine = line.Replace("#", " # ");
|
||||
var trimmedLine = adjustedLine.TrimStart(' ');
|
||||
|
||||
var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length;
|
||||
|
||||
var lineOption = trimmedLine.Substring(0, spaceOrEndOfLinePos);
|
||||
@@ -75,11 +73,25 @@ namespace Filtration.Translators
|
||||
case "Show":
|
||||
showHideFound = true;
|
||||
block.Action = BlockAction.Show;
|
||||
block.Enabled = true;
|
||||
AddBlockGroupToBlock(block, trimmedLine);
|
||||
break;
|
||||
case "Hide":
|
||||
showHideFound = true;
|
||||
block.Action = BlockAction.Hide;
|
||||
block.Enabled = true;
|
||||
AddBlockGroupToBlock(block, trimmedLine);
|
||||
break;
|
||||
case "ShowDisabled":
|
||||
showHideFound = true;
|
||||
block.Action = BlockAction.Show;
|
||||
block.Enabled = false;
|
||||
AddBlockGroupToBlock(block, trimmedLine);
|
||||
break;
|
||||
case "HideDisabled":
|
||||
showHideFound = true;
|
||||
block.Action = BlockAction.Hide;
|
||||
block.Enabled = false;
|
||||
AddBlockGroupToBlock(block, trimmedLine);
|
||||
break;
|
||||
case "ItemLevel":
|
||||
@@ -300,9 +312,9 @@ namespace Filtration.Translators
|
||||
{
|
||||
throw new Exception("Parsing error - unknown theme component type");
|
||||
}
|
||||
if (_themeComponentListBuilder.IsInitialised)
|
||||
if (_masterComponentCollection != null)
|
||||
{
|
||||
blockItem.ThemeComponent = _themeComponentListBuilder.AddComponent(componentType, componentName,
|
||||
blockItem.ThemeComponent = _masterComponentCollection.AddComponent(componentType, componentName,
|
||||
blockItem.Color);
|
||||
}
|
||||
}
|
||||
@@ -404,12 +416,17 @@ namespace Filtration.Translators
|
||||
|
||||
var outputString = string.Empty;
|
||||
|
||||
if (!block.Enabled)
|
||||
{
|
||||
outputString += "#Disabled Block Start" + Environment.NewLine;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(block.Description))
|
||||
{
|
||||
outputString += "# " + block.Description + Environment.NewLine;
|
||||
}
|
||||
|
||||
outputString += block.Action.GetAttributeDescription();
|
||||
outputString += (!block.Enabled ? "#" : string.Empty) + block.Action.GetAttributeDescription();
|
||||
|
||||
if (block.BlockGroup != null)
|
||||
{
|
||||
@@ -421,10 +438,15 @@ namespace Filtration.Translators
|
||||
{
|
||||
if (blockItem.OutputText != string.Empty)
|
||||
{
|
||||
outputString += _newLine + blockItem.OutputText;
|
||||
outputString += (!block.Enabled ? _disabledNewLine : _newLine) + blockItem.OutputText;
|
||||
}
|
||||
}
|
||||
|
||||
if (!block.Enabled)
|
||||
{
|
||||
outputString += Environment.NewLine + "#Disabled Block End";
|
||||
}
|
||||
|
||||
return outputString;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,15 +20,72 @@ namespace Filtration.Translators
|
||||
{
|
||||
private readonly IItemFilterBlockTranslator _blockTranslator;
|
||||
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
|
||||
private readonly IThemeComponentListBuilder _themeComponentListBuilder;
|
||||
|
||||
public ItemFilterScriptTranslator(IItemFilterBlockTranslator blockTranslator,
|
||||
IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder,
|
||||
IThemeComponentListBuilder themeComponentListBuilder)
|
||||
IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
|
||||
{
|
||||
_blockTranslator = blockTranslator;
|
||||
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
|
||||
_themeComponentListBuilder = themeComponentListBuilder;
|
||||
}
|
||||
|
||||
public string PreprocessDisabledBlocks(string inputString)
|
||||
{
|
||||
bool inDisabledBlock = false;
|
||||
var showHideFound = false;
|
||||
|
||||
var lines = Regex.Split(inputString, "\r\n|\r|\n").ToList();
|
||||
var linesToRemove = new List<int>();
|
||||
|
||||
for (var i = 0; i < lines.Count; i++)
|
||||
{
|
||||
if (lines[i].StartsWith("#Disabled Block Start"))
|
||||
{
|
||||
inDisabledBlock = true;
|
||||
linesToRemove.Add(i);
|
||||
continue;
|
||||
}
|
||||
if (inDisabledBlock)
|
||||
{
|
||||
if (lines[i].StartsWith("#Disabled Block End"))
|
||||
{
|
||||
inDisabledBlock = false;
|
||||
showHideFound = false;
|
||||
linesToRemove.Add(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
lines[i] = lines[i].TrimStart('#');
|
||||
lines[i] = lines[i].Replace("#", " # ");
|
||||
var spaceOrEndOfLinePos = lines[i].IndexOf(" ", StringComparison.Ordinal) > 0 ? lines[i].IndexOf(" ", StringComparison.Ordinal) : lines[i].Length;
|
||||
var lineOption = lines[i].Substring(0, spaceOrEndOfLinePos);
|
||||
|
||||
// If we haven't found a Show or Hide line yet, then this is probably the block comment.
|
||||
// Put its # back on and skip to the next line.
|
||||
if (lineOption != "Show" && lineOption != "Hide" && showHideFound == false)
|
||||
{
|
||||
lines[i] = "#" + lines[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lineOption == "Show")
|
||||
{
|
||||
lines[i] = lines[i].Replace("Show", "ShowDisabled");
|
||||
showHideFound = true;
|
||||
}
|
||||
else if (lineOption == "Hide")
|
||||
{
|
||||
lines[i] = lines[i].Replace("Hide", "HideDisabled");
|
||||
showHideFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = linesToRemove.Count - 1; i >= 0; i--)
|
||||
{
|
||||
lines.RemoveAt(linesToRemove[i]);
|
||||
}
|
||||
|
||||
return lines.Aggregate((c, n) => c + Environment.NewLine + n);
|
||||
}
|
||||
|
||||
public ItemFilterScript TranslateStringToItemFilterScript(string inputString)
|
||||
@@ -37,6 +94,11 @@ namespace Filtration.Translators
|
||||
_blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First());
|
||||
|
||||
inputString = inputString.Replace("\t", "");
|
||||
if (inputString.Contains("#Disabled Block Start"))
|
||||
{
|
||||
inputString = PreprocessDisabledBlocks(inputString);
|
||||
}
|
||||
|
||||
var conditionBoundaries = IdentifyBlockBoundaries(inputString);
|
||||
|
||||
var lines = Regex.Split(inputString, "\r\n|\r|\n");
|
||||
@@ -55,8 +117,6 @@ namespace Filtration.Translators
|
||||
script.Description = script.Description.TrimEnd('\n').TrimEnd('\r');
|
||||
}
|
||||
|
||||
_themeComponentListBuilder.Initialise();
|
||||
|
||||
// Extract each block from between boundaries and translate it into a ItemFilterBlock object
|
||||
// and add that object to the ItemFilterBlocks list
|
||||
for (var boundary = conditionBoundaries.First; boundary != null; boundary = boundary.Next)
|
||||
@@ -66,12 +126,10 @@ namespace Filtration.Translators
|
||||
var block = new string[end - begin];
|
||||
Array.Copy(lines, begin, block, 0, end - begin);
|
||||
var blockString = string.Join("\r\n", block);
|
||||
script.ItemFilterBlocks.Add(_blockTranslator.TranslateStringToItemFilterBlock(blockString));
|
||||
script.ItemFilterBlocks.Add(_blockTranslator.TranslateStringToItemFilterBlock(blockString, script.ThemeComponents));
|
||||
}
|
||||
|
||||
script.ThemeComponents = _themeComponentListBuilder.GetComponents();
|
||||
_blockGroupHierarchyBuilder.Cleanup();
|
||||
_themeComponentListBuilder.Cleanup();
|
||||
return script;
|
||||
}
|
||||
|
||||
@@ -92,7 +150,10 @@ namespace Filtration.Translators
|
||||
// as it represents the block description.
|
||||
// currentLine > 2 caters for an edge case where the script description is a single line and the first
|
||||
// block has no description. This prevents the script description from being assigned to the first block's description.
|
||||
blockBoundaries.AddLast(previousLine.StartsWith("#") && !previousLine.StartsWith("# Section:") && currentLine > 2 ? currentLine - 2 : currentLine - 1);
|
||||
blockBoundaries.AddLast(previousLine.StartsWith("#") && !previousLine.StartsWith("# Section:") &&
|
||||
currentLine > 2
|
||||
? currentLine - 2
|
||||
: currentLine - 1);
|
||||
}
|
||||
previousLine = line;
|
||||
}
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
|
||||
namespace Filtration.Translators
|
||||
{
|
||||
internal interface IThemeComponentListBuilder
|
||||
{
|
||||
void Initialise();
|
||||
void Initialise(List<ThemeComponent> themeComponents);
|
||||
bool IsInitialised { get; }
|
||||
ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, Color componentColor);
|
||||
List<ThemeComponent> GetComponents();
|
||||
void Cleanup();
|
||||
}
|
||||
|
||||
internal class ThemeComponentListBuilder : IThemeComponentListBuilder
|
||||
{
|
||||
private List<ThemeComponent> _themeComponents;
|
||||
|
||||
public ThemeComponentListBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsInitialised
|
||||
{
|
||||
get
|
||||
{
|
||||
return _themeComponents != null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialise()
|
||||
{
|
||||
_themeComponents = new List<ThemeComponent>();
|
||||
}
|
||||
|
||||
public void Initialise(List<ThemeComponent> themeComponents)
|
||||
{
|
||||
_themeComponents = themeComponents;
|
||||
}
|
||||
|
||||
public void Cleanup()
|
||||
{
|
||||
_themeComponents = null;
|
||||
}
|
||||
|
||||
public ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, Color componentColor)
|
||||
{
|
||||
if (ComponentExists(componentType, componentName))
|
||||
{
|
||||
return _themeComponents.FirstOrDefault(t => t.ComponentName == componentName && t.ComponentType == componentType);
|
||||
}
|
||||
|
||||
var component = new ThemeComponent(componentType, componentName, componentColor);
|
||||
_themeComponents.Add(component);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
public List<ThemeComponent> GetComponents()
|
||||
{
|
||||
return _themeComponents;
|
||||
}
|
||||
|
||||
private bool ComponentExists(ThemeComponentType componentType, string componentName)
|
||||
{
|
||||
return _themeComponents.Exists(c => c.ComponentName == componentName && c.ComponentType == componentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,21 +13,6 @@
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=userControls:BlockItemControl}"
|
||||
d:DesignHeight="200" d:DesignWidth="150">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary>
|
||||
<Style TargetType="{x:Type Border}" x:Key="BlockItemBorder">
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="BorderBrush" Value="Black" />
|
||||
<Setter Property="CornerRadius" Value="3" />
|
||||
<Setter Property="Margin" Value="0,0,5,5" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary Source="../Views/SharedResourcesDictionary.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Border Style="{StaticResource BlockItemBorder}" Width="142">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
@@ -86,7 +71,19 @@
|
||||
|
||||
<!-- Color Template -->
|
||||
<DataTemplate DataType="{x:Type blockItemBaseTypes:ColorBlockItem}">
|
||||
<StackPanel>
|
||||
<xctk:ColorPicker SelectedColor="{Binding Color}" AvailableColors="{Binding ElementName=BlockItemContentControl, Path=DataContext.AvailableColors }" ShowAvailableColors="True" AvailableColorsHeader="Path of Exile Colors"/>
|
||||
<userControls:ThemeComponentSelectionControl ThemeComponent="{Binding ThemeComponent}"
|
||||
|
||||
Margin="0,2,0,2">
|
||||
<userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
|
||||
<MultiBinding Converter="{StaticResource AvailableThemeComponentsConverter}">
|
||||
<Binding Path="DataContext.Script.ThemeComponents" RelativeSource="{RelativeSource AncestorType={x:Type views:ItemFilterScriptView}}"/>
|
||||
<Binding Path="." />
|
||||
</MultiBinding>
|
||||
</userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
|
||||
</userControls:ThemeComponentSelectionControl>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- Font Size Template -->
|
||||
|
||||
@@ -19,8 +19,12 @@ namespace Filtration.UserControls
|
||||
InitializeComponent();
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
(Content as FrameworkElement).DataContext = this;
|
||||
|
||||
SetBlockColorCommand = new RelayCommand(OnSetBlockColorCommmand);
|
||||
}
|
||||
|
||||
public RelayCommand SetBlockColorCommand { get; private set; }
|
||||
|
||||
public static readonly DependencyProperty BlockItemProperty = DependencyProperty.Register(
|
||||
"BlockItem",
|
||||
typeof(IItemFilterBlockItem),
|
||||
@@ -94,6 +98,14 @@ namespace Filtration.UserControls
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSetBlockColorCommmand()
|
||||
{
|
||||
var blockItem = BlockItem as ColorBlockItem;
|
||||
if (blockItem == null || blockItem.ThemeComponent == null) return;
|
||||
|
||||
blockItem.Color = blockItem.ThemeComponent.Color;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=userControls:ItemPreviewControl}"
|
||||
d:DesignHeight="35" d:DesignWidth="170">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary Source="../Views/SharedResourcesDictionary.xaml" />
|
||||
</UserControl.Resources>
|
||||
<Border BorderBrush="Black" BorderThickness="1">
|
||||
<Grid Width="166" Height="39">
|
||||
<Image Source="pack://application:,,,/resources/groundtile.png" Stretch="Fill" />
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Filtration.UserControls
|
||||
|
||||
79
Filtration/UserControls/ThemeComponentSelectionControl.xaml
Normal file
79
Filtration/UserControls/ThemeComponentSelectionControl.xaml
Normal file
@@ -0,0 +1,79 @@
|
||||
<UserControl x:Class="Filtration.UserControls.ThemeComponentSelectionControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:userControls="clr-namespace:Filtration.UserControls"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=userControls:ThemeComponentSelectionControl}"
|
||||
d:DesignHeight="50" d:DesignWidth="300">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/Filtration.Common;component/Styles/SharedResourcesDictionary.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid Height="20">
|
||||
<Grid.Resources>
|
||||
<Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource MetroComboBox}">
|
||||
<Setter Property="MinHeight" Value="0" />
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ComboBox Grid.Column="0"
|
||||
ItemsSource="{Binding AvailableThemeComponents}"
|
||||
SelectedValue="{Binding ThemeComponent}"
|
||||
Grid.IsSharedSizeScope="True"
|
||||
Visibility="{Binding ShowThemeComponentComboBox, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="SelectionChanged">
|
||||
<i:InvokeCommandAction Command="{Binding SetBlockColorCommand, RelativeSource={RelativeSource AncestorType=userControls:BlockItemControl}}" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate >
|
||||
<ContentControl Content="{Binding}">
|
||||
<ContentControl.Style>
|
||||
<Style TargetType="{x:Type ContentControl}">
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition SharedSizeGroup="ComponentNameColumn" Width="Auto" />
|
||||
<ColumnDefinition SharedSizeGroup="ComponentColorColumn" Width="20" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="{Binding ComponentName}" Margin="0,0,2,0" />
|
||||
<Border Grid.Column="1" Background="{Binding Color, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ComboBoxItem}}" Value="{x:Null}">
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding ComponentName}" />
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ContentControl.Style>
|
||||
</ContentControl>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<userControls:CrossButton Grid.Column="1" Height="12" Command="{Binding RemoveThemeComponentCommand}" VerticalAlignment="Top" Visibility="{Binding ShowThemeComponentComboBox, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
<TextBlock Grid.Column="0" Grid.ColumnSpan="2" Visibility="{Binding ShowThemeComponentComboBox, Converter={StaticResource InverseBooleanVisibilityConverter}}" VerticalAlignment="Center">
|
||||
<Hyperlink Command="{Binding AddThemeComponentCommand}">Add Theme Tag</Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,99 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
using Filtration.Annotations;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
|
||||
namespace Filtration.UserControls
|
||||
{
|
||||
public partial class ThemeComponentSelectionControl : INotifyPropertyChanged
|
||||
{
|
||||
public ThemeComponentSelectionControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
(Content as FrameworkElement).DataContext = this;
|
||||
AddThemeComponentCommand = new RelayCommand(OnAddThemeComponentCommand);
|
||||
RemoveThemeComponentCommand = new RelayCommand(OnRemoveThemeComponentCommand);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ThemeComponentProperty = DependencyProperty.Register(
|
||||
"ThemeComponent",
|
||||
typeof(ThemeComponent),
|
||||
typeof(ThemeComponentSelectionControl),
|
||||
new FrameworkPropertyMetadata() { BindsTwoWayByDefault = true });
|
||||
|
||||
public static readonly DependencyProperty AvailableThemeComponentsProperty = DependencyProperty.Register(
|
||||
"AvailableThemeComponents",
|
||||
typeof(List<ThemeComponent>),
|
||||
typeof(ThemeComponentSelectionControl),
|
||||
new FrameworkPropertyMetadata());
|
||||
|
||||
private bool _showThemeComponentComboBox;
|
||||
|
||||
public RelayCommand AddThemeComponentCommand { get; private set; }
|
||||
public RelayCommand RemoveThemeComponentCommand { get; private set; }
|
||||
|
||||
public ThemeComponent ThemeComponent
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ThemeComponent)GetValue(ThemeComponentProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(ThemeComponentProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
public List<ThemeComponent> AvailableThemeComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
return (List<ThemeComponent>)GetValue(AvailableThemeComponentsProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(AvailableThemeComponentsProperty, value);
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowThemeComponentComboBox
|
||||
{
|
||||
get { return _showThemeComponentComboBox || HasThemeComponent; }
|
||||
set
|
||||
{
|
||||
_showThemeComponentComboBox = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged("HasThemeComponent");
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasThemeComponent
|
||||
{
|
||||
get { return ThemeComponent != null; }
|
||||
}
|
||||
|
||||
private void OnAddThemeComponentCommand()
|
||||
{
|
||||
ShowThemeComponentComboBox = true;
|
||||
}
|
||||
|
||||
private void OnRemoveThemeComponentCommand()
|
||||
{
|
||||
ThemeComponent = null;
|
||||
ShowThemeComponentComboBox = false;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
var handler = PropertyChanged;
|
||||
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,8 @@ namespace Filtration.Utilities
|
||||
if (viewModel.ChildGroups.All(g => g.IsChecked == true))
|
||||
{
|
||||
viewModel.IsChecked = true;
|
||||
} else if (viewModel.ChildGroups.Any(g => g.IsChecked == true))
|
||||
}
|
||||
else if (viewModel.ChildGroups.Any(g => g.IsChecked == true || g.IsChecked == null))
|
||||
{
|
||||
viewModel.IsChecked = null;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Net.Mime;
|
||||
using AutoMapper;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ViewModels;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.Interface;
|
||||
using Filtration.ThemeEditor.ViewModels;
|
||||
using Filtration.ViewModels.ToolPanes;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
|
||||
@@ -14,12 +16,14 @@ namespace Filtration.ViewModels
|
||||
IDocument ActiveDocument { get; set; }
|
||||
ReadOnlyObservableCollection<IDocument> OpenDocuments { get; }
|
||||
IItemFilterScriptViewModel ActiveScriptViewModel { get; }
|
||||
IThemeEditorViewModel ActiveThemeViewModel { get; }
|
||||
ISectionBrowserViewModel SectionBrowserViewModel { get; }
|
||||
IBlockGroupBrowserViewModel BlockGroupBrowserViewModel { get; }
|
||||
IBlockOutputPreviewViewModel BlockOutputPreviewViewModel { get; }
|
||||
void AddDocument(IDocument document);
|
||||
void CloseDocument(IDocument document);
|
||||
void SwitchActiveDocument(IDocument document);
|
||||
IThemeEditorViewModel OpenMasterThemeForScript(IItemFilterScriptViewModel scriptViewModel);
|
||||
}
|
||||
|
||||
internal class AvalonDockWorkspaceViewModel : FiltrationViewModelBase, IAvalonDockWorkspaceViewModel
|
||||
@@ -30,6 +34,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
private IDocument _activeDocument;
|
||||
private IItemFilterScriptViewModel _activeScriptViewModel;
|
||||
private IThemeEditorViewModel _activeThemeViewModel;
|
||||
private readonly ObservableCollection<IDocument> _openDocuments;
|
||||
private readonly ReadOnlyObservableCollection<IDocument> _readOnlyOpenDocuments;
|
||||
|
||||
@@ -72,9 +77,14 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
_activeScriptViewModel = (IItemFilterScriptViewModel) value;
|
||||
}
|
||||
else if (value.IsTheme)
|
||||
{
|
||||
_activeThemeViewModel = (IThemeEditorViewModel) value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_activeScriptViewModel = null;
|
||||
_activeThemeViewModel = null;
|
||||
}
|
||||
|
||||
if (ActiveDocumentChanged != null)
|
||||
@@ -91,6 +101,11 @@ namespace Filtration.ViewModels
|
||||
get { return _activeScriptViewModel; }
|
||||
}
|
||||
|
||||
public IThemeEditorViewModel ActiveThemeViewModel
|
||||
{
|
||||
get { return _activeThemeViewModel; }
|
||||
}
|
||||
|
||||
public IBlockGroupBrowserViewModel BlockGroupBrowserViewModel
|
||||
{
|
||||
get { return _blockGroupBrowserViewModel; }
|
||||
@@ -127,6 +142,10 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
_activeScriptViewModel = (IItemFilterScriptViewModel) document;
|
||||
}
|
||||
else if (document.IsTheme)
|
||||
{
|
||||
_activeThemeViewModel = (IThemeEditorViewModel) document;
|
||||
}
|
||||
|
||||
_openDocuments.Add(document);
|
||||
ActiveDocument = document;
|
||||
@@ -151,6 +170,19 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
_activeDocument = null;
|
||||
}
|
||||
|
||||
|
||||
// TODO: Replace _activeScriptViewModel and _activeThemeViewModel with a better solution.
|
||||
|
||||
if (document.IsScript && _activeScriptViewModel == (IItemFilterScriptViewModel) document)
|
||||
{
|
||||
_activeScriptViewModel = null;
|
||||
}
|
||||
|
||||
if (document.IsTheme && _activeThemeViewModel == (IThemeEditorViewModel)document)
|
||||
{
|
||||
_activeThemeViewModel = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void SwitchActiveDocument(IDocument document)
|
||||
@@ -162,5 +194,19 @@ namespace Filtration.ViewModels
|
||||
|
||||
ActiveDocument = document;
|
||||
}
|
||||
|
||||
public IThemeEditorViewModel OpenMasterThemeForScript(IItemFilterScriptViewModel scriptViewModel)
|
||||
{
|
||||
var existingMasterThemeViewModelCount =
|
||||
OpenDocuments.OfType<IThemeEditorViewModel>()
|
||||
.Count(c => c.IsMasterThemeForScript == scriptViewModel.Script);
|
||||
if (existingMasterThemeViewModelCount > 0)
|
||||
{
|
||||
return OpenDocuments.OfType<IThemeEditorViewModel>()
|
||||
.First(c => c.IsMasterThemeForScript == scriptViewModel.Script);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Filtration.ViewModels
|
||||
bool IsDirty { get; set; }
|
||||
bool IsExpanded { get; set; }
|
||||
ItemFilterBlock Block { get; }
|
||||
bool BlockEnabled { get; set; }
|
||||
void RefreshBlockPreview();
|
||||
}
|
||||
|
||||
@@ -209,6 +210,20 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool BlockEnabled
|
||||
{
|
||||
get { return Block.Enabled; }
|
||||
set
|
||||
{
|
||||
if (Block.Enabled != value)
|
||||
{
|
||||
Block.Enabled = value;
|
||||
IsDirty = true;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string BlockDescription
|
||||
{
|
||||
get
|
||||
@@ -302,6 +317,12 @@ namespace Filtration.ViewModels
|
||||
get { return Block.HasBlockItemOfType<SoundBlockItem>(); }
|
||||
}
|
||||
|
||||
|
||||
public bool HasAudioVisualBlockItems
|
||||
{
|
||||
get { return AudioVisualBlockItems.Any(); }
|
||||
}
|
||||
|
||||
private void OnSwitchBlockItemsViewCommand()
|
||||
{
|
||||
AudioVisualBlockItemsGridVisible = !AudioVisualBlockItemsGridVisible;
|
||||
@@ -444,6 +465,7 @@ namespace Filtration.ViewModels
|
||||
RaisePropertyChanged("RegularBlockItems");
|
||||
RaisePropertyChanged("SummaryBlockItems");
|
||||
RaisePropertyChanged("AudioVisualBlockItems");
|
||||
RaisePropertyChanged("HasAudioVisualBlockItems");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,21 +4,21 @@ using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Castle.Core.Internal;
|
||||
using Filtration.Common.Services;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.Interface;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.Services;
|
||||
using Filtration.Translators;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
using NLog;
|
||||
using Clipboard = System.Windows.Clipboard;
|
||||
|
||||
namespace Filtration.ViewModels
|
||||
{
|
||||
@@ -37,9 +37,13 @@ namespace Filtration.ViewModels
|
||||
void Initialise(ItemFilterScript itemFilterScript, bool newScript);
|
||||
void RemoveDirtyFlag();
|
||||
void SetDirtyFlag();
|
||||
bool HasSelectedEnabledBlock();
|
||||
bool HasSelectedDisabledBlock();
|
||||
|
||||
RelayCommand AddBlockCommand { get; }
|
||||
RelayCommand AddSectionCommand { get; }
|
||||
RelayCommand DisableBlockCommand { get; }
|
||||
RelayCommand EnableBlockCommand { get; }
|
||||
RelayCommand DeleteBlockCommand { get; }
|
||||
RelayCommand MoveBlockUpCommand { get; }
|
||||
RelayCommand MoveBlockDownCommand { get; }
|
||||
@@ -71,6 +75,8 @@ namespace Filtration.ViewModels
|
||||
private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel;
|
||||
private readonly IItemFilterPersistenceService _persistenceService;
|
||||
private readonly IMessageBoxService _messageBoxService;
|
||||
private readonly IClipboardService _clipboardService;
|
||||
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
|
||||
|
||||
private bool _isDirty;
|
||||
private IItemFilterBlockViewModel _selectedBlockViewModel;
|
||||
@@ -83,7 +89,9 @@ namespace Filtration.ViewModels
|
||||
IItemFilterBlockTranslator blockTranslator,
|
||||
IAvalonDockWorkspaceViewModel avalonDockWorkspaceViewModel,
|
||||
IItemFilterPersistenceService persistenceService,
|
||||
IMessageBoxService messageBoxService)
|
||||
IMessageBoxService messageBoxService,
|
||||
IClipboardService clipboardService,
|
||||
IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
|
||||
{
|
||||
_itemFilterBlockViewModelFactory = itemFilterBlockViewModelFactory;
|
||||
_blockTranslator = blockTranslator;
|
||||
@@ -91,11 +99,13 @@ namespace Filtration.ViewModels
|
||||
_avalonDockWorkspaceViewModel.ActiveDocumentChanged += OnActiveDocumentChanged;
|
||||
_persistenceService = persistenceService;
|
||||
_messageBoxService = messageBoxService;
|
||||
_clipboardService = clipboardService;
|
||||
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
|
||||
_itemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModel>();
|
||||
|
||||
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand);
|
||||
ClearFilterCommand = new RelayCommand(OnClearFilterCommand, () => BlockFilterPredicate != null);
|
||||
CloseCommand = new RelayCommand(OnCloseCommand);
|
||||
CloseCommand = new RelayCommand(async () => await OnCloseCommand());
|
||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => SelectedBlockViewModel != null);
|
||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => SelectedBlockViewModel != null);
|
||||
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => SelectedBlockViewModel != null);
|
||||
@@ -103,6 +113,8 @@ namespace Filtration.ViewModels
|
||||
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => SelectedBlockViewModel != null);
|
||||
AddBlockCommand = new RelayCommand(OnAddBlockCommand);
|
||||
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => SelectedBlockViewModel != null);
|
||||
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand, HasSelectedEnabledBlock);
|
||||
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand, HasSelectedDisabledBlock);
|
||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => SelectedBlockViewModel != null);
|
||||
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => SelectedBlockViewModel != null);
|
||||
PasteBlockCommand = new RelayCommand(OnPasteBlockCommand, () => SelectedBlockViewModel != null);
|
||||
@@ -127,6 +139,8 @@ namespace Filtration.ViewModels
|
||||
public RelayCommand MoveBlockToBottomCommand { get; private set; }
|
||||
public RelayCommand AddBlockCommand { get; private set; }
|
||||
public RelayCommand AddSectionCommand { get; private set; }
|
||||
public RelayCommand EnableBlockCommand { get; private set; }
|
||||
public RelayCommand DisableBlockCommand { get; private set; }
|
||||
public RelayCommand CopyBlockCommand { get; private set; }
|
||||
public RelayCommand CopyBlockStyleCommand { get; private set; }
|
||||
public RelayCommand PasteBlockCommand { get; private set; }
|
||||
@@ -214,6 +228,21 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasSelectedBlock()
|
||||
{
|
||||
return SelectedBlockViewModel != null;
|
||||
}
|
||||
|
||||
public bool HasSelectedEnabledBlock()
|
||||
{
|
||||
return HasSelectedBlock() && !(SelectedBlockViewModel.Block is ItemFilterSection) && SelectedBlockViewModel.BlockEnabled;
|
||||
}
|
||||
|
||||
public bool HasSelectedDisabledBlock()
|
||||
{
|
||||
return HasSelectedBlock() && !(SelectedBlockViewModel.Block is ItemFilterSection) && !SelectedBlockViewModel.BlockEnabled;
|
||||
}
|
||||
|
||||
public IItemFilterBlockViewModel SelectedBlockViewModel
|
||||
{
|
||||
get { return _selectedBlockViewModel; }
|
||||
@@ -323,19 +352,21 @@ namespace Filtration.ViewModels
|
||||
ContentId = "ScriptContentId";
|
||||
}
|
||||
|
||||
public void Save()
|
||||
public async Task SaveAsync()
|
||||
{
|
||||
if (!ValidateScript()) return;
|
||||
if (!CheckForUnusedThemeComponents()) return;
|
||||
|
||||
if (_filenameIsFake)
|
||||
{
|
||||
SaveAs();
|
||||
await SaveAsAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
Messenger.Default.Send(new NotificationMessage("ShowLoadingBanner"));
|
||||
try
|
||||
{
|
||||
_persistenceService.SaveItemFilterScript(Script);
|
||||
await _persistenceService.SaveItemFilterScriptAsync(Script);
|
||||
RemoveDirtyFlag();
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -348,11 +379,18 @@ namespace Filtration.ViewModels
|
||||
_messageBoxService.Show("Save Error", "Error saving filter file - " + e.Message, MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
|
||||
}
|
||||
|
||||
public void SaveAs()
|
||||
return;
|
||||
}
|
||||
|
||||
public async Task SaveAsAsync()
|
||||
{
|
||||
if (!ValidateScript()) return;
|
||||
if (!CheckForUnusedThemeComponents()) return;
|
||||
|
||||
var saveDialog = new SaveFileDialog
|
||||
{
|
||||
@@ -365,11 +403,13 @@ namespace Filtration.ViewModels
|
||||
|
||||
if (result != DialogResult.OK) return;
|
||||
|
||||
Messenger.Default.Send(new NotificationMessage("ShowLoadingBanner"));
|
||||
|
||||
var previousFilePath = Script.FilePath;
|
||||
try
|
||||
{
|
||||
Script.FilePath = saveDialog.FileName;
|
||||
_persistenceService.SaveItemFilterScript(Script);
|
||||
await _persistenceService.SaveItemFilterScriptAsync(Script);
|
||||
_filenameIsFake = false;
|
||||
Title = Filename;
|
||||
RemoveDirtyFlag();
|
||||
@@ -385,6 +425,31 @@ namespace Filtration.ViewModels
|
||||
MessageBoxImage.Error);
|
||||
Script.FilePath = previousFilePath;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckForUnusedThemeComponents()
|
||||
{
|
||||
var unusedThemeComponents =
|
||||
Script.ThemeComponents.Where(
|
||||
t =>
|
||||
Script.ItemFilterBlocks.Count(
|
||||
b => b.BlockItems.OfType<ColorBlockItem>().Count(i => i.ThemeComponent == t) > 0) == 0).ToList();
|
||||
|
||||
if (unusedThemeComponents.Count <= 0) return true;
|
||||
|
||||
var themeComponents = unusedThemeComponents.Aggregate(string.Empty,
|
||||
(current, themeComponent) => current + (themeComponent.ComponentName + Environment.NewLine));
|
||||
|
||||
var ignoreUnusedThemeComponents = _messageBoxService.Show("Unused Theme Components",
|
||||
"The following theme components are unused, they will be lost when this script is reopened. Save anyway?" +
|
||||
Environment.NewLine + Environment.NewLine + themeComponents, MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Exclamation);
|
||||
|
||||
return ignoreUnusedThemeComponents != MessageBoxResult.No;
|
||||
}
|
||||
|
||||
private void OnActiveDocumentChanged(object sender, EventArgs e)
|
||||
@@ -429,12 +494,12 @@ namespace Filtration.ViewModels
|
||||
return false;
|
||||
}
|
||||
|
||||
private void OnCloseCommand()
|
||||
private async Task OnCloseCommand()
|
||||
{
|
||||
Close();
|
||||
await Close();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
public async Task Close()
|
||||
{
|
||||
if (!IsDirty)
|
||||
{
|
||||
@@ -443,13 +508,13 @@ namespace Filtration.ViewModels
|
||||
else
|
||||
{
|
||||
var result = _messageBoxService.Show("Filtration",
|
||||
"Want to save your changes to this script?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
|
||||
"Save script \"" + Filename + "\"?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case MessageBoxResult.Yes:
|
||||
{
|
||||
Save();
|
||||
await SaveAsync();
|
||||
CloseScript();
|
||||
break;
|
||||
}
|
||||
@@ -468,6 +533,13 @@ namespace Filtration.ViewModels
|
||||
|
||||
private void CloseScript()
|
||||
{
|
||||
var openMasterThemForScript =
|
||||
_avalonDockWorkspaceViewModel.OpenMasterThemeForScript(this);
|
||||
if (openMasterThemForScript != null)
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.CloseDocument(openMasterThemForScript);
|
||||
}
|
||||
|
||||
_avalonDockWorkspaceViewModel.ActiveDocumentChanged -= OnActiveDocumentChanged;
|
||||
_avalonDockWorkspaceViewModel.CloseDocument(this);
|
||||
}
|
||||
@@ -490,7 +562,16 @@ namespace Filtration.ViewModels
|
||||
|
||||
public void CopyBlock(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
{
|
||||
Clipboard.SetText(_blockTranslator.TranslateItemFilterBlockToString(SelectedBlockViewModel.Block));
|
||||
try
|
||||
{
|
||||
_clipboardService.SetClipboardText(
|
||||
_blockTranslator.TranslateItemFilterBlockToString(SelectedBlockViewModel.Block));
|
||||
}
|
||||
catch
|
||||
{
|
||||
_messageBoxService.Show("Clipboard Error", "Failed to access the clipboard, copy command not completed.",
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCopyBlockStyleCommand()
|
||||
@@ -510,8 +591,15 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
outputText += blockItem.OutputText;
|
||||
}
|
||||
|
||||
Clipboard.SetText(outputText);
|
||||
try
|
||||
{
|
||||
_clipboardService.SetClipboardText(outputText);
|
||||
}
|
||||
catch
|
||||
{
|
||||
_messageBoxService.Show("Clipboard Error", "Failed to access the clipboard, copy command not completed.",
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPasteBlockStyleCommand()
|
||||
@@ -521,7 +609,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
public void PasteBlockStyle(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
{
|
||||
var clipboardText = Clipboard.GetText();
|
||||
var clipboardText = _clipboardService.GetClipboardText();
|
||||
if (string.IsNullOrEmpty(clipboardText))
|
||||
{
|
||||
return;
|
||||
@@ -540,11 +628,11 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
try
|
||||
{
|
||||
var clipboardText = Clipboard.GetText();
|
||||
if (clipboardText.IsNullOrEmpty()) return;
|
||||
var clipboardText = _clipboardService.GetClipboardText();
|
||||
if (string.IsNullOrEmpty(clipboardText)) return;
|
||||
_blockGroupHierarchyBuilder.Initialise(Script.ItemFilterBlockGroups.First());
|
||||
|
||||
_blockTranslator.InitialiseForExistingScript(Script);
|
||||
var translatedBlock = _blockTranslator.TranslateStringToItemFilterBlock(clipboardText);
|
||||
var translatedBlock = _blockTranslator.TranslateStringToItemFilterBlock(clipboardText, Script.ThemeComponents);
|
||||
if (translatedBlock == null) return;
|
||||
|
||||
var vm = _itemFilterBlockViewModelFactory.Create();
|
||||
@@ -568,9 +656,12 @@ namespace Filtration.ViewModels
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.Error(e);
|
||||
var innerException = e.InnerException != null
|
||||
? e.InnerException.Message
|
||||
: string.Empty;
|
||||
|
||||
_messageBoxService.Show("Paste Error",
|
||||
e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine +
|
||||
e.InnerException.Message + Environment.NewLine + e.InnerException.StackTrace, MessageBoxButton.OK,
|
||||
e.Message + Environment.NewLine + innerException, MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
@@ -700,6 +791,7 @@ namespace Filtration.ViewModels
|
||||
IsDirty = true;
|
||||
SelectedBlockViewModel = vm;
|
||||
RaisePropertyChanged("ItemFilterSectionViewModels");
|
||||
Messenger.Default.Send(new NotificationMessage("SectionsChanged"));
|
||||
}
|
||||
|
||||
private void OnExpandAllBlocksCommand()
|
||||
@@ -731,11 +823,39 @@ namespace Filtration.ViewModels
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
var isSection = targetBlockViewModel.Block is ItemFilterSection;
|
||||
|
||||
Script.ItemFilterBlocks.Remove(targetBlockViewModel.Block);
|
||||
ItemFilterBlockViewModels.Remove(targetBlockViewModel);
|
||||
IsDirty = true;
|
||||
|
||||
if (isSection)
|
||||
{
|
||||
Messenger.Default.Send(new NotificationMessage("SectionsChanged"));
|
||||
}
|
||||
|
||||
}
|
||||
SelectedBlockViewModel = null;
|
||||
}
|
||||
|
||||
private void OnDisableBlockCommand()
|
||||
{
|
||||
DisableBlock(SelectedBlockViewModel);
|
||||
}
|
||||
|
||||
private void DisableBlock(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
{
|
||||
targetBlockViewModel.BlockEnabled = false;
|
||||
}
|
||||
|
||||
private void OnEnableBlockCommand()
|
||||
{
|
||||
EnableBlock(SelectedBlockViewModel);
|
||||
}
|
||||
|
||||
private void EnableBlock(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
{
|
||||
targetBlockViewModel.BlockEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.VisualStyles;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Filtration.Common.Services;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.Interface;
|
||||
using Filtration.Models;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
using Filtration.Properties;
|
||||
using Filtration.Repositories;
|
||||
using Filtration.Services;
|
||||
using Filtration.ThemeEditor.Messages;
|
||||
using Filtration.ThemeEditor.Providers;
|
||||
using Filtration.ThemeEditor.Services;
|
||||
using Filtration.ThemeEditor.ViewModels;
|
||||
@@ -22,7 +28,6 @@ using Filtration.Views;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
using NLog;
|
||||
using Clipboard = System.Windows.Clipboard;
|
||||
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
|
||||
|
||||
namespace Filtration.ViewModels
|
||||
@@ -31,6 +36,8 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
RelayCommand OpenScriptCommand { get; }
|
||||
RelayCommand NewScriptCommand { get; }
|
||||
Task<bool> CloseAllDocumentsAsync();
|
||||
Task OpenDroppedFilesAsync(List<string> filenames);
|
||||
}
|
||||
|
||||
internal class MainWindowViewModel : FiltrationViewModelBase, IMainWindowViewModel
|
||||
@@ -47,6 +54,8 @@ namespace Filtration.ViewModels
|
||||
private readonly IUpdateCheckService _updateCheckService;
|
||||
private readonly IUpdateAvailableViewModel _updateAvailableViewModel;
|
||||
private readonly IMessageBoxService _messageBoxService;
|
||||
private readonly IClipboardService _clipboardService;
|
||||
private bool _showLoadingBanner;
|
||||
|
||||
public MainWindowViewModel(IItemFilterScriptRepository itemFilterScriptRepository,
|
||||
IItemFilterScriptTranslator itemFilterScriptTranslator,
|
||||
@@ -57,7 +66,8 @@ namespace Filtration.ViewModels
|
||||
IThemeService themeService,
|
||||
IUpdateCheckService updateCheckService,
|
||||
IUpdateAvailableViewModel updateAvailableViewModel,
|
||||
IMessageBoxService messageBoxService)
|
||||
IMessageBoxService messageBoxService,
|
||||
IClipboardService clipboardService)
|
||||
{
|
||||
_itemFilterScriptRepository = itemFilterScriptRepository;
|
||||
_itemFilterScriptTranslator = itemFilterScriptTranslator;
|
||||
@@ -69,15 +79,16 @@ namespace Filtration.ViewModels
|
||||
_updateCheckService = updateCheckService;
|
||||
_updateAvailableViewModel = updateAvailableViewModel;
|
||||
_messageBoxService = messageBoxService;
|
||||
_clipboardService = clipboardService;
|
||||
|
||||
NewScriptCommand = new RelayCommand(OnNewScriptCommand);
|
||||
CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => ActiveDocumentIsScript);
|
||||
OpenScriptCommand = new RelayCommand(OnOpenScriptCommand);
|
||||
OpenThemeCommand = new RelayCommand(OnOpenThemeCommand);
|
||||
OpenScriptCommand = new RelayCommand(async () => await OnOpenScriptCommand());
|
||||
OpenThemeCommand = new RelayCommand(async () => await OnOpenThemeCommandAsync());
|
||||
|
||||
SaveCommand = new RelayCommand(OnSaveDocumentCommand, ActiveDocumentIsEditable);
|
||||
SaveAsCommand = new RelayCommand(OnSaveAsCommand, ActiveDocumentIsEditable);
|
||||
CloseCommand = new RelayCommand(OnCloseDocumentCommand, () => AvalonDockWorkspaceViewModel.ActiveDocument != null);
|
||||
SaveCommand = new RelayCommand(async () => await OnSaveDocumentCommandAsync(), ActiveDocumentIsEditable);
|
||||
SaveAsCommand = new RelayCommand(async () => await OnSaveAsCommandAsync(), ActiveDocumentIsEditable);
|
||||
CloseCommand = new RelayCommand(OnCloseDocumentCommand, ActiveDocumentIsEditable);
|
||||
|
||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
@@ -92,11 +103,24 @@ namespace Filtration.ViewModels
|
||||
AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => ActiveDocumentIsScript);
|
||||
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => ActiveDocumentIsScript);
|
||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
|
||||
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand,
|
||||
() => ActiveDocumentIsScript && ActiveScriptHasSelectedEnabledBlock);
|
||||
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand,
|
||||
() => ActiveDocumentIsScript && ActiveScriptHasSelectedDisabledBlock);
|
||||
OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand);
|
||||
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
CreateThemeCommand = new RelayCommand(OnCreateThemeCommand, () => ActiveDocumentIsScript);
|
||||
ApplyThemeToScriptCommand = new RelayCommand(OnApplyThemeToScriptCommand, () => ActiveDocumentIsScript);
|
||||
ApplyThemeToScriptCommand = new RelayCommand(async () => await OnApplyThemeToScriptCommandAsync(), () => ActiveDocumentIsScript);
|
||||
EditMasterThemeCommand = new RelayCommand(OnEditMasterThemeCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||
DeleteThemeComponentCommand = new RelayCommand(OnDeleteThemeComponentCommand,
|
||||
() =>
|
||||
ActiveDocumentIsTheme && ActiveThemeIsEditable &&
|
||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent != null);
|
||||
|
||||
ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript);
|
||||
CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => ActiveDocumentIsScript);
|
||||
@@ -115,6 +139,12 @@ namespace Filtration.ViewModels
|
||||
icon.EndInit();
|
||||
Icon = icon;
|
||||
|
||||
Messenger.Default.Register<ThemeClosedMessage>(this, message =>
|
||||
{
|
||||
if (message.ClosedViewModel == null) return;
|
||||
AvalonDockWorkspaceViewModel.CloseDocument(message.ClosedViewModel);
|
||||
});
|
||||
|
||||
Messenger.Default.Register<NotificationMessage>(this, message =>
|
||||
{
|
||||
switch (message.Notification)
|
||||
@@ -129,7 +159,10 @@ namespace Filtration.ViewModels
|
||||
PasteCommand.RaiseCanExecuteChanged();
|
||||
ReplaceColorsCommand.RaiseCanExecuteChanged();
|
||||
ApplyThemeToScriptCommand.RaiseCanExecuteChanged();
|
||||
EditMasterThemeCommand.RaiseCanExecuteChanged();
|
||||
CreateThemeCommand.RaiseCanExecuteChanged();
|
||||
RaisePropertyChanged("ActiveDocumentIsScript");
|
||||
RaisePropertyChanged("ActiveDocumentIsTheme");
|
||||
RaisePropertyChanged("ShowAdvancedStatus");
|
||||
break;
|
||||
}
|
||||
@@ -140,12 +173,28 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
case "OpenScript":
|
||||
{
|
||||
#pragma warning disable 4014
|
||||
OnOpenScriptCommand();
|
||||
#pragma warning restore 4014
|
||||
break;
|
||||
}
|
||||
case "ShowLoadingBanner":
|
||||
{
|
||||
ShowLoadingBanner = true;
|
||||
break;
|
||||
}
|
||||
case "HideLoadingBanner":
|
||||
{
|
||||
ShowLoadingBanner = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
CheckForUpdates();
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await CheckForUpdatesAsync();
|
||||
}).Wait();
|
||||
}
|
||||
|
||||
public RelayCommand OpenScriptCommand { get; private set; }
|
||||
@@ -161,12 +210,21 @@ namespace Filtration.ViewModels
|
||||
public RelayCommand CloseCommand { get; private set; }
|
||||
public RelayCommand OpenAboutWindowCommand { get; private set; }
|
||||
public RelayCommand ReplaceColorsCommand { get; private set; }
|
||||
|
||||
public RelayCommand EditMasterThemeCommand { get; private set; }
|
||||
public RelayCommand CreateThemeCommand { get; private set; }
|
||||
public RelayCommand ApplyThemeToScriptCommand { get; private set; }
|
||||
|
||||
public RelayCommand AddTextColorThemeComponentCommand { get; private set; }
|
||||
public RelayCommand AddBackgroundColorThemeComponentCommand { get; private set; }
|
||||
public RelayCommand AddBorderColorThemeComponentCommand { get; private set; }
|
||||
public RelayCommand DeleteThemeComponentCommand { get; private set; }
|
||||
|
||||
public RelayCommand AddBlockCommand { get; private set; }
|
||||
public RelayCommand AddSectionCommand { get; private set; }
|
||||
public RelayCommand DeleteBlockCommand { get; private set; }
|
||||
public RelayCommand DisableBlockCommand { get; private set; }
|
||||
public RelayCommand EnableBlockCommand { get; private set; }
|
||||
|
||||
public RelayCommand MoveBlockUpCommand { get; private set; }
|
||||
public RelayCommand MoveBlockDownCommand { get; private set; }
|
||||
@@ -180,14 +238,14 @@ namespace Filtration.ViewModels
|
||||
public RelayCommand ClearFiltersCommand { get; private set; }
|
||||
|
||||
|
||||
public async void CheckForUpdates()
|
||||
public async Task CheckForUpdatesAsync()
|
||||
{
|
||||
var assemblyVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
|
||||
|
||||
var result = await _updateCheckService.GetUpdateData();
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _updateCheckService.GetUpdateDataAsync();
|
||||
|
||||
if (result.LatestVersionMajorPart >= assemblyVersion.FileMajorPart &&
|
||||
result.LatestVersionMinorPart > assemblyVersion.FileMinorPart)
|
||||
{
|
||||
@@ -244,15 +302,24 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowLoadingBanner
|
||||
{
|
||||
get { return _showLoadingBanner; }
|
||||
private set
|
||||
{
|
||||
_showLoadingBanner = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ActiveDocumentIsScript
|
||||
{
|
||||
get
|
||||
{
|
||||
{
|
||||
var isScript = AvalonDockWorkspaceViewModel.ActiveDocument is ItemFilterScriptViewModel;
|
||||
return isScript;
|
||||
}
|
||||
get { return _avalonDockWorkspaceViewModel.ActiveDocument != null && _avalonDockWorkspaceViewModel.ActiveDocument.IsScript; }
|
||||
}
|
||||
|
||||
public bool ActiveDocumentIsTheme
|
||||
{
|
||||
get { return _avalonDockWorkspaceViewModel.ActiveDocument!= null && _avalonDockWorkspaceViewModel.ActiveDocument.IsTheme; }
|
||||
}
|
||||
|
||||
public bool ActiveScriptHasSelectedBlock
|
||||
@@ -260,9 +327,19 @@ namespace Filtration.ViewModels
|
||||
get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel != null; }
|
||||
}
|
||||
|
||||
public bool ActiveDocumentIsTheme
|
||||
public bool ActiveScriptHasSelectedEnabledBlock
|
||||
{
|
||||
get { { return AvalonDockWorkspaceViewModel.ActiveDocument is ThemeViewModel; } }
|
||||
get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.HasSelectedEnabledBlock(); }
|
||||
}
|
||||
|
||||
public bool ActiveScriptHasSelectedDisabledBlock
|
||||
{
|
||||
get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.HasSelectedDisabledBlock(); }
|
||||
}
|
||||
|
||||
public bool ActiveThemeIsEditable
|
||||
{
|
||||
get { return AvalonDockWorkspaceViewModel.ActiveThemeViewModel.IsMasterTheme; }
|
||||
}
|
||||
|
||||
private bool ActiveDocumentIsEditable()
|
||||
@@ -278,21 +355,61 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public async Task OpenDroppedFilesAsync(List<string> filenames)
|
||||
{
|
||||
foreach (var filename in filenames)
|
||||
{
|
||||
var extension = Path.GetExtension(filename);
|
||||
if (extension == null) continue;
|
||||
|
||||
switch (extension.ToUpperInvariant())
|
||||
{
|
||||
case ".FILTER":
|
||||
{
|
||||
await LoadScriptAsync(filename);
|
||||
break;
|
||||
}
|
||||
case ".FILTERTHEME":
|
||||
{
|
||||
await LoadThemeAsync(filename);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCreateThemeCommand()
|
||||
{
|
||||
var themeViewModel = _themeProvider.NewThemeForScript(AvalonDockWorkspaceViewModel.ActiveScriptViewModel.Script);
|
||||
OpenTheme(themeViewModel);
|
||||
}
|
||||
|
||||
private void OpenTheme(IThemeViewModel themeViewModel)
|
||||
private void OnEditMasterThemeCommand()
|
||||
{
|
||||
if (AvalonDockWorkspaceViewModel.OpenDocuments.Contains(themeViewModel))
|
||||
var openMasterThemForScript =
|
||||
AvalonDockWorkspaceViewModel.OpenMasterThemeForScript(AvalonDockWorkspaceViewModel.ActiveScriptViewModel);
|
||||
|
||||
if (openMasterThemForScript != null)
|
||||
{
|
||||
AvalonDockWorkspaceViewModel.SwitchActiveDocument(themeViewModel);
|
||||
AvalonDockWorkspaceViewModel.SwitchActiveDocument(openMasterThemForScript);
|
||||
}
|
||||
else
|
||||
{
|
||||
AvalonDockWorkspaceViewModel.AddDocument(themeViewModel);
|
||||
var themeViewModel =
|
||||
_themeProvider.MasterThemeForScript(AvalonDockWorkspaceViewModel.ActiveScriptViewModel.Script);
|
||||
OpenTheme(themeViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenTheme(IThemeEditorViewModel themeEditorViewModel)
|
||||
{
|
||||
if (AvalonDockWorkspaceViewModel.OpenDocuments.Contains(themeEditorViewModel))
|
||||
{
|
||||
AvalonDockWorkspaceViewModel.SwitchActiveDocument(themeEditorViewModel);
|
||||
}
|
||||
else
|
||||
{
|
||||
AvalonDockWorkspaceViewModel.AddDocument(themeEditorViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,24 +418,31 @@ namespace Filtration.ViewModels
|
||||
var aboutWindow = new AboutWindow();
|
||||
aboutWindow.ShowDialog();
|
||||
}
|
||||
private void OnOpenScriptCommand()
|
||||
{
|
||||
var openFileDialog = new OpenFileDialog
|
||||
{
|
||||
Filter = "Filter Files (*.filter)|*.filter|All Files (*.*)|*.*",
|
||||
InitialDirectory = _itemFilterScriptRepository.GetItemFilterScriptDirectory()
|
||||
};
|
||||
|
||||
if (openFileDialog.ShowDialog() != true) return;
|
||||
private async Task OnOpenScriptCommand()
|
||||
{
|
||||
var filePath = ShowOpenScriptDialog();
|
||||
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await LoadScriptAsync(filePath);
|
||||
}
|
||||
|
||||
private async Task LoadScriptAsync(string scriptFilename)
|
||||
{
|
||||
IItemFilterScriptViewModel loadedViewModel;
|
||||
|
||||
Messenger.Default.Send(new NotificationMessage("ShowLoadingBanner"));
|
||||
try
|
||||
{
|
||||
loadedViewModel = _itemFilterScriptRepository.LoadScriptFromFile(openFileDialog.FileName);
|
||||
loadedViewModel = await _itemFilterScriptRepository.LoadScriptFromFileAsync(scriptFilename);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
|
||||
if (_logger.IsErrorEnabled)
|
||||
{
|
||||
_logger.Error(e);
|
||||
@@ -329,23 +453,28 @@ namespace Filtration.ViewModels
|
||||
return;
|
||||
}
|
||||
|
||||
Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
|
||||
_avalonDockWorkspaceViewModel.AddDocument(loadedViewModel);
|
||||
}
|
||||
|
||||
private void OnOpenThemeCommand()
|
||||
private async Task OnOpenThemeCommandAsync()
|
||||
{
|
||||
|
||||
var filePath = ShowOpenThemeDialog();
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IThemeViewModel loadedViewModel;
|
||||
await LoadThemeAsync(filePath);
|
||||
}
|
||||
|
||||
private async Task LoadThemeAsync(string themeFilename)
|
||||
{
|
||||
IThemeEditorViewModel loadedViewModel;
|
||||
|
||||
try
|
||||
{
|
||||
loadedViewModel = _themeProvider.LoadThemeFromFile(filePath);
|
||||
loadedViewModel = await _themeProvider.LoadThemeFromFile(themeFilename);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
@@ -362,7 +491,7 @@ namespace Filtration.ViewModels
|
||||
_avalonDockWorkspaceViewModel.AddDocument(loadedViewModel);
|
||||
}
|
||||
|
||||
private void OnApplyThemeToScriptCommand()
|
||||
private async Task OnApplyThemeToScriptCommandAsync()
|
||||
{
|
||||
var filePath = ShowOpenThemeDialog();
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
@@ -374,7 +503,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
try
|
||||
{
|
||||
loadedTheme = _themeProvider.LoadThemeModelFromFile(filePath);
|
||||
loadedTheme = await _themeProvider.LoadThemeModelFromFile(filePath);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
@@ -400,6 +529,16 @@ namespace Filtration.ViewModels
|
||||
AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SetDirtyFlag();
|
||||
}
|
||||
|
||||
private string ShowOpenScriptDialog()
|
||||
{
|
||||
var openFileDialog = new OpenFileDialog
|
||||
{
|
||||
Filter = "Filter Files (*.filter)|*.filter|All Files (*.*)|*.*",
|
||||
InitialDirectory = _itemFilterScriptRepository.GetItemFilterScriptDirectory()
|
||||
};
|
||||
|
||||
return openFileDialog.ShowDialog() != true ? string.Empty : openFileDialog.FileName;
|
||||
}
|
||||
|
||||
private string ShowOpenThemeDialog()
|
||||
{
|
||||
@@ -412,8 +551,6 @@ namespace Filtration.ViewModels
|
||||
return openFileDialog.ShowDialog() != true ? string.Empty : openFileDialog.FileName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void SetItemFilterScriptDirectory()
|
||||
{
|
||||
var dlg = new FolderBrowserDialog
|
||||
@@ -429,14 +566,14 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSaveDocumentCommand()
|
||||
private async Task OnSaveDocumentCommandAsync()
|
||||
{
|
||||
((IEditableDocument)_avalonDockWorkspaceViewModel.ActiveDocument).Save();
|
||||
await ((IEditableDocument)_avalonDockWorkspaceViewModel.ActiveDocument).SaveAsync();
|
||||
}
|
||||
|
||||
private void OnSaveAsCommand()
|
||||
private async Task OnSaveAsCommandAsync()
|
||||
{
|
||||
((IEditableDocument)_avalonDockWorkspaceViewModel.ActiveDocument).SaveAs();
|
||||
await ((IEditableDocument)_avalonDockWorkspaceViewModel.ActiveDocument).SaveAsAsync();
|
||||
}
|
||||
|
||||
private void OnReplaceColorsCommand()
|
||||
@@ -448,7 +585,18 @@ namespace Filtration.ViewModels
|
||||
|
||||
private void OnCopyScriptCommand()
|
||||
{
|
||||
Clipboard.SetText(_itemFilterScriptTranslator.TranslateItemFilterScriptToString(_avalonDockWorkspaceViewModel.ActiveScriptViewModel.Script));
|
||||
try
|
||||
{
|
||||
|
||||
_clipboardService.SetClipboardText(
|
||||
_itemFilterScriptTranslator.TranslateItemFilterScriptToString(
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.Script));
|
||||
}
|
||||
catch
|
||||
{
|
||||
_messageBoxService.Show("Clipboard Error", "Failed to access the clipboard, copy command not completed.",
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCopyBlockCommand()
|
||||
@@ -517,6 +665,16 @@ namespace Filtration.ViewModels
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.DeleteBlockCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void OnDisableBlockCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.DisableBlockCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void OnEnableBlockCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.EnableBlockCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void OnExpandAllBlocksCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.ExpandAllBlocksCommand.Execute(null);
|
||||
@@ -536,5 +694,43 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.ClearFilterCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void OnAddTextColorThemeComponentCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.TextColor);
|
||||
}
|
||||
|
||||
private void OnAddBackgroundColorThemeComponentCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.BackgroundColor);
|
||||
}
|
||||
|
||||
private void OnAddBorderColorThemeComponentCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.BorderColor);
|
||||
}
|
||||
|
||||
private void OnDeleteThemeComponentCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.DeleteThemeComponentCommand.Execute(
|
||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent);
|
||||
}
|
||||
|
||||
public async Task<bool> CloseAllDocumentsAsync()
|
||||
{
|
||||
var openDocuments = _avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().ToList();
|
||||
|
||||
foreach (var document in openDocuments)
|
||||
{
|
||||
var docCount = _avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().Count();
|
||||
await document.Close();
|
||||
if (_avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().Count() == docCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Filtration.Common.ViewModels;
|
||||
using System.Threading.Tasks;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.Interface;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
@@ -25,7 +26,7 @@ namespace Filtration.ViewModels
|
||||
public bool IsScript { get { return false; } }
|
||||
public bool IsTheme { get { return false; } }
|
||||
|
||||
public void Close()
|
||||
public Task Close()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Media.Imaging;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
|
||||
namespace Filtration.ViewModels.ToolPanes
|
||||
{
|
||||
@@ -23,6 +24,18 @@ namespace Filtration.ViewModels.ToolPanes
|
||||
icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/add_section_icon.png");
|
||||
icon.EndInit();
|
||||
IconSource = icon;
|
||||
|
||||
Messenger.Default.Register<NotificationMessage>(this, message =>
|
||||
{
|
||||
switch (message.Notification)
|
||||
{
|
||||
case "SectionsChanged":
|
||||
{
|
||||
OnActiveDocumentChanged(this, EventArgs.Empty);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public const string ToolContentId = "SectionBrowserTool";
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
xmlns:converters="clr-namespace:Filtration.Converters"
|
||||
xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
|
||||
xmlns:themeEditorViews="clr-namespace:Filtration.ThemeEditor.Views;assembly=Filtration.ThemeEditor"
|
||||
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance d:Type=viewModels:AvalonDockWorkspaceViewModel}"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
d:DesignHeight="300" d:DesignWidth="700">
|
||||
<UserControl.Resources>
|
||||
<xcad:BoolToVisibilityConverter x:Key="AvalonBoolToVisibilityConverter" />
|
||||
<converters:ActiveDocumentConverter x:Key="ActiveDocumentConverter" />
|
||||
@@ -56,7 +57,7 @@
|
||||
</viewsAvalonDock:PanesTemplateSelector.StartPageTemplate>
|
||||
<viewsAvalonDock:PanesTemplateSelector.ThemeTemplate>
|
||||
<DataTemplate>
|
||||
<themeEditorViews:ThemeControl DataContext="{Binding}" />
|
||||
<themeEditorViews:ThemeEditorView DataContext="{Binding}" />
|
||||
</DataTemplate>
|
||||
</viewsAvalonDock:PanesTemplateSelector.ThemeTemplate>
|
||||
</viewsAvalonDock:PanesTemplateSelector>
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Filtration.Views.AvalonDock
|
||||
return ItemFilterScriptTemplate;
|
||||
}
|
||||
|
||||
if (item is IThemeViewModel)
|
||||
if (item is IThemeEditorViewModel)
|
||||
{
|
||||
return ThemeTemplate;
|
||||
}
|
||||
|
||||
@@ -29,4 +29,8 @@
|
||||
<Image Source="/Filtration;component/Resources/Icons/Paste.ico" x:Key="PasteIcon" x:Shared="False" />
|
||||
<Image Source="/Filtration;component/Resources/Icons/PasteStyle.ico" x:Key="PasteStyleIcon" x:Shared="False" />
|
||||
<Image Source="/Filtration;component/Resources/Icons/filtration_icon.png" x:Key="FiltrationIcon" x:Shared="False" />
|
||||
<Image Source="/Filtration;component/Resources/Icons/Add.ico" x:Key="AddIcon" x:Shared="False" />
|
||||
<Image Source="/Filtration;component/Resources/Icons/ThemeComponentDelete.ico" x:Key="ThemeComponentDeleteIcon" x:Shared="False" />
|
||||
<Image Source="/Filtration;component/Resources/Icons/standby_enabled_icon.png" x:Key="StandbyEnabledIcon" x:Shared="False" />
|
||||
<Image Source="/Filtration;component/Resources/Icons/standby_disabled_icon.png" x:Key="StandbyDisabledIcon" x:Shared="False" />
|
||||
</ResourceDictionary>
|
||||
@@ -15,7 +15,6 @@
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="SharedResourcesDictionary.xaml" />
|
||||
<ResourceDictionary>
|
||||
<views:BindingProxy x:Key="proxy" Data="{Binding}" />
|
||||
<converters:BlockGroupAdvancedFillColorConverter x:Key="BlockGroupAdvancedFillColorConverter" />
|
||||
@@ -42,6 +41,11 @@
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid x:Name="TopLevelGrid">
|
||||
<Grid x:Name="DisabledBlockOverlay" IsHitTestVisible="False" Panel.ZIndex="1000" Visibility="{Binding BlockEnabled, Converter={StaticResource InverseBooleanVisibilityConverter}}">
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="Gray" Opacity=".5" />
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
<Border BorderThickness="1" BorderBrush="SlateGray" CornerRadius="2" Background="White">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -63,8 +67,8 @@
|
||||
<Expander.ContextMenu>
|
||||
<ContextMenu>
|
||||
<ContextMenu.Items>
|
||||
<MenuItem Header="Copy" Command="{Binding CopyBlockCommand}" Icon="{StaticResource CopyIcon}" />
|
||||
<MenuItem Header="Paste" Command="{Binding PasteBlockCommand}" Icon="{StaticResource PasteIcon}" />
|
||||
<MenuItem Header="Copy Block" Command="{Binding CopyBlockCommand}" Icon="{StaticResource CopyIcon}" />
|
||||
<MenuItem Header="Paste Block" Command="{Binding PasteBlockCommand}" Icon="{StaticResource PasteIcon}" />
|
||||
<Separator />
|
||||
<MenuItem Header="Block Style">
|
||||
<MenuItem Header="Copy Block Style" Command="{Binding CopyBlockStyleCommand}" Icon="{StaticResource CopyIcon}" />
|
||||
@@ -90,6 +94,7 @@
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- BlockItems Summary Panel -->
|
||||
<StackPanel Grid.Row="0" Grid.Column="0" VerticalAlignment="Center">
|
||||
@@ -124,7 +129,7 @@
|
||||
</StackPanel>
|
||||
|
||||
<!-- Item Preview Box -->
|
||||
<WrapPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<WrapPanel Grid.Row="0" Grid.Column="2" VerticalAlignment="Center">
|
||||
<Button Command="{Binding PlaySoundCommand}"
|
||||
Width="25"
|
||||
Height="25"
|
||||
@@ -161,6 +166,10 @@
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Right">
|
||||
<Hyperlink Command="{Binding SwitchBlockItemsViewCommand}">
|
||||
Switch to Appearance Block Items
|
||||
@@ -168,7 +177,7 @@
|
||||
</TextBlock>
|
||||
|
||||
<!-- Add Block Item Links -->
|
||||
<ItemsControl ItemsSource="{Binding BlockItemTypesAvailable}" Grid.Row="0" Margin="0,0,0,10">
|
||||
<ItemsControl Grid.Column="0" ItemsSource="{Binding BlockItemTypesAvailable}" Grid.Row="0" Margin="0,0,0,10">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel></WrapPanel>
|
||||
@@ -185,8 +194,34 @@
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<!-- Enable/Disable Block Button -->
|
||||
<ToggleButton Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Style="{StaticResource ChromelessToggleButton}"
|
||||
IsChecked="{Binding BlockEnabled}"
|
||||
Margin="0,0,5,0"
|
||||
ToolTip="Enable/Disable Block"
|
||||
Cursor="Hand"
|
||||
Width="25"
|
||||
Height="25">
|
||||
<Image RenderOptions.BitmapScalingMode="HighQuality">
|
||||
<Image.Style>
|
||||
<Style TargetType="{x:Type Image}">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding BlockEnabled}" Value="true">
|
||||
<Setter Property="Source" Value="/Filtration;component/Resources/Icons/standby_enabled_icon.png"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding BlockEnabled}" Value="false">
|
||||
<Setter Property="Source" Value="/Filtration;component/Resources/Icons/standby_disabled_icon.png"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Image.Style>
|
||||
</Image>
|
||||
</ToggleButton>
|
||||
|
||||
<!-- Block Items -->
|
||||
<WrapPanel Grid.Row="1" MaxHeight="200">
|
||||
<WrapPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" MaxHeight="200">
|
||||
<WrapPanel.Resources>
|
||||
<CollectionViewSource Source="{Binding RegularBlockItems}" x:Key="BlockItemsCollectionViewSource">
|
||||
<CollectionViewSource.SortDescriptions>
|
||||
@@ -237,6 +272,8 @@
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<TextBlock Grid.Row="1" FontStyle="Italic" Visibility="{Binding HasAudioVisualBlockItems, Converter={StaticResource InverseBooleanVisibilityConverter}}">To change the appearance of this block, add a Text, Background or Border Block Item above.</TextBlock>
|
||||
|
||||
<!-- Block Items -->
|
||||
<WrapPanel Grid.Row="1" MaxHeight="200">
|
||||
<WrapPanel.Resources>
|
||||
|
||||
@@ -7,20 +7,19 @@
|
||||
xmlns:fluent="clr-namespace:Fluent;assembly=Fluent"
|
||||
xmlns:viewModels="clr-namespace:Filtration.ViewModels"
|
||||
xmlns:viewsAvalonDock="clr-namespace:Filtration.Views.AvalonDock"
|
||||
xmlns:converters="clr-namespace:Filtration.Converters"
|
||||
xmlns:views="clr-namespace:Filtration.Views"
|
||||
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=viewModels:MainWindowViewModel}"
|
||||
Title="{Binding WindowTitle}" Height="768" Width="1100" BorderThickness="1" BorderBrush="Black" IsIconVisible="True" >
|
||||
Title="{Binding WindowTitle}" Height="762" Width="1126" IsIconVisible="True"
|
||||
Closing="MainWindow_OnClosing" Drop="MainWindow_OnDrop" AllowDrop="True">
|
||||
<fluent:RibbonWindow.InputBindings>
|
||||
<KeyBinding Command="{Binding SaveCommand}" Modifiers="Control" Key="S" />
|
||||
<KeyBinding Command="{Binding OpenScriptCommand}" Modifiers="Control" Key="O" />
|
||||
<KeyBinding Command="{Binding NewScriptCommand}" Modifiers="Control" Key="N" />
|
||||
</fluent:RibbonWindow.InputBindings>
|
||||
<fluent:RibbonWindow.Resources>
|
||||
<converters:BooleanVisibilityConverterCopy x:Key="BooleanVisibilityConverterCopy" />
|
||||
</fluent:RibbonWindow.Resources>
|
||||
<DockPanel x:Name="RootDockPanel">
|
||||
<fluent:Ribbon DockPanel.Dock="Top">
|
||||
<fluent:Ribbon DockPanel.Dock="Top" x:Name="RibbonRoot" IsEnabled="{Binding ShowLoadingBanner, Converter={StaticResource BoolInverterConverter}}">
|
||||
<fluent:Ribbon.Menu>
|
||||
<fluent:Backstage>
|
||||
<fluent:BackstageTabControl>
|
||||
@@ -33,10 +32,10 @@
|
||||
</DataTemplate>
|
||||
</fluent:BackstageTabItem.ContentTemplate>
|
||||
</fluent:BackstageTabItem>
|
||||
<fluent:Button Header="New Script" Command="{Binding NewScriptCommand}" Icon="{StaticResource NewIcon}" />
|
||||
<fluent:Button Header="Open Script" Command="{Binding OpenScriptCommand}" Icon="{StaticResource OpenIcon}" />
|
||||
<fluent:Button Header="New Script" Command="{Binding NewScriptCommand}" Icon="{StaticResource NewIcon}" ToolTip="New Script (Ctrl+N)" />
|
||||
<fluent:Button Header="Open Script" Command="{Binding OpenScriptCommand}" Icon="{StaticResource OpenIcon}" ToolTip="Open Script (Ctrl+O)" />
|
||||
<fluent:Button Header="Open Theme" Command="{Binding OpenThemeCommand}" Icon="{StaticResource OpenIcon}" />
|
||||
<fluent:Button Header="Save" Command="{Binding SaveCommand}" Icon="{StaticResource SaveIcon}" />
|
||||
<fluent:Button Header="Save" Command="{Binding SaveCommand}" Icon="{StaticResource SaveIcon}" ToolTip="Save (Ctrl+S)" />
|
||||
<fluent:Button Header="Save As" Command="{Binding SaveAsCommand}" Icon="{StaticResource SaveIcon}" />
|
||||
<fluent:Button Header="Close" Command="{Binding CloseCommand}" />
|
||||
<fluent:SeparatorTabItem />
|
||||
@@ -53,19 +52,32 @@
|
||||
</fluent:Backstage>
|
||||
</fluent:Ribbon.Menu>
|
||||
<fluent:Ribbon.ContextualGroups>
|
||||
<fluent:RibbonContextualTabGroup Header="Script Tools"
|
||||
<fluent:RibbonContextualTabGroup Header="Script"
|
||||
Background="ForestGreen"
|
||||
BorderBrush="ForestGreen"
|
||||
x:Name="ScriptToolsGroup"
|
||||
Visibility="{Binding ActiveDocumentIsScript, Converter={StaticResource BooleanVisibilityConverterCopy}, Mode=OneWay}" />
|
||||
IsVisibleChanged="ScriptToolsGroup_OnIsVisibleChanged"
|
||||
Visibility="{Binding ActiveDocumentIsScript, Converter={StaticResource BooleanVisibilityConverter}, Mode=OneWay}" />
|
||||
<fluent:RibbonContextualTabGroup Header="Theme"
|
||||
Background="DodgerBlue"
|
||||
BorderBrush="DodgerBlue"
|
||||
x:Name="ThemeToolsGroup"
|
||||
IsVisibleChanged="ThemeToolsGroup_OnIsVisibleChanged"
|
||||
Visibility="{Binding ActiveDocumentIsTheme, Converter={StaticResource BooleanVisibilityConverter}, Mode=OneWay}" />
|
||||
</fluent:Ribbon.ContextualGroups>
|
||||
<fluent:RibbonTabItem Header="Script Tools" Group="{Binding ElementName=ScriptToolsGroup}">
|
||||
<fluent:RibbonTabItem Header="View">
|
||||
<fluent:RibbonGroupBox Header="Tools">
|
||||
<fluent:ToggleButton Header="Section Browser" Width="150" Size="Middle" Icon="{StaticResource AddSectionIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.SectionBrowserViewModel.IsVisible}"/>
|
||||
<fluent:ToggleButton Header="Block Group Browser" SizeDefinition="Middle" Icon="{StaticResource BlockGroupBrowserIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.BlockGroupBrowserViewModel.IsVisible}" />
|
||||
<fluent:ToggleButton Header="Block Output Preview" SizeDefinition="Middle" Icon="{StaticResource BlockOutputPreviewIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.BlockOutputPreviewViewModel.IsVisible}" />
|
||||
</fluent:RibbonGroupBox>
|
||||
</fluent:RibbonTabItem>
|
||||
<fluent:RibbonTabItem x:Name="ScriptToolsTabItem" Header="Script Tools" Group="{Binding ElementName=ScriptToolsGroup}" Visibility="{Binding ActiveDocumentIsScript, Converter={StaticResource BooleanVisibilityConverter}, Mode=OneWay}" >
|
||||
<fluent:RibbonGroupBox Header="Clipboard">
|
||||
<fluent:Button Header="Copy Block" Command="{Binding CopyBlockCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource CopyIcon}">
|
||||
</fluent:Button>
|
||||
<fluent:Button Header="Paste Block" Command="{Binding PasteCommand}" Icon="{StaticResource PasteIcon}" LargeIcon="{StaticResource PasteIcon}" />
|
||||
<fluent:Button Header="Copy Style" Command="{Binding CopyBlockStyleCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource CopyIcon}" SizeDefinition="Middle" />
|
||||
<fluent:Button Header="Paste Style" Command="{Binding PasteBlockStyleCommand}" Icon="{StaticResource PasteStyleIcon}" LargeIcon="{StaticResource PasteIcon}" SizeDefinition="Middle" />
|
||||
<fluent:Button Header="Copy Block" Command="{Binding CopyBlockCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource CopyIcon}" ToolTip="Copy Block (Ctrl+C)"/>
|
||||
<fluent:Button Header="Paste Block" Command="{Binding PasteCommand}" Icon="{StaticResource PasteIcon}" LargeIcon="{StaticResource PasteIcon}" ToolTip="Paste Block (Ctrl+V)"/>
|
||||
<fluent:Button Header="Copy Style" Command="{Binding CopyBlockStyleCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource CopyIcon}" SizeDefinition="Middle" ToolTip="Copy Style (Ctrl+Shift+C)" />
|
||||
<fluent:Button Header="Paste Style" Command="{Binding PasteBlockStyleCommand}" Icon="{StaticResource PasteStyleIcon}" LargeIcon="{StaticResource PasteIcon}" SizeDefinition="Middle" ToolTip="Paste Style (Ctrl+Shift+V)" />
|
||||
<fluent:Button Header="Copy Script" Command="{Binding CopyScriptCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource PasteIcon}" SizeDefinition="Middle" />
|
||||
</fluent:RibbonGroupBox>
|
||||
<fluent:RibbonGroupBox Header="Blocks">
|
||||
@@ -76,6 +88,8 @@
|
||||
<fluent:Button Header="Move Up" Command="{Binding MoveBlockUpCommand}" SizeDefinition="Middle" Icon="{StaticResource MoveUpIcon}" />
|
||||
<fluent:Button Header="Move Down" Command="{Binding MoveBlockDownCommand}" SizeDefinition="Middle" Icon="{StaticResource MoveDownIcon}" />
|
||||
<fluent:Button Header="Move To Bottom" Command="{Binding MoveBlockToBottomCommand}" SizeDefinition="Middle" Icon="{StaticResource MoveToBottomIcon}" />
|
||||
<fluent:Button Header="Enable Block" Command="{Binding EnableBlockCommand}" SizeDefinition="Middle" Icon="{StaticResource StandbyEnabledIcon}" />
|
||||
<fluent:Button Header="Disable Block" Command="{Binding DisableBlockCommand}" SizeDefinition="Middle" Icon="{StaticResource StandbyDisabledIcon}" />
|
||||
</fluent:RibbonGroupBox>
|
||||
<fluent:RibbonGroupBox Header="Expand / Collapse">
|
||||
<fluent:Button Header="Expand All" Command="{Binding ExpandAllBlocksCommand}" SizeDefinition="Middle" Icon="{StaticResource ExpandIcon}" />
|
||||
@@ -86,21 +100,50 @@
|
||||
<fluent:Button Header="Clear All Filters" Command="{Binding ClearFiltersCommand}" SizeDefinition="Middle" Icon="{StaticResource ClearFilterIcon}" />
|
||||
</fluent:RibbonGroupBox>
|
||||
<fluent:RibbonGroupBox Header="Themes">
|
||||
<fluent:Button Header="Edit Master Theme" Command="{Binding EditMasterThemeCommand}" Icon="{StaticResource ThemeIcon}" LargeIcon="{StaticResource ThemeIcon}" />
|
||||
<fluent:Button Header="Apply Theme" Command="{Binding ApplyThemeToScriptCommand}" Icon="{StaticResource ThemeIcon}" LargeIcon="{StaticResource ThemeIcon}" />
|
||||
<fluent:Button Header="Create Theme" Command="{Binding CreateThemeCommand}" Icon="{StaticResource ThemeIcon}" LargeIcon="{StaticResource ThemeIcon}" />
|
||||
<fluent:Button Header="Replace Colours" Command="{Binding ReplaceColorsCommand}" Icon="{StaticResource ReplaceColorsIcon}" LargeIcon="{StaticResource ReplaceColorsIcon}" />
|
||||
</fluent:RibbonGroupBox>
|
||||
</fluent:RibbonTabItem>
|
||||
<fluent:RibbonTabItem Header="View">
|
||||
<fluent:RibbonGroupBox Header="Tools">
|
||||
<fluent:ToggleButton Header="Section Browser" Width="150" SizeDefinition="Middle" Icon="{StaticResource AddSectionIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.SectionBrowserViewModel.IsVisible}" />
|
||||
<fluent:ToggleButton Header="Block Group Browser" Width="150" SizeDefinition="Middle" Icon="{StaticResource BlockGroupBrowserIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.BlockGroupBrowserViewModel.IsVisible}" />
|
||||
<fluent:ToggleButton Header="Block Output Preview" Width="150" SizeDefinition="Middle" Icon="{StaticResource BlockOutputPreviewIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.BlockOutputPreviewViewModel.IsVisible}" />
|
||||
<fluent:RibbonTabItem x:Name="ThemeToolsTabItem" Header="Theme Tools" Group="{Binding ElementName=ThemeToolsGroup}" Visibility="{Binding ActiveDocumentIsTheme, Converter={StaticResource BooleanVisibilityConverter}, Mode=OneWay}">
|
||||
<fluent:RibbonGroupBox Header="Add Components">
|
||||
<fluent:Button SizeDefinition="Middle" Header="Add Text Color" Icon="{StaticResource AddIcon}" Command="{Binding AddTextColorThemeComponentCommand}" />
|
||||
<fluent:Button SizeDefinition="Middle" Header="Add Background Color" Icon="{StaticResource AddIcon}" Command="{Binding AddBackgroundColorThemeComponentCommand}" />
|
||||
<fluent:Button SizeDefinition="Middle" Header="Add Border Color" Icon="{StaticResource AddIcon}" Command="{Binding AddBorderColorThemeComponentCommand}" />
|
||||
</fluent:RibbonGroupBox>
|
||||
<fluent:RibbonGroupBox Header="Delete">
|
||||
<fluent:Button Header="Delete Theme Component" Icon="{StaticResource ThemeComponentDeleteIcon}" LargeIcon="{StaticResource ThemeComponentDeleteIcon}" Command="{Binding DeleteThemeComponentCommand}" />
|
||||
</fluent:RibbonGroupBox>
|
||||
</fluent:RibbonTabItem>
|
||||
</fluent:Ribbon>
|
||||
<Grid>
|
||||
<viewsAvalonDock:AvalonDockWorkspaceView DataContext="{Binding AvalonDockWorkspaceViewModel}" />
|
||||
<Grid ZIndex="9999" Visibility="{Binding ShowLoadingBanner, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter={x:Static Visibility.Hidden}}">
|
||||
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="Black" Opacity="0.5" />
|
||||
</Grid.Background>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Border Grid.Row="1" Grid.Column="1" BorderBrush="Black" BorderThickness="1" Background="White" Padding="20">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" FontWeight="DemiBold">Working...</TextBlock>
|
||||
<Image gif:ImageBehavior.AnimatedSource="/Filtration;component/Resources/loading_spinner.gif" Height="32" Margin="10,0,0,0"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</fluent:RibbonWindow>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
using Filtration.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Filtration.ViewModels;
|
||||
|
||||
namespace Filtration.Views
|
||||
{
|
||||
@@ -9,10 +14,62 @@ namespace Filtration.Views
|
||||
|
||||
internal partial class MainWindow : IMainWindow
|
||||
{
|
||||
private readonly IMainWindowViewModel _mainWindowViewModel;
|
||||
|
||||
public MainWindow(IMainWindowViewModel mainWindowViewModel)
|
||||
{
|
||||
_mainWindowViewModel = mainWindowViewModel;
|
||||
InitializeComponent();
|
||||
DataContext = mainWindowViewModel;
|
||||
}
|
||||
|
||||
private void ScriptToolsGroup_OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (ScriptToolsGroup.IsVisible)
|
||||
{
|
||||
RibbonRoot.SelectedTabItem = ScriptToolsTabItem;
|
||||
}
|
||||
}
|
||||
|
||||
private void ThemeToolsGroup_OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (ThemeToolsGroup.IsVisible)
|
||||
{
|
||||
RibbonRoot.SelectedTabItem = ThemeToolsTabItem;
|
||||
}
|
||||
}
|
||||
|
||||
private void MainWindow_OnClosing(object sender, CancelEventArgs e)
|
||||
{
|
||||
var allDocumentsClosed = _mainWindowViewModel.CloseAllDocumentsAsync().Result;
|
||||
if (!allDocumentsClosed)
|
||||
{
|
||||
e.Cancel = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private async void MainWindow_OnDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (!e.Data.GetDataPresent(DataFormats.FileDrop)) return;
|
||||
|
||||
var filenames = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
var droppedFilterFiles = new List<string>();
|
||||
|
||||
foreach (var filename in filenames)
|
||||
{
|
||||
var extension = Path.GetExtension(filename);
|
||||
if (extension != null &&
|
||||
(extension.ToUpperInvariant() == ".FILTER" || extension.ToUpperInvariant() == ".FILTERTHEME"))
|
||||
{
|
||||
droppedFilterFiles.Add(filename);
|
||||
}
|
||||
}
|
||||
|
||||
if (droppedFilterFiles.Count > 0)
|
||||
{
|
||||
await _mainWindowViewModel.OpenDroppedFilesAsync(droppedFilterFiles);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,14 +11,6 @@
|
||||
Title="Replace Script Colors" Height="280" Width="540"
|
||||
BorderThickness="1" BorderBrush="Black"
|
||||
Loaded="ReplaceColorsWindow_OnLoaded" ResizeMode="CanMinimize">
|
||||
<!--ShowMaxRestoreButton="False"-->
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="SharedResourcesDictionary.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
<Grid Margin="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
|
||||
@@ -1,23 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Filtration.Views
|
||||
namespace Filtration.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for UpdateAvailableView.xaml
|
||||
/// </summary>
|
||||
public partial class UpdateAvailableView : Window
|
||||
public partial class UpdateAvailableView
|
||||
{
|
||||
public UpdateAvailableView()
|
||||
{
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
using Castle.MicroKernel.Registration;
|
||||
using Castle.MicroKernel.SubSystems.Configuration;
|
||||
using Castle.Windsor;
|
||||
|
||||
namespace Filtration.WindsorInstallers
|
||||
{
|
||||
public class ModelsInstaller : IWindsorInstaller
|
||||
{
|
||||
public void Install(IWindsorContainer container, IConfigurationStore store)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,11 @@ namespace Filtration.WindsorInstallers
|
||||
Component.For<IUpdateCheckService>()
|
||||
.ImplementedBy<UpdateCheckService>()
|
||||
.LifeStyle.Singleton);
|
||||
|
||||
container.Register(
|
||||
Component.For<IClipboardService>()
|
||||
.ImplementedBy<ClipboardService>()
|
||||
.LifeStyle.Singleton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,6 @@ namespace Filtration.WindsorInstallers
|
||||
Component.For<IBlockGroupHierarchyBuilder>()
|
||||
.ImplementedBy<BlockGroupHierarchyBuilder>()
|
||||
.LifeStyle.Singleton);
|
||||
|
||||
container.Register(
|
||||
Component.For<IThemeComponentListBuilder>()
|
||||
.ImplementedBy<ThemeComponentListBuilder>()
|
||||
.LifeStyle.Singleton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,5 +11,6 @@
|
||||
<package id="NLog" version="4.0.1" targetFramework="net451" />
|
||||
<package id="NLog.Config" version="4.0.1" targetFramework="net451" />
|
||||
<package id="NLog.Schema" version="4.0.1" targetFramework="net451" />
|
||||
<package id="WpfAnimatedGif" version="1.4.13" targetFramework="net451" />
|
||||
<package id="WPFToolkit" version="3.5.50211.1" targetFramework="net451" />
|
||||
</packages>
|
||||
19
README.md
19
README.md
@@ -2,10 +2,10 @@
|
||||
|
||||
Filtration is an editor for Path of Exile item filter scripts.
|
||||
|
||||
## Current Release
|
||||
<b>Installer (6.01mb)</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.5/filtration_0.5_setup.exe">filtration_0.5_setup.exe</a>
|
||||
## Current Release (Released 2015-07-15)
|
||||
<b>Installer (6.3mb)</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.9/filtration_0.9_setup.exe">filtration_0.9_setup.exe</a>
|
||||
|
||||
<b>Zip File (7.54mb)</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.5/filtration_0.5.zip">filtration_0.5.zip</a>
|
||||
<b>Zip File (7.89mb)</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.9/filtration_0.9.zip">filtration_0.9.zip</a>
|
||||
|
||||
## System Requirements
|
||||
Filtration requires .NET Framework 4.5.1 installed.
|
||||
@@ -26,19 +26,10 @@ If you'd like to make your script fully compatible with Filtration, please take
|
||||
## Screenshots
|
||||
|
||||
##### Main Window
|
||||
<img src="http://i.imgur.com/s2lNHCm.png" />
|
||||
|
||||
##### Block Editor
|
||||
<img src="http://i.imgur.com/BqWGxs7.png" />
|
||||
<img src="http://i.imgur.com/eAsMoSo.png" />
|
||||
|
||||
##### Theme Editor
|
||||
<img src="http://i.imgur.com/R2w7Hf2.png" />
|
||||
|
||||
##### Block Color Editor
|
||||
<img src="http://i.imgur.com/nlBGiG4.png" />
|
||||
|
||||
##### Replace Colors Tool
|
||||
<img src="http://i.imgur.com/oY1q6hq.png" />
|
||||
<img src="http://i.imgur.com/FJWJknO.png" />
|
||||
|
||||
## Contact
|
||||
|
||||
|
||||
Reference in New Issue
Block a user