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()
{
_newItemFilterBlock = new ItemFilterCommentBlock(_itemFilterScript);
_newItemFilterBlock = new ItemFilterCommentBlock(_itemFilterScript)
{
Comment = string.Empty
};
if (_addAfterItemFilterBlock != null)
{
_itemFilterScript.ItemFilterBlocks.Insert(_itemFilterScript.ItemFilterBlocks.IndexOf(_addAfterItemFilterBlock) + 1, _newItemFilterBlock);

View File

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

View File

@ -1,6 +1,7 @@
using System;
using Filtration.ObjectModel;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.CommandWpf;
namespace Filtration.ViewModels
{
@ -16,14 +17,40 @@ namespace Filtration.ViewModels
{
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)
{
BaseBlock = itemfilterBlock;
_parentScriptViewModel = itemFilterScriptViewModel;
}
public event EventHandler BlockBecameDirty;
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
{
@ -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
{
public ItemFilterCommentBlockViewModel()
{
}
public override void Initialise(IItemFilterBlockBase itemfilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel)
{
_parentScriptViewModel = itemFilterScriptViewModel;
ItemFilterCommentBlock = itemfilterBlock as IItemFilterCommentBlock;
BaseBlock = ItemFilterCommentBlock;
@ -24,6 +21,21 @@ namespace Filtration.ViewModels
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:d="http://schemas.microsoft.com/expression/blend/2008"
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}"
mc:Ignorable="d"
d:DesignHeight="50" d:DesignWidth="300">
<UserControl.Resources>
<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>
<views:BindingProxy x:Key="Proxy" Data="{Binding}" />
<converters:BlockGroupAdvancedFillColorConverter x:Key="BlockGroupAdvancedFillColorConverter" />
<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>
<Grid>
<Grid.ContextMenu>
@ -45,7 +76,7 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</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>
</Border>
</Grid>