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