forked from PieroCastillo/Aura.UI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
915efa3
commit dd2ecc2
Showing
12 changed files
with
226 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Styles xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<Design.PreviewWith> | ||
<Border Padding="20"> | ||
<HSVViewer Width="100" Height="100" Hue="360" Saturation="0.7" Value="0.5"/> | ||
</Border> | ||
</Design.PreviewWith> | ||
|
||
<Style Selector="HSVViewer"> | ||
<Setter Property="Template"> | ||
<ControlTemplate> | ||
<Border> | ||
<Border.Background> | ||
<SolidColorBrush Color="{Binding $parent[HSVViewer].SelectedColor}"/> | ||
</Border.Background> | ||
</Border> | ||
</ControlTemplate> | ||
</Setter> | ||
</Style> | ||
</Styles> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using Avalonia; | ||
using Avalonia.Controls.Primitives; | ||
using Avalonia.Media; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Aura.UI.Extensions; | ||
|
||
namespace Aura.UI.Controls.Painting | ||
{ | ||
public class HSVViewer : TemplatedControl | ||
{ | ||
public HSVViewer() | ||
{ | ||
this.GetObservable(HueProperty).Subscribe(UpdateColor); | ||
this.GetObservable(ValueProperty).Subscribe(UpdateColor); | ||
this.GetObservable(SaturationProperty).Subscribe(UpdateColor); | ||
} | ||
|
||
private void UpdateColor(double @object) | ||
{ | ||
SelectedColor = new HSV(Hue, Saturation, Value).ToColor(); | ||
//await Task.Run(() => | ||
//{ | ||
// | ||
//}); | ||
} | ||
|
||
public double Hue | ||
{ | ||
get => GetValue(HueProperty); | ||
set => SetValue(HueProperty, value); | ||
} | ||
|
||
public static readonly StyledProperty<double> HueProperty = | ||
AvaloniaProperty.Register<HSVViewer, double>(nameof(Hue),0); | ||
|
||
public double Saturation | ||
{ | ||
get => GetValue(SaturationProperty); | ||
set => SetValue(SaturationProperty, value); | ||
} | ||
|
||
public static readonly StyledProperty<double> SaturationProperty = | ||
AvaloniaProperty.Register<HSVViewer, double>(nameof(Saturation),0); | ||
|
||
public double Value | ||
{ | ||
get => GetValue(ValueProperty); | ||
set => SetValue(ValueProperty, value); | ||
} | ||
|
||
public static readonly StyledProperty<double> ValueProperty = | ||
AvaloniaProperty.Register<HSVViewer, double>(nameof(Value),1); | ||
|
||
|
||
private Color _SelectedColor; | ||
public Color SelectedColor | ||
{ | ||
get => _SelectedColor; | ||
set => SetAndRaise(SelectedColorProperty, ref _SelectedColor, value); | ||
} | ||
|
||
public static readonly DirectProperty<HSVViewer, Color> SelectedColorProperty = | ||
AvaloniaProperty.RegisterDirect<HSVViewer, Color>(nameof(SelectedColor), o => o.SelectedColor, (o, v) => o.SelectedColor = v); | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.