1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2026-03-24 10:18:47 +00:00

Added functionality to disable brush types in ColorBox

This commit is contained in:
SpoinkyNL 2016-10-10 19:09:50 +02:00
parent 481f1aab3b
commit edd9cf5332
6 changed files with 74 additions and 36 deletions

View File

@ -1,9 +1,10 @@
<UserControl x:Class="Artemis.Profiles.Layers.Types.Generic.GenericPropertiesView" <UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ncore="http://schemas.ncore.com/wpf/xaml/colorbox" xmlns:ncore="http://schemas.ncore.com/wpf/xaml/colorbox"
xmlns:ObjectModel="clr-namespace:System.Collections.ObjectModel;assembly=System" x:Class="Artemis.Profiles.Layers.Types.Generic.GenericPropertiesView"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="500"> d:DesignHeight="600" d:DesignWidth="500">
<Grid> <Grid>
@ -29,7 +30,7 @@
Height="22"> Height="22">
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding Path=Name, Mode=OneWay}" /> <TextBlock Text="{Binding Name, Mode=OneWay}" />
</DataTemplate> </DataTemplate>
</ComboBox.ItemTemplate> </ComboBox.ItemTemplate>
</ComboBox> </ComboBox>
@ -39,7 +40,7 @@
VerticalAlignment="Center" Height="18" /> VerticalAlignment="Center" Height="18" />
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Center" <Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Center"
TickPlacement="None" TickFrequency="0.05" TickPlacement="None" TickFrequency="0.05"
Value="{Binding Path=LayerModel.Properties.AnimationSpeed, Mode=TwoWay}" Minimum="0.05" Maximum="3" Value="{Binding LayerModel.Properties.AnimationSpeed, Mode=TwoWay}" Minimum="0.05" Maximum="3"
SmallChange="0" IsSnapToTickEnabled="True" Margin="10,12,10,2" Height="24" /> SmallChange="0" IsSnapToTickEnabled="True" Margin="10,12,10,2" Height="24" />
<!-- Colors --> <!-- Colors -->
@ -48,7 +49,7 @@
VerticalAlignment="Top" Height="18" Width="130" /> VerticalAlignment="Top" Height="18" Width="130" />
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}" <Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit"> BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" Height="24" Width="134" /> <ncore:ColorBox Brush="{Binding Brush, Mode=TwoWay}" Height="24" Width="134"/>
</Border> </Border>
</StackPanel> </StackPanel>
@ -62,15 +63,7 @@
<!-- Note --> <!-- Note -->
<TextBlock Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" Margin="10,2,10,10" FontSize="13.333" <TextBlock Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" Margin="10,2,10,10" FontSize="13.333"
Foreground="{DynamicResource HighlightBrush}" Foreground="{DynamicResource HighlightBrush}"
VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap"> VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap"><Run Text="Note: Generic devices are devices over which Artemis has limited control." /><LineBreak /><Run /><LineBreak /><Run Text="You can use this layer type to assign a color to all generic devices at once." /><LineBreak /><Run
<Run Text="Note: Generic devices are devices over which Artemis has limited control." /><LineBreak /> Text="Should your generic device have multiple LEDs, Artemis will try to take the colors from the Brush and spread them over the LEDs." /><LineBreak /><Run /><LineBreak /><Run Text="Examples of supported generic devices:" /><LineBreak /><Run Text="- Logitech mice and headsets" /><LineBreak /><Run Text="- Logitech G19" /><LineBreak /><Run Text="- Logitech G510" /><LineBreak /><Run /></TextBlock>
<Run /><LineBreak />
<Run Text="You can use this layer type to assign a color to all generic devices at once." /><LineBreak />
<Run
Text="Should your generic device have multiple LEDs, Artemis will try to take the colors from the Brush and spread them over the LEDs." />
<LineBreak /><Run /><LineBreak /><Run Text="Examples of supported generic devices:" /><LineBreak />
<Run Text="- Logitech mice and headsets" /><LineBreak /><Run Text="- Logitech G19" /><LineBreak />
<Run Text="- Logitech G510" /><LineBreak /><Run />
</TextBlock>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -1,13 +1,16 @@
using System.Linq; using System.Collections.Generic;
using System.Linq;
using Artemis.Profiles.Layers.Abstract; using Artemis.Profiles.Layers.Abstract;
using Artemis.Profiles.Layers.Interfaces; using Artemis.Profiles.Layers.Interfaces;
using Artemis.ViewModels.Profiles; using Artemis.ViewModels.Profiles;
using Caliburn.Micro; using Caliburn.Micro;
using ColorBox;
namespace Artemis.Profiles.Layers.Types.Generic namespace Artemis.Profiles.Layers.Types.Generic
{ {
public class GenericPropertiesViewModel : LayerPropertiesViewModel public class GenericPropertiesViewModel : LayerPropertiesViewModel
{ {
private IEnumerable<BrushTypes> _availableBrushTypes;
private ILayerAnimation _selectedLayerAnimation; private ILayerAnimation _selectedLayerAnimation;
public GenericPropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm) public GenericPropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)

View File

@ -60,7 +60,7 @@
VerticalAlignment="Top" Height="18" Width="130" /> VerticalAlignment="Top" Height="18" Width="130" />
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}" <Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit"> BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" Height="24" Width="134" /> <ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" Height="24" Width="134" ShowSolid="False"/>
</Border> </Border>
</StackPanel> </StackPanel>

View File

@ -207,7 +207,7 @@
<!-- Available brush types --> <!-- Available brush types -->
<ListBox x:Name="listAvailableBrushType" HorizontalContentAlignment="Center" <ListBox x:Name="listAvailableBrushType" HorizontalContentAlignment="Center"
SelectedItem="{Binding BrushType, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" SelectedItem="{Binding BrushType, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
ItemsSource="{Binding AvailableBrushTypes, RelativeSource={RelativeSource TemplatedParent}}"> ItemsSource="{Binding AvailableBrushTypes, RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Center">
<ListBox.ItemsPanel> <ListBox.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<UniformGrid Rows="1" Columns="4" /> <UniformGrid Rows="1" Columns="4" />
@ -219,7 +219,7 @@
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="ListBoxItem"> <ControlTemplate TargetType="ListBoxItem">
<Border x:Name="Border" Background="Transparent" <Border x:Name="Border" Background="Transparent"
Padding="0,3"> Padding="0,3" Margin="3,0">
<Path x:Name="Icon" Height="12" Width="20" <Path x:Name="Icon" Height="12" Width="20"
Stretch="Fill" Fill="#FF403C3C" Stretch="Fill" Fill="#FF403C3C"
StrokeThickness="1" StrokeThickness="1"

View File

@ -9,9 +9,12 @@
***********************************************************************************/ ***********************************************************************************/
using System;
namespace ColorBox namespace ColorBox
{ {
internal enum BrushTypes [Flags]
public enum BrushTypes
{ {
None, None,
Solid, Solid,

View File

@ -655,10 +655,14 @@ namespace ColorBox
{ {
get get
{ {
var temp = BrushTypes.None | BrushTypes.Solid | BrushTypes.Linear | BrushTypes.Radial; if (ShowNone)
foreach (Enum value in Enum.GetValues(temp.GetType())) yield return BrushTypes.None;
if (temp.HasFlag(value)) if (ShowSolid)
yield return value; yield return BrushTypes.Solid;
if (ShowLinear)
yield return BrushTypes.Linear;
if (ShowRadial)
yield return BrushTypes.Radial;
} }
} }
@ -668,9 +672,44 @@ namespace ColorBox
set { SetValue(BrushProperty, value); } set { SetValue(BrushProperty, value); }
} }
public static readonly DependencyProperty BrushProperty = public bool ShowNone
DependencyProperty.Register("Brush", typeof(Brush), typeof(ColorBox) {
, new FrameworkPropertyMetadata(null, BrushChanged)); get { return (bool) GetValue(ShowNoneProperty); }
set { SetValue(ShowNoneProperty, value); }
}
public bool ShowSolid
{
get { return (bool) GetValue(ShowSolidProperty); }
set { SetValue(ShowSolidProperty, value); }
}
public bool ShowLinear
{
get { return (bool) GetValue(ShowLinearProperty); }
set { SetValue(ShowLinearProperty, value); }
}
public bool ShowRadial
{
get { return (bool) GetValue(ShowRadialProperty); }
set { SetValue(ShowRadialProperty, value); }
}
public static readonly DependencyProperty ShowNoneProperty = DependencyProperty.Register("ShowNone",
typeof(bool), typeof(ColorBox), new FrameworkPropertyMetadata(true));
public static readonly DependencyProperty ShowSolidProperty = DependencyProperty.Register("ShowSolid",
typeof(bool), typeof(ColorBox), new FrameworkPropertyMetadata(true));
public static readonly DependencyProperty ShowLinearProperty = DependencyProperty.Register("ShowLinear",
typeof(bool), typeof(ColorBox), new FrameworkPropertyMetadata(true));
public static readonly DependencyProperty ShowRadialProperty = DependencyProperty.Register("ShowRadial",
typeof(bool), typeof(ColorBox), new FrameworkPropertyMetadata(true));
public static readonly DependencyProperty BrushProperty = DependencyProperty.Register("Brush", typeof(Brush),
typeof(ColorBox), new FrameworkPropertyMetadata(null, BrushChanged));
private static void BrushChanged(DependencyObject property, DependencyPropertyChangedEventArgs args) private static void BrushChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
{ {