Fixed another copy paste bug, changed speaker icon to button

This commit is contained in:
Ben 2015-07-04 17:28:34 +01:00
parent 0c470b3c97
commit 3337531161
14 changed files with 119 additions and 45 deletions

View File

@ -49,11 +49,13 @@
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@ -64,6 +66,7 @@
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\FileSystemService.cs" />
<Compile Include="Services\MessageBoxService.cs" />
<Compile Include="ViewModels\FiltrationViewModelBase.cs" />
<Compile Include="ViewModels\PaneViewModel.cs" />
<Compile Include="WindsorInstallers\ServicesInstaller.cs" />

View File

@ -0,0 +1,17 @@
using System.Windows;
namespace Filtration.Common.Services
{
public interface IMessageBoxService
{
MessageBoxResult Show(string caption, string message, MessageBoxButton buttons, MessageBoxImage image);
}
public class MessageBoxService : IMessageBoxService
{
public MessageBoxResult Show(string caption, string message, MessageBoxButton buttons, MessageBoxImage image)
{
return MessageBox.Show(message, caption, buttons, image);
}
}
}

View File

@ -13,6 +13,11 @@ namespace Filtration.Common.WindsorInstallers
Component.For<IFileSystemService>()
.ImplementedBy<FileSystemService>()
.LifeStyle.Singleton);
container.Register(
Component.For<IMessageBoxService>()
.ImplementedBy<MessageBoxService>()
.LifeStyle.Singleton);
}
}
}

View File

@ -55,6 +55,10 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Filtration.Common\Filtration.Common.csproj">
<Project>{8cb44f28-2956-4c2a-9314-72727262edd4}</Project>
<Name>Filtration.Common</Name>
</ProjectReference>
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
<Project>{4aac3beb-1dc1-483e-9d11-0e9334e80227}</Project>
<Name>Filtration.ObjectModel</Name>

View File

@ -1,9 +1,11 @@
using System.Windows.Media;
using Filtration.Common.Services;
using Filtration.ObjectModel;
using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.ThemeEditor;
using Filtration.ThemeEditor.Services;
using Moq;
using NUnit.Framework;
namespace Filtration.ThemeEditor.Tests.Services
@ -27,8 +29,9 @@ namespace Filtration.ThemeEditor.Tests.Services
var testInputThemeComponent = new ThemeComponent(ThemeComponentType.TextColor, "Test Component 1", testInputThemeComponentColor);
testInputTheme.Components.Add(testInputThemeComponent);
testInputBlockItem.ThemeComponent = testInputThemeComponent;
var mockMessageBoxService = new Mock<IMessageBoxService>();
var service = new ThemeService();
var service = new ThemeService(mockMessageBoxService.Object);
// Act
service.ApplyThemeToScript(testInputTheme, testInputScript);
@ -55,7 +58,9 @@ namespace Filtration.ThemeEditor.Tests.Services
testInputTheme.Components.Add(testInputThemeComponent);
testInputBlockItem.ThemeComponent = testInputBlockItemThemeComponent;
var service = new ThemeService();
var mockMessageBoxService = new Mock<IMessageBoxService>();
var service = new ThemeService(mockMessageBoxService.Object);
// Act
service.ApplyThemeToScript(testInputTheme, testInputScript);

View File

@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Windows;
using Filtration.Common.Services;
using Filtration.ObjectModel;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.BlockItemTypes;
@ -16,6 +17,13 @@ namespace Filtration.ThemeEditor.Services
public class ThemeService : IThemeService
{
private readonly IMessageBoxService _messageBoxService;
public ThemeService(IMessageBoxService messageBoxService)
{
_messageBoxService = messageBoxService;
}
public void ApplyThemeToScript(Theme theme, ItemFilterScript script)
{
var mismatchedComponents = false;
@ -58,9 +66,9 @@ namespace Filtration.ThemeEditor.Services
if (mismatchedComponents)
{
MessageBox.Show(
_messageBoxService.Show("Possible Theme Mismatch",
"Not all theme components had matches - are you sure this theme is designed for this script?",
"Possible Theme Mismatch", MessageBoxButton.OK, MessageBoxImage.Exclamation);
MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
}
}

View File

@ -4,6 +4,7 @@ using System.IO;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Media.Imaging;
using Filtration.Common.Services;
using Filtration.Common.ViewModels;
using Filtration.Interface;
using Filtration.ThemeEditor.Providers;
@ -27,12 +28,15 @@ namespace Filtration.ThemeEditor.ViewModels
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
private readonly IThemeProvider _themeProvider;
private readonly IMessageBoxService _messageBoxService;
private bool _filenameIsFake;
private string _filePath;
public ThemeViewModel(IThemeProvider themeProvider)
public ThemeViewModel(IThemeProvider themeProvider,
IMessageBoxService messageBoxService)
{
_themeProvider = themeProvider;
_messageBoxService = messageBoxService;
Components = new ObservableCollection<ThemeComponentViewModel>();
@ -93,8 +97,7 @@ namespace Filtration.ThemeEditor.ViewModels
_logger.Error(e);
}
MessageBox.Show(@"Error saving filter theme - " + e.Message, @"Save Error", MessageBoxButton.OK,
MessageBoxImage.Error);
_messageBoxService.Show("Save Error", "Error saving filter theme - " + e.Message, MessageBoxButton.OK, MessageBoxImage.Error);
}
}
@ -125,7 +128,7 @@ namespace Filtration.ThemeEditor.ViewModels
_logger.Error(e);
}
MessageBox.Show(@"Error saving theme file - " + e.Message, @"Save Error", MessageBoxButton.OK,
_messageBoxService.Show("Save Error", "Error saving theme file - " + e.Message, MessageBoxButton.OK,
MessageBoxImage.Error);
FilePath = previousFilePath;
}

View File

@ -9,7 +9,6 @@ namespace Filtration.Converters
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool) value ? Visibility.Visible : Visibility.Hidden;
if (value is bool && targetType == typeof (Visibility))
{
var val = (bool) value;

View File

@ -16,6 +16,7 @@ namespace Filtration.Translators
{
internal interface IItemFilterBlockTranslator
{
void InitialiseForExistingScript(ItemFilterScript script);
ItemFilterBlock TranslateStringToItemFilterBlock(string inputString);
string TranslateItemFilterBlockToString(ItemFilterBlock block);
void ReplaceColorBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString);
@ -34,6 +35,12 @@ namespace Filtration.Translators
_themeComponentListBuilder = themeComponentListBuilder;
}
public void InitialiseForExistingScript(ItemFilterScript script)
{
_themeComponentListBuilder.Initialise(script.ThemeComponents);
_blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First());
}
// This method converts a string into a ItemFilterBlock. This is used for pasting ItemFilterBlocks
// and reading ItemFilterScripts from a file.
public ItemFilterBlock TranslateStringToItemFilterBlock(string inputString)

View File

@ -9,6 +9,7 @@ using System.Windows.Data;
using System.Windows.Forms;
using System.Windows.Media.Imaging;
using Castle.Core.Internal;
using Filtration.Common.Services;
using Filtration.Common.ViewModels;
using Filtration.Interface;
using Filtration.ObjectModel;
@ -18,7 +19,6 @@ using GalaSoft.MvvmLight.CommandWpf;
using GalaSoft.MvvmLight.Messaging;
using NLog;
using Clipboard = System.Windows.Clipboard;
using MessageBox = System.Windows.MessageBox;
namespace Filtration.ViewModels
{
@ -70,6 +70,7 @@ namespace Filtration.ViewModels
private readonly IItemFilterBlockTranslator _blockTranslator;
private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel;
private readonly IItemFilterPersistenceService _persistenceService;
private readonly IMessageBoxService _messageBoxService;
private bool _isDirty;
private IItemFilterBlockViewModel _selectedBlockViewModel;
@ -81,13 +82,15 @@ namespace Filtration.ViewModels
public ItemFilterScriptViewModel(IItemFilterBlockViewModelFactory itemFilterBlockViewModelFactory,
IItemFilterBlockTranslator blockTranslator,
IAvalonDockWorkspaceViewModel avalonDockWorkspaceViewModel,
IItemFilterPersistenceService persistenceService)
IItemFilterPersistenceService persistenceService,
IMessageBoxService messageBoxService)
{
_itemFilterBlockViewModelFactory = itemFilterBlockViewModelFactory;
_blockTranslator = blockTranslator;
_avalonDockWorkspaceViewModel = avalonDockWorkspaceViewModel;
_avalonDockWorkspaceViewModel.ActiveDocumentChanged += OnActiveDocumentChanged;
_persistenceService = persistenceService;
_messageBoxService = messageBoxService;
_itemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModel>();
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand);
@ -342,7 +345,7 @@ namespace Filtration.ViewModels
_logger.Error(e);
}
MessageBox.Show(@"Error saving filter file - " + e.Message, @"Save Error", MessageBoxButton.OK,
_messageBoxService.Show("Save Error", "Error saving filter file - " + e.Message, MessageBoxButton.OK,
MessageBoxImage.Error);
}
}
@ -378,7 +381,7 @@ namespace Filtration.ViewModels
_logger.Error(e);
}
MessageBox.Show(@"Error saving filter file - " + e.Message, @"Save Error", MessageBoxButton.OK,
_messageBoxService.Show("Save Error", "Error saving filter file - " + e.Message, MessageBoxButton.OK,
MessageBoxImage.Error);
Script.FilePath = previousFilePath;
}
@ -421,7 +424,8 @@ namespace Filtration.ViewModels
var messageText = "The following script validation errors occurred:" + Environment.NewLine + failures;
MessageBox.Show(messageText, "Script Validation Failure", MessageBoxButton.OK, MessageBoxImage.Exclamation);
_messageBoxService.Show("Script Validation Failure", messageText, MessageBoxButton.OK,
MessageBoxImage.Exclamation);
return false;
}
@ -438,8 +442,9 @@ namespace Filtration.ViewModels
}
else
{
var result = MessageBox.Show(@"Want to save your changes to this script?",
@"Filtration", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
var result = _messageBoxService.Show("Filtration",
"Want to save your changes to this script?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
switch (result)
{
case MessageBoxResult.Yes:
@ -538,6 +543,7 @@ namespace Filtration.ViewModels
var clipboardText = Clipboard.GetText();
if (clipboardText.IsNullOrEmpty()) return;
_blockTranslator.InitialiseForExistingScript(Script);
var translatedBlock = _blockTranslator.TranslateStringToItemFilterBlock(clipboardText);
if (translatedBlock == null) return;
@ -562,8 +568,10 @@ namespace Filtration.ViewModels
catch (Exception e)
{
_logger.Error(e);
MessageBox.Show(e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine +
e.InnerException.Message + Environment.NewLine + e.InnerException.StackTrace, "Paste Error", MessageBoxButton.OK);
_messageBoxService.Show("Paste Error",
e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine +
e.InnerException.Message + Environment.NewLine + e.InnerException.StackTrace, MessageBoxButton.OK,
MessageBoxImage.Error);
}
}
@ -717,8 +725,9 @@ namespace Filtration.ViewModels
public void DeleteBlock(IItemFilterBlockViewModel targetBlockViewModel)
{
var result = MessageBox.Show("Are you sure you wish to delete this block?", "Delete Confirmation",
MessageBoxButton.YesNo, MessageBoxImage.Question);
var result = _messageBoxService.Show("Delete Confirmation", "Are you sure you wish to delete this block?",
MessageBoxButton.YesNo,
MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{

View File

@ -1,11 +1,12 @@
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Filtration.Common.Services;
using Filtration.Common.ViewModels;
using Filtration.Interface;
using Filtration.Models;
@ -45,6 +46,7 @@ namespace Filtration.ViewModels
private readonly IThemeService _themeService;
private readonly IUpdateCheckService _updateCheckService;
private readonly IUpdateAvailableViewModel _updateAvailableViewModel;
private readonly IMessageBoxService _messageBoxService;
public MainWindowViewModel(IItemFilterScriptRepository itemFilterScriptRepository,
IItemFilterScriptTranslator itemFilterScriptTranslator,
@ -54,7 +56,8 @@ namespace Filtration.ViewModels
IThemeProvider themeProvider,
IThemeService themeService,
IUpdateCheckService updateCheckService,
IUpdateAvailableViewModel updateAvailableViewModel)
IUpdateAvailableViewModel updateAvailableViewModel,
IMessageBoxService messageBoxService)
{
_itemFilterScriptRepository = itemFilterScriptRepository;
_itemFilterScriptTranslator = itemFilterScriptTranslator;
@ -65,6 +68,7 @@ namespace Filtration.ViewModels
_themeService = themeService;
_updateCheckService = updateCheckService;
_updateAvailableViewModel = updateAvailableViewModel;
_messageBoxService = messageBoxService;
NewScriptCommand = new RelayCommand(OnNewScriptCommand);
CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => ActiveDocumentIsScript);
@ -319,9 +323,9 @@ namespace Filtration.ViewModels
{
_logger.Error(e);
}
MessageBox.Show(@"Error loading filter script - " + e.Message, @"Script Load Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
_messageBoxService.Show("Script Load Error", "Error loading filter script - " + e.Message,
MessageBoxButton.OK,
MessageBoxImage.Error);
return;
}
@ -349,9 +353,9 @@ namespace Filtration.ViewModels
{
_logger.Error(e);
}
MessageBox.Show(@"Error loading filter theme - " + e.Message, @"Theme Load Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
_messageBoxService.Show("Theme Load Error", "Error loading filter theme - " + e.Message,
MessageBoxButton.OK,
MessageBoxImage.Error);
return;
}
@ -378,15 +382,16 @@ namespace Filtration.ViewModels
{
_logger.Error(e);
}
MessageBox.Show(@"Error loading filter theme - " + e.Message, @"Theme Load Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
_messageBoxService.Show("Theme Load Error", "Error loading filter theme - " + e.Message,
MessageBoxButton.OK,
MessageBoxImage.Error);
return;
}
var result = MessageBox.Show(@"Are you sure you wish to apply this theme to the current filter script?",
@"Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.No)
var result = _messageBoxService.Show("Confirm",
"Are you sure you wish to apply this theme to the current filter script?", MessageBoxButton.YesNo,
MessageBoxImage.Question);
if (result == MessageBoxResult.No)
{
return;
}

View File

@ -1,5 +1,6 @@
using System.IO;
using System.Windows;
using Filtration.Common.Services;
using Filtration.Common.ViewModels;
using Filtration.Properties;
using Filtration.Services;
@ -14,10 +15,12 @@ namespace Filtration.ViewModels
internal class SettingsPageViewModel : FiltrationViewModelBase, ISettingsPageViewModel
{
private readonly IItemFilterPersistenceService _itemFilterPersistenceService;
private readonly IMessageBoxService _messageBoxService;
public SettingsPageViewModel(IItemFilterPersistenceService itemFilterPersistenceService)
public SettingsPageViewModel(IItemFilterPersistenceService itemFilterPersistenceService, IMessageBoxService messageBoxService)
{
_itemFilterPersistenceService = itemFilterPersistenceService;
_messageBoxService = messageBoxService;
SaveCommand = new RelayCommand(OnSaveCommand);
DefaultFilterDirectory = Settings.Default.DefaultFilterDirectory;
@ -41,7 +44,7 @@ namespace Filtration.ViewModels
}
catch (DirectoryNotFoundException)
{
MessageBox.Show("The entered Default Filter Directory is invalid or does not exist.", "Error",
_messageBoxService.Show("Error", "The entered Default Filter Directory is invalid or does not exist.",
MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
}

View File

@ -91,7 +91,7 @@
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Text="{Binding DisplayHeading}" Style="{StaticResource DisplayHeading}" />
<WrapPanel Grid.Column="1" Grid.Row="0" HorizontalAlignment="Right">
<Button Command="{Binding ElementName=SettingsGrid, Path=DataContext.PlaySoundCommand}" Width="20" Height="20" Padding="3" Background="Transparent" BorderBrush="Transparent">
<Button Command="{Binding ElementName=SettingsGrid, Path=DataContext.PlaySoundCommand}" Width="20" Height="20" Background="Transparent" BorderBrush="Transparent">
<Image Source="/Filtration;component/Resources/Icons/speaker_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button>
<ComboBox ItemsSource="{Binding ElementName=SettingsGrid, Path=DataContext.SoundsAvailable}" SelectedValue="{Binding Value}" />

View File

@ -111,12 +111,18 @@
<!-- Item Preview Box -->
<WrapPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
<Image Source="/Filtration;component/Resources/Icons/speaker_icon.png"
<Button Command="{Binding PlaySoundCommand}"
Width="25"
Height="25"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Height="15" Width="15"
Margin="0,0,3,0"
Visibility="{Binding HasSound, Converter={StaticResource BooleanVisibilityConverter}}" />
Visibility="{Binding HasSound, Converter={StaticResource BooleanVisibilityConverter}}"
Background="Transparent"
BorderBrush="Transparent"
ToolTip="Click to preview drop sound">
<Image Source="/Filtration;component/Resources/Icons/speaker_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button>
<ToggleButton Margin="0,2,2,2"
Style="{StaticResource ChromelessToggleButton}"
x:Name="ItemPreviewButton"