Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Fixed theme serialization/deserialization and added them toolbar icons
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-wallis committed Jul 6, 2015
1 parent a496ab9 commit 1b63f68
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 34 deletions.
3 changes: 3 additions & 0 deletions Filtration.ObjectModel/ThemeEditor/Theme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media;
using System.Xml.Serialization;
using Filtration.ObjectModel.Enums;

namespace Filtration.ObjectModel.ThemeEditor
Expand All @@ -17,6 +18,8 @@ public Theme()
}

public string Name { get; set; }

[XmlIgnore]
public string FilePath { get; set; }

public ThemeComponentCollection Components
Expand Down
10 changes: 8 additions & 2 deletions Filtration.ObjectModel/ThemeEditor/ThemeComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Media;
using System.Xml.Serialization;
using Filtration.ObjectModel.Annotations;
using Filtration.ObjectModel.Enums;

Expand All @@ -13,7 +14,12 @@ public class ThemeComponent : INotifyPropertyChanged
private Color _color;
private EventHandler _themeComponentUpdatedEventHandler;
private readonly object _eventLock = new object();


public ThemeComponent()
{

}

public ThemeComponent(ThemeComponentType componentType, string componentName, Color componentColor)
{
if (componentName == null || componentColor == null)
Expand Down Expand Up @@ -51,7 +57,7 @@ public event EventHandler ThemeComponentUpdated
public event EventHandler ThemeComponentDeleted;

public string ComponentName { get; set; }
public ThemeComponentType ComponentType{ get; private set; }
public ThemeComponentType ComponentType{ get; set; }

public Color Color
{
Expand Down
1 change: 1 addition & 0 deletions Filtration.ThemeEditor/ViewModels/ThemeEditorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public void SaveAs()
FilePath = saveDialog.FileName;
_themeProvider.SaveTheme(this, FilePath);
_filenameIsFake = false;
Title = Filename;
//RemoveDirtyFlag();
}
catch (Exception e)
Expand Down
42 changes: 20 additions & 22 deletions Filtration.ThemeEditor/Views/ThemeComponentControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="25" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.Resources>
<DataTemplate x:Key="EditableComponentNameTemplate">
<TextBox Text="{Binding ComponentName}" />
Expand All @@ -31,23 +27,25 @@
<TextBlock Text="{Binding ComponentName}" ToolTip="{Binding ComponentName}" />
</DataTemplate>
</Grid.Resources>
<TextBlock Grid.Row="0"
Grid.Column="1"
Text="{Binding UsageCount, StringFormat='Usages: {0}'}"
FontSize="10"
Visibility="{Binding Path=DataContext.EditEnabled, RelativeSource={RelativeSource AncestorType={x:Type views:ThemeEditorView}}, Converter={StaticResource BooleanVisibilityConverter}}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding UsageCount}" Value="0">
<Setter Property="Foreground" Value="Red" />
</DataTrigger>
</Style.Triggers>
<Setter Property="Foreground" Value="SteelBlue"></Setter>
</Style>
</TextBlock.Style>
</TextBlock>
<ContentControl Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Content="{Binding}">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Left"
Text="{Binding UsageCount, StringFormat='Usages: {0}'}"
FontSize="10"
HorizontalAlignment="Right"
Visibility="{Binding Path=DataContext.EditEnabled, RelativeSource={RelativeSource AncestorType={x:Type views:ThemeEditorView}}, Converter={StaticResource BooleanVisibilityConverter}}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding UsageCount}" Value="0">
<Setter Property="Foreground" Value="Red" />
</DataTrigger>
</Style.Triggers>
<Setter Property="Foreground" Value="SteelBlue" />
</Style>
</TextBlock.Style>
</TextBlock>
</DockPanel>
<ContentControl Grid.Row="1" Content="{Binding}">
<ContentControl.Style>
<Style TargetType="ContentControl">
<Style.Triggers>
Expand All @@ -62,6 +60,6 @@
</ContentControl.Style>
</ContentControl>

<xctk:ColorPicker Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" SelectedColor="{Binding Color}" />
<xctk:ColorPicker Grid.Row="2" SelectedColor="{Binding Color}" />
</Grid>
</UserControl>
4 changes: 2 additions & 2 deletions Filtration.ThemeEditor/Views/ThemeEditorView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<Border Name="Border" Padding="2" SnapsToDevicePixels="true">
<Border Name="Border" BorderBrush="Black" Background="White" BorderThickness="1" CornerRadius="3" Margin="2" SnapsToDevicePixels="true">
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
Expand All @@ -62,7 +62,7 @@
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock FontWeight="Bold" FontSize="15" Text="{Binding Path=Name, Converter={StaticResource ThemeComponentTypeToStringConverter}}"/>
<TextBlock Margin="7,5,0,0" FontWeight="Bold" FontSize="15" Text="{Binding Path=Name, Converter={StaticResource ThemeComponentTypeToStringConverter}}"/>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
Expand Down
2 changes: 2 additions & 0 deletions Filtration/Filtration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@
<Resource Include="Resources\Icons\ReplaceColors.ico" />
<Resource Include="Resources\Icons\Theme.ico" />
<Resource Include="Resources\Icons\filtration_icon.png" />
<Resource Include="Resources\Icons\Add.ico" />
<Resource Include="Resources\Icons\ThemeComponentDelete.ico" />
<Content Include="Resources\ItemBaseTypes.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down
Binary file added Filtration/Resources/Icons/Add.ico
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions Filtration/Views/IconsDictionary.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@
<Image Source="/Filtration;component/Resources/Icons/Paste.ico" x:Key="PasteIcon" x:Shared="False" />
<Image Source="/Filtration;component/Resources/Icons/PasteStyle.ico" x:Key="PasteStyleIcon" x:Shared="False" />
<Image Source="/Filtration;component/Resources/Icons/filtration_icon.png" x:Key="FiltrationIcon" x:Shared="False" />
<Image Source="/Filtration;component/Resources/Icons/Add.ico" x:Key="AddIcon" x:Shared="False" />
<Image Source="/Filtration;component/Resources/Icons/ThemeComponentDelete.ico" x:Key="ThemeComponentDeleteIcon" x:Shared="False" />
</ResourceDictionary>
16 changes: 8 additions & 8 deletions Filtration/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
xmlns:views="clr-namespace:Filtration.Views"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:MainWindowViewModel}"
Title="{Binding WindowTitle}" Height="768" Width="1100" BorderThickness="1" BorderBrush="Black" IsIconVisible="True" >
Title="{Binding WindowTitle}" Height="762" Width="1126" IsIconVisible="True" >
<fluent:RibbonWindow.InputBindings>
<KeyBinding Command="{Binding SaveCommand}" Modifiers="Control" Key="S" />
<KeyBinding Command="{Binding OpenScriptCommand}" Modifiers="Control" Key="O" />
Expand Down Expand Up @@ -64,9 +64,9 @@
</fluent:Ribbon.ContextualGroups>
<fluent:RibbonTabItem Header="View">
<fluent:RibbonGroupBox Header="Tools">
<fluent:ToggleButton Header="Section Browser" Width="150" SizeDefinition="Middle" Icon="{StaticResource AddSectionIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.SectionBrowserViewModel.IsVisible}" />
<fluent:ToggleButton Header="Block Group Browser" Width="150" SizeDefinition="Middle" Icon="{StaticResource BlockGroupBrowserIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.BlockGroupBrowserViewModel.IsVisible}" />
<fluent:ToggleButton Header="Block Output Preview" Width="150" SizeDefinition="Middle" Icon="{StaticResource BlockOutputPreviewIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.BlockOutputPreviewViewModel.IsVisible}" />
<fluent:ToggleButton Header="Section Browser" Width="150" Size="Middle" Icon="{StaticResource AddSectionIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.SectionBrowserViewModel.IsVisible}"/>
<fluent:ToggleButton Header="Block Group Browser" SizeDefinition="Middle" Icon="{StaticResource BlockGroupBrowserIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.BlockGroupBrowserViewModel.IsVisible}" />
<fluent:ToggleButton Header="Block Output Preview" SizeDefinition="Middle" Icon="{StaticResource BlockOutputPreviewIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.BlockOutputPreviewViewModel.IsVisible}" />
</fluent:RibbonGroupBox>
</fluent:RibbonTabItem>
<fluent:RibbonTabItem x:Name="ScriptToolsTabItem" Header="Script Tools" Group="{Binding ElementName=ScriptToolsGroup}" Visibility="{Binding ActiveDocumentIsScript, Converter={StaticResource BooleanVisibilityConverter}, Mode=OneWay}" >
Expand Down Expand Up @@ -103,12 +103,12 @@
</fluent:RibbonTabItem>
<fluent:RibbonTabItem x:Name="ThemeToolsTabItem" Header="Theme Tools" Group="{Binding ElementName=ThemeToolsGroup}" Visibility="{Binding ActiveDocumentIsTheme, Converter={StaticResource BooleanVisibilityConverter}, Mode=OneWay}">
<fluent:RibbonGroupBox Header="Add Components">
<fluent:Button SizeDefinition="Middle" Header="Add Text Color" Command="{Binding AddTextColorThemeComponentCommand}" />
<fluent:Button SizeDefinition="Middle" Header="Add Background Color" Command="{Binding AddBackgroundColorThemeComponentCommand}" />
<fluent:Button SizeDefinition="Middle" Header="Add Border Color" Command="{Binding AddBorderColorThemeComponentCommand}" />
<fluent:Button SizeDefinition="Middle" Header="Add Text Color" Icon="{StaticResource AddIcon}" Command="{Binding AddTextColorThemeComponentCommand}" />
<fluent:Button SizeDefinition="Middle" Header="Add Background Color" Icon="{StaticResource AddIcon}" Command="{Binding AddBackgroundColorThemeComponentCommand}" />
<fluent:Button SizeDefinition="Middle" Header="Add Border Color" Icon="{StaticResource AddIcon}" Command="{Binding AddBorderColorThemeComponentCommand}" />
</fluent:RibbonGroupBox>
<fluent:RibbonGroupBox Header="Delete">
<fluent:Button Header="Delete Theme Component" Command="{Binding DeleteThemeComponentCommand}" />
<fluent:Button Header="Delete Theme Component" Icon="{StaticResource ThemeComponentDeleteIcon}" LargeIcon="{StaticResource ThemeComponentDeleteIcon}" Command="{Binding DeleteThemeComponentCommand}" />
</fluent:RibbonGroupBox>
</fluent:RibbonTabItem>
</fluent:Ribbon>
Expand Down

0 comments on commit 1b63f68

Please sign in to comment.