Merge pull request #51 from GlenCFL/fixes

0.16 Regression Fixing
This commit is contained in:
Ben Wallis 2017-12-08 17:57:13 +00:00 committed by GitHub
commit 404a04c210
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 209 additions and 110 deletions

View File

@ -15,7 +15,10 @@ namespace Filtration.ObjectModel.Commands.ItemFilterScript
} }
public void Execute() public void Execute()
{ {
_newItemFilterBlock = new ItemFilterCommentBlock(_itemFilterScript); _newItemFilterBlock = new ItemFilterCommentBlock(_itemFilterScript)
{
Comment = string.Empty
};
if (_addAfterItemFilterBlock != null) if (_addAfterItemFilterBlock != null)
{ {
_itemFilterScript.ItemFilterBlocks.Insert(_itemFilterScript.ItemFilterBlocks.IndexOf(_addAfterItemFilterBlock) + 1, _newItemFilterBlock); _itemFilterScript.ItemFilterBlocks.Insert(_itemFilterScript.ItemFilterBlocks.IndexOf(_addAfterItemFilterBlock) + 1, _newItemFilterBlock);

View File

@ -28,7 +28,6 @@ namespace Filtration.ViewModels
private readonly IStaticDataService _staticDataService; private readonly IStaticDataService _staticDataService;
private readonly IReplaceColorsViewModel _replaceColorsViewModel; private readonly IReplaceColorsViewModel _replaceColorsViewModel;
private readonly MediaPlayer _mediaPlayer = new MediaPlayer(); private readonly MediaPlayer _mediaPlayer = new MediaPlayer();
private IItemFilterScriptViewModel _parentScriptViewModel;
private bool _displaySettingsPopupOpen; private bool _displaySettingsPopupOpen;
private bool _isExpanded; private bool _isExpanded;
@ -39,17 +38,8 @@ namespace Filtration.ViewModels
_staticDataService = staticDataService; _staticDataService = staticDataService;
_replaceColorsViewModel = replaceColorsViewModel; _replaceColorsViewModel = replaceColorsViewModel;
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand);
PasteBlockCommand = new RelayCommand(OnPasteBlockCommand);
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand); CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand);
PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand); PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand);
AddBlockCommand = new RelayCommand(OnAddBlockCommand);
AddSectionCommand = new RelayCommand(OnAddSectionCommand);
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand);
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand);
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand);
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand);
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand);
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand); ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand);
AddFilterBlockItemCommand = new RelayCommand<Type>(OnAddFilterBlockItemCommand); AddFilterBlockItemCommand = new RelayCommand<Type>(OnAddFilterBlockItemCommand);
ToggleBlockActionCommand = new RelayCommand(OnToggleBlockActionCommand); ToggleBlockActionCommand = new RelayCommand(OnToggleBlockActionCommand);
@ -82,17 +72,8 @@ namespace Filtration.ViewModels
base.Initialise(itemFilterBlock, parentScriptViewModel); base.Initialise(itemFilterBlock, parentScriptViewModel);
} }
public RelayCommand CopyBlockCommand { get; }
public RelayCommand PasteBlockCommand { get; }
public RelayCommand CopyBlockStyleCommand { get; } public RelayCommand CopyBlockStyleCommand { get; }
public RelayCommand PasteBlockStyleCommand { get; } public RelayCommand PasteBlockStyleCommand { get; }
public RelayCommand AddBlockCommand { get; }
public RelayCommand AddSectionCommand { get; }
public RelayCommand DeleteBlockCommand { get; }
public RelayCommand MoveBlockUpCommand { get; }
public RelayCommand MoveBlockDownCommand { get; }
public RelayCommand MoveBlockToTopCommand { get; }
public RelayCommand MoveBlockToBottomCommand { get; }
public RelayCommand ToggleBlockActionCommand { get; } public RelayCommand ToggleBlockActionCommand { get; }
public RelayCommand ReplaceColorsCommand { get; } public RelayCommand ReplaceColorsCommand { get; }
public RelayCommand<Type> AddFilterBlockItemCommand { get; } public RelayCommand<Type> AddFilterBlockItemCommand { get; }
@ -231,7 +212,7 @@ namespace Filtration.ViewModels
public bool HasSound => Block.HasBlockItemOfType<SoundBlockItem>(); public bool HasSound => Block.HasBlockItemOfType<SoundBlockItem>();
public bool HasPositionalSound => Block.HasBlockItemOfType<PositionalSoundBlockItem>(); public bool HasPositionalSound => Block.HasBlockItemOfType<PositionalSoundBlockItem>();
public bool HasAudioVisualBlockItems => AudioVisualBlockItems.Any(); public bool HasAudioVisualBlockItems => AudioVisualBlockItems.Any();
private void OnSwitchBlockItemsViewCommand() private void OnSwitchBlockItemsViewCommand()
@ -338,63 +319,63 @@ namespace Filtration.ViewModels
return blockCount < blockItem.MaximumAllowed; return blockCount < blockItem.MaximumAllowed;
} }
private string ComputeFilePartFromNumber(string identifier) private string ComputeFilePartFromNumber(string identifier)
{ {
if (Int32.TryParse(identifier, out int x)) if (Int32.TryParse(identifier, out int x))
{ {
if (x <= 9) if (x <= 9)
{ {
return "AlertSound_0" + x + ".wav"; return "AlertSound_0" + x + ".wav";
} }
else else
{ {
return "AlertSound_" + x + ".wav"; return "AlertSound_" + x + ".wav";
} }
} }
return ""; return "";
} }
private string ComputeFilePartFromID(string identifier) private string ComputeFilePartFromID(string identifier)
{ {
string filePart; string filePart;
switch (identifier) { switch (identifier) {
case "ShGeneral": case "ShGeneral":
filePart = "SH22General.wav"; filePart = "SH22General.wav";
break; break;
case "ShBlessed": case "ShBlessed":
filePart = "SH22Blessed.wav"; filePart = "SH22Blessed.wav";
break; break;
case "SH22Chaos": case "ShChaos":
filePart = "SH22Chaos.wav"; filePart = "SH22Chaos.wav";
break; break;
case "ShDivine": case "ShDivine":
filePart = "SH22Divine.wav"; filePart = "SH22Divine.wav";
break; break;
case "ShExalted": case "ShExalted":
filePart = "SH22Exalted.wav"; filePart = "SH22Exalted.wav";
break; break;
case "ShMirror": case "ShMirror":
filePart = "SH22Mirror.wav"; filePart = "SH22Mirror.wav";
break; break;
case "ShAlchemy": case "ShAlchemy":
filePart = "SH22Alchemy.wav"; filePart = "SH22Alchemy.wav";
break; break;
case "ShFusing": case "ShFusing":
filePart = "SH22Fusing.wav"; filePart = "SH22Fusing.wav";
break; break;
case "ShRegal": case "ShRegal":
filePart = "SH22Regal.wav"; filePart = "SH22Regal.wav";
break; break;
case "ShVaal": case "ShVaal":
filePart = "SH22Vaal.wav"; filePart = "SH22Vaal.wav";
break; break;
default: default:
filePart = ComputeFilePartFromNumber(identifier); filePart = ComputeFilePartFromNumber(identifier);
break; break;
} }
return filePart; return filePart;
} }
private void OnPlaySoundCommand() private void OnPlaySoundCommand()
@ -403,32 +384,32 @@ namespace Filtration.ViewModels
var prefix = "Resources/AlertSounds/"; var prefix = "Resources/AlertSounds/";
var filePart = ComputeFilePartFromID(identifier); var filePart = ComputeFilePartFromID(identifier);
if (filePart == "") if (filePart == "")
{ {
return; return;
} }
else else
{ {
_mediaPlayer.Open(new Uri(prefix + filePart, UriKind.Relative)); _mediaPlayer.Open(new Uri(prefix + filePart, UriKind.Relative));
_mediaPlayer.Play(); _mediaPlayer.Play();
} }
} }
private void OnPlayPositionalSoundCommand() private void OnPlayPositionalSoundCommand()
{ {
var identifier = BlockItems.OfType<PositionalSoundBlockItem>().First().Value; var identifier = BlockItems.OfType<PositionalSoundBlockItem>().First().Value;
var prefix = "Resources/AlertSounds/"; var prefix = "Resources/AlertSounds/";
var filePart = ComputeFilePartFromID(identifier); var filePart = ComputeFilePartFromID(identifier);
if (filePart == "") if (filePart == "")
{ {
return; return;
} }
else else
{ {
_mediaPlayer.Open(new Uri(prefix + filePart, UriKind.Relative)); _mediaPlayer.Open(new Uri(prefix + filePart, UriKind.Relative));
_mediaPlayer.Play(); _mediaPlayer.Play();
} }
} }
private void OnBlockItemChanged(object sender, EventArgs e) private void OnBlockItemChanged(object sender, EventArgs e)

View File

@ -1,6 +1,7 @@
using System; using System;
using Filtration.ObjectModel; using Filtration.ObjectModel;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.CommandWpf;
namespace Filtration.ViewModels namespace Filtration.ViewModels
{ {
@ -16,14 +17,40 @@ namespace Filtration.ViewModels
{ {
private bool _isDirty; private bool _isDirty;
public ItemFilterBlockViewModelBase()
{
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand);
PasteBlockCommand = new RelayCommand(OnPasteBlockCommand);
AddBlockCommand = new RelayCommand(OnAddBlockCommand);
AddSectionCommand = new RelayCommand(OnAddSectionCommand);
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand);
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand);
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand);
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand);
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand);
}
public virtual void Initialise(IItemFilterBlockBase itemfilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel) public virtual void Initialise(IItemFilterBlockBase itemfilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel)
{ {
BaseBlock = itemfilterBlock; BaseBlock = itemfilterBlock;
_parentScriptViewModel = itemFilterScriptViewModel;
} }
public event EventHandler BlockBecameDirty; public event EventHandler BlockBecameDirty;
public IItemFilterBlockBase BaseBlock { get; protected set; } public IItemFilterBlockBase BaseBlock { get; protected set; }
public IItemFilterScriptViewModel _parentScriptViewModel;
public RelayCommand CopyBlockCommand { get; }
public RelayCommand PasteBlockCommand { get; }
public RelayCommand AddBlockCommand { get; }
public RelayCommand AddSectionCommand { get; }
public RelayCommand DeleteBlockCommand { get; }
public RelayCommand MoveBlockUpCommand { get; }
public RelayCommand MoveBlockDownCommand { get; }
public RelayCommand MoveBlockToTopCommand { get; }
public RelayCommand MoveBlockToBottomCommand { get; }
public bool IsDirty public bool IsDirty
{ {
@ -38,5 +65,50 @@ namespace Filtration.ViewModels
} }
} }
} }
private void OnCopyBlockCommand()
{
_parentScriptViewModel.CopyBlock(this);
}
private void OnPasteBlockCommand()
{
_parentScriptViewModel.PasteBlock(this);
}
private void OnAddBlockCommand()
{
_parentScriptViewModel.AddBlock(this);
}
private void OnAddSectionCommand()
{
_parentScriptViewModel.AddCommentBlock(this);
}
private void OnDeleteBlockCommand()
{
_parentScriptViewModel.DeleteBlock(this);
}
private void OnMoveBlockUpCommand()
{
_parentScriptViewModel.MoveBlockUp(this);
}
private void OnMoveBlockDownCommand()
{
_parentScriptViewModel.MoveBlockDown(this);
}
private void OnMoveBlockToTopCommand()
{
_parentScriptViewModel.MoveBlockToTop(this);
}
private void OnMoveBlockToBottomCommand()
{
_parentScriptViewModel.MoveBlockToBottom(this);
}
} }
} }

View File

@ -10,12 +10,9 @@ namespace Filtration.ViewModels
internal class ItemFilterCommentBlockViewModel : ItemFilterBlockViewModelBase, IItemFilterCommentBlockViewModel internal class ItemFilterCommentBlockViewModel : ItemFilterBlockViewModelBase, IItemFilterCommentBlockViewModel
{ {
public ItemFilterCommentBlockViewModel()
{
}
public override void Initialise(IItemFilterBlockBase itemfilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel) public override void Initialise(IItemFilterBlockBase itemfilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel)
{ {
_parentScriptViewModel = itemFilterScriptViewModel;
ItemFilterCommentBlock = itemfilterBlock as IItemFilterCommentBlock; ItemFilterCommentBlock = itemfilterBlock as IItemFilterCommentBlock;
BaseBlock = ItemFilterCommentBlock; BaseBlock = ItemFilterCommentBlock;
@ -24,6 +21,21 @@ namespace Filtration.ViewModels
public IItemFilterCommentBlock ItemFilterCommentBlock { get; private set; } public IItemFilterCommentBlock ItemFilterCommentBlock { get; private set; }
public string Comment => ItemFilterCommentBlock.Comment; public string Comment
{
get
{
return ItemFilterCommentBlock.Comment;
}
set
{
if (ItemFilterCommentBlock.Comment != value)
{
ItemFilterCommentBlock.Comment = value;
IsDirty = true;
RaisePropertyChanged();
}
}
}
} }
} }

View File

@ -4,16 +4,47 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:viewModels="clr-namespace:Filtration.ViewModels" xmlns:viewModels="clr-namespace:Filtration.ViewModels"
xmlns:views="clr-namespace:Filtration.Views"
xmlns:converters="clr-namespace:Filtration.Converters"
d:DataContext="{d:DesignInstance Type=viewModels:ItemFilterCommentBlockViewModel}" d:DataContext="{d:DesignInstance Type=viewModels:ItemFilterCommentBlockViewModel}"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="50" d:DesignWidth="300"> d:DesignHeight="50" d:DesignWidth="300">
<UserControl.Resources> <UserControl.Resources>
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MetroTextBox}"> <ResourceDictionary>
<Style.Setters> <ResourceDictionary.MergedDictionaries>
<Setter Property="BorderBrush" Value="Transparent" /> <ResourceDictionary>
<Setter Property="Background" Value="Transparent" /> <views:BindingProxy x:Key="Proxy" Data="{Binding}" />
</Style.Setters> <converters:BlockGroupAdvancedFillColorConverter x:Key="BlockGroupAdvancedFillColorConverter" />
</Style> <Style TargetType="{x:Type ContentPresenter}" x:Key="BlockItemFadeInStyle">
<Setter Property="LayoutTransform">
<Setter.Value>
<ScaleTransform x:Name="transform" />
</Setter.Value>
</Setter>
<Style.Triggers>
<EventTrigger RoutedEvent="Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
<ResourceDictionary>
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MetroTextBox}">
<Style.Setters>
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Background" Value="Transparent" />
</Style.Setters>
</Style>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
<Grid> <Grid>
<Grid.ContextMenu> <Grid.ContextMenu>
@ -45,7 +76,7 @@
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBox Grid.Column ="0" Text="{Binding Comment, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}" VerticalAlignment="Center" TextWrapping="Wrap" MinWidth="150"/> <TextBox Grid.Column ="0" Text="{Binding Comment, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" VerticalAlignment="Center" TextWrapping="Wrap" MinWidth="150"/>
</Grid> </Grid>
</Border> </Border>
</Grid> </Grid>