Skip to content

master pull request dev #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 60 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
ce64bc0
Update AnimationAudio.xaml
yanjinhuagood Aug 4, 2023
897ca8f
update CountdownTimer
yanjinhuagood Aug 4, 2023
cebba11
Update App.xaml
yanjinhuagood Aug 4, 2023
b41134d
Update Theme.xaml
yanjinhuagood Aug 4, 2023
74f2ac1
Merge branch 'dev' of https://github.com/WPFDevelopersOrg/WPFDevelope…
yanjinhuagood Aug 4, 2023
f50e43f
add in ColorPicker
yanjinhuagood Aug 6, 2023
aeafae4
add in ColorPickerExample
yanjinhuagood Aug 6, 2023
15ab960
Update MenuEnum.cs
yanjinhuagood Aug 6, 2023
99b44cf
Update MainVM.cs
yanjinhuagood Aug 6, 2023
6f58c14
Update Styles.GroupBox.xaml
yanjinhuagood Aug 6, 2023
4a83638
Update Styles.Menu.xaml
yanjinhuagood Aug 6, 2023
1e0a24f
Update Styles.MessageBox.xaml
yanjinhuagood Aug 6, 2023
29de636
Update Styles.PasswordBox.xaml
yanjinhuagood Aug 6, 2023
5d12759
Update Styles.RepeatButton.xaml
yanjinhuagood Aug 6, 2023
7209ada
Update ControlBasic.xaml
yanjinhuagood Aug 6, 2023
c580cf4
Update Message.xaml
yanjinhuagood Aug 6, 2023
b718ead
Update Theme40.txt
yanjinhuagood Aug 6, 2023
ed6dcb6
Update Theme45x.txt
yanjinhuagood Aug 6, 2023
04f63ed
Update Generic.xaml
yanjinhuagood Aug 6, 2023
b448736
Update Generic.xaml
yanjinhuagood Aug 6, 2023
e572673
Update Theme.xaml
yanjinhuagood Aug 6, 2023
ffc3011
Update Theme.xaml
yanjinhuagood Aug 6, 2023
1ef4619
Update WPFDevelopers.Shared.projitems
yanjinhuagood Aug 6, 2023
aa7ac2c
Update WPFDevelopers.SamplesCode.csproj
yanjinhuagood Aug 6, 2023
1705e89
Update WPFDevelopers.Samples.Shared.projitems
yanjinhuagood Aug 6, 2023
0a0603f
Update PackIconKind.cs
yanjinhuagood Aug 7, 2023
47ab849
Update PathIcon.xaml
yanjinhuagood Aug 7, 2023
05cf2f3
Update CropAvatar.xaml
yanjinhuagood Aug 7, 2023
f25f623
Update ColorPicker.xaml
yanjinhuagood Aug 7, 2023
376a3c8
Update CircularMenu.xaml
yanjinhuagood Aug 7, 2023
588caca
Update Geometrys.xaml
yanjinhuagood Aug 7, 2023
b31374f
Update ControlBasic.xaml
yanjinhuagood Aug 7, 2023
f81e7f8
Update ColorUtil.cs
yanjinhuagood Aug 7, 2023
37ded01
Update ColorPicker.cs
yanjinhuagood Aug 8, 2023
662fdf1
Update NumericBox.xaml
yanjinhuagood Aug 8, 2023
d62b82f
Update ColorPicker.xaml
yanjinhuagood Aug 8, 2023
a8e6666
Update ColorUtil.cs
yanjinhuagood Aug 8, 2023
c3909f7
Update TextBoxHelper.cs
yanjinhuagood Aug 8, 2023
7dddaac
Update ListBoxItemExtensions.cs
yanjinhuagood Aug 8, 2023
de508eb
Update WidthHeightEqualValueConverter.cs
yanjinhuagood Aug 8, 2023
c81fff3
Update ColorTypeToVisibilityConverter.cs
yanjinhuagood Aug 8, 2023
bb69347
Update ColorConverter.cs
yanjinhuagood Aug 8, 2023
4965ab2
Update Theme.xaml
yanjinhuagood Aug 8, 2023
825e660
Update NumericBox.xaml
yanjinhuagood Aug 15, 2023
d33cc69
Update ColorPicker.xaml
yanjinhuagood Aug 15, 2023
8317670
Update ColorUtil.cs
yanjinhuagood Aug 15, 2023
fe5fd2f
Update ColorConverter.cs
yanjinhuagood Aug 15, 2023
60ba9d6
Create HSL.cs
yanjinhuagood Aug 15, 2023
3d7b8c2
Update NumericBoxExample.xaml
yanjinhuagood Aug 15, 2023
6ef63a7
Update ColorPickerExample.xaml
yanjinhuagood Aug 15, 2023
1db36c3
Update Theme.xaml
yanjinhuagood Aug 15, 2023
07b4ade
Update Theme.xaml
yanjinhuagood Aug 15, 2023
0fa524f
Update WPFDevelopers.Shared.projitems
yanjinhuagood Aug 15, 2023
52fe61f
Update ColorPicker.xaml
yanjinhuagood Aug 16, 2023
fdb2bbe
Update ScreenCut.cs
yanjinhuagood Aug 16, 2023
f77f998
Update WPFMessageBox.cs
yanjinhuagood Aug 16, 2023
7c7cec5
Update ColorPicker.cs
yanjinhuagood Aug 16, 2023
0bfd665
Update WPFDevelopers.Samples45x.csproj
yanjinhuagood Aug 16, 2023
ef46790
Update WPFDevelopers.Samples40.csproj
yanjinhuagood Aug 16, 2023
cbb102c
Update Theme.xaml
yanjinhuagood Aug 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/WPFDevelopers.Net40/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type wd:Window}">
<Border
Name="PART_Border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Expand Down Expand Up @@ -161,7 +162,7 @@
<Trigger Property="WindowState" Value="Maximized">
<Setter TargetName="PART_RestoreButton" Property="Visibility" Value="Visible" />
<Setter TargetName="PART_MaximizeButton" Property="Visibility" Value="Collapsed" />
<Setter TargetName="LayoutRoot" Property="Margin" Value="7" />
<Setter TargetName="PART_Border" Property="Margin" Value="7" />
</Trigger>
<Trigger Property="WindowStyle" Value="ToolWindow">
<Setter TargetName="PART_MinAndMax" Property="Visibility" Value="Collapsed" />
Expand Down
287 changes: 245 additions & 42 deletions src/WPFDevelopers.Net40/Themes/Theme.xaml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/WPFDevelopers.Net45x/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type wd:Window}">
<Border
Name="PART_Border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Expand Down Expand Up @@ -167,7 +168,7 @@
<Trigger Property="WindowState" Value="Maximized">
<Setter TargetName="PART_RestoreButton" Property="Visibility" Value="Visible" />
<Setter TargetName="PART_MaximizeButton" Property="Visibility" Value="Collapsed" />
<Setter TargetName="LayoutRoot" Property="Margin" Value="7" />
<Setter TargetName="PART_Border" Property="Margin" Value="7" />
</Trigger>
<Trigger Property="WindowStyle" Value="ToolWindow">
<Setter TargetName="PART_MinAndMax" Property="Visibility" Value="Collapsed" />
Expand Down
287 changes: 245 additions & 42 deletions src/WPFDevelopers.Net45x/Themes/Theme.xaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/WPFDevelopers.Samples.Shared/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<!-- 需要注意ws:Resources 必须再配色主题后,Theme="Dark" 为黑色皮肤 -->
<wd:Resources Theme="Light" />
<ResourceDictionary Source="pack://application:,,,/WPFDevelopers;component/Themes/Theme.xaml" />
<!-- 下方不用拷贝 -->
<ResourceDictionary Source="pack://application:,,,/WPFDevelopers.Samples;component/ExampleViews/LoginWindow/Generic.xaml" />
<ResourceDictionary Source="pack://application:,,,/WPFDevelopers.Samples;component/Controls/CodeViewer/CodeViewer.xaml" />
<ResourceDictionary Source="pack://application:,,,/WPFDevelopers.Samples;component/Controls/TimeLine/TimeLine.xaml" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<UserControl
x:Class="WPFDevelopers.Samples.ExampleViews.ColorPickerExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<controls:CodeViewer>
<wd:ColorPicker />
<controls:CodeViewer.SourceCodes>
<controls:SourceCodeModel CodeSource="/WPFDevelopers.SamplesCode;component/ExampleViews/ColorPickerExample.xaml" CodeType="Xaml" />
<controls:SourceCodeModel CodeSource="/WPFDevelopers.SamplesCode;component/ExampleViews/ColorPickerExample.xaml.cs" CodeType="CSharp" />
</controls:CodeViewer.SourceCodes>
</controls:CodeViewer>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Windows.Controls;

namespace WPFDevelopers.Samples.ExampleViews
{
/// <summary>
/// BarrageExample.xaml 的交互逻辑
/// </summary>
public partial class ColorPickerExample : UserControl
{
public ColorPickerExample()
{
InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
Rows="1">
<wd:NumericBox
Width="100"
Height="30"
Maximum="100"
Minimum="0" />
<wd:NumericBox
Width="100"
Height="40"
Margin="10,0"
Maximum="1000"
Minimum="100"
Expand Down
1 change: 1 addition & 0 deletions src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public enum MenuEnum
Message,
PathIcon,
NumericBox,
ColorPicker,
VirtualizingWrapPanel,
AcrylicBlur,
TaskbarInfo
Expand Down
3 changes: 3 additions & 0 deletions src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ void MenuItemSelection(string _menuName)
case MenuEnum.NumericBox:
ControlPanel = new NumericBoxExample();
break;
case MenuEnum.ColorPicker:
ControlPanel = new ColorPickerExample();
break;
case MenuEnum.VirtualizingWrapPanel:
ControlPanel = new VirtualizingWrapPanel();
new VirtualizingWrapPanelExample().MaskShowDialog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@
<SubType>Code</SubType>
<DependentUpon>CircularProgressBarExample.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)ExampleViews\ColorPickerExample.xaml.cs">
<DependentUpon>ColorPickerExample.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)ExampleViews\CountdownTimerExample.xaml.cs">
<SubType>Code</SubType>
<DependentUpon>CountdownTimerExample.xaml</DependentUpon>
Expand Down Expand Up @@ -556,6 +559,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="$(MSBuildThisFileDirectory)ExampleViews\ColorPickerExample.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="$(MSBuildThisFileDirectory)ExampleViews\CountdownTimerExample.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
2 changes: 1 addition & 1 deletion src/WPFDevelopers.Samples40/WPFDevelopers.Samples40.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<PackageReference Include="WPFDevelopers" Version="1.1.0.2-preview1" />
<PackageReference Include="WPFDevelopers" Version="1.1.0.2-preview2" />
</ItemGroup>
<ItemGroup>
<Resource Include="..\WPFDevelopers.Samples.Shared\WPFDevelopers.ico">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ApplicationIcon>..\WPFDevelopers.Samples.Shared\WPFDevelopers.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="WPFDevelopers" Version="1.1.0.2-preview1" />
<PackageReference Include="WPFDevelopers" Version="1.1.0.2-preview2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
<Resource Include="..\WPFDevelopers.Samples.Shared\Controls\ScrollViewer\ScrollViewerAnimation.cs" Link="Controls\ScrollViewer\ScrollViewerAnimation.cs" />
<Resource Include="..\WPFDevelopers.Samples.Shared\Controls\ScrollViewer\ScrollViewerBehavior.cs" Link="Controls\ScrollViewer\ScrollViewerBehavior.cs" />
<Resource Include="..\WPFDevelopers.Samples.Shared\Controls\SongWords\SongWords.cs" Link="Controls\SongWords\SongWords.cs" />
<Resource Include="..\WPFDevelopers.Samples.Shared\Controls\CountdownTimer\CountdownTimer.cs" Link="Controls\CountdownTimer\CountdownTimer.cs" />
<Resource Include="..\WPFDevelopers.Samples.Shared\Controls\ElementAdorner\ElementAdorner.cs" Link="Controls\ElementAdorner\ElementAdorner.cs" />
<Resource Include="..\WPFDevelopers.Samples.Shared\Controls\ElementAdorner\ThumbAngle.cs" Link="Controls\ElementAdorner\ThumbAngle.cs" />
<Resource Include="..\WPFDevelopers.Samples.Shared\Controls\CropControl\CropControl.cs" Link="Controls\CropControl\CropControl.cs" />
Expand All @@ -137,6 +138,7 @@
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\NoneNoChromeWindow.xaml.cs" Link="ExampleViews\NoneNoChromeWindow.xaml.cs" DependentUpon="NoneNoChromeWindow.xaml" />
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\PathIconExample.xaml.cs" Link="ExampleViews\PathIconExample.xaml.cs" DependentUpon="PathIconExample.xaml" />
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\NumericBoxExample.xaml.cs" Link="ExampleViews\NumericBoxExample.xaml.cs" DependentUpon="NumericBoxExample.xaml" />
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\ColorPickerExample.xaml.cs" Link="ExampleViews\ColorPickerExample.xaml.cs" DependentUpon="ColorPickerExample.xaml" />
</ItemGroup>
<ItemGroup>
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\AboutWindow.xaml">
Expand Down Expand Up @@ -463,5 +465,8 @@
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\NumericBoxExample.xaml">
<Link>ExampleViews\NumericBoxExample.xaml</Link>
</Resource>
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\ColorPickerExample.xaml">
<Link>ExampleViews\ColorPickerExample.xaml</Link>
</Resource>
</ItemGroup>
</Project>
223 changes: 223 additions & 0 deletions src/WPFDevelopers.Shared/Controls/ColorPicker/ColorPicker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
using WPFDevelopers.Utilities;

namespace WPFDevelopers.Controls
{
[TemplatePart(Name = HueSliderColorTemplateName, Type = typeof(Slider))]
[TemplatePart(Name = CanvasTemplateName, Type = typeof(Canvas))]
[TemplatePart(Name = ThumbTemplateName, Type = typeof(Thumb))]
[TemplatePart(Name = ButtonTemplateName, Type = typeof(Button))]
public class ColorPicker : Control
{
private const string HueSliderColorTemplateName = "PART_HueSlider";

private const string CanvasTemplateName = "PART_Canvas";

private const string ThumbTemplateName = "PART_Thumb";

private const string ButtonTemplateName = "PART_Button";

private static readonly DependencyPropertyKey HueColorPropertyKey =
DependencyProperty.RegisterReadOnly("HueColor", typeof(Color), typeof(ColorPicker),
new PropertyMetadata(Colors.Red));

public static readonly DependencyProperty HueColorProperty = HueColorPropertyKey.DependencyProperty;

public static readonly DependencyProperty SelectedColorProperty =
DependencyProperty.Register("SelectedColor", typeof(Color), typeof(ColorPicker),
new FrameworkPropertyMetadata(Colors.Red, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
OnSelectedColorChanged));

private static readonly DependencyPropertyKey HSBPropertyKey =
DependencyProperty.RegisterReadOnly("HSB", typeof(HSB), typeof(ColorPicker),
new PropertyMetadata(new HSB()));

public static readonly DependencyProperty HSBHProperty = HSBPropertyKey.DependencyProperty;

public static readonly DependencyProperty ColorTypeProperty =
DependencyProperty.Register("ColorType", typeof(ColorTypeEnum), typeof(ColorPicker),
new PropertyMetadata(ColorTypeEnum.RGB));

private Button _button;

private Canvas _canvas;

private Slider _hueSliderColor;

private bool _isInnerUpdateSelectedColor;

private Thumb _thumb;

private ColorTypeEnum[] colorTypeEnums;

private int currentGridStateIndex;


static ColorPicker()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(ColorPicker),
new FrameworkPropertyMetadata(typeof(ColorPicker)));
}

public Color HueColor => (Color) GetValue(HueColorProperty);

public Color SelectedColor
{
get => (Color) GetValue(SelectedColorProperty);
set => SetValue(SelectedColorProperty, value);
}

public HSB HSB => (HSB) GetValue(HSBHProperty);


public ColorTypeEnum ColorType
{
get => (ColorTypeEnum) GetValue(ColorTypeProperty);
set => SetValue(ColorTypeProperty, value);
}

private static void OnSelectedColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var ctrl = d as ColorPicker;
if (ctrl._isInnerUpdateSelectedColor)
{
ctrl._isInnerUpdateSelectedColor = false;
return;
}

var color = (Color) e.NewValue;
double h = 0, s = 0, b = 0;
ColorUtil.HsbFromColor(color, ref h, ref s, ref b);
var hsb = new HSB {H = h, S = s, B = b};
ctrl.SetValue(HueColorPropertyKey, ColorUtil.ColorFromHsb(hsb.H, 1, 1));
ctrl.SetValue(HSBPropertyKey, hsb);
Canvas.SetLeft(ctrl._thumb, s * ctrl._canvas.ActualWidth - ctrl._thumb.ActualWidth / 2);
Canvas.SetTop(ctrl._thumb, (1 - b) * ctrl._canvas.ActualHeight - ctrl._thumb.ActualHeight / 2);
ctrl._hueSliderColor.Value = 1 - h;
}

public override void OnApplyTemplate()
{
base.OnApplyTemplate();
if (_hueSliderColor != null)
_hueSliderColor.ValueChanged -= HueSliderColor_OnValueChanged;
_canvas = GetTemplateChild(CanvasTemplateName) as Canvas;
if (_canvas != null)
{
_canvas.Loaded += Canvas_Loaded;
_canvas.MouseUp += Canvas_MouseUp;
}

_thumb = GetTemplateChild(ThumbTemplateName) as Thumb;
if (_thumb != null)
_thumb.DragDelta += Thumb_DragDelta;
_hueSliderColor = GetTemplateChild(HueSliderColorTemplateName) as Slider;
if (_hueSliderColor != null)
_hueSliderColor.ValueChanged += HueSliderColor_OnValueChanged;

_button = GetTemplateChild(ButtonTemplateName) as Button;
currentGridStateIndex = 0;
colorTypeEnums = (ColorTypeEnum[]) Enum.GetValues(typeof(ColorTypeEnum));
if (_button != null)
_button.Click += Button_Click;
}

private void Button_Click(object sender, RoutedEventArgs e)
{
currentGridStateIndex = (currentGridStateIndex + 1) % colorTypeEnums.Length;
ColorType = colorTypeEnums[currentGridStateIndex];
}

private void Canvas_MouseUp(object sender, MouseButtonEventArgs e)
{
var canvasPosition = e.GetPosition(_canvas);
GetHSB(canvasPosition);
}

private void Canvas_MouseDown(object sender, MouseButtonEventArgs e)
{
var canvasPosition = e.GetPosition(_canvas);
GetHSB(canvasPosition);
}

private void GetHSB(Point point, bool isMove = true)
{
var newLeft = point.X - _thumb.ActualWidth / 2;
var newTop = point.Y - _thumb.ActualHeight / 2;
var thumbW = _thumb.ActualWidth / 2;
var thumbH = _thumb.ActualHeight / 2;
var canvasRight = _canvas.ActualWidth - thumbW;
var canvasBottom = _canvas.ActualHeight - thumbH;
if (newLeft < -thumbW)
newLeft = -thumbW;
else if (newLeft > canvasRight)
newLeft = canvasRight;
if (newTop < -thumbH)
newTop = -thumbH;
else if (newTop > canvasBottom)
newTop = canvasBottom;

if (isMove)
{
Canvas.SetLeft(_thumb, newLeft);
Canvas.SetTop(_thumb, newTop);
}

var hsb = new HSB
{
H = HSB.H, S = (newLeft + thumbW) / _canvas.ActualWidth,
B = 1 - (newTop + thumbH) / _canvas.ActualHeight
};
SetValue(HSBPropertyKey, hsb);
var currentColor = ColorUtil.ColorFromAhsb(1, HSB.H, HSB.S, HSB.B);
if (SelectedColor != currentColor)
{
_isInnerUpdateSelectedColor = true;
SelectedColor = currentColor;
}
}

private void Thumb_DragDelta(object sender, DragDeltaEventArgs e)
{
var point = Mouse.GetPosition(_canvas);
GetHSB(point);
}

private void Canvas_Loaded(object sender, RoutedEventArgs e)
{
var width = (int) _canvas.ActualWidth;
var height = (int) _canvas.ActualHeight;
var point = new Point(width - _thumb.ActualWidth / 2, -_thumb.ActualHeight / 2);
Canvas.SetLeft(_thumb, point.X);
Canvas.SetTop(_thumb, point.Y);
var hsb = new HSB {H = _hueSliderColor.Value, S = HSB.S, B = HSB.B};
SetValue(HSBPropertyKey, hsb);
}

private void HueSliderColor_OnValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (DoubleUtil.AreClose(HSB.H, e.NewValue))
return;
var hsb = new HSB {H = 1 - e.NewValue, S = HSB.S, B = HSB.B};
SetValue(HSBPropertyKey, hsb);
SetValue(HueColorPropertyKey, ColorUtil.ColorFromHsb(HSB.H, 1, 1));

var newLeft = Canvas.GetLeft(_thumb);
var newTop = Canvas.GetTop(_thumb);
var point = new Point(newLeft, newTop);
GetHSB(point, false);
}
}

public enum ColorTypeEnum
{
RGB,
HSL,
HEX
}
}
Loading