Refactored the Item Preview boxes in the block list and the replace colors dialog to use a common UserControl
This commit is contained in:
parent
0bab1e7c9a
commit
dffe301c87
|
@ -148,6 +148,9 @@
|
||||||
<Compile Include="UserControls\EditableListBoxControl.xaml.cs">
|
<Compile Include="UserControls\EditableListBoxControl.xaml.cs">
|
||||||
<DependentUpon>EditableListBoxControl.xaml</DependentUpon>
|
<DependentUpon>EditableListBoxControl.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="UserControls\ItemPreviewControl.xaml.cs">
|
||||||
|
<DependentUpon>ItemPreviewControl.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Utilities\LineReader.cs" />
|
<Compile Include="Utilities\LineReader.cs" />
|
||||||
<Compile Include="ViewModels\FiltrationViewModelBase.cs" />
|
<Compile Include="ViewModels\FiltrationViewModelBase.cs" />
|
||||||
<Compile Include="ViewModels\ILootFilterScriptViewModelFactory.cs" />
|
<Compile Include="ViewModels\ILootFilterScriptViewModelFactory.cs" />
|
||||||
|
@ -183,6 +186,10 @@
|
||||||
<Compile Include="WindsorInstallers\TranslatorsInstaller.cs" />
|
<Compile Include="WindsorInstallers\TranslatorsInstaller.cs" />
|
||||||
<Compile Include="WindsorInstallers\ViewModelsInstaller.cs" />
|
<Compile Include="WindsorInstallers\ViewModelsInstaller.cs" />
|
||||||
<Compile Include="WindsorInstallers\ViewsInstaller.cs" />
|
<Compile Include="WindsorInstallers\ViewsInstaller.cs" />
|
||||||
|
<Page Include="UserControls\ItemPreviewControl.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\CrossButton.xaml">
|
<Page Include="Views\CrossButton.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
@ -203,7 +210,7 @@
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="Views\LootFilterBlockViewDictionary.xaml">
|
<Page Include="Views\SharedResourcesDictionary.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using Filtration.Annotations;
|
||||||
|
|
||||||
|
namespace Filtration.Models.BlockItemBaseTypes
|
||||||
|
{
|
||||||
|
abstract class BlockItemBase : ILootFilterBlockItem
|
||||||
|
{
|
||||||
|
public abstract string PrefixText { get; }
|
||||||
|
public abstract int MaximumAllowed { get; }
|
||||||
|
public abstract string DisplayHeading { get; }
|
||||||
|
public abstract string SummaryText { get; }
|
||||||
|
public abstract Color SummaryBackgroundColor { get; }
|
||||||
|
public abstract Color SummaryTextColor { get; }
|
||||||
|
public abstract int SortOrder { get; }
|
||||||
|
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
[NotifyPropertyChangedInvocator]
|
||||||
|
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||||
|
{
|
||||||
|
var handler = PropertyChanged;
|
||||||
|
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
<UserControl x:Class="Filtration.UserControls.ItemPreviewControl"
|
||||||
|
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:userControls="clr-namespace:Filtration.UserControls"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DataContext="{d:DesignInstance Type=userControls:ItemPreviewControl}"
|
||||||
|
d:DesignHeight="35" d:DesignWidth="170">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<ResourceDictionary Source="../Views/SharedResourcesDictionary.xaml" />
|
||||||
|
</UserControl.Resources>
|
||||||
|
<Grid Width="143" Height="28">
|
||||||
|
<Image Source="pack://application:,,,/resources/groundtile.png" Stretch="Fill" />
|
||||||
|
<Border Margin="3" Padding="4,0,4,2" BorderThickness="2" BorderBrush="{Binding BorderColor, Converter={StaticResource ColorToSolidColorBrushConverter}}">
|
||||||
|
<Border.Background>
|
||||||
|
<SolidColorBrush Color="{Binding BackgroundColor}" />
|
||||||
|
</Border.Background>
|
||||||
|
<TextBlock TextAlignment="Center" Text="Test Item Preview" Style="{StaticResource PathOfExileFont}">
|
||||||
|
<TextBlock.Foreground>
|
||||||
|
<SolidColorBrush Color="{Binding TextColor}" />
|
||||||
|
</TextBlock.Foreground>
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
|
@ -0,0 +1,74 @@
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
|
namespace Filtration.UserControls
|
||||||
|
{
|
||||||
|
public partial class ItemPreviewControl
|
||||||
|
{
|
||||||
|
public ItemPreviewControl()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
// ReSharper disable once PossibleNullReferenceException
|
||||||
|
(Content as FrameworkElement).DataContext = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty TextColorProperty = DependencyProperty.Register(
|
||||||
|
"TextColor",
|
||||||
|
typeof (Color),
|
||||||
|
typeof(ItemPreviewControl),
|
||||||
|
new FrameworkPropertyMetadata()
|
||||||
|
);
|
||||||
|
|
||||||
|
public static readonly DependencyProperty BackgroundColorProperty = DependencyProperty.Register(
|
||||||
|
"BackgroundColor",
|
||||||
|
typeof(Color),
|
||||||
|
typeof(ItemPreviewControl),
|
||||||
|
new FrameworkPropertyMetadata()
|
||||||
|
);
|
||||||
|
|
||||||
|
public static readonly DependencyProperty BorderColorProperty = DependencyProperty.Register(
|
||||||
|
"BorderColor",
|
||||||
|
typeof(Color),
|
||||||
|
typeof(ItemPreviewControl),
|
||||||
|
new FrameworkPropertyMetadata()
|
||||||
|
);
|
||||||
|
|
||||||
|
public Color TextColor
|
||||||
|
{
|
||||||
|
get { return (Color) GetValue(TextColorProperty); }
|
||||||
|
set { SetValue(TextColorProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color BackgroundColor
|
||||||
|
{
|
||||||
|
get { return (Color)GetValue(BackgroundColorProperty); }
|
||||||
|
set { SetValue(BackgroundColorProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color BorderColor
|
||||||
|
{
|
||||||
|
get { return (Color)GetValue(BorderColorProperty); }
|
||||||
|
set { SetValue(BorderColorProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
//private static void OnItemPreviewControlPropertyChanged(DependencyObject source,
|
||||||
|
// DependencyPropertyChangedEventArgs e)
|
||||||
|
//{
|
||||||
|
// var control = source as ItemPreviewControl;
|
||||||
|
// if (control == null) return;
|
||||||
|
|
||||||
|
// control.OnPropertyChanged("TextColor");
|
||||||
|
// control.OnPropertyChanged("BackgroundColor");
|
||||||
|
// control.OnPropertyChanged("BorderColor");
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
//[NotifyPropertyChangedInvocator]
|
||||||
|
//protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||||
|
//{
|
||||||
|
// var handler = PropertyChanged;
|
||||||
|
// if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,25 +31,28 @@ namespace Filtration.ViewModels
|
||||||
if (initialiseFromBlock.BlockItems.Count(b => b.GetType() == typeof (TextColorBlockItem)) > 0)
|
if (initialiseFromBlock.BlockItems.Count(b => b.GetType() == typeof (TextColorBlockItem)) > 0)
|
||||||
{
|
{
|
||||||
_replaceColorsParameterSet.ReplaceTextColor = true;
|
_replaceColorsParameterSet.ReplaceTextColor = true;
|
||||||
_replaceColorsParameterSet.OldTextColor =
|
var existingBlockColor = ((TextColorBlockItem)
|
||||||
((TextColorBlockItem)
|
|
||||||
initialiseFromBlock.BlockItems.First(b => b.GetType() == typeof (TextColorBlockItem))).Color;
|
initialiseFromBlock.BlockItems.First(b => b.GetType() == typeof (TextColorBlockItem))).Color;
|
||||||
|
_replaceColorsParameterSet.OldTextColor = existingBlockColor;
|
||||||
|
_replaceColorsParameterSet.NewTextColor = existingBlockColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initialiseFromBlock.BlockItems.Count(b => b.GetType() == typeof(BackgroundColorBlockItem)) > 0)
|
if (initialiseFromBlock.BlockItems.Count(b => b.GetType() == typeof(BackgroundColorBlockItem)) > 0)
|
||||||
{
|
{
|
||||||
_replaceColorsParameterSet.ReplaceBackgroundColor = true;
|
_replaceColorsParameterSet.ReplaceBackgroundColor = true;
|
||||||
_replaceColorsParameterSet.OldBackgroundColor =
|
var existingBlockColor = ((BackgroundColorBlockItem)
|
||||||
((BackgroundColorBlockItem)
|
|
||||||
initialiseFromBlock.BlockItems.First(b => b.GetType() == typeof(BackgroundColorBlockItem))).Color;
|
initialiseFromBlock.BlockItems.First(b => b.GetType() == typeof(BackgroundColorBlockItem))).Color;
|
||||||
|
_replaceColorsParameterSet.OldBackgroundColor = existingBlockColor;
|
||||||
|
_replaceColorsParameterSet.NewBackgroundColor = existingBlockColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initialiseFromBlock.BlockItems.Count(b => b.GetType() == typeof(BorderColorBlockItem)) > 0)
|
if (initialiseFromBlock.BlockItems.Count(b => b.GetType() == typeof(BorderColorBlockItem)) > 0)
|
||||||
{
|
{
|
||||||
_replaceColorsParameterSet.ReplaceBorderColor = true;
|
_replaceColorsParameterSet.ReplaceBorderColor = true;
|
||||||
_replaceColorsParameterSet.OldBorderColor =
|
var existingBlockColor = ((BorderColorBlockItem)
|
||||||
((BorderColorBlockItem)
|
|
||||||
initialiseFromBlock.BlockItems.First(b => b.GetType() == typeof(BorderColorBlockItem))).Color;
|
initialiseFromBlock.BlockItems.First(b => b.GetType() == typeof(BorderColorBlockItem))).Color;
|
||||||
|
_replaceColorsParameterSet.OldBorderColor = existingBlockColor;
|
||||||
|
_replaceColorsParameterSet.NewBorderColor = existingBlockColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
_lootFilterScript = lootFilterScript;
|
_lootFilterScript = lootFilterScript;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="LootFilterBlockViewDictionary.xaml" />
|
<ResourceDictionary Source="SharedResourcesDictionary.xaml" />
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<CollectionViewSource x:Key="AudioVisualBlockItemsViewSource" Source="{Binding AudioVisualBlockItems}">
|
<CollectionViewSource x:Key="AudioVisualBlockItemsViewSource" Source="{Binding AudioVisualBlockItems}">
|
||||||
<CollectionViewSource.SortDescriptions>
|
<CollectionViewSource.SortDescriptions>
|
||||||
|
|
|
@ -10,14 +10,13 @@
|
||||||
xmlns:blockItemTypes="clr-namespace:Filtration.Models.BlockItemTypes"
|
xmlns:blockItemTypes="clr-namespace:Filtration.Models.BlockItemTypes"
|
||||||
xmlns:enums="clr-namespace:Filtration.Enums"
|
xmlns:enums="clr-namespace:Filtration.Enums"
|
||||||
xmlns:extensions="clr-namespace:Filtration.Extensions"
|
xmlns:extensions="clr-namespace:Filtration.Extensions"
|
||||||
xmlns:models="clr-namespace:Filtration.Models"
|
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DataContext="{d:DesignInstance Type=viewModels:LootFilterBlockViewModel}"
|
d:DataContext="{d:DesignInstance Type=viewModels:LootFilterBlockViewModel}"
|
||||||
d:DesignHeight="200" d:DesignWidth="800">
|
d:DesignHeight="200" d:DesignWidth="800">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="LootFilterBlockViewDictionary.xaml" />
|
<ResourceDictionary Source="SharedResourcesDictionary.xaml" />
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<views:BindingProxy x:Key="proxy" Data="{Binding}" />
|
<views:BindingProxy x:Key="proxy" Data="{Binding}" />
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
@ -74,9 +73,6 @@
|
||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</ItemsControl.ItemsPanel>
|
</ItemsControl.ItemsPanel>
|
||||||
<ItemsControl.Resources>
|
<ItemsControl.Resources>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<DataTemplate DataType="{x:Type blockItemBaseTypes:BlockItemBase}">
|
<DataTemplate DataType="{x:Type blockItemBaseTypes:BlockItemBase}">
|
||||||
<Border BorderBrush="Black" CornerRadius="4" Margin="0,2,2,2" BorderThickness="1" Background="{Binding SummaryBackgroundColor, Converter={StaticResource ColorToSolidColorBrushConverter}}">
|
<Border BorderBrush="Black" CornerRadius="4" Margin="0,2,2,2" BorderThickness="1" Background="{Binding SummaryBackgroundColor, Converter={StaticResource ColorToSolidColorBrushConverter}}">
|
||||||
<TextBlock Text="{Binding SummaryText}" Margin="5,1,5,1" Foreground="{Binding SummaryTextColor, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
|
<TextBlock Text="{Binding SummaryText}" Margin="5,1,5,1" Foreground="{Binding SummaryTextColor, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
|
||||||
|
@ -89,7 +85,6 @@
|
||||||
</Border>
|
</Border>
|
||||||
</Button>
|
</Button>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
<!--</ItemsControl.ItemTemplate>-->
|
|
||||||
</ItemsControl.Resources>
|
</ItemsControl.Resources>
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -104,19 +99,7 @@
|
||||||
x:Name="ItemPreviewButton"
|
x:Name="ItemPreviewButton"
|
||||||
IsChecked="{Binding DisplaySettingsPopupOpen, Mode=OneWayToSource}"
|
IsChecked="{Binding DisplaySettingsPopupOpen, Mode=OneWayToSource}"
|
||||||
ToolTip="Click here to change color and font settings" Cursor="Hand" >
|
ToolTip="Click here to change color and font settings" Cursor="Hand" >
|
||||||
<Grid>
|
<userControls:ItemPreviewControl TextColor="{Binding DisplayTextColor}" BackgroundColor="{Binding DisplayBackgroundColor}" BorderColor="{Binding DisplayBorderColor}" />
|
||||||
<Image Source="pack://application:,,,/resources/groundtile.png" Stretch="Fill" />
|
|
||||||
<Border Margin="3" Padding="4,0,4,2" BorderThickness="2" BorderBrush="{Binding DisplayBorderColor, Converter={StaticResource ColorToSolidColorBrushConverter}}">
|
|
||||||
<Border.Background>
|
|
||||||
<SolidColorBrush Color="{Binding DisplayBackgroundColor}" />
|
|
||||||
</Border.Background>
|
|
||||||
<TextBlock TextAlignment="Center" Text="Test Item Preview" Style="{StaticResource PathOfExileFont}">
|
|
||||||
<TextBlock.Foreground>
|
|
||||||
<SolidColorBrush Color="{Binding DisplayTextColor}" />
|
|
||||||
</TextBlock.Foreground>
|
|
||||||
</TextBlock>
|
|
||||||
</Border>
|
|
||||||
</Grid>
|
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||||
xmlns:viewModels="clr-namespace:Filtration.ViewModels"
|
xmlns:viewModels="clr-namespace:Filtration.ViewModels"
|
||||||
|
xmlns:userControls="clr-namespace:Filtration.UserControls"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DataContext="{d:DesignInstance Type=viewModels:ReplaceColorsViewModel}"
|
d:DataContext="{d:DesignInstance Type=viewModels:ReplaceColorsViewModel}"
|
||||||
ShowMaxRestoreButton="False"
|
ShowMaxRestoreButton="False"
|
||||||
|
@ -15,7 +16,7 @@
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="LootFilterBlockViewDictionary.xaml" />
|
<ResourceDictionary Source="SharedResourcesDictionary.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
|
@ -56,19 +57,7 @@
|
||||||
<TextBlock Grid.Row="5" Grid.Column="2" VerticalAlignment="Center">New Border Color</TextBlock>
|
<TextBlock Grid.Row="5" Grid.Column="2" VerticalAlignment="Center">New Border Color</TextBlock>
|
||||||
<xctk:ColorPicker Grid.Row="5" Grid.Column="4" SelectedColor="{Binding NewBorderColor}" />
|
<xctk:ColorPicker Grid.Row="5" Grid.Column="4" SelectedColor="{Binding NewBorderColor}" />
|
||||||
|
|
||||||
<Grid Grid.Row="6" Grid.Column="4">
|
<userControls:ItemPreviewControl Grid.Row="6" Grid.Column="4" TextColor="{Binding DisplayTextColor}" BackgroundColor="{Binding DisplayBackgroundColor}" BorderColor="{Binding DisplayBorderColor}" />
|
||||||
<Image Source="pack://application:,,,/resources/groundtile.png" Stretch="Fill" />
|
|
||||||
<Border Padding="4,2,4,2" BorderThickness="2" BorderBrush="{Binding DisplayBorderColor, Converter={StaticResource ColorToSolidColorBrushConverter}}">
|
|
||||||
<Border.Background>
|
|
||||||
<SolidColorBrush Color="{Binding DisplayBackgroundColor}" />
|
|
||||||
</Border.Background>
|
|
||||||
<TextBlock TextAlignment="Center" Text="Test Item Preview" Style="{StaticResource PathOfExileFont}">
|
|
||||||
<TextBlock.Foreground>
|
|
||||||
<SolidColorBrush Color="{Binding DisplayTextColor}" />
|
|
||||||
</TextBlock.Foreground>
|
|
||||||
</TextBlock>
|
|
||||||
</Border>
|
|
||||||
</Grid>
|
|
||||||
<TextBlock Grid.Row="6" Grid.Column="2" VerticalAlignment="Center">Preview</TextBlock>
|
<TextBlock Grid.Row="6" Grid.Column="2" VerticalAlignment="Center">Preview</TextBlock>
|
||||||
<Button Grid.Row="7" Grid.Column="4" Command="{Binding ReplaceColorsCommand}">Replace Colors</Button>
|
<Button Grid.Row="7" Grid.Column="4" Command="{Binding ReplaceColorsCommand}">Replace Colors</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
Loading…
Reference in New Issue