Implemented disabled block support
This commit is contained in:
parent
1b63f68eee
commit
9fcb609a51
|
@ -13,8 +13,10 @@ namespace Filtration.ObjectModel
|
||||||
public ItemFilterBlock()
|
public ItemFilterBlock()
|
||||||
{
|
{
|
||||||
BlockItems = new ObservableCollection<IItemFilterBlockItem> {new ActionBlockItem(BlockAction.Show)};
|
BlockItems = new ObservableCollection<IItemFilterBlockItem> {new ActionBlockItem(BlockAction.Show)};
|
||||||
|
Enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Enabled { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
|
||||||
public ItemFilterBlockGroup BlockGroup
|
public ItemFilterBlockGroup BlockGroup
|
||||||
|
|
|
@ -25,6 +25,36 @@ namespace Filtration.Tests.Translators
|
||||||
_testUtility = new ItemFilterBlockTranslatorTestUtility();
|
_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]
|
[Test]
|
||||||
public void TranslateStringToItemFilterBlock_NoDescriptionComment_ReturnsCorrectObject()
|
public void TranslateStringToItemFilterBlock_NoDescriptionComment_ReturnsCorrectObject()
|
||||||
{
|
{
|
||||||
|
@ -1264,6 +1294,26 @@ namespace Filtration.Tests.Translators
|
||||||
Assert.AreEqual(expectedResult, result);
|
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]
|
[Test]
|
||||||
public void TranslateItemFilterBlockToString_Everything_ReturnsCorrectString()
|
public void TranslateItemFilterBlockToString_Everything_ReturnsCorrectString()
|
||||||
{
|
{
|
||||||
|
|
|
@ -253,6 +253,79 @@ namespace Filtration.Tests.Translators
|
||||||
Assert.IsNullOrEmpty(firstBlock.Description);
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private class ItemFilterScriptTranslatorTestUtility
|
private class ItemFilterScriptTranslatorTestUtility
|
||||||
{
|
{
|
||||||
public ItemFilterScriptTranslatorTestUtility()
|
public ItemFilterScriptTranslatorTestUtility()
|
||||||
|
|
|
@ -429,6 +429,8 @@
|
||||||
<Resource Include="Resources\Icons\filtration_icon.png" />
|
<Resource Include="Resources\Icons\filtration_icon.png" />
|
||||||
<Resource Include="Resources\Icons\Add.ico" />
|
<Resource Include="Resources\Icons\Add.ico" />
|
||||||
<Resource Include="Resources\Icons\ThemeComponentDelete.ico" />
|
<Resource Include="Resources\Icons\ThemeComponentDelete.ico" />
|
||||||
|
<Resource Include="Resources\Icons\standby_disabled_icon.png" />
|
||||||
|
<Resource Include="Resources\Icons\standby_enabled_icon.png" />
|
||||||
<Content Include="Resources\ItemBaseTypes.txt">
|
<Content Include="Resources\ItemBaseTypes.txt">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
|
@ -50,7 +50,7 @@ using System.Windows;
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("0.6.*")]
|
[assembly: AssemblyVersion("0.7.*")]
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("Filtration.Tests")]
|
[assembly: InternalsVisibleTo("Filtration.Tests")]
|
||||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
|
@ -28,6 +28,7 @@ namespace Filtration.Translators
|
||||||
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
|
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
|
||||||
private const string Indent = " ";
|
private const string Indent = " ";
|
||||||
private readonly string _newLine = Environment.NewLine + Indent;
|
private readonly string _newLine = Environment.NewLine + Indent;
|
||||||
|
private readonly string _disabledNewLine = Environment.NewLine + "#" + Indent;
|
||||||
private ThemeComponentCollection _masterComponentCollection;
|
private ThemeComponentCollection _masterComponentCollection;
|
||||||
|
|
||||||
public ItemFilterBlockTranslator(IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
|
public ItemFilterBlockTranslator(IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
|
||||||
|
@ -42,6 +43,7 @@ namespace Filtration.Translators
|
||||||
_masterComponentCollection = masterComponentCollection;
|
_masterComponentCollection = masterComponentCollection;
|
||||||
var block = new ItemFilterBlock();
|
var block = new ItemFilterBlock();
|
||||||
var showHideFound = false;
|
var showHideFound = false;
|
||||||
|
|
||||||
foreach (var line in new LineReader(() => new StringReader(inputString)))
|
foreach (var line in new LineReader(() => new StringReader(inputString)))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -62,6 +64,7 @@ namespace Filtration.Translators
|
||||||
|
|
||||||
var adjustedLine = line.Replace("#", " # ");
|
var adjustedLine = line.Replace("#", " # ");
|
||||||
var trimmedLine = adjustedLine.TrimStart(' ');
|
var trimmedLine = adjustedLine.TrimStart(' ');
|
||||||
|
|
||||||
var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length;
|
var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length;
|
||||||
|
|
||||||
var lineOption = trimmedLine.Substring(0, spaceOrEndOfLinePos);
|
var lineOption = trimmedLine.Substring(0, spaceOrEndOfLinePos);
|
||||||
|
@ -70,11 +73,25 @@ namespace Filtration.Translators
|
||||||
case "Show":
|
case "Show":
|
||||||
showHideFound = true;
|
showHideFound = true;
|
||||||
block.Action = BlockAction.Show;
|
block.Action = BlockAction.Show;
|
||||||
|
block.Enabled = true;
|
||||||
AddBlockGroupToBlock(block, trimmedLine);
|
AddBlockGroupToBlock(block, trimmedLine);
|
||||||
break;
|
break;
|
||||||
case "Hide":
|
case "Hide":
|
||||||
showHideFound = true;
|
showHideFound = true;
|
||||||
block.Action = BlockAction.Hide;
|
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);
|
AddBlockGroupToBlock(block, trimmedLine);
|
||||||
break;
|
break;
|
||||||
case "ItemLevel":
|
case "ItemLevel":
|
||||||
|
@ -399,12 +416,17 @@ namespace Filtration.Translators
|
||||||
|
|
||||||
var outputString = string.Empty;
|
var outputString = string.Empty;
|
||||||
|
|
||||||
|
if (!block.Enabled)
|
||||||
|
{
|
||||||
|
outputString += "#Disabled Block Start" + Environment.NewLine;
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(block.Description))
|
if (!string.IsNullOrEmpty(block.Description))
|
||||||
{
|
{
|
||||||
outputString += "# " + block.Description + Environment.NewLine;
|
outputString += "# " + block.Description + Environment.NewLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
outputString += block.Action.GetAttributeDescription();
|
outputString += (!block.Enabled ? "#" : string.Empty) + block.Action.GetAttributeDescription();
|
||||||
|
|
||||||
if (block.BlockGroup != null)
|
if (block.BlockGroup != null)
|
||||||
{
|
{
|
||||||
|
@ -416,10 +438,15 @@ namespace Filtration.Translators
|
||||||
{
|
{
|
||||||
if (blockItem.OutputText != string.Empty)
|
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;
|
return outputString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Windows.Documents;
|
||||||
using Castle.Core.Internal;
|
using Castle.Core.Internal;
|
||||||
using Filtration.ObjectModel;
|
using Filtration.ObjectModel;
|
||||||
using Filtration.Properties;
|
using Filtration.Properties;
|
||||||
|
@ -28,12 +29,63 @@ namespace Filtration.Translators
|
||||||
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
|
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string PreprocessDisabledBlocks(string inputString)
|
||||||
|
{
|
||||||
|
bool inDisabledBlock = 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;
|
||||||
|
linesToRemove.Add(i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
lines[i] = lines[i].TrimStart('#');
|
||||||
|
var spaceOrEndOfLinePos = lines[i].IndexOf(" ", StringComparison.Ordinal) > 0 ? lines[i].IndexOf(" ", StringComparison.Ordinal) : lines[i].Length;
|
||||||
|
var lineOption = lines[i].Substring(0, spaceOrEndOfLinePos);
|
||||||
|
if (lineOption == "Show")
|
||||||
|
{
|
||||||
|
lines[i] = lines[i].Replace("Show", "ShowDisabled");
|
||||||
|
}
|
||||||
|
else if (lineOption == "Hide")
|
||||||
|
{
|
||||||
|
lines[i] = lines[i].Replace("Hide", "HideDisabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
public ItemFilterScript TranslateStringToItemFilterScript(string inputString)
|
||||||
{
|
{
|
||||||
var script = new ItemFilterScript();
|
var script = new ItemFilterScript();
|
||||||
_blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First());
|
_blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First());
|
||||||
|
|
||||||
inputString = inputString.Replace("\t", "");
|
inputString = inputString.Replace("\t", "");
|
||||||
|
if (inputString.Contains("#Disabled Block Start"))
|
||||||
|
{
|
||||||
|
inputString = PreprocessDisabledBlocks(inputString);
|
||||||
|
}
|
||||||
|
|
||||||
var conditionBoundaries = IdentifyBlockBoundaries(inputString);
|
var conditionBoundaries = IdentifyBlockBoundaries(inputString);
|
||||||
|
|
||||||
var lines = Regex.Split(inputString, "\r\n|\r|\n");
|
var lines = Regex.Split(inputString, "\r\n|\r|\n");
|
||||||
|
@ -85,7 +137,10 @@ namespace Filtration.Translators
|
||||||
// as it represents the block description.
|
// as it represents the block description.
|
||||||
// currentLine > 2 caters for an edge case where the script description is a single line and the first
|
// 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.
|
// 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;
|
previousLine = line;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ namespace Filtration.ViewModels
|
||||||
bool IsDirty { get; set; }
|
bool IsDirty { get; set; }
|
||||||
bool IsExpanded { get; set; }
|
bool IsExpanded { get; set; }
|
||||||
ItemFilterBlock Block { get; }
|
ItemFilterBlock Block { get; }
|
||||||
|
bool BlockEnabled { get; set; }
|
||||||
void RefreshBlockPreview();
|
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
|
public string BlockDescription
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
@ -38,9 +38,13 @@ namespace Filtration.ViewModels
|
||||||
void Initialise(ItemFilterScript itemFilterScript, bool newScript);
|
void Initialise(ItemFilterScript itemFilterScript, bool newScript);
|
||||||
void RemoveDirtyFlag();
|
void RemoveDirtyFlag();
|
||||||
void SetDirtyFlag();
|
void SetDirtyFlag();
|
||||||
|
bool HasSelectedEnabledBlock();
|
||||||
|
bool HasSelectedDisabledBlock();
|
||||||
|
|
||||||
RelayCommand AddBlockCommand { get; }
|
RelayCommand AddBlockCommand { get; }
|
||||||
RelayCommand AddSectionCommand { get; }
|
RelayCommand AddSectionCommand { get; }
|
||||||
|
RelayCommand DisableBlockCommand { get; }
|
||||||
|
RelayCommand EnableBlockCommand { get; }
|
||||||
RelayCommand DeleteBlockCommand { get; }
|
RelayCommand DeleteBlockCommand { get; }
|
||||||
RelayCommand MoveBlockUpCommand { get; }
|
RelayCommand MoveBlockUpCommand { get; }
|
||||||
RelayCommand MoveBlockDownCommand { get; }
|
RelayCommand MoveBlockDownCommand { get; }
|
||||||
|
@ -104,6 +108,8 @@ namespace Filtration.ViewModels
|
||||||
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => SelectedBlockViewModel != null);
|
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => SelectedBlockViewModel != null);
|
||||||
AddBlockCommand = new RelayCommand(OnAddBlockCommand);
|
AddBlockCommand = new RelayCommand(OnAddBlockCommand);
|
||||||
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => SelectedBlockViewModel != null);
|
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => SelectedBlockViewModel != null);
|
||||||
|
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand, HasSelectedEnabledBlock);
|
||||||
|
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand, HasSelectedDisabledBlock);
|
||||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => SelectedBlockViewModel != null);
|
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => SelectedBlockViewModel != null);
|
||||||
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => SelectedBlockViewModel != null);
|
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => SelectedBlockViewModel != null);
|
||||||
PasteBlockCommand = new RelayCommand(OnPasteBlockCommand, () => SelectedBlockViewModel != null);
|
PasteBlockCommand = new RelayCommand(OnPasteBlockCommand, () => SelectedBlockViewModel != null);
|
||||||
|
@ -128,6 +134,8 @@ namespace Filtration.ViewModels
|
||||||
public RelayCommand MoveBlockToBottomCommand { get; private set; }
|
public RelayCommand MoveBlockToBottomCommand { get; private set; }
|
||||||
public RelayCommand AddBlockCommand { get; private set; }
|
public RelayCommand AddBlockCommand { get; private set; }
|
||||||
public RelayCommand AddSectionCommand { 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 CopyBlockCommand { get; private set; }
|
||||||
public RelayCommand CopyBlockStyleCommand { get; private set; }
|
public RelayCommand CopyBlockStyleCommand { get; private set; }
|
||||||
public RelayCommand PasteBlockCommand { get; private set; }
|
public RelayCommand PasteBlockCommand { get; private set; }
|
||||||
|
@ -215,6 +223,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
|
public IItemFilterBlockViewModel SelectedBlockViewModel
|
||||||
{
|
{
|
||||||
get { return _selectedBlockViewModel; }
|
get { return _selectedBlockViewModel; }
|
||||||
|
@ -767,5 +790,25 @@ namespace Filtration.ViewModels
|
||||||
}
|
}
|
||||||
SelectedBlockViewModel = null;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,10 @@ namespace Filtration.ViewModels
|
||||||
AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => _activeDocumentIsScript);
|
AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => _activeDocumentIsScript);
|
||||||
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => _activeDocumentIsScript);
|
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => _activeDocumentIsScript);
|
||||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
|
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand,
|
||||||
|
() => _activeDocumentIsScript && ActiveScriptHasSelectedEnabledBlock);
|
||||||
|
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand,
|
||||||
|
() => _activeDocumentIsScript && ActiveScriptHasSelectedDisabledBlock);
|
||||||
OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand);
|
OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand);
|
||||||
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => _activeDocumentIsScript);
|
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => _activeDocumentIsScript);
|
||||||
|
|
||||||
|
@ -198,6 +201,8 @@ namespace Filtration.ViewModels
|
||||||
public RelayCommand AddBlockCommand { get; private set; }
|
public RelayCommand AddBlockCommand { get; private set; }
|
||||||
public RelayCommand AddSectionCommand { get; private set; }
|
public RelayCommand AddSectionCommand { get; private set; }
|
||||||
public RelayCommand DeleteBlockCommand { 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 MoveBlockUpCommand { get; private set; }
|
||||||
public RelayCommand MoveBlockDownCommand { get; private set; }
|
public RelayCommand MoveBlockDownCommand { get; private set; }
|
||||||
|
@ -306,6 +311,16 @@ namespace Filtration.ViewModels
|
||||||
get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel != null; }
|
get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel != null; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ActiveScriptHasSelectedEnabledBlock
|
||||||
|
{
|
||||||
|
get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.HasSelectedEnabledBlock(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ActiveScriptHasSelectedDisabledBlock
|
||||||
|
{
|
||||||
|
get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.HasSelectedDisabledBlock(); }
|
||||||
|
}
|
||||||
|
|
||||||
public bool ActiveThemeIsEditable
|
public bool ActiveThemeIsEditable
|
||||||
{
|
{
|
||||||
get { return AvalonDockWorkspaceViewModel.ActiveThemeViewModel.IsMasterTheme; }
|
get { return AvalonDockWorkspaceViewModel.ActiveThemeViewModel.IsMasterTheme; }
|
||||||
|
@ -580,6 +595,16 @@ namespace Filtration.ViewModels
|
||||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.DeleteBlockCommand.Execute(null);
|
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.DeleteBlockCommand.Execute(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDisableBlockCommand()
|
||||||
|
{
|
||||||
|
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.DisableBlockCommand.Execute(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEnableBlockCommand()
|
||||||
|
{
|
||||||
|
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.EnableBlockCommand.Execute(null);
|
||||||
|
}
|
||||||
|
|
||||||
private void OnExpandAllBlocksCommand()
|
private void OnExpandAllBlocksCommand()
|
||||||
{
|
{
|
||||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.ExpandAllBlocksCommand.Execute(null);
|
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.ExpandAllBlocksCommand.Execute(null);
|
||||||
|
|
|
@ -31,4 +31,6 @@
|
||||||
<Image Source="/Filtration;component/Resources/Icons/filtration_icon.png" x:Key="FiltrationIcon" 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/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/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>
|
</ResourceDictionary>
|
|
@ -41,6 +41,11 @@
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Grid x:Name="TopLevelGrid">
|
<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">
|
<Border BorderThickness="1" BorderBrush="SlateGray" CornerRadius="2" Background="White">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
|
@ -62,8 +67,8 @@
|
||||||
<Expander.ContextMenu>
|
<Expander.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<ContextMenu.Items>
|
<ContextMenu.Items>
|
||||||
<MenuItem Header="Copy" Command="{Binding CopyBlockCommand}" Icon="{StaticResource CopyIcon}" />
|
<MenuItem Header="Copy Block" Command="{Binding CopyBlockCommand}" Icon="{StaticResource CopyIcon}" />
|
||||||
<MenuItem Header="Paste" Command="{Binding PasteBlockCommand}" Icon="{StaticResource PasteIcon}" />
|
<MenuItem Header="Paste Block" Command="{Binding PasteBlockCommand}" Icon="{StaticResource PasteIcon}" />
|
||||||
<Separator />
|
<Separator />
|
||||||
<MenuItem Header="Block Style">
|
<MenuItem Header="Block Style">
|
||||||
<MenuItem Header="Copy Block Style" Command="{Binding CopyBlockStyleCommand}" Icon="{StaticResource CopyIcon}" />
|
<MenuItem Header="Copy Block Style" Command="{Binding CopyBlockStyleCommand}" Icon="{StaticResource CopyIcon}" />
|
||||||
|
@ -89,6 +94,7 @@
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<!-- BlockItems Summary Panel -->
|
<!-- BlockItems Summary Panel -->
|
||||||
<StackPanel Grid.Row="0" Grid.Column="0" VerticalAlignment="Center">
|
<StackPanel Grid.Row="0" Grid.Column="0" VerticalAlignment="Center">
|
||||||
|
@ -123,7 +129,7 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Item Preview Box -->
|
<!-- 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}"
|
<Button Command="{Binding PlaySoundCommand}"
|
||||||
Width="25"
|
Width="25"
|
||||||
Height="25"
|
Height="25"
|
||||||
|
@ -160,6 +166,10 @@
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
<TextBlock Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Right">
|
<TextBlock Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Right">
|
||||||
<Hyperlink Command="{Binding SwitchBlockItemsViewCommand}">
|
<Hyperlink Command="{Binding SwitchBlockItemsViewCommand}">
|
||||||
Switch to Appearance Block Items
|
Switch to Appearance Block Items
|
||||||
|
@ -167,7 +177,7 @@
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
|
|
||||||
<!-- Add Block Item Links -->
|
<!-- 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>
|
<ItemsControl.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<WrapPanel></WrapPanel>
|
<WrapPanel></WrapPanel>
|
||||||
|
@ -184,8 +194,34 @@
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
</ItemsControl>
|
</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 -->
|
<!-- Block Items -->
|
||||||
<WrapPanel Grid.Row="1" MaxHeight="200">
|
<WrapPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" MaxHeight="200">
|
||||||
<WrapPanel.Resources>
|
<WrapPanel.Resources>
|
||||||
<CollectionViewSource Source="{Binding RegularBlockItems}" x:Key="BlockItemsCollectionViewSource">
|
<CollectionViewSource Source="{Binding RegularBlockItems}" x:Key="BlockItemsCollectionViewSource">
|
||||||
<CollectionViewSource.SortDescriptions>
|
<CollectionViewSource.SortDescriptions>
|
||||||
|
|
|
@ -85,6 +85,8 @@
|
||||||
<fluent:Button Header="Move Up" Command="{Binding MoveBlockUpCommand}" SizeDefinition="Middle" Icon="{StaticResource MoveUpIcon}" />
|
<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 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="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>
|
||||||
<fluent:RibbonGroupBox Header="Expand / Collapse">
|
<fluent:RibbonGroupBox Header="Expand / Collapse">
|
||||||
<fluent:Button Header="Expand All" Command="{Binding ExpandAllBlocksCommand}" SizeDefinition="Middle" Icon="{StaticResource ExpandIcon}" />
|
<fluent:Button Header="Expand All" Command="{Binding ExpandAllBlocksCommand}" SizeDefinition="Middle" Icon="{StaticResource ExpandIcon}" />
|
||||||
|
|
Loading…
Reference in New Issue