Implemented opening/saving themes
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using AutoMapper;
|
||||
using Castle.Facilities.TypedFactory;
|
||||
using Castle.MicroKernel.ModelBuilder.Inspectors;
|
||||
using Castle.Windsor;
|
||||
using Castle.Windsor.Installer;
|
||||
@@ -23,8 +25,13 @@ namespace Filtration
|
||||
|
||||
_container.Kernel.ComponentModelBuilder.RemoveContributor(propInjector);
|
||||
|
||||
_container.AddFacility<TypedFactoryFacility>();
|
||||
_container.Install(FromAssembly.InThisApplication());
|
||||
|
||||
Mapper.Configuration.ConstructServicesUsing(_container.Resolve);
|
||||
|
||||
Mapper.AssertConfigurationIsValid();
|
||||
|
||||
var mainWindow = _container.Resolve<IMainWindow>();
|
||||
mainWindow.Show();
|
||||
}
|
||||
|
||||
@@ -133,7 +133,6 @@
|
||||
<Compile Include="Extensions\HyperlinkExtensions.cs" />
|
||||
<Compile Include="Properties\Annotations.cs" />
|
||||
<Compile Include="Repositories\ItemFilterScriptRepository.cs" />
|
||||
<Compile Include="Services\FileSystemService.cs" />
|
||||
<Compile Include="Services\ItemFilterPersistenceService.cs" />
|
||||
<Compile Include="Services\StaticDataService.cs" />
|
||||
<Compile Include="Settings.cs" />
|
||||
@@ -155,14 +154,12 @@
|
||||
<Compile Include="ViewModels\AvalonDockWorkspaceViewModel.cs" />
|
||||
<Compile Include="ViewModels\SettingsWindowViewModel.cs" />
|
||||
<Compile Include="ViewModels\ToolPanes\BlockGroupBrowserViewModel.cs" />
|
||||
<Compile Include="ViewModels\FiltrationViewModelBase.cs" />
|
||||
<Compile Include="ViewModels\IItemFilterScriptViewModelFactory.cs" />
|
||||
<Compile Include="ViewModels\IItemFilterBlockViewModelFactory.cs" />
|
||||
<Compile Include="ViewModels\ItemFilterBlockGroupViewModel.cs" />
|
||||
<Compile Include="ViewModels\ItemFilterBlockViewModel.cs" />
|
||||
<Compile Include="ViewModels\ItemFilterScriptViewModel.cs" />
|
||||
<Compile Include="ViewModels\ToolPanes\BlockOutputPreviewViewModel.cs" />
|
||||
<Compile Include="ViewModels\ToolPanes\PaneViewModel.cs" />
|
||||
<Compile Include="ViewModels\ReplaceColorsViewModel.cs" />
|
||||
<Compile Include="ViewModels\ToolPanes\SectionBrowserViewModel.cs" />
|
||||
<Compile Include="ViewModels\StartPageViewModel.cs" />
|
||||
@@ -372,6 +369,8 @@
|
||||
<Resource Include="Resources\Icons\block_output_preview_icon.png" />
|
||||
<Resource Include="Resources\Icons\collapse_icon.png" />
|
||||
<Resource Include="Resources\Icons\expand_icon.png" />
|
||||
<Resource Include="Resources\Icons\theme_icon.png" />
|
||||
<Resource Include="Resources\Icons\script_icon.png" />
|
||||
<Content Include="Resources\ItemBaseTypes.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
@@ -420,6 +419,10 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Filtration.Common\Filtration.Common.csproj">
|
||||
<Project>{8cb44f28-2956-4c2a-9314-72727262edd4}</Project>
|
||||
<Name>Filtration.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Filtration.Interface\Filtration.Interface.csproj">
|
||||
<Project>{0f333344-7695-47b2-b0e6-172e4de74819}</Project>
|
||||
<Name>Filtration.Interface</Name>
|
||||
|
||||
@@ -18,7 +18,6 @@ namespace Filtration.Repositories
|
||||
{
|
||||
private readonly IItemFilterPersistenceService _itemFilterPersistenceService;
|
||||
private readonly IItemFilterScriptViewModelFactory _itemFilterScriptViewModelFactory;
|
||||
//private List<ItemFilterScript> _itemFilterScripts;
|
||||
|
||||
public ItemFilterScriptRepository(IItemFilterPersistenceService itemFilterPersistenceService,
|
||||
IItemFilterScriptViewModelFactory itemFilterScriptViewModelFactory)
|
||||
|
||||
BIN
Filtration/Resources/Icons/script_icon.png
Normal file
BIN
Filtration/Resources/Icons/script_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 242 B |
BIN
Filtration/Resources/Icons/theme_icon.png
Normal file
BIN
Filtration/Resources/Icons/theme_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 235 B |
@@ -1,36 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Filtration.Services
|
||||
{
|
||||
internal interface IFileSystemService
|
||||
{
|
||||
string ReadFileAsString(string filePath);
|
||||
void WriteFileFromString(string filePath, string inputString);
|
||||
bool DirectoryExists(string directoryPath);
|
||||
string GetUserProfilePath();
|
||||
}
|
||||
|
||||
internal class FileSystemService : IFileSystemService
|
||||
{
|
||||
public string ReadFileAsString(string filePath)
|
||||
{
|
||||
return File.ReadAllText(filePath);
|
||||
}
|
||||
|
||||
public void WriteFileFromString(string filePath, string inputString)
|
||||
{
|
||||
File.WriteAllText(filePath, inputString);
|
||||
}
|
||||
|
||||
public bool DirectoryExists(string directoryPath)
|
||||
{
|
||||
return Directory.Exists(directoryPath);
|
||||
}
|
||||
|
||||
public string GetUserProfilePath()
|
||||
{
|
||||
return Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using Filtration.Common.Services;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.Properties;
|
||||
using Filtration.Translators;
|
||||
@@ -72,7 +73,5 @@ namespace Filtration.Services
|
||||
_fileSystemService.WriteFileFromString(script.FilePath,
|
||||
_itemFilterScriptTranslator.TranslateItemFilterScriptToString(script));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Filtration.Common.Services;
|
||||
using Filtration.Utilities;
|
||||
|
||||
namespace Filtration.Services
|
||||
|
||||
@@ -270,7 +270,25 @@ namespace Filtration.Translators
|
||||
var componentName = result[0].Groups[2].Value.Trim();
|
||||
if (!string.IsNullOrEmpty(componentName))
|
||||
{
|
||||
blockItem.ThemeComponent = _themeComponentListBuilder.AddComponent(typeof(T), componentName, blockItem.Color);
|
||||
ThemeComponentType componentType;
|
||||
if (typeof (T) == typeof (TextColorBlockItem))
|
||||
{
|
||||
componentType = ThemeComponentType.TextColor;
|
||||
}
|
||||
else if (typeof (T) == typeof (BackgroundColorBlockItem))
|
||||
{
|
||||
componentType = ThemeComponentType.BackgroundColor;
|
||||
}
|
||||
else if (typeof (T) == typeof (BorderColorBlockItem))
|
||||
{
|
||||
componentType = ThemeComponentType.BorderColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Parsing error - unknown theme component type");
|
||||
}
|
||||
|
||||
blockItem.ThemeComponent = _themeComponentListBuilder.AddComponent(componentType, componentName, blockItem.Color);
|
||||
}
|
||||
|
||||
block.BlockItems.Add(blockItem);
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ThemeEditor.Models;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
|
||||
namespace Filtration.Translators
|
||||
{
|
||||
internal interface IThemeComponentListBuilder
|
||||
{
|
||||
void Initialise();
|
||||
ThemeComponent AddComponent(Type targetType, string componentName, Color componentColor);
|
||||
ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, Color componentColor);
|
||||
List<ThemeComponent> GetComponents();
|
||||
}
|
||||
|
||||
@@ -27,14 +28,14 @@ namespace Filtration.Translators
|
||||
_themeComponents = new List<ThemeComponent>();
|
||||
}
|
||||
|
||||
public ThemeComponent AddComponent(Type targetType, string componentName, Color componentColor)
|
||||
public ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, Color componentColor)
|
||||
{
|
||||
if (ComponentExists(targetType, componentName))
|
||||
if (ComponentExists(componentType, componentName))
|
||||
{
|
||||
return _themeComponents.FirstOrDefault(t => t.ComponentName == componentName && t.TargetType == targetType);
|
||||
return _themeComponents.FirstOrDefault(t => t.ComponentName == componentName && t.ComponentType == componentType);
|
||||
}
|
||||
|
||||
var component = new ThemeComponent(targetType, componentName, componentColor);
|
||||
var component = new ThemeComponent(componentType, componentName, componentColor);
|
||||
_themeComponents.Add(component);
|
||||
|
||||
return component;
|
||||
@@ -45,9 +46,9 @@ namespace Filtration.Translators
|
||||
return _themeComponents;
|
||||
}
|
||||
|
||||
private bool ComponentExists(Type targetType, string componentName)
|
||||
private bool ComponentExists(ThemeComponentType componentType, string componentName)
|
||||
{
|
||||
return _themeComponents.Exists(c => c.ComponentName == componentName && c.TargetType == targetType);
|
||||
return _themeComponents.Exists(c => c.ComponentName == componentName && c.ComponentType == componentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Filtration.Utilities
|
||||
ObservableCollection<ItemFilterBlockGroup> blockGroups, bool showAdvanced)
|
||||
{
|
||||
|
||||
Mapper.Reset();
|
||||
//Mapper.Reset();
|
||||
if (showAdvanced)
|
||||
{
|
||||
Mapper.CreateMap<ItemFilterBlockGroup, ItemFilterBlockGroupViewModel>()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.Interface;
|
||||
using Filtration.ViewModels.ToolPanes;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using Filtration.Annotations;
|
||||
using GalaSoft.MvvmLight;
|
||||
|
||||
namespace Filtration.ViewModels
|
||||
{
|
||||
internal class FiltrationViewModelBase : ViewModelBase
|
||||
{
|
||||
/// This gives us the ReSharper option to transform an autoproperty into a property with change notification
|
||||
/// Also leverages .net 4.5 callermembername attribute
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected override void RaisePropertyChanged([CallerMemberName]string property = "")
|
||||
{
|
||||
base.RaisePropertyChanged(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.ObjectModel;
|
||||
|
||||
namespace Filtration.ViewModels
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
|
||||
@@ -7,7 +7,10 @@ using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Castle.Core.Internal;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.Interface;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.Services;
|
||||
@@ -20,23 +23,21 @@ using MessageBox = System.Windows.MessageBox;
|
||||
|
||||
namespace Filtration.ViewModels
|
||||
{
|
||||
internal interface IItemFilterScriptViewModel : IDocument
|
||||
internal interface IItemFilterScriptViewModel : IEditableDocument
|
||||
{
|
||||
ItemFilterScript Script { get; }
|
||||
IItemFilterBlockViewModel SelectedBlockViewModel { get; set; }
|
||||
IItemFilterBlockViewModel SectionBrowserSelectedBlockViewModel { get; set; }
|
||||
IEnumerable<IItemFilterBlockViewModel> ItemFilterSectionViewModels { get; }
|
||||
Predicate<IItemFilterBlockViewModel> BlockFilterPredicate { get; set; }
|
||||
bool IsDirty { get; }
|
||||
|
||||
bool ShowAdvanced { get; }
|
||||
string Description { get; set; }
|
||||
string DisplayName { get; }
|
||||
|
||||
void Initialise(ItemFilterScript itemFilterScript, bool newScript);
|
||||
void RemoveDirtyFlag();
|
||||
void SaveScript();
|
||||
void SaveScriptAs();
|
||||
void Close();
|
||||
|
||||
void AddSection(IItemFilterBlockViewModel targetBlockViewModel);
|
||||
void AddBlock(IItemFilterBlockViewModel targetBlockViewModel);
|
||||
void CopyBlock(IItemFilterBlockViewModel targetBlockViewModel);
|
||||
@@ -81,6 +82,12 @@ namespace Filtration.ViewModels
|
||||
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => SelectedBlockViewModel != null);
|
||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => SelectedBlockViewModel != null);
|
||||
PasteBlockCommand = new RelayCommand(OnPasteBlockCommand, () => SelectedBlockViewModel != null);
|
||||
|
||||
var icon = new BitmapImage();
|
||||
icon.BeginInit();
|
||||
icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/script_icon.png");
|
||||
icon.EndInit();
|
||||
IconSource = icon;
|
||||
}
|
||||
|
||||
public RelayCommand<bool> ToggleShowAdvancedCommand { get; private set; }
|
||||
@@ -151,10 +158,8 @@ namespace Filtration.ViewModels
|
||||
get { return ItemFilterBlockViewModels.Where(b => b.Block.GetType() == typeof (ItemFilterSection)); }
|
||||
}
|
||||
|
||||
public bool IsScript
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
public bool IsScript { get { return true; } }
|
||||
public bool IsTheme { get { return false; } }
|
||||
|
||||
public string Description
|
||||
{
|
||||
@@ -264,12 +269,6 @@ namespace Filtration.ViewModels
|
||||
ItemFilterBlockViewModels.Add(vm);
|
||||
}
|
||||
|
||||
//BlockGroupViewModels =_blockGroupMapper.MapBlockGroupsToViewModels(Script.ItemFilterBlockGroups, false);
|
||||
|
||||
// Necessary to perform the AfterMap here instead of in the AutoMapper config due to the mapping being
|
||||
// performed on a collection, but the postmap needs to be performed from the root BlockGroup.
|
||||
//AutoMapperHelpers.ItemFilterBlockGroupViewModelPostMap(BlockGroupViewModels.First());
|
||||
|
||||
_filenameIsFake = newScript;
|
||||
|
||||
if (newScript)
|
||||
@@ -281,13 +280,13 @@ namespace Filtration.ViewModels
|
||||
ContentId = "testcontentid";
|
||||
}
|
||||
|
||||
public void SaveScript()
|
||||
public void Save()
|
||||
{
|
||||
if (!ValidateScript()) return;
|
||||
|
||||
if (_filenameIsFake)
|
||||
{
|
||||
SaveScriptAs();
|
||||
SaveAs();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -303,7 +302,7 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveScriptAs()
|
||||
public void SaveAs()
|
||||
{
|
||||
if (!ValidateScript()) return;
|
||||
|
||||
@@ -395,7 +394,7 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
case MessageBoxResult.Yes:
|
||||
{
|
||||
SaveScript();
|
||||
Save();
|
||||
CloseScript();
|
||||
break;
|
||||
}
|
||||
@@ -411,7 +410,7 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void CloseScript()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveDocumentChanged -= OnActiveDocumentChanged;
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.Interface;
|
||||
using Filtration.Repositories;
|
||||
using Filtration.ThemeEditor.Providers;
|
||||
using Filtration.ThemeEditor.ViewModels;
|
||||
using Filtration.Translators;
|
||||
using Filtration.Views;
|
||||
@@ -27,7 +29,7 @@ namespace Filtration.ViewModels
|
||||
private readonly IReplaceColorsViewModel _replaceColorsViewModel;
|
||||
private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel;
|
||||
private readonly ISettingsWindowViewModel _settingsWindowViewModel;
|
||||
private readonly IThemeEditorViewModel _themeEditorViewModel;
|
||||
private readonly IThemeProvider _themeProvider;
|
||||
|
||||
private IDocument _activeDocument;
|
||||
|
||||
@@ -36,27 +38,31 @@ namespace Filtration.ViewModels
|
||||
IReplaceColorsViewModel replaceColorsViewModel,
|
||||
IAvalonDockWorkspaceViewModel avalonDockWorkspaceViewModel,
|
||||
ISettingsWindowViewModel settingsWindowViewModel,
|
||||
IThemeEditorViewModel themeEditorViewModel)
|
||||
IThemeProvider themeProvider)
|
||||
{
|
||||
_itemFilterScriptRepository = itemFilterScriptRepository;
|
||||
_itemFilterScriptTranslator = itemFilterScriptTranslator;
|
||||
_replaceColorsViewModel = replaceColorsViewModel;
|
||||
_avalonDockWorkspaceViewModel = avalonDockWorkspaceViewModel;
|
||||
_settingsWindowViewModel = settingsWindowViewModel;
|
||||
_themeEditorViewModel = themeEditorViewModel;
|
||||
_themeProvider = themeProvider;
|
||||
|
||||
NewScriptCommand = new RelayCommand(OnNewScriptCommand);
|
||||
CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, ActiveDocumentIsScript);
|
||||
OpenScriptCommand = new RelayCommand(OnOpenScriptCommand);
|
||||
OpenThemeCommand = new RelayCommand(OnOpenThemeCommand);
|
||||
|
||||
SaveCommand = new RelayCommand(OnSaveDocumentCommand, ActiveDocumentIsEditable);
|
||||
SaveAsCommand = new RelayCommand(OnSaveAsCommand, ActiveDocumentIsEditable);
|
||||
CloseCommand = new RelayCommand(OnCloseDocumentCommand, () => AvalonDockWorkspaceViewModel.ActiveDocument != null);
|
||||
|
||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => ActiveDocumentIsScript() && (_avalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel != null));
|
||||
PasteCommand = new RelayCommand(OnPasteCommand, () => ActiveDocumentIsScript() && (_avalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel != null));
|
||||
|
||||
OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand);
|
||||
OpenSettingsWindowCommand = new RelayCommand(OnOpenSettingsWindowCommand);
|
||||
OpenThemeEditorCommand = new RelayCommand(OnOpenThemeEditorCommand);
|
||||
OpenScriptCommand = new RelayCommand(OnOpenScriptCommand);
|
||||
SaveScriptCommand = new RelayCommand(OnSaveScriptCommand, ActiveDocumentIsScript);
|
||||
SaveScriptAsCommand = new RelayCommand(OnSaveScriptAsCommand, ActiveDocumentIsScript);
|
||||
CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, ActiveDocumentIsScript);
|
||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => ActiveDocumentIsScript() && (_avalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel != null));
|
||||
PasteCommand = new RelayCommand(OnPasteCommand, () => ActiveDocumentIsScript() && (_avalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel != null));
|
||||
NewScriptCommand = new RelayCommand(OnNewScriptCommand);
|
||||
CloseScriptCommand = new RelayCommand(OnCloseScriptCommand, ActiveDocumentIsScript);
|
||||
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, ActiveDocumentIsScript);
|
||||
CreateThemeCommand = new RelayCommand(OnCreateThemeCommand, ActiveDocumentIsScript);
|
||||
|
||||
//LoadScriptFromFile("C:\\ThioleLootFilter.txt");
|
||||
|
||||
@@ -72,13 +78,13 @@ namespace Filtration.ViewModels
|
||||
case "ActiveDocumentChanged":
|
||||
{
|
||||
_activeDocument = _avalonDockWorkspaceViewModel.ActiveDocument;
|
||||
SaveScriptCommand.RaiseCanExecuteChanged();
|
||||
SaveScriptAsCommand.RaiseCanExecuteChanged();
|
||||
SaveCommand.RaiseCanExecuteChanged();
|
||||
SaveAsCommand.RaiseCanExecuteChanged();
|
||||
CopyScriptCommand.RaiseCanExecuteChanged();
|
||||
CopyBlockCommand.RaiseCanExecuteChanged();
|
||||
PasteCommand.RaiseCanExecuteChanged();
|
||||
NewScriptCommand.RaiseCanExecuteChanged();
|
||||
CloseScriptCommand.RaiseCanExecuteChanged();
|
||||
CloseCommand.RaiseCanExecuteChanged();
|
||||
ReplaceColorsCommand.RaiseCanExecuteChanged();
|
||||
break;
|
||||
}
|
||||
@@ -97,17 +103,18 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
|
||||
public RelayCommand OpenScriptCommand { get; private set; }
|
||||
public RelayCommand SaveScriptCommand { get; private set; }
|
||||
public RelayCommand SaveScriptAsCommand { get; private set; }
|
||||
public RelayCommand OpenThemeCommand { get; private set; }
|
||||
public RelayCommand SaveCommand { get; private set; }
|
||||
public RelayCommand SaveAsCommand { get; private set; }
|
||||
public RelayCommand CopyBlockCommand { get; private set; }
|
||||
public RelayCommand PasteCommand { get; private set; }
|
||||
public RelayCommand CopyScriptCommand { get; private set; }
|
||||
public RelayCommand NewScriptCommand { get; private set; }
|
||||
public RelayCommand CloseScriptCommand { get; private set; }
|
||||
public RelayCommand CloseCommand { get; private set; }
|
||||
public RelayCommand OpenAboutWindowCommand { get; private set; }
|
||||
public RelayCommand OpenSettingsWindowCommand { get; private set; }
|
||||
public RelayCommand OpenThemeEditorCommand { get; private set; }
|
||||
public RelayCommand ReplaceColorsCommand { get; private set; }
|
||||
public RelayCommand CreateThemeCommand { get; private set; }
|
||||
|
||||
public IAvalonDockWorkspaceViewModel AvalonDockWorkspaceViewModel
|
||||
{
|
||||
@@ -126,18 +133,29 @@ namespace Filtration.ViewModels
|
||||
|
||||
private bool ActiveDocumentIsScript()
|
||||
{
|
||||
return _activeDocument != null && _activeDocument.IsScript;
|
||||
return _activeDocument is IItemFilterScriptViewModel;
|
||||
}
|
||||
|
||||
private void OnOpenThemeEditorCommand()
|
||||
private bool ActiveDocumentIsEditable()
|
||||
{
|
||||
if (AvalonDockWorkspaceViewModel.OpenDocuments.Contains(_themeEditorViewModel))
|
||||
return _activeDocument is IEditableDocument;
|
||||
}
|
||||
|
||||
private void OnCreateThemeCommand()
|
||||
{
|
||||
var themeViewModel = _themeProvider.NewThemeForScript(AvalonDockWorkspaceViewModel.ActiveScriptViewModel.Script);
|
||||
OpenTheme(themeViewModel);
|
||||
}
|
||||
|
||||
private void OpenTheme(IThemeViewModel themeViewModel)
|
||||
{
|
||||
if (AvalonDockWorkspaceViewModel.OpenDocuments.Contains(themeViewModel))
|
||||
{
|
||||
AvalonDockWorkspaceViewModel.SwitchActiveDocument(_themeEditorViewModel);
|
||||
AvalonDockWorkspaceViewModel.SwitchActiveDocument(themeViewModel);
|
||||
}
|
||||
else
|
||||
{
|
||||
AvalonDockWorkspaceViewModel.AddDocument(_themeEditorViewModel);
|
||||
AvalonDockWorkspaceViewModel.AddDocument(themeViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,6 +199,33 @@ namespace Filtration.ViewModels
|
||||
_avalonDockWorkspaceViewModel.AddDocument(loadedViewModel);
|
||||
}
|
||||
|
||||
private void OnOpenThemeCommand()
|
||||
{
|
||||
var openFileDialog = new OpenFileDialog
|
||||
{
|
||||
Filter = "Filter Theme Files (*.filtertheme)|*.filtertheme|All Files (*.*)|*.*",
|
||||
InitialDirectory = _itemFilterScriptRepository.GetItemFilterScriptDirectory()
|
||||
};
|
||||
|
||||
if (openFileDialog.ShowDialog() != true) return;
|
||||
|
||||
IThemeViewModel loadedViewModel;
|
||||
|
||||
try
|
||||
{
|
||||
loadedViewModel = _themeProvider.LoadThemeFromFile(openFileDialog.FileName);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
MessageBox.Show(@"Error loading filter theme - " + e.Message, @"Theme Load Error",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_avalonDockWorkspaceViewModel.AddDocument(loadedViewModel);
|
||||
}
|
||||
|
||||
private void SetItemFilterScriptDirectory()
|
||||
{
|
||||
var dlg = new FolderBrowserDialog
|
||||
@@ -196,14 +241,14 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSaveScriptCommand()
|
||||
private void OnSaveDocumentCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.SaveScript();
|
||||
((IEditableDocument)_avalonDockWorkspaceViewModel.ActiveDocument).Save();
|
||||
}
|
||||
|
||||
private void OnSaveScriptAsCommand()
|
||||
private void OnSaveAsCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.SaveScriptAs();
|
||||
((IEditableDocument)_avalonDockWorkspaceViewModel.ActiveDocument).SaveAs();
|
||||
}
|
||||
|
||||
private void OnReplaceColorsCommand()
|
||||
@@ -234,9 +279,9 @@ namespace Filtration.ViewModels
|
||||
_avalonDockWorkspaceViewModel.AddDocument(newViewModel);
|
||||
}
|
||||
|
||||
private void OnCloseScriptCommand()
|
||||
private void OnCloseDocumentCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.Close();
|
||||
_avalonDockWorkspaceViewModel.ActiveDocument.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.Views;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.Properties;
|
||||
using Filtration.Services;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Filtration.Interface;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.Interface;
|
||||
using Filtration.ViewModels.ToolPanes;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
@@ -23,7 +24,13 @@ namespace Filtration.ViewModels
|
||||
public RelayCommand NewScriptCommand { get; private set; }
|
||||
|
||||
public bool IsScript { get { return false; } }
|
||||
public bool IsTheme { get { return false; } }
|
||||
|
||||
public void Close()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
private static void OnOpenScriptCommand()
|
||||
{
|
||||
Messenger.Default.Send(new NotificationMessage("OpenScript"));
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Filtration.ViewModels.ToolPanes
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Filtration.Common.ViewModels;
|
||||
|
||||
namespace Filtration.ViewModels.ToolPanes
|
||||
{
|
||||
|
||||
@@ -54,11 +54,11 @@
|
||||
<views:StartPageView DataContext="{Binding}" />
|
||||
</DataTemplate>
|
||||
</viewsAvalonDock:PanesTemplateSelector.StartPageTemplate>
|
||||
<viewsAvalonDock:PanesTemplateSelector.ThemeEditorTemplate>
|
||||
<viewsAvalonDock:PanesTemplateSelector.ThemeTemplate>
|
||||
<DataTemplate>
|
||||
<themeEditorViews:ThemeEditorView DataContext="{Binding}" />
|
||||
<themeEditorViews:ThemeControl DataContext="{Binding}" />
|
||||
</DataTemplate>
|
||||
</viewsAvalonDock:PanesTemplateSelector.ThemeEditorTemplate>
|
||||
</viewsAvalonDock:PanesTemplateSelector.ThemeTemplate>
|
||||
</viewsAvalonDock:PanesTemplateSelector>
|
||||
</xcad:DockingManager.LayoutItemTemplateSelector>
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Filtration.Views.AvalonDock
|
||||
public DataTemplate SectionBrowserTemplate { get; set; }
|
||||
public DataTemplate BlockOutputPreviewTemplate { get; set; }
|
||||
public DataTemplate StartPageTemplate { get; set; }
|
||||
public DataTemplate ThemeEditorTemplate { get; set; }
|
||||
public DataTemplate ThemeTemplate { get; set; }
|
||||
|
||||
public override DataTemplate SelectTemplate(object item, DependencyObject container)
|
||||
{
|
||||
@@ -25,9 +25,9 @@ namespace Filtration.Views.AvalonDock
|
||||
return ItemFilterScriptTemplate;
|
||||
}
|
||||
|
||||
if (item is ThemeEditorViewModel)
|
||||
if (item is IThemeViewModel)
|
||||
{
|
||||
return ThemeEditorTemplate;
|
||||
return ThemeTemplate;
|
||||
}
|
||||
|
||||
if (item is SectionBrowserViewModel)
|
||||
|
||||
@@ -24,4 +24,6 @@
|
||||
<Image Source="/Filtration;component/Resources/Icons/block_output_preview_icon.png" x:Key="BlockOutputPreviewIcon" x:Shared="False" />
|
||||
<Image Source="/Filtration;component/Resources/Icons/expand_icon.png" x:Key="ExpandIcon" x:Shared="False" />
|
||||
<Image Source="/Filtration;component/Resources/Icons/collapse_icon.png" x:Key="CollapseIcon" x:Shared="False" />
|
||||
<Image Source="/Filtration;component/Resources/Icons/theme_icon.png" x:Key="ThemeIcon" x:Shared="False" />
|
||||
<Image Source="/Filtration;component/Resources/Icons/script_icon.png" x:Key="ScriptIcon" x:Shared="False" />
|
||||
</ResourceDictionary>
|
||||
@@ -15,9 +15,10 @@
|
||||
<MenuItem Header="_File">
|
||||
<MenuItem Header="_New Script" Command="{Binding NewScriptCommand}" Icon="{StaticResource NewIcon}"/>
|
||||
<MenuItem Header="_Open Script" Command="{Binding OpenScriptCommand}" Icon="{StaticResource OpenIcon}"/>
|
||||
<MenuItem Header="_Save Script" Command="{Binding SaveScriptCommand}" Icon="{StaticResource SaveIcon}"/>
|
||||
<MenuItem Header="Save Script _As" Command="{Binding SaveScriptAsCommand}" Icon="{StaticResource SaveIcon}"/>
|
||||
<MenuItem Header="_Close Script" Command="{Binding CloseScriptCommand}" />
|
||||
<MenuItem Header="_Open Theme" Command="{Binding OpenThemeCommand}" Icon="{StaticResource OpenIcon}"/>
|
||||
<MenuItem Header="_Save" Command="{Binding SaveCommand}" Icon="{StaticResource SaveIcon}"/>
|
||||
<MenuItem Header="Save _As" Command="{Binding SaveAsCommand}" Icon="{StaticResource SaveIcon}"/>
|
||||
<MenuItem Header="_Close Script" Command="{Binding CloseCommand}" />
|
||||
<MenuItem Header="E_xit"/>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Edit">
|
||||
@@ -33,7 +34,6 @@
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Tools">
|
||||
<MenuItem Header="_Replace Colors" Command="{Binding ReplaceColorsCommand}" Icon="{StaticResource ReplaceColorsIcon}" />
|
||||
<MenuItem Header="_Theme Editor" Command="{Binding OpenThemeEditorCommand}" Icon="{StaticResource ReplaceColorsIcon}" />
|
||||
<MenuItem Header="_Settings" Command="{Binding OpenSettingsWindowCommand}" />
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Help">
|
||||
@@ -44,7 +44,10 @@
|
||||
<ToolBar>
|
||||
<Button Command="{Binding NewScriptCommand}" Content="{StaticResource NewIcon}" ToolTip="New Script" />
|
||||
<Button Command="{Binding OpenScriptCommand}" Content="{StaticResource OpenIcon}" ToolTip="Open Script" />
|
||||
<Button Command="{Binding SaveScriptCommand}" Content="{StaticResource SaveIcon}" ToolTip="Save Script" />
|
||||
<Button Command="{Binding SaveCommand}" Content="{StaticResource SaveIcon}" ToolTip="Save" />
|
||||
<Separator />
|
||||
<Button Command="{Binding CreateThemeCommand}" Content="{StaticResource ThemeIcon}" ToolTip="Create Theme for Script" />
|
||||
|
||||
</ToolBar>
|
||||
</ToolBarTray>
|
||||
<Grid>
|
||||
|
||||
@@ -10,11 +10,6 @@ namespace Filtration.WindsorInstallers
|
||||
{
|
||||
public void Install(IWindsorContainer container, IConfigurationStore store)
|
||||
{
|
||||
container.Register(
|
||||
Component.For<IFileSystemService>()
|
||||
.ImplementedBy<FileSystemService>()
|
||||
.LifeStyle.Singleton);
|
||||
|
||||
container.Register(
|
||||
Component.For<IItemFilterPersistenceService>()
|
||||
.ImplementedBy<ItemFilterPersistenceService>()
|
||||
|
||||
@@ -60,8 +60,7 @@ namespace Filtration.WindsorInstallers
|
||||
Component.For<ISettingsWindowViewModel>()
|
||||
.ImplementedBy<SettingsWindowViewModel>()
|
||||
.LifeStyle.Transient);
|
||||
|
||||
container.AddFacility<TypedFactoryFacility>();
|
||||
|
||||
container.Register(
|
||||
Component.For<IItemFilterBlockViewModelFactory>().AsFactory());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user