diff --git a/Filtration/Converters/ActiveDocumentConverter.cs b/Filtration/Converters/ActiveDocumentConverter.cs
new file mode 100644
index 0000000..9d5939f
--- /dev/null
+++ b/Filtration/Converters/ActiveDocumentConverter.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Globalization;
+using System.Windows.Data;
+using Filtration.ViewModels;
+
+namespace Filtration.Converters
+{
+ class ActiveDocumentConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is ItemFilterScriptViewModel)
+ return value;
+
+ return Binding.DoNothing;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is ItemFilterScriptViewModel)
+ return value;
+
+ return Binding.DoNothing;
+ }
+ }
+}
diff --git a/Filtration/Filtration.csproj b/Filtration/Filtration.csproj
index 1135f42..2f534f8 100644
--- a/Filtration/Filtration.csproj
+++ b/Filtration/Filtration.csproj
@@ -79,6 +79,21 @@
..\packages\WPFToolkit.3.5.50211.1\lib\WPFToolkit.dll
+
+ ..\packages\AvalonDock.2.0.2000\lib\net40\Xceed.Wpf.AvalonDock.dll
+
+
+ ..\packages\AvalonDock.2.0.2000\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll
+
+
+ ..\packages\AvalonDock.2.0.2000\lib\net40\Xceed.Wpf.AvalonDock.Themes.Expression.dll
+
+
+ ..\packages\AvalonDock.2.0.2000\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll
+
+
+ ..\packages\AvalonDock.2.0.2000\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll
+
False
..\packages\Extended.Wpf.Toolkit.2.4\lib\net40\Xceed.Wpf.Toolkit.dll
@@ -89,6 +104,7 @@
MSBuild:Compile
Designer
+
@@ -159,7 +175,10 @@
+
+
+
@@ -180,9 +199,15 @@
AboutWindow.xaml
+
+
+
ReplaceColorsWindow.xaml
+
+ SectionBrowserView.xaml
+
@@ -212,6 +237,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/Filtration/ViewModels/ItemFilterScriptViewModel.cs b/Filtration/ViewModels/ItemFilterScriptViewModel.cs
index a6083ba..f56fe65 100644
--- a/Filtration/ViewModels/ItemFilterScriptViewModel.cs
+++ b/Filtration/ViewModels/ItemFilterScriptViewModel.cs
@@ -19,13 +19,14 @@ namespace Filtration.ViewModels
void Initialise(ItemFilterScript itemFilterScript);
IItemFilterBlockViewModel SelectedBlockViewModel { get; set; }
void RemoveDirtyFlag();
+ IEnumerable ItemFilterSectionViewModels { get; }
void AddSection(IItemFilterBlockViewModel targetBlockViewModel);
void AddBlock(IItemFilterBlockViewModel targetBlockViewModel);
void CopyBlock(IItemFilterBlockViewModel targetBlockViewModel);
void PasteBlock(IItemFilterBlockViewModel targetBlockViewModel);
}
- internal class ItemFilterScriptViewModel : FiltrationViewModelBase, IItemFilterScriptViewModel
+ internal class ItemFilterScriptViewModel : PaneViewModel, IItemFilterScriptViewModel
{
private readonly IItemFilterBlockViewModelFactory _itemFilterBlockViewModelFactory;
private readonly IItemFilterBlockTranslator _blockTranslator;
@@ -147,6 +148,9 @@ namespace Filtration.ViewModels
vm.Initialise(block, this);
ItemFilterBlockViewModels.Add(vm);
}
+
+ Title = Filename;
+ ContentId = "testcontentid";
}
private void OnCopyBlockCommand()
diff --git a/Filtration/ViewModels/MainWindowViewModel.cs b/Filtration/ViewModels/MainWindowViewModel.cs
index d1fb76b..f9332a1 100644
--- a/Filtration/ViewModels/MainWindowViewModel.cs
+++ b/Filtration/ViewModels/MainWindowViewModel.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Reflection;
@@ -9,6 +10,7 @@ using Filtration.Services;
using Filtration.Translators;
using Filtration.Views;
using GalaSoft.MvvmLight.CommandWpf;
+using Xceed.Wpf.AvalonDock.Layout;
using Clipboard = System.Windows.Clipboard;
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
@@ -16,19 +18,23 @@ namespace Filtration.ViewModels
{
internal interface IMainWindowViewModel
{
+ IItemFilterScriptViewModel ActiveDocument { get; set; }
+ event EventHandler ActiveDocumentChanged;
void LoadScriptFromFile(string path);
}
internal class MainWindowViewModel : FiltrationViewModelBase, IMainWindowViewModel
{
+
private ItemFilterScript _loadedScript;
private readonly IItemFilterScriptViewModelFactory _itemFilterScriptViewModelFactory;
private readonly IItemFilterPersistenceService _persistenceService;
private readonly IItemFilterScriptTranslator _itemFilterScriptTranslator;
private readonly IReplaceColorsViewModel _replaceColorsViewModel;
- private IItemFilterScriptViewModel _currentScriptViewModel;
+ private IItemFilterScriptViewModel _activeDocument;
private readonly ObservableCollection _scriptViewModels;
+ private readonly SectionBrowserViewModel _sectionBrowserViewModel;
public MainWindowViewModel(IItemFilterScriptViewModelFactory itemFilterScriptViewModelFactory,
IItemFilterPersistenceService persistenceService,
@@ -39,19 +45,21 @@ namespace Filtration.ViewModels
_persistenceService = persistenceService;
_itemFilterScriptTranslator = itemFilterScriptTranslator;
_replaceColorsViewModel = replaceColorsViewModel;
+ _sectionBrowserViewModel = new SectionBrowserViewModel();
+ _sectionBrowserViewModel.Initialise(this);
_scriptViewModels = new ObservableCollection();
OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand);
OpenScriptCommand = new RelayCommand(OnOpenScriptCommand);
- SaveScriptCommand = new RelayCommand(OnSaveScriptCommand, () => CurrentScriptViewModel != null);
- SaveScriptAsCommand = new RelayCommand(OnSaveScriptAsCommand, () => CurrentScriptViewModel != null);
- CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => CurrentScriptViewModel != null);
- CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => CurrentScriptViewModel != null && CurrentScriptViewModel.SelectedBlockViewModel != null);
- PasteCommand = new RelayCommand(OnPasteCommand, () => CurrentScriptViewModel != null && CurrentScriptViewModel.SelectedBlockViewModel != null);
+ SaveScriptCommand = new RelayCommand(OnSaveScriptCommand, () => ActiveDocument != null);
+ SaveScriptAsCommand = new RelayCommand(OnSaveScriptAsCommand, () => ActiveDocument != null);
+ CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => ActiveDocument != null);
+ CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => ActiveDocument != null && ActiveDocument.SelectedBlockViewModel != null);
+ PasteCommand = new RelayCommand(OnPasteCommand, () => ActiveDocument != null && ActiveDocument.SelectedBlockViewModel != null);
NewScriptCommand = new RelayCommand(OnNewScriptCommand);
- CloseScriptCommand = new RelayCommand(OnCloseScriptCommand, v => CurrentScriptViewModel != null);
- ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => CurrentScriptViewModel != null);
+ CloseScriptCommand = new RelayCommand(OnCloseScriptCommand, v => ActiveDocument != null);
+ ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => ActiveDocument != null);
//LoadScriptFromFile("C:\\ThioleLootFilter.txt");
@@ -74,6 +82,29 @@ namespace Filtration.ViewModels
get { return _scriptViewModels; }
}
+ private List _tools;
+
+ public IEnumerable Tools
+ {
+ get
+ {
+ if (_tools == null)
+ {
+ _tools = new List { _sectionBrowserViewModel };
+ }
+
+ return _tools;
+ }
+ }
+
+ public SectionBrowserViewModel SectionBrowserViewModel
+ {
+ get
+ {
+ return _sectionBrowserViewModel;
+ }
+ }
+
public string WindowTitle
{
get
@@ -85,22 +116,29 @@ namespace Filtration.ViewModels
}
[DoNotWire]
- public IItemFilterScriptViewModel CurrentScriptViewModel
+ public IItemFilterScriptViewModel ActiveDocument
{
- get { return _currentScriptViewModel; }
+ get { return _activeDocument; }
set
{
- _currentScriptViewModel = value;
+ _activeDocument = value;
RaisePropertyChanged();
+ if (ActiveDocumentChanged != null)
+ {
+ ActiveDocumentChanged(this, EventArgs.Empty);
+ }
+
RaisePropertyChanged("NoScriptsOpen");
SaveScriptCommand.RaiseCanExecuteChanged();
SaveScriptAsCommand.RaiseCanExecuteChanged();
}
}
+ public event EventHandler ActiveDocumentChanged;
+
public bool NoScriptsOpen
{
- get { return _currentScriptViewModel == null; }
+ get { return _activeDocument == null; }
}
private void OnOpenAboutWindowCommand()
@@ -138,7 +176,7 @@ namespace Filtration.ViewModels
var newViewModel = _itemFilterScriptViewModelFactory.Create();
newViewModel.Initialise(_loadedScript);
ScriptViewModels.Add(newViewModel);
- CurrentScriptViewModel = newViewModel;
+ ActiveDocument = newViewModel;
}
private void SetItemFilterScriptDirectory()
@@ -168,7 +206,7 @@ namespace Filtration.ViewModels
{
if (!ValidateScript()) return;
- if (string.IsNullOrEmpty(CurrentScriptViewModel.Script.FilePath))
+ if (string.IsNullOrEmpty(ActiveDocument.Script.FilePath))
{
OnSaveScriptAsCommand();
return;
@@ -176,8 +214,8 @@ namespace Filtration.ViewModels
try
{
- _persistenceService.SaveItemFilterScript(CurrentScriptViewModel.Script);
- CurrentScriptViewModel.RemoveDirtyFlag();
+ _persistenceService.SaveItemFilterScript(ActiveDocument.Script);
+ ActiveDocument.RemoveDirtyFlag();
}
catch (Exception e)
{
@@ -202,31 +240,31 @@ namespace Filtration.ViewModels
if (result != DialogResult.OK) return;
- var previousFilePath = CurrentScriptViewModel.Script.FilePath;
+ var previousFilePath = ActiveDocument.Script.FilePath;
try
{
- CurrentScriptViewModel.Script.FilePath = saveDialog.FileName;
- _persistenceService.SaveItemFilterScript(CurrentScriptViewModel.Script);
- CurrentScriptViewModel.RemoveDirtyFlag();
+ ActiveDocument.Script.FilePath = saveDialog.FileName;
+ _persistenceService.SaveItemFilterScript(ActiveDocument.Script);
+ ActiveDocument.RemoveDirtyFlag();
}
catch (Exception e)
{
MessageBox.Show(@"Error saving filter file - " + e.Message, @"Save Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
- CurrentScriptViewModel.Script.FilePath = previousFilePath;
+ ActiveDocument.Script.FilePath = previousFilePath;
}
}
private void OnReplaceColorsCommand()
{
- _replaceColorsViewModel.Initialise(CurrentScriptViewModel.Script);
+ _replaceColorsViewModel.Initialise(ActiveDocument.Script);
var replaceColorsWindow = new ReplaceColorsWindow {DataContext = _replaceColorsViewModel};
replaceColorsWindow.ShowDialog();
}
private bool ValidateScript()
{
- var result = CurrentScriptViewModel.Script.Validate();
+ var result = ActiveDocument.Script.Validate();
if (result.Count == 0) return true;
@@ -245,17 +283,17 @@ namespace Filtration.ViewModels
private void OnCopyScriptCommand()
{
- Clipboard.SetText(_itemFilterScriptTranslator.TranslateItemFilterScriptToString(_currentScriptViewModel.Script));
+ Clipboard.SetText(_itemFilterScriptTranslator.TranslateItemFilterScriptToString(_activeDocument.Script));
}
private void OnCopyBlockCommand()
{
- _currentScriptViewModel.CopyBlock(_currentScriptViewModel.SelectedBlockViewModel);
+ _activeDocument.CopyBlock(_activeDocument.SelectedBlockViewModel);
}
private void OnPasteCommand()
{
- _currentScriptViewModel.PasteBlock(_currentScriptViewModel.SelectedBlockViewModel);
+ _activeDocument.PasteBlock(_activeDocument.SelectedBlockViewModel);
}
private void OnNewScriptCommand()
@@ -265,15 +303,15 @@ namespace Filtration.ViewModels
newViewModel.Initialise(newScript);
newViewModel.Description = "New Script";
ScriptViewModels.Add(newViewModel);
- CurrentScriptViewModel = newViewModel;
+ ActiveDocument = newViewModel;
}
private void OnCloseScriptCommand(IItemFilterScriptViewModel scriptViewModel)
{
- CurrentScriptViewModel = scriptViewModel;
- if (!CurrentScriptViewModel.IsDirty)
+ ActiveDocument = scriptViewModel;
+ if (!ActiveDocument.IsDirty)
{
- ScriptViewModels.Remove(CurrentScriptViewModel);
+ ScriptViewModels.Remove(ActiveDocument);
}
else
{
@@ -284,12 +322,12 @@ namespace Filtration.ViewModels
case DialogResult.Yes:
{
OnSaveScriptCommand();
- ScriptViewModels.Remove(CurrentScriptViewModel);
+ ScriptViewModels.Remove(ActiveDocument);
break;
}
case DialogResult.No:
{
- ScriptViewModels.Remove(CurrentScriptViewModel);
+ ScriptViewModels.Remove(ActiveDocument);
break;
}
case DialogResult.Cancel:
diff --git a/Filtration/ViewModels/PaneViewModel.cs b/Filtration/ViewModels/PaneViewModel.cs
new file mode 100644
index 0000000..8fce535
--- /dev/null
+++ b/Filtration/ViewModels/PaneViewModel.cs
@@ -0,0 +1,65 @@
+using System.Windows.Media;
+
+namespace Filtration.ViewModels
+{
+ class PaneViewModel : FiltrationViewModelBase
+ {
+ private string _title;
+ public string Title
+ {
+ get { return _title; }
+ set
+ {
+ if (_title != value)
+ {
+ _title = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ public ImageSource IconSource { get; protected set; }
+
+ private string _contentId;
+ public string ContentId
+ {
+ get { return _contentId; }
+ set
+ {
+ if (_contentId != value)
+ {
+ _contentId = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ private bool _isSelected;
+ public bool IsSelected
+ {
+ get { return _isSelected; }
+ set
+ {
+ if (_isSelected != value)
+ {
+ _isSelected = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ private bool _isActive;
+ public bool IsActive
+ {
+ get { return _isActive; }
+ set
+ {
+ if (_isActive != value)
+ {
+ _isActive = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+ }
+}
diff --git a/Filtration/ViewModels/SectionBrowserViewModel.cs b/Filtration/ViewModels/SectionBrowserViewModel.cs
new file mode 100644
index 0000000..d043ebf
--- /dev/null
+++ b/Filtration/ViewModels/SectionBrowserViewModel.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+
+namespace Filtration.ViewModels
+{
+ internal interface ISectionBrowserViewModel
+ {
+ }
+
+ internal class SectionBrowserViewModel : ToolViewModel, ISectionBrowserViewModel
+ {
+ private IMainWindowViewModel _mainWindowViewModel;
+ private IEnumerable _sectionBlockViewModels;
+ private IItemFilterBlockViewModel _selectedSectionBlockViewModel;
+
+ public SectionBrowserViewModel() : base("Section Browser")
+ {
+
+ ContentId = ToolContentId;
+ }
+
+ public void Initialise(IMainWindowViewModel mainWindowViewModel)
+ {
+ _mainWindowViewModel = mainWindowViewModel;
+ _mainWindowViewModel.ActiveDocumentChanged += OnActiveDocumentChanged;
+ }
+
+ public const string ToolContentId = "SectionBrowserTool";
+
+ public IEnumerable SectionBlockViewModels
+ {
+ get { return _sectionBlockViewModels; }
+ private set
+ {
+ _sectionBlockViewModels = value;
+ RaisePropertyChanged();
+ }
+ }
+
+ public IItemFilterBlockViewModel SelectedSectionBlockViewModel
+ {
+ get { return _selectedSectionBlockViewModel; }
+ set
+ {
+ _selectedSectionBlockViewModel = value;
+ RaisePropertyChanged();
+ }
+ }
+
+ private void OnActiveDocumentChanged(object sender, EventArgs e)
+ {
+ SectionBlockViewModels = _mainWindowViewModel.ActiveDocument != null ? _mainWindowViewModel.ActiveDocument.ItemFilterSectionViewModels : null;
+ }
+ }
+}
diff --git a/Filtration/ViewModels/ToolViewModel.cs b/Filtration/ViewModels/ToolViewModel.cs
new file mode 100644
index 0000000..f9c3fda
--- /dev/null
+++ b/Filtration/ViewModels/ToolViewModel.cs
@@ -0,0 +1,27 @@
+namespace Filtration.ViewModels
+{
+ class ToolViewModel : PaneViewModel
+ {
+ public ToolViewModel(string name)
+ {
+ Name = name;
+ Title = name;
+ }
+
+ public string Name { get; private set; }
+
+ private bool _isVisible = true;
+ public bool IsVisible
+ {
+ get { return _isVisible; }
+ set
+ {
+ if (_isVisible != value)
+ {
+ _isVisible = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+ }
+}
diff --git a/Filtration/Views/ItemFilterScriptView.xaml b/Filtration/Views/ItemFilterScriptView.xaml
index 7a0097c..a8288f5 100644
--- a/Filtration/Views/ItemFilterScriptView.xaml
+++ b/Filtration/Views/ItemFilterScriptView.xaml
@@ -59,7 +59,7 @@
-
+
() != null)
+ return false;
+
+ var toolsPane = layout.Descendents().OfType().FirstOrDefault(d => d.Name == "ToolsPane");
+ if (toolsPane != null)
+ {
+ toolsPane.Children.Add(anchorableToShow);
+ return true;
+ }
+
+ return false;
+
+ }
+
+
+ public void AfterInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableShown)
+ {
+ }
+
+
+ public bool BeforeInsertDocument(LayoutRoot layout, LayoutDocument anchorableToShow, ILayoutContainer destinationContainer)
+ {
+ return false;
+ }
+
+ public void AfterInsertDocument(LayoutRoot layout, LayoutDocument anchorableShown)
+ {
+
+ }
+ }
+}
diff --git a/Filtration/Views/MainWindow.xaml b/Filtration/Views/MainWindow.xaml
index 1360db6..a8f20d3 100644
--- a/Filtration/Views/MainWindow.xaml
+++ b/Filtration/Views/MainWindow.xaml
@@ -5,14 +5,16 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
- xmlns:views="clr-namespace:Filtration.Views"
xmlns:viewModels="clr-namespace:Filtration.ViewModels"
- xmlns:userControls="clr-namespace:Filtration.UserControls"
+ xmlns:avalonDock="http://schemas.xceed.com/wpf/xaml/avalondock"
+ xmlns:converters="clr-namespace:Filtration.Converters"
+ xmlns:views="clr-namespace:Filtration.Views"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:MainWindowViewModel}"
Title="{Binding WindowTitle}" Height="707" Width="930" BorderThickness="1" BorderBrush="Black">
+
@@ -22,7 +24,7 @@
-
+