Added Theme Editor window and added to Tools menu

This commit is contained in:
Ben 2015-06-26 10:17:32 +01:00
parent cc05945108
commit aa5cedcbba
22 changed files with 199 additions and 17 deletions

View File

@ -0,0 +1,7 @@
namespace Filtration.Interface
{
public interface IDocument
{
bool IsScript { get; }
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Filtration.Interface")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Filtration.Interface")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f21659a3-839a-41ca-97b9-78cc6f6af353")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -64,6 +64,10 @@
<Folder Include="ViewModels\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Filtration.Interface\Filtration.Interface.csproj">
<Project>{0f333344-7695-47b2-b0e6-172e4de74819}</Project>
<Name>Filtration.Interface</Name>
</ProjectReference>
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
<Project>{4aac3beb-1dc1-483e-9d11-0e9334e80227}</Project>
<Name>Filtration.ObjectModel</Name>

View File

@ -30,24 +30,54 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Castle.Core">
<HintPath>..\packages\Castle.Core.3.3.0\lib\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Castle.Windsor">
<HintPath>..\packages\Castle.Windsor.3.3.0\lib\net45\Castle.Windsor.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ViewModels\ThemeEditorViewModel.cs" />
<Compile Include="Views\ThemeEditorView.xaml.cs">
<DependentUpon>ThemeEditorView.xaml</DependentUpon>
</Compile>
<Compile Include="WindsorInstallers\ViewModelsInstaller.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Filtration.Interface\Filtration.Interface.csproj">
<Project>{0f333344-7695-47b2-b0e6-172e4de74819}</Project>
<Name>Filtration.Interface</Name>
</ProjectReference>
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
<Project>{4aac3beb-1dc1-483e-9d11-0e9334e80227}</Project>
<Name>Filtration.ObjectModel</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Page Include="Views\ThemeEditorView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -0,0 +1,14 @@
using Filtration.Interface;
namespace Filtration.ThemeEditor.ViewModels
{
public interface IThemeEditorViewModel : IDocument
{
}
public class ThemeEditorViewModel : IThemeEditorViewModel
{
public bool IsScript { get { return false; }}
public string Title { get { return "Theme Editor"; } }
}
}

View File

@ -0,0 +1,13 @@
<UserControl x:Class="Filtration.ThemeEditor.Views.ThemeEditorView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:viewModels="clr-namespace:Filtration.ThemeEditor.ViewModels"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:ThemeEditorViewModel}"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<TextBlock>theme editor goes here!</TextBlock>
</Grid>
</UserControl>

View File

@ -0,0 +1,10 @@
namespace Filtration.ThemeEditor.Views
{
public partial class ThemeEditorView
{
public ThemeEditorView()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,18 @@
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using Filtration.ThemeEditor.ViewModels;
namespace Filtration.ThemeEditor.WindsorInstallers
{
public class ViewModelsInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(
Component.For<IThemeEditorViewModel>()
.ImplementedBy<ThemeEditorViewModel>()
.LifeStyle.Singleton);
}
}
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="3.3.0" targetFramework="net451" />
<package id="Castle.Windsor" version="3.3.0" targetFramework="net451" />
</packages>

View File

@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.ThemeEditor", "F
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.ThemeEditor.Tests", "Filtration.ThemeEditor.Tests\Filtration.ThemeEditor.Tests.csproj", "{450AC313-BF25-4BFD-A066-9F39F026FDCF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.Interface", "Filtration.Interface\Filtration.Interface.csproj", "{0F333344-7695-47B2-B0E6-172E4DE74819}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -45,6 +47,10 @@ Global
{450AC313-BF25-4BFD-A066-9F39F026FDCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{450AC313-BF25-4BFD-A066-9F39F026FDCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{450AC313-BF25-4BFD-A066-9F39F026FDCF}.Release|Any CPU.Build.0 = Release|Any CPU
{0F333344-7695-47B2-B0E6-172E4DE74819}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F333344-7695-47B2-B0E6-172E4DE74819}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F333344-7695-47B2-B0E6-172E4DE74819}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F333344-7695-47B2-B0E6-172E4DE74819}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -23,7 +23,7 @@ namespace Filtration
_container.Kernel.ComponentModelBuilder.RemoveContributor(propInjector);
_container.Install(FromAssembly.This());
_container.Install(FromAssembly.InThisApplication());
var mainWindow = _container.Resolve<IMainWindow>();
mainWindow.Show();

View File

@ -1,7 +1,7 @@
using System;
using System.Globalization;
using System.Windows.Data;
using Filtration.ViewModels;
using Filtration.Interface;
namespace Filtration.Converters
{

View File

@ -156,7 +156,6 @@
<Compile Include="ViewModels\SettingsWindowViewModel.cs" />
<Compile Include="ViewModels\ToolPanes\BlockGroupBrowserViewModel.cs" />
<Compile Include="ViewModels\FiltrationViewModelBase.cs" />
<Compile Include="ViewModels\IDocument.cs" />
<Compile Include="ViewModels\IItemFilterScriptViewModelFactory.cs" />
<Compile Include="ViewModels\IItemFilterBlockViewModelFactory.cs" />
<Compile Include="ViewModels\ItemFilterBlockGroupViewModel.cs" />
@ -421,10 +420,18 @@
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Filtration.Interface\Filtration.Interface.csproj">
<Project>{0f333344-7695-47b2-b0e6-172e4de74819}</Project>
<Name>Filtration.Interface</Name>
</ProjectReference>
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
<Project>{4aac3beb-1dc1-483e-9d11-0e9334e80227}</Project>
<Name>Filtration.ObjectModel</Name>
</ProjectReference>
<ProjectReference Include="..\Filtration.ThemeEditor\Filtration.ThemeEditor.csproj">
<Project>{41b8f5c2-65aa-42f0-a20b-6f95b13a9f48}</Project>
<Name>Filtration.ThemeEditor</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Filtration.Interface;
using Filtration.ViewModels.ToolPanes;
using GalaSoft.MvvmLight.Messaging;
@ -10,6 +11,7 @@ namespace Filtration.ViewModels
{
event EventHandler ActiveDocumentChanged;
IDocument ActiveDocument { get; set; }
ReadOnlyObservableCollection<IDocument> OpenDocuments { get; }
IItemFilterScriptViewModel ActiveScriptViewModel { get; }
ISectionBrowserViewModel SectionBrowserViewModel { get; }
IBlockGroupBrowserViewModel BlockGroupBrowserViewModel { get; }
@ -28,6 +30,7 @@ namespace Filtration.ViewModels
private IDocument _activeDocument;
private IItemFilterScriptViewModel _activeScriptViewModel;
private readonly ObservableCollection<IDocument> _openDocuments;
private readonly ReadOnlyObservableCollection<IDocument> _readOnlyOpenDocuments;
public AvalonDockWorkspaceViewModel(ISectionBrowserViewModel sectionBrowserViewModel,
IBlockGroupBrowserViewModel blockGroupBrowserViewModel,
@ -43,14 +46,15 @@ namespace Filtration.ViewModels
_blockOutputPreviewViewModel.Initialise(this);
_openDocuments = new ObservableCollection<IDocument> {startPageViewModel};
_readOnlyOpenDocuments = new ReadOnlyObservableCollection<IDocument>(_openDocuments);
ActiveDocument = startPageViewModel;
}
public event EventHandler ActiveDocumentChanged;
public ObservableCollection<IDocument> OpenDocuments
public ReadOnlyObservableCollection<IDocument> OpenDocuments
{
get { return _openDocuments; }
get { return _readOnlyOpenDocuments; }
}
public IDocument ActiveDocument
@ -121,7 +125,7 @@ namespace Filtration.ViewModels
_activeScriptViewModel = (IItemFilterScriptViewModel) document;
}
OpenDocuments.Add(document);
_openDocuments.Add(document);
ActiveDocument = document;
}
@ -139,7 +143,7 @@ namespace Filtration.ViewModels
_blockOutputPreviewViewModel.ClearDown();
}
OpenDocuments.Remove(document);
_openDocuments.Remove(document);
}
public void SwitchActiveDocument(IDocument document)

View File

@ -1,7 +0,0 @@
namespace Filtration.ViewModels
{
interface IDocument
{
bool IsScript { get; }
}
}

View File

@ -8,6 +8,7 @@ using System.Windows;
using System.Windows.Data;
using System.Windows.Forms;
using Castle.Core.Internal;
using Filtration.Interface;
using Filtration.ObjectModel;
using Filtration.Services;
using Filtration.Translators;

View File

@ -2,7 +2,9 @@
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using Filtration.Interface;
using Filtration.Repositories;
using Filtration.ThemeEditor.ViewModels;
using Filtration.Translators;
using Filtration.Views;
using GalaSoft.MvvmLight.CommandWpf;
@ -25,6 +27,7 @@ namespace Filtration.ViewModels
private readonly IReplaceColorsViewModel _replaceColorsViewModel;
private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel;
private readonly ISettingsWindowViewModel _settingsWindowViewModel;
private readonly IThemeEditorViewModel _themeEditorViewModel;
private IDocument _activeDocument;
@ -32,16 +35,19 @@ namespace Filtration.ViewModels
IItemFilterScriptTranslator itemFilterScriptTranslator,
IReplaceColorsViewModel replaceColorsViewModel,
IAvalonDockWorkspaceViewModel avalonDockWorkspaceViewModel,
ISettingsWindowViewModel settingsWindowViewModel)
ISettingsWindowViewModel settingsWindowViewModel,
IThemeEditorViewModel themeEditorViewModel)
{
_itemFilterScriptRepository = itemFilterScriptRepository;
_itemFilterScriptTranslator = itemFilterScriptTranslator;
_replaceColorsViewModel = replaceColorsViewModel;
_avalonDockWorkspaceViewModel = avalonDockWorkspaceViewModel;
_settingsWindowViewModel = settingsWindowViewModel;
_themeEditorViewModel = themeEditorViewModel;
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);
@ -100,6 +106,7 @@ namespace Filtration.ViewModels
public RelayCommand CloseScriptCommand { 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 IAvalonDockWorkspaceViewModel AvalonDockWorkspaceViewModel
@ -122,6 +129,18 @@ namespace Filtration.ViewModels
return _activeDocument != null && _activeDocument.IsScript;
}
private void OnOpenThemeEditorCommand()
{
if (AvalonDockWorkspaceViewModel.OpenDocuments.Contains(_themeEditorViewModel))
{
AvalonDockWorkspaceViewModel.SwitchActiveDocument(_themeEditorViewModel);
}
else
{
AvalonDockWorkspaceViewModel.AddDocument(_themeEditorViewModel);
}
}
private void OnOpenAboutWindowCommand()
{
var aboutWindow = new AboutWindow();

View File

@ -1,4 +1,5 @@
using Filtration.ViewModels.ToolPanes;
using Filtration.Interface;
using Filtration.ViewModels.ToolPanes;
using GalaSoft.MvvmLight.CommandWpf;
using GalaSoft.MvvmLight.Messaging;

View File

@ -9,6 +9,7 @@
xmlns:toolPanes="clr-namespace:Filtration.Views.ToolPanes"
xmlns:converters="clr-namespace:Filtration.Converters"
xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
xmlns:themeEditorViews="clr-namespace:Filtration.ThemeEditor.Views;assembly=Filtration.ThemeEditor"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance d:Type=viewModels:AvalonDockWorkspaceViewModel}"
d:DesignHeight="300" d:DesignWidth="300">
@ -53,6 +54,11 @@
<views:StartPageView DataContext="{Binding}" />
</DataTemplate>
</viewsAvalonDock:PanesTemplateSelector.StartPageTemplate>
<viewsAvalonDock:PanesTemplateSelector.ThemeEditorTemplate>
<DataTemplate>
<themeEditorViews:ThemeEditorView DataContext="{Binding}" />
</DataTemplate>
</viewsAvalonDock:PanesTemplateSelector.ThemeEditorTemplate>
</viewsAvalonDock:PanesTemplateSelector>
</xcad:DockingManager.LayoutItemTemplateSelector>

View File

@ -1,6 +1,6 @@
using System.Windows;
using System.Windows.Controls;
using Filtration.ViewModels;
using Filtration.Interface;
using Filtration.ViewModels.ToolPanes;
namespace Filtration.Views.AvalonDock

View File

@ -1,5 +1,6 @@
using System.Windows;
using System.Windows.Controls;
using Filtration.ThemeEditor.ViewModels;
using Filtration.ViewModels;
using Filtration.ViewModels.ToolPanes;
using Xceed.Wpf.AvalonDock.Layout;
@ -13,6 +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 override DataTemplate SelectTemplate(object item, DependencyObject container)
{
@ -23,6 +25,11 @@ namespace Filtration.Views.AvalonDock
return ItemFilterScriptTemplate;
}
if (item is ThemeEditorViewModel)
{
return ThemeEditorTemplate;
}
if (item is SectionBrowserViewModel)
{
return SectionBrowserTemplate;

View File

@ -33,6 +33,7 @@
</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">