Fixed block group advanced status being lost during save
This commit is contained in:
parent
4faa12474a
commit
e53e24100f
|
@ -44,14 +44,14 @@ namespace Filtration.ObjectModel
|
|||
{
|
||||
var currentBlockGroup = this;
|
||||
|
||||
var outputString = GroupName;
|
||||
var outputString = (Advanced ? "~" : string.Empty) + GroupName;
|
||||
|
||||
// TODO: This is retarded, fix this.
|
||||
if (currentBlockGroup.ParentGroup != null)
|
||||
{
|
||||
while (currentBlockGroup.ParentGroup.ParentGroup != null)
|
||||
{
|
||||
outputString = currentBlockGroup.ParentGroup.GroupName + " - " + outputString;
|
||||
outputString = (currentBlockGroup.ParentGroup.Advanced ? "~" : string.Empty) + currentBlockGroup.ParentGroup.GroupName + " - " + outputString;
|
||||
currentBlockGroup = currentBlockGroup.ParentGroup;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.Properties;
|
||||
using Filtration.Translators;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
@ -19,6 +20,7 @@ namespace Filtration.Tests.Translators
|
|||
public void ItemFilterScriptTranslatorTestSetup()
|
||||
{
|
||||
_testUtility = new ItemFilterScriptTranslatorTestUtility();
|
||||
Settings.Default.Reset();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -99,6 +101,43 @@ namespace Filtration.Tests.Translators
|
|||
_testUtility.MockItemFilterBlockTranslator.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateItemFilterScriptToString_ExtraLineBetweenBlocksSettingFalse_ReturnsCorrectOutput()
|
||||
{
|
||||
Settings.Default.ExtraLineBetweenBlocks = false;
|
||||
|
||||
var script = new ItemFilterScript();
|
||||
var block1 = new ItemFilterBlock { Description = "Test Filter 1" };
|
||||
block1.BlockItems.Add(new ItemLevelBlockItem(FilterPredicateOperator.GreaterThan, 5));
|
||||
|
||||
var block2 = new ItemFilterBlock();
|
||||
block2.BlockItems.Add(new QualityBlockItem(FilterPredicateOperator.LessThan, 15));
|
||||
block2.BlockItems.Add(new FontSizeBlockItem(7));
|
||||
block2.BlockItems.Add(new WidthBlockItem(FilterPredicateOperator.Equal, 3));
|
||||
|
||||
script.ItemFilterBlocks.Add(block1);
|
||||
script.ItemFilterBlocks.Add(block2);
|
||||
|
||||
var expectedOutput = "# Script edited with Filtration - https://github.com/ben-wallis/Filtration" + Environment.NewLine +
|
||||
"# Test Filter 1" + Environment.NewLine +
|
||||
"Show" + Environment.NewLine +
|
||||
" ItemLevel > 5" + Environment.NewLine +
|
||||
"Show" + Environment.NewLine +
|
||||
" Quality < 15" + Environment.NewLine +
|
||||
" Width = 3" + Environment.NewLine +
|
||||
" SetFontSize 7" + Environment.NewLine;
|
||||
|
||||
var mockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();
|
||||
var blockTranslator = new ItemFilterBlockTranslator(mockBlockGroupHierarchyBuilder.Object);
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator, mockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
var result = translator.TranslateItemFilterScriptToString(script);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(expectedOutput, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateItemFilterScriptToString_FullScript_ReturnsCorrectOutput()
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.Linq;
|
|||
using System.Text.RegularExpressions;
|
||||
using Castle.Core.Internal;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.Properties;
|
||||
using Filtration.Utilities;
|
||||
|
||||
namespace Filtration.Translators
|
||||
|
@ -111,7 +112,12 @@ namespace Filtration.Translators
|
|||
// ReSharper disable once LoopCanBeConvertedToQuery
|
||||
foreach (var block in script.ItemFilterBlocks)
|
||||
{
|
||||
outputString += _blockTranslator.TranslateItemFilterBlockToString(block) + Environment.NewLine + Environment.NewLine;
|
||||
outputString += _blockTranslator.TranslateItemFilterBlockToString(block) + Environment.NewLine;
|
||||
|
||||
if (Settings.Default.ExtraLineBetweenBlocks)
|
||||
{
|
||||
outputString += Environment.NewLine;
|
||||
}
|
||||
}
|
||||
|
||||
return outputString;
|
||||
|
|
|
@ -89,10 +89,12 @@
|
|||
<xcad:LayoutAnchorablePane Name="SectionBrowserPane" DockWidth="150" />
|
||||
<xcad:LayoutPanel Orientation="Vertical">
|
||||
<xcad:LayoutDocumentPane />
|
||||
<xcad:LayoutAnchorablePane Name="BlockOutputPreviewPane" DockHeight="100">
|
||||
</xcad:LayoutAnchorablePane>
|
||||
|
||||
</xcad:LayoutPanel>
|
||||
<xcad:LayoutAnchorablePane Name="BlockGroupBrowserPane" DockWidth="200" />
|
||||
<xcad:LayoutAnchorablePaneGroup DockWidth="200" Orientation="Vertical">
|
||||
<xcad:LayoutAnchorablePane Name="BlockGroupBrowserPane" />
|
||||
<xcad:LayoutAnchorablePane Name="BlockOutputPreviewPane" />
|
||||
</xcad:LayoutAnchorablePaneGroup>
|
||||
</xcad:LayoutPanel>
|
||||
</xcad:LayoutRoot>
|
||||
</xcad:DockingManager>
|
||||
|
|
|
@ -8,40 +8,41 @@
|
|||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=viewModels:SettingsWindowViewModel}"
|
||||
Title="Options" Height="150" Width="500" IsMaxRestoreButtonEnabled="False">
|
||||
<DockPanel Margin="10">
|
||||
<Grid DockPanel.Dock="Bottom">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border BorderBrush="Black" BorderThickness="1">
|
||||
<DockPanel Margin="10">
|
||||
<Grid DockPanel.Dock="Bottom">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="5" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Grid.Column="0">Default Filter Directory:</TextBlock>
|
||||
<TextBox Grid.Row="0" Grid.Column="2" Text="{Binding DefaultFilterDirectory}" />
|
||||
<TextBlock Grid.Row="2" Grid.Column="0">Add blank line between blocks when saving</TextBlock>
|
||||
<CheckBox Grid.Row="2" Grid.Column="2" IsChecked="{Binding ExtraLineBetweenBlocks}" />
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="5" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Grid.Column="0">Default Filter Directory:</TextBlock>
|
||||
<TextBox Grid.Row="0" Grid.Column="2" Text="{Binding DefaultFilterDirectory}" />
|
||||
<TextBlock Grid.Row="2" Grid.Column="0">Add blank line between blocks when saving</TextBlock>
|
||||
<CheckBox Grid.Row="2" Grid.Column="2" IsChecked="{Binding ExtraLineBetweenBlocks}" />
|
||||
</Grid>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Right">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="{x:Type Button}">
|
||||
<Setter Property="Width" Value="80" />
|
||||
<Setter Property="Margin" Value="3" />
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<Button Command="{Binding SaveCommand}">OK</Button>
|
||||
<Button Command="{Binding CancelCommand}">Cancel</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Right">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="{x:Type Button}">
|
||||
<Setter Property="Width" Value="80" />
|
||||
<Setter Property="Margin" Value="3" />
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<Button Command="{Binding SaveCommand}">OK</Button>
|
||||
<Button Command="{Binding CancelCommand}">Cancel</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
</DockPanel>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
</controls:MetroWindow>
|
||||
|
|
Loading…
Reference in New Issue