More theme changes

This commit is contained in:
Ben
2015-07-06 13:41:46 +01:00
parent d6bd1678b4
commit cbbc7c25fa
24 changed files with 174 additions and 101 deletions

View File

@@ -19,17 +19,17 @@ namespace Filtration.ThemeEditor.Converters
switch (type.GetAttributeDescription())
{
case "TextColor":
case "Text":
{
return "Text";
return "Text Color Theme Components";
}
case "BorderColor":
case "Border":
{
return "Border";
return "Border Color Theme Components";
}
case "BackgroundColor":
case "Background":
{
return "Background";
return "Background Color Theme Components";
}
}

View File

@@ -95,6 +95,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Converters\ThemeComponentTypeToStringConverter.cs" />
<Compile Include="Messages\ThemeClosedMessage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Providers\ThemeProvider.cs" />
<Compile Include="Services\ThemePersistenceService.cs" />

View File

@@ -0,0 +1,9 @@
using Filtration.ThemeEditor.ViewModels;
namespace Filtration.ThemeEditor.Messages
{
public class ThemeClosedMessage
{
public IThemeEditorViewModel ClosedViewModel { get; set; }
}
}

View File

@@ -39,7 +39,7 @@ namespace Filtration.ThemeEditor.Providers
});
var themeViewModel = _themeViewModelFactory.Create();
themeViewModel.Initialise(themeComponentCollection, true);
themeViewModel.InitialiseForNewTheme(themeComponentCollection);
themeViewModel.FilePath = "Untitled.filtertheme";
return themeViewModel;
@@ -48,7 +48,7 @@ namespace Filtration.ThemeEditor.Providers
public IThemeEditorViewModel MasterThemeForScript(ItemFilterScript script)
{
var themeViewModel = _themeViewModelFactory.Create();
themeViewModel.Initialise(script.ThemeComponents, true);
themeViewModel.InitialiseForMasterTheme(script);
themeViewModel.FilePath = "<Master Theme> " + Path.GetFileName(script.FilePath);
return themeViewModel;

View File

@@ -7,10 +7,13 @@ using System.Windows.Media.Imaging;
using Filtration.Common.Services;
using Filtration.Common.ViewModels;
using Filtration.Interface;
using Filtration.ObjectModel;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.ThemeEditor;
using Filtration.ThemeEditor.Messages;
using Filtration.ThemeEditor.Providers;
using GalaSoft.MvvmLight.CommandWpf;
using GalaSoft.MvvmLight.Messaging;
using NLog;
namespace Filtration.ThemeEditor.ViewModels
@@ -19,9 +22,12 @@ namespace Filtration.ThemeEditor.ViewModels
{
RelayCommand<ThemeComponentType> AddThemeComponentCommand { get; }
RelayCommand<ThemeComponent> DeleteThemeComponentCommand { get; }
RelayCommand CloseCommand { get; }
void Initialise(ThemeComponentCollection themeComponentCollection, bool newTheme);
bool EditEnabled { get; }
void InitialiseForNewTheme(ThemeComponentCollection themeComponentCollection);
void InitialiseForMasterTheme(ItemFilterScript script);
bool IsMasterTheme { get; }
ItemFilterScript IsMasterThemeForScript { get; }
string Title { get; }
string FilePath { get; set; }
string Filename { get; }
@@ -46,29 +52,42 @@ namespace Filtration.ThemeEditor.ViewModels
_themeProvider = themeProvider;
_messageBoxService = messageBoxService;
AddThemeComponentCommand = new RelayCommand<ThemeComponentType>(OnAddThemeComponentCommand, t => EditEnabled);
AddThemeComponentCommand = new RelayCommand<ThemeComponentType>(OnAddThemeComponentCommand, t => IsMasterTheme);
DeleteThemeComponentCommand = new RelayCommand<ThemeComponent>(OnDeleteThemeComponentCommand,
t => EditEnabled && SelectedThemeComponent != null);
t => IsMasterTheme && SelectedThemeComponent != null);
CloseCommand = new RelayCommand(OnCloseCommand);
var icon = new BitmapImage();
icon.BeginInit();
icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/Theme.ico");
icon.EndInit();
IconSource = icon;
}
public RelayCommand<ThemeComponentType> AddThemeComponentCommand { get; private set; }
public RelayCommand<ThemeComponent> DeleteThemeComponentCommand { get; private set; }
public RelayCommand CloseCommand { get; private set; }
public bool EditEnabled
public bool IsMasterTheme
{
get { return Components.IsMasterCollection; }
}
public void Initialise(ThemeComponentCollection themeComponentCollection, bool newTheme)
public ItemFilterScript IsMasterThemeForScript { get; private set; }
public void InitialiseForNewTheme(ThemeComponentCollection themeComponentCollection)
{
Components = themeComponentCollection;
_filenameIsFake = newTheme;
_filenameIsFake = true;
}
public void InitialiseForMasterTheme(ItemFilterScript script)
{
Components = script.ThemeComponents;
IsMasterThemeForScript = script;
_filenameIsFake = true;
}
public bool IsScript { get { return false; } }
@@ -106,6 +125,8 @@ namespace Filtration.ThemeEditor.ViewModels
public void Save()
{
if (IsMasterTheme) return;
if (_filenameIsFake)
{
SaveAs();
@@ -130,6 +151,8 @@ namespace Filtration.ThemeEditor.ViewModels
public void SaveAs()
{
if (IsMasterTheme) return;
var saveDialog = new SaveFileDialog
{
DefaultExt = ".filter",
@@ -161,11 +184,16 @@ namespace Filtration.ThemeEditor.ViewModels
}
}
public void Close()
public void OnCloseCommand()
{
throw new NotImplementedException();
Close();
}
public void Close()
{
Messenger.Default.Send(new ThemeClosedMessage { ClosedViewModel = this });
}
private void OnAddThemeComponentCommand(ThemeComponentType themeComponentType)
{
Components.Add(new ThemeComponent(themeComponentType, "Untitled Component",

View File

@@ -4,15 +4,13 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:converters="clr-namespace:Filtration.ThemeEditor.Converters"
xmlns:commonConverters="clr-namespace:Filtration.Common.Converters;assembly=Filtration.Common"
xmlns:themeEditor="clr-namespace:Filtration.ObjectModel.ThemeEditor;assembly=Filtration.ObjectModel"
xmlns:views="clr-namespace:Filtration.ThemeEditor.Views"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=themeEditor:ThemeComponent}"
d:DesignHeight="40" d:DesignWidth="200">
d:DesignHeight="100" d:DesignWidth="200">
<UserControl.Resources>
<converters:ThemeComponentTypeToStringConverter x:Key="ThemeComponentTypeToStringConverter" />
<commonConverters:BooleanVisibilityConverter x:Key="BooleanVisibilityConverter" />
</UserControl.Resources>
<Grid Width="200">
@@ -53,17 +51,17 @@
<ContentControl.Style>
<Style TargetType="ContentControl">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=DataContext.EditEnabled, RelativeSource={RelativeSource AncestorType={x:Type views:ThemeEditorView}}}" Value="true">
<DataTrigger Binding="{Binding Path=DataContext.IsMasterTheme, RelativeSource={RelativeSource AncestorType={x:Type views:ThemeEditorView}}}" Value="true">
<Setter Property="ContentTemplate" Value="{StaticResource EditableComponentNameTemplate}" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=DataContext.EditEnabled, RelativeSource={RelativeSource AncestorType={x:Type views:ThemeEditorView}}}" Value="false">
<DataTrigger Binding="{Binding Path=DataContext.IsMasterTheme, RelativeSource={RelativeSource AncestorType={x:Type views:ThemeEditorView}}}" Value="false">
<Setter Property="ContentTemplate" Value="{StaticResource ViewOnlyComponentNameTemplate}" />
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
</ContentControl>
<xctk:ColorPicker Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" SelectedColor="{Binding Color}" />
</Grid>
</UserControl>

View File

@@ -6,24 +6,33 @@
xmlns:viewModels="clr-namespace:Filtration.ThemeEditor.ViewModels"
xmlns:views="clr-namespace:Filtration.ThemeEditor.Views"
xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
xmlns:converters="clr-namespace:Filtration.ThemeEditor.Converters"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:ThemeEditorViewModel}"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<CollectionViewSource Source="{Binding Components}" x:Key="ComponentsViewSource">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="ComponentType" />
</CollectionViewSource.GroupDescriptions>
<CollectionViewSource.SortDescriptions>
<componentModel:SortDescription PropertyName="ComponentType" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<CollectionViewSource Source="{Binding Components}" x:Key="ComponentsViewSource">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="ComponentType" />
</CollectionViewSource.GroupDescriptions>
<CollectionViewSource.SortDescriptions>
<componentModel:SortDescription PropertyName="ComponentType" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
<converters:ThemeComponentTypeToStringConverter x:Key="ThemeComponentTypeToStringConverter" />
</ResourceDictionary>
<ResourceDictionary Source="pack://application:,,,/Filtration.Common;component/Styles/SharedResourcesDictionary.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid Margin="10">
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
<ListView ItemsSource="{Binding Source={StaticResource ComponentsViewSource}}"
SelectedItem="{Binding SelectedThemeComponent}"
Margin="10"
Margin="5"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.Resources>
<Style TargetType="ListViewItem">
@@ -53,7 +62,7 @@
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock FontWeight="Bold" FontSize="15" Text="{Binding Path=Name}"/>
<TextBlock FontWeight="Bold" FontSize="15" Text="{Binding Path=Name, Converter={StaticResource ThemeComponentTypeToStringConverter}}"/>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>