Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e80295cb69 | ||
|
|
f3ed386845 | ||
|
|
89e0c717e8 | ||
|
|
8924637b98 | ||
|
|
b0b912c676 | ||
|
|
92ebc51e7b | ||
|
|
95e7581a5b | ||
|
|
9cb854b584 | ||
|
|
61c2902f0c | ||
|
|
dc157713f3 | ||
|
|
16fe837544 | ||
|
|
58de6f06b9 | ||
|
|
af2dace29a | ||
|
|
59cf604430 | ||
|
|
93a51e7829 | ||
|
|
9d928a374a | ||
|
|
b5788504cb | ||
|
|
6e71005e93 | ||
|
|
56e163e3e0 | ||
|
|
c856bbcee7 | ||
|
|
490496f2f7 | ||
|
|
9fcb609a51 |
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
@@ -1264,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()
|
||||
{
|
||||
|
||||
@@ -253,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()
|
||||
|
||||
@@ -21,15 +21,8 @@
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.Resources>
|
||||
<DataTemplate x:Key="EditableComponentNameTemplate">
|
||||
<TextBox Text="{Binding ComponentName}" />
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="ViewOnlyComponentNameTemplate">
|
||||
<TextBlock Text="{Binding ComponentName}" ToolTip="{Binding ComponentName}" />
|
||||
</DataTemplate>
|
||||
</Grid.Resources>
|
||||
<DockPanel LastChildFill="True">
|
||||
<TextBlock DockPanel.Dock="Left"
|
||||
Text="{Binding UsageCount, StringFormat='Usages: {0}'}"
|
||||
<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}}">
|
||||
@@ -44,7 +37,13 @@
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
</DockPanel>
|
||||
<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">
|
||||
@@ -59,7 +58,6 @@
|
||||
</Style>
|
||||
</ContentControl.Style>
|
||||
</ContentControl>
|
||||
|
||||
<xctk:ColorPicker Grid.Row="2" SelectedColor="{Binding Color}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -17,7 +17,7 @@ using NLog;
|
||||
|
||||
namespace Filtration
|
||||
{
|
||||
public partial class App
|
||||
public partial class App : Application
|
||||
{
|
||||
private IWindsorContainer _container;
|
||||
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
@@ -429,6 +429,8 @@
|
||||
<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>
|
||||
|
||||
@@ -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.9.*")]
|
||||
|
||||
[assembly: InternalsVisibleTo("Filtration.Tests")]
|
||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
||||
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 |
@@ -8,7 +8,6 @@ Claws
|
||||
Daggers
|
||||
Wands
|
||||
One Hand Swords
|
||||
Thrusting One Hand Swords
|
||||
One Hand Axes
|
||||
One Hand Maces
|
||||
Bows
|
||||
@@ -25,7 +24,6 @@ Boots
|
||||
Body Armours
|
||||
Helmets
|
||||
Shields
|
||||
Stackable Currency
|
||||
Quest Items
|
||||
Sceptres
|
||||
Utility Flasks
|
||||
@@ -35,3 +33,4 @@ Map Fragments
|
||||
Hideout Doodads
|
||||
Microtransactions
|
||||
Divination Card
|
||||
Jewel
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace Filtration.Translators
|
||||
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
|
||||
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)
|
||||
@@ -42,6 +43,7 @@ namespace Filtration.Translators
|
||||
_masterComponentCollection = masterComponentCollection;
|
||||
var block = new ItemFilterBlock();
|
||||
var showHideFound = false;
|
||||
|
||||
foreach (var line in new LineReader(() => new StringReader(inputString)))
|
||||
{
|
||||
|
||||
@@ -62,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);
|
||||
@@ -70,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":
|
||||
@@ -399,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)
|
||||
{
|
||||
@@ -416,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Documents;
|
||||
using Castle.Core.Internal;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.Properties;
|
||||
@@ -28,12 +29,77 @@ namespace Filtration.Translators
|
||||
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
var script = new ItemFilterScript();
|
||||
_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");
|
||||
@@ -85,7 +151,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;
|
||||
}
|
||||
|
||||
@@ -171,6 +171,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)
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,9 +38,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; }
|
||||
@@ -104,6 +108,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);
|
||||
@@ -128,6 +134,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; }
|
||||
@@ -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
|
||||
{
|
||||
get { return _selectedBlockViewModel; }
|
||||
@@ -467,7 +490,7 @@ 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)
|
||||
{
|
||||
@@ -767,5 +790,25 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
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,6 +1,7 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
@@ -33,6 +34,7 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
RelayCommand OpenScriptCommand { get; }
|
||||
RelayCommand NewScriptCommand { get; }
|
||||
bool CloseAllDocuments();
|
||||
}
|
||||
|
||||
internal class MainWindowViewModel : FiltrationViewModelBase, IMainWindowViewModel
|
||||
@@ -49,8 +51,6 @@ namespace Filtration.ViewModels
|
||||
private readonly IUpdateCheckService _updateCheckService;
|
||||
private readonly IUpdateAvailableViewModel _updateAvailableViewModel;
|
||||
private readonly IMessageBoxService _messageBoxService;
|
||||
private bool _activeDocumentIsScript;
|
||||
private bool _activeDocumentIsTheme;
|
||||
|
||||
public MainWindowViewModel(IItemFilterScriptRepository itemFilterScriptRepository,
|
||||
IItemFilterScriptTranslator itemFilterScriptTranslator,
|
||||
@@ -75,48 +75,51 @@ namespace Filtration.ViewModels
|
||||
_messageBoxService = messageBoxService;
|
||||
|
||||
NewScriptCommand = new RelayCommand(OnNewScriptCommand);
|
||||
CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => _activeDocumentIsScript);
|
||||
CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => ActiveDocumentIsScript);
|
||||
OpenScriptCommand = new RelayCommand(OnOpenScriptCommand);
|
||||
OpenThemeCommand = new RelayCommand(OnOpenThemeCommand);
|
||||
|
||||
SaveCommand = new RelayCommand(OnSaveDocumentCommand, ActiveDocumentIsEditable);
|
||||
SaveAsCommand = new RelayCommand(OnSaveAsCommand, ActiveDocumentIsEditable);
|
||||
CloseCommand = new RelayCommand(OnCloseDocumentCommand, () => AvalonDockWorkspaceViewModel.ActiveDocument != null);
|
||||
CloseCommand = new RelayCommand(OnCloseDocumentCommand, ActiveDocumentIsEditable);
|
||||
|
||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
PasteCommand = new RelayCommand(OnPasteCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
PasteCommand = new RelayCommand(OnPasteCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
|
||||
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
|
||||
AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => _activeDocumentIsScript);
|
||||
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => _activeDocumentIsScript);
|
||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
|
||||
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);
|
||||
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
CreateThemeCommand = new RelayCommand(OnCreateThemeCommand, () => _activeDocumentIsScript);
|
||||
ApplyThemeToScriptCommand = new RelayCommand(OnApplyThemeToScriptCommand, () => _activeDocumentIsScript);
|
||||
EditMasterThemeCommand = new RelayCommand(OnEditMasterThemeCommand, () => _activeDocumentIsScript);
|
||||
CreateThemeCommand = new RelayCommand(OnCreateThemeCommand, () => ActiveDocumentIsScript);
|
||||
ApplyThemeToScriptCommand = new RelayCommand(OnApplyThemeToScriptCommand, () => ActiveDocumentIsScript);
|
||||
EditMasterThemeCommand = new RelayCommand(OnEditMasterThemeCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => _activeDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => _activeDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => _activeDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||
DeleteThemeComponentCommand = new RelayCommand(OnDeleteThemeComponentCommand,
|
||||
() =>
|
||||
ActiveDocumentIsTheme && _activeDocumentIsTheme &&
|
||||
ActiveDocumentIsTheme && ActiveThemeIsEditable &&
|
||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent != null);
|
||||
|
||||
ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => _activeDocumentIsScript);
|
||||
CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => _activeDocumentIsScript);
|
||||
ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript);
|
||||
CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand, s => _activeDocumentIsScript);
|
||||
ClearFiltersCommand = new RelayCommand(OnClearFiltersCommand, () => _activeDocumentIsScript);
|
||||
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand, s => ActiveDocumentIsScript);
|
||||
ClearFiltersCommand = new RelayCommand(OnClearFiltersCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
if (string.IsNullOrEmpty(_itemFilterScriptRepository.GetItemFilterScriptDirectory()))
|
||||
{
|
||||
@@ -151,7 +154,8 @@ namespace Filtration.ViewModels
|
||||
ApplyThemeToScriptCommand.RaiseCanExecuteChanged();
|
||||
EditMasterThemeCommand.RaiseCanExecuteChanged();
|
||||
CreateThemeCommand.RaiseCanExecuteChanged();
|
||||
SetActiveDocumentStatusProperties();
|
||||
RaisePropertyChanged("ActiveDocumentIsScript");
|
||||
RaisePropertyChanged("ActiveDocumentIsTheme");
|
||||
RaisePropertyChanged("ShowAdvancedStatus");
|
||||
break;
|
||||
}
|
||||
@@ -168,8 +172,6 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
});
|
||||
CheckForUpdates();
|
||||
ActiveDocumentIsScript = false;
|
||||
ActiveDocumentIsTheme = false;
|
||||
}
|
||||
|
||||
public RelayCommand OpenScriptCommand { get; private set; }
|
||||
@@ -198,6 +200,8 @@ namespace Filtration.ViewModels
|
||||
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; }
|
||||
@@ -215,10 +219,10 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
var assemblyVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
|
||||
|
||||
var result = await _updateCheckService.GetUpdateData();
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _updateCheckService.GetUpdateData();
|
||||
|
||||
if (result.LatestVersionMajorPart >= assemblyVersion.FileMajorPart &&
|
||||
result.LatestVersionMinorPart > assemblyVersion.FileMinorPart)
|
||||
{
|
||||
@@ -275,30 +279,14 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private void SetActiveDocumentStatusProperties()
|
||||
{
|
||||
ActiveDocumentIsScript = AvalonDockWorkspaceViewModel.ActiveDocument is ItemFilterScriptViewModel;
|
||||
ActiveDocumentIsTheme = AvalonDockWorkspaceViewModel.ActiveDocument is ThemeEditorViewModel;
|
||||
}
|
||||
|
||||
public bool ActiveDocumentIsScript
|
||||
{
|
||||
get { return _activeDocumentIsScript; }
|
||||
private set
|
||||
{
|
||||
_activeDocumentIsScript = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
get { return _avalonDockWorkspaceViewModel.ActiveDocument != null && _avalonDockWorkspaceViewModel.ActiveDocument.IsScript; }
|
||||
}
|
||||
|
||||
public bool ActiveDocumentIsTheme
|
||||
{
|
||||
get { return _activeDocumentIsTheme; }
|
||||
private set
|
||||
{
|
||||
_activeDocumentIsTheme = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
get { return _avalonDockWorkspaceViewModel.ActiveDocument!= null && _avalonDockWorkspaceViewModel.ActiveDocument.IsTheme; }
|
||||
}
|
||||
|
||||
public bool ActiveScriptHasSelectedBlock
|
||||
@@ -306,6 +294,16 @@ namespace Filtration.ViewModels
|
||||
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
|
||||
{
|
||||
get { return AvalonDockWorkspaceViewModel.ActiveThemeViewModel.IsMasterTheme; }
|
||||
@@ -580,6 +578,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);
|
||||
@@ -620,5 +628,22 @@ namespace Filtration.ViewModels
|
||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.DeleteThemeComponentCommand.Execute(
|
||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent);
|
||||
}
|
||||
|
||||
public bool CloseAllDocuments()
|
||||
{
|
||||
var openDocuments = _avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().ToList();
|
||||
|
||||
foreach (var document in openDocuments)
|
||||
{
|
||||
var docCount = _avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().Count();
|
||||
document.Close();
|
||||
if (_avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().Count() == docCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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/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>
|
||||
@@ -41,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>
|
||||
@@ -62,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}" />
|
||||
@@ -89,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">
|
||||
@@ -123,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"
|
||||
@@ -160,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
|
||||
@@ -167,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>
|
||||
@@ -184,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>
|
||||
@@ -236,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>
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
xmlns:views="clr-namespace:Filtration.Views"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=viewModels:MainWindowViewModel}"
|
||||
Title="{Binding WindowTitle}" Height="762" Width="1126" IsIconVisible="True" >
|
||||
Title="{Binding WindowTitle}" Height="762" Width="1126" IsIconVisible="True"
|
||||
Closing="MainWindow_OnClosing">
|
||||
<fluent:RibbonWindow.InputBindings>
|
||||
<KeyBinding Command="{Binding SaveCommand}" Modifiers="Control" Key="S" />
|
||||
<KeyBinding Command="{Binding OpenScriptCommand}" Modifiers="Control" Key="O" />
|
||||
@@ -85,6 +86,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}" />
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using System.Windows;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using Filtration.Annotations;
|
||||
using Filtration.ViewModels;
|
||||
|
||||
namespace Filtration.Views
|
||||
@@ -10,8 +13,11 @@ namespace Filtration.Views
|
||||
|
||||
internal partial class MainWindow : IMainWindow
|
||||
{
|
||||
private IMainWindowViewModel _mainWindowViewModel;
|
||||
|
||||
public MainWindow(IMainWindowViewModel mainWindowViewModel)
|
||||
{
|
||||
_mainWindowViewModel = mainWindowViewModel;
|
||||
InitializeComponent();
|
||||
DataContext = mainWindowViewModel;
|
||||
}
|
||||
@@ -31,5 +37,15 @@ namespace Filtration.Views
|
||||
RibbonRoot.SelectedTabItem = ThemeToolsTabItem;
|
||||
}
|
||||
}
|
||||
|
||||
private void MainWindow_OnClosing(object sender, CancelEventArgs e)
|
||||
{
|
||||
var allDocumentsClosed = _mainWindowViewModel.CloseAllDocuments();
|
||||
|
||||
if (!allDocumentsClosed)
|
||||
{
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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-10)
|
||||
<b>Installer (6.31mb)</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.8/filtration_0.8_setup.exe">filtration_0.8_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.9mb)</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.8/filtration_0.8.zip">filtration_0.8.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