feat: add color resource copy.

This commit is contained in:
rabbitism
2023-03-27 11:25:47 +08:00
parent fd33972dda
commit e6531d89eb
4 changed files with 55 additions and 11 deletions

View File

@@ -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;
}
}