Fixed another copy paste bug, changed speaker icon to button
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,8 +345,8 @@ namespace Filtration.ViewModels
|
||||
_logger.Error(e);
|
||||
}
|
||||
|
||||
MessageBox.Show(@"Error saving filter file - " + e.Message, @"Save Error", MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
_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,9 +725,10 @@ 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)
|
||||
{
|
||||
Script.ItemFilterBlocks.Remove(targetBlockViewModel.Block);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}" />
|
||||
|
||||
@@ -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"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Height="15" Width="15"
|
||||
Margin="0,0,3,0"
|
||||
Visibility="{Binding HasSound, Converter={StaticResource BooleanVisibilityConverter}}" />
|
||||
<Button Command="{Binding PlaySoundCommand}"
|
||||
Width="25"
|
||||
Height="25"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,0,3,0"
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user