feat: add color resource copy.
This commit is contained in:
parent
fd33972dda
commit
e6531d89eb
@ -21,8 +21,8 @@
|
||||
HorizontalAlignment="Stretch"
|
||||
Background="{TemplateBinding Background}"
|
||||
CornerRadius="6" />
|
||||
<Grid ColumnDefinitions="*, Auto" RowDefinitions="*, *, *, *, *, *">
|
||||
<!-- Row 0-1 ResourceKey -->
|
||||
<Grid ColumnDefinitions="*, Auto" RowDefinitions="*, *, *, *, *, *, *">
|
||||
<!-- Row 0-1-2 ResourceKey -->
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
@ -48,23 +48,43 @@
|
||||
Data="{StaticResource CopyIcon}"
|
||||
Foreground="{Binding $parent[Button].Foreground}" />
|
||||
</Button>
|
||||
|
||||
<!-- Row 2-3 HEX -->
|
||||
<TextBlock
|
||||
<SelectableTextBlock
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
IsVisible="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ColorResourceKey, Converter={x:Static ObjectConverters.IsNotNull}}"
|
||||
Text="{TemplateBinding ColorResourceKey}" />
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Classes="Tertiary"
|
||||
Command="{Binding $parent[controls:ColorDetailControl].Copy}"
|
||||
CommandParameter="{x:Static controls:ColorDetailControl.KEY_ColorResourceKey}"
|
||||
IsVisible="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ColorResourceKey, Converter={x:Static ObjectConverters.IsNotNull}}"
|
||||
Theme="{DynamicResource BorderlessButton}">
|
||||
<PathIcon
|
||||
Width="12"
|
||||
Height="12"
|
||||
Data="{StaticResource CopyIcon}"
|
||||
Foreground="{Binding $parent[Button].Foreground}" />
|
||||
</Button>
|
||||
|
||||
<!-- Row 3-4 HEX -->
|
||||
<TextBlock
|
||||
Grid.Row="3"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="4,8,0,0"
|
||||
VerticalAlignment="Center"
|
||||
Classes="Tertiary"
|
||||
Text="ARGB" />
|
||||
<SelectableTextBlock
|
||||
Grid.Row="3"
|
||||
Grid.Row="4"
|
||||
Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
Text="{TemplateBinding Hex}" />
|
||||
<Button
|
||||
Grid.Row="3"
|
||||
Grid.Row="4"
|
||||
Grid.Column="1"
|
||||
Classes="Tertiary"
|
||||
Command="{Binding $parent[controls:ColorDetailControl].Copy}"
|
||||
@ -77,9 +97,9 @@
|
||||
Foreground="{Binding $parent[Button].Foreground}" />
|
||||
</Button>
|
||||
|
||||
<!-- Row 4-5 Opacity -->
|
||||
<!-- Row 5-6 Opacity -->
|
||||
<TextBlock
|
||||
Grid.Row="4"
|
||||
Grid.Row="5"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="4,8,0,0"
|
||||
@ -87,12 +107,12 @@
|
||||
Classes="Tertiary"
|
||||
Text="Opacity" />
|
||||
<SelectableTextBlock
|
||||
Grid.Row="5"
|
||||
Grid.Row="6"
|
||||
Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
Text="{TemplateBinding OpacityNumber}" />
|
||||
<Button
|
||||
Grid.Row="5"
|
||||
Grid.Row="6"
|
||||
Grid.Column="1"
|
||||
Classes="Tertiary"
|
||||
Command="{Binding $parent[controls:ColorDetailControl].Copy}"
|
||||
|
@ -12,6 +12,7 @@ public class ColorDetailControl: TemplatedControl
|
||||
public const string KEY_ResourceKey = "ResourceKey";
|
||||
public const string KEY_Hex = "Hex";
|
||||
public const string KEY_Opacity = "Opacity";
|
||||
public const string KEY_ColorResourceKey = "ColorResourceKey";
|
||||
|
||||
public static readonly StyledProperty<string?> ResourceKeyProperty = AvaloniaProperty.Register<ColorDetailControl, string?>(
|
||||
nameof(ResourceKey));
|
||||
@ -30,6 +31,15 @@ public class ColorDetailControl: TemplatedControl
|
||||
set => SetValue(ResourceNameProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<string?> ColorResourceKeyProperty = AvaloniaProperty.Register<ColorDetailControl, string?>(
|
||||
nameof(ColorResourceKey));
|
||||
|
||||
public string? ColorResourceKey
|
||||
{
|
||||
get => GetValue(ColorResourceKeyProperty);
|
||||
set => SetValue(ColorResourceKeyProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DirectProperty<ColorDetailControl, string?> HexProperty = AvaloniaProperty.RegisterDirect<ColorDetailControl, string?>(
|
||||
nameof(Hex), o => o.Hex);
|
||||
private string? _hex;
|
||||
@ -49,6 +59,8 @@ public class ColorDetailControl: TemplatedControl
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static ColorDetailControl()
|
||||
{
|
||||
BackgroundProperty.Changed.AddClassHandler<ColorDetailControl>((o, e) => o.OnBackgroundChanged(e));
|
||||
@ -77,6 +89,8 @@ public class ColorDetailControl: TemplatedControl
|
||||
break;
|
||||
case KEY_Opacity: text = OpacityNumber;
|
||||
break;
|
||||
case KEY_ColorResourceKey: text = ColorResourceKey;
|
||||
break;
|
||||
default: text = string.Empty; break;
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,7 @@
|
||||
TextWrapping="Wrap" />
|
||||
<controls:ColorDetailControl
|
||||
Background="{Binding SelectedColor.Brush}"
|
||||
ColorResourceKey="{Binding SelectedColor.ColorResourceKey}"
|
||||
IsVisible="{Binding SelectedColor, Converter={x:Static ObjectConverters.IsNotNull}}"
|
||||
ResourceKey="{Binding SelectedColor.ResourceKey}"
|
||||
ResourceName="{Binding SelectedColor.ColorDisplayName}" />
|
||||
|
@ -134,6 +134,7 @@ public class ColorListViewModel: ObservableObject
|
||||
{
|
||||
string name = color + " " + i;
|
||||
var item = new ColorItemViewModel(name, brush, key, light, i);
|
||||
item.ColorResourceKey = item.ResourceKey + "Color";
|
||||
Color.Add(item);
|
||||
}
|
||||
}
|
||||
@ -173,6 +174,14 @@ public class ColorItemViewModel : ObservableObject
|
||||
set => SetProperty(ref _resourceKey, value);
|
||||
}
|
||||
|
||||
private string _colorResourceKey = null!;
|
||||
|
||||
public string ColorResourceKey
|
||||
{
|
||||
get => _colorResourceKey;
|
||||
set => SetProperty(ref _colorResourceKey, value);
|
||||
}
|
||||
|
||||
private string _hex = null!;
|
||||
|
||||
public string Hex
|
||||
|
Loading…
x
Reference in New Issue
Block a user