Skip to content

Commit 5247372

Browse files
committed
Merge branch 'Color-Helper' of https://github.com/Avid29/CommunityToolkit-Windows into Color-Helper
2 parents bb8a350 + 08fffc6 commit 5247372

33 files changed

Lines changed: 439 additions & 93 deletions

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"uno.check": {
6-
"version": "1.27.4",
6+
"version": "1.33.1",
77
"commands": [
88
"uno-check"
99
]

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ jobs:
121121
--skip wsl
122122
--skip androidemulator
123123
--skip vswinworkloads
124+
--skip vswin
124125
--verbose
125126
126127
- name: Add msbuild to PATH
@@ -254,6 +255,7 @@ jobs:
254255
--skip wsl
255256
--skip androidemulator
256257
--skip vswinworkloads
258+
--skip vswin
257259
--verbose
258260
259261
- name: Add msbuild to PATH

ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Please read the [Getting Started with the Windows Community Toolkit](https://doc
2121
> [!NOTE]
2222
> If you're updating from a pre-8.x version of the Windows Community Toolkit, see [our migration notes here](https://aka.ms/toolkit/windows/migration).
2323
24-
## Windows Community Toolkit Gallery app
24+
## <sub><img src="icon.png" width="24" height="24" hspace="4"></sub> Windows Community Toolkit Gallery app
2525

2626
Want to see the Toolkit in action before jumping into the code? Download and play with the [Windows Community Toolkit Gallery](https://aka.ms/windowstoolkitapp) from the Microsoft Store.
2727

components/ColorPicker/src/ColorPicker.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ namespace CommunityToolkit.WinUI.Controls;
4646
[TemplatePart(Name = nameof(ColorPicker.ColorSpectrumControl), Type = typeof(ColorSpectrum))]
4747
[TemplatePart(Name = nameof(ColorPicker.ColorSpectrumAlphaSlider), Type = typeof(ColorPickerSlider))]
4848
[TemplatePart(Name = nameof(ColorPicker.ColorSpectrumThirdDimensionSlider), Type = typeof(ColorPickerSlider))]
49+
[TemplatePart(Name = nameof(ColorPicker.PaletteItemGridView), Type = typeof(GridView))]
4950
[TemplatePart(Name = nameof(ColorPicker.HexInputTextBox), Type = typeof(TextBox))]
5051
[TemplatePart(Name = nameof(ColorPicker.ColorModeComboBox), Type = typeof(ComboBox))]
5152

@@ -81,6 +82,7 @@ public partial class ColorPicker : Microsoft.UI.Xaml.Controls.ColorPicker
8182
private ColorSpectrum ColorSpectrumControl;
8283
private ColorPickerSlider ColorSpectrumAlphaSlider;
8384
private ColorPickerSlider ColorSpectrumThirdDimensionSlider;
85+
private GridView PaletteItemGridView;
8486
private TextBox HexInputTextBox;
8587
private ComboBox ColorModeComboBox;
8688

@@ -186,6 +188,8 @@ protected override void OnApplyTemplate()
186188
this.ColorSpectrumAlphaSlider = (ColorPickerSlider)this.GetTemplateChild(nameof(ColorSpectrumAlphaSlider));
187189
this.ColorSpectrumThirdDimensionSlider = (ColorPickerSlider)this.GetTemplateChild(nameof(ColorSpectrumThirdDimensionSlider));
188190

191+
this.PaletteItemGridView = (GridView)GetTemplateChild(nameof(PaletteItemGridView));
192+
189193
this.HexInputTextBox = (TextBox)this.GetTemplateChild(nameof(HexInputTextBox));
190194
this.ColorModeComboBox = (ComboBox)this.GetTemplateChild(nameof(ColorModeComboBox));
191195

@@ -263,6 +267,9 @@ private void ConnectEvents(bool connected)
263267

264268
if (this.ColorSpectrumControl != null) { this.ColorSpectrumControl.ColorChanged += ColorSpectrum_ColorChanged; }
265269
if (this.ColorSpectrumControl != null) { this.ColorSpectrumControl.GotFocus += ColorSpectrum_GotFocus; }
270+
271+
if (this.PaletteItemGridView != null) { this.PaletteItemGridView.SelectionChanged += this.PaletteItemGridView_SelectionChanged; }
272+
266273
if (this.HexInputTextBox != null) { this.HexInputTextBox.KeyDown += HexInputTextBox_KeyDown; }
267274
if (this.HexInputTextBox != null) { this.HexInputTextBox.LostFocus += HexInputTextBox_LostFocus; }
268275
if (this.ColorModeComboBox != null) { this.ColorModeComboBox.SelectionChanged += ColorModeComboBox_SelectionChanged; }
@@ -309,6 +316,9 @@ private void ConnectEvents(bool connected)
309316

310317
if (this.ColorSpectrumControl != null) { this.ColorSpectrumControl.ColorChanged -= ColorSpectrum_ColorChanged; }
311318
if (this.ColorSpectrumControl != null) { this.ColorSpectrumControl.GotFocus -= ColorSpectrum_GotFocus; }
319+
320+
if (this.PaletteItemGridView != null) { this.PaletteItemGridView.SelectionChanged -= this.PaletteItemGridView_SelectionChanged; }
321+
312322
if (this.HexInputTextBox != null) { this.HexInputTextBox.KeyDown -= HexInputTextBox_KeyDown; }
313323
if (this.HexInputTextBox != null) { this.HexInputTextBox.LostFocus -= HexInputTextBox_LostFocus; }
314324
if (this.ColorModeComboBox != null) { this.ColorModeComboBox.SelectionChanged -= ColorModeComboBox_SelectionChanged; }
@@ -1316,6 +1326,20 @@ private void ColorSpectrum_GotFocus(object sender, RoutedEventArgs e)
13161326
return;
13171327
}
13181328

1329+
/// <summary>
1330+
/// Event handler for when a color is selected from the palette.
1331+
/// This will update the current color.
1332+
/// </summary>
1333+
private void PaletteItemGridView_SelectionChanged(object sender, SelectionChangedEventArgs e)
1334+
{
1335+
if ((sender as GridView)?.SelectedValue is not Color selectedColor)
1336+
{
1337+
return;
1338+
}
1339+
1340+
this.Color = selectedColor;
1341+
}
1342+
13191343
/// <summary>
13201344
/// Event handler for when the selected color representation changes.
13211345
/// This will convert between RGB and HSV.

components/ColorPicker/src/ColorPicker.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,12 @@
286286
</controls:Case>
287287
<controls:Case Value="PaletteItem">
288288
<Grid HorizontalAlignment="Stretch">
289-
<GridView Margin="0"
289+
<GridView x:Name="PaletteItemGridView"
290+
Margin="0"
290291
Padding="0"
291292
animations:Implicit.HideAnimations="{StaticResource HideTransitions}"
292293
animations:Implicit.ShowAnimations="{StaticResource ShowTransitions}"
293294
ItemsSource="{TemplateBinding CustomPaletteColors}"
294-
SelectedValue="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Color, Converter={StaticResource NullToTransparentConverter}, Mode=TwoWay}"
295295
SelectionMode="Single"
296296
Tag="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Color, Mode=OneWay}">
297297
<GridView.ItemsPanel>

components/Extensions/samples/Dispatcher/KeyboardDebounceSample.xaml renamed to components/Extensions/samples/DispatcherQueueTimerExtensions/KeyboardDebounceSample.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Page x:Class="ExtensionsExperiment.Samples.DispatcherQueueExtensions.KeyboardDebounceSample"
1+
<Page x:Class="ExtensionsExperiment.Samples.DispatcherQueueTimerExtensions.KeyboardDebounceSample"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

components/Extensions/samples/Dispatcher/KeyboardDebounceSample.xaml.cs renamed to components/Extensions/samples/DispatcherQueueTimerExtensions/KeyboardDebounceSample.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
using DispatcherQueueTimer = Windows.System.DispatcherQueueTimer;
1212
#endif
1313

14-
namespace ExtensionsExperiment.Samples.DispatcherQueueExtensions;
14+
namespace ExtensionsExperiment.Samples.DispatcherQueueTimerExtensions;
1515

1616
[ToolkitSample(id: nameof(KeyboardDebounceSample), "DispatcherQueueTimer Debounce Keyboard", description: "A sample for showing how to use the DispatcherQueueTimer Debounce extension to smooth keyboard input.")]
1717
[ToolkitSampleNumericOption("Interval", 120, 60, 240)]

components/Extensions/samples/Dispatcher/MouseDebounceSample.xaml renamed to components/Extensions/samples/DispatcherQueueTimerExtensions/MouseDebounceSample.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Page x:Class="ExtensionsExperiment.Samples.DispatcherQueueExtensions.MouseDebounceSample"
1+
<Page x:Class="ExtensionsExperiment.Samples.DispatcherQueueTimerExtensions.MouseDebounceSample"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

components/Extensions/samples/Dispatcher/MouseDebounceSample.xaml.cs renamed to components/Extensions/samples/DispatcherQueueTimerExtensions/MouseDebounceSample.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
using DispatcherQueueTimer = Windows.System.DispatcherQueueTimer;
1212
#endif
1313

14-
namespace ExtensionsExperiment.Samples.DispatcherQueueExtensions;
14+
namespace ExtensionsExperiment.Samples.DispatcherQueueTimerExtensions;
1515

1616
[ToolkitSample(id: nameof(MouseDebounceSample), "DispatcherQueueTimer Debounce Mouse", description: "A sample for showing how to use the DispatcherQueueTimer Debounce extension to smooth mouse input.")]
1717
[ToolkitSampleNumericOption("Interval", 400, 300, 1000)]

components/LayoutTransformControl/src/LayoutTransformControl.Properties.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ private void UnsubscribeFromTransformPropertyChanges(Transform transform)
127127
foreach (var propertyChangeEventSource in propertyChangeEventSources)
128128
{
129129
propertyChangeEventSource.ValueChanged -= OnTransformPropertyChanged;
130+
propertyChangeEventSource.Unregister();
130131
}
131132

132133
_transformPropertyChangeEventSources.Remove(transform);
@@ -153,7 +154,7 @@ private void SubscribeToTransformPropertyChanges(Transform transform)
153154

154155
if (rotateTransform != null)
155156
{
156-
var anglePropertyChangeEventSource = new PropertyChangeEventSource<double>(rotateTransform, "Angle");
157+
var anglePropertyChangeEventSource = new PropertyChangeEventSource<double>(rotateTransform, RotateTransform.AngleProperty);
157158
anglePropertyChangeEventSource.ValueChanged += OnTransformPropertyChanged;
158159
propertyChangeEventSources.Add(anglePropertyChangeEventSource);
159160
return;
@@ -163,11 +164,11 @@ private void SubscribeToTransformPropertyChanges(Transform transform)
163164

164165
if (scaleTransform != null)
165166
{
166-
var scaleXPropertyChangeEventSource = new PropertyChangeEventSource<double>(scaleTransform, "ScaleX");
167+
var scaleXPropertyChangeEventSource = new PropertyChangeEventSource<double>(scaleTransform, ScaleTransform.ScaleXProperty);
167168
scaleXPropertyChangeEventSource.ValueChanged += OnTransformPropertyChanged;
168169
propertyChangeEventSources.Add(scaleXPropertyChangeEventSource);
169170

170-
var scaleYPropertyChangeEventSource = new PropertyChangeEventSource<double>(scaleTransform, "ScaleY");
171+
var scaleYPropertyChangeEventSource = new PropertyChangeEventSource<double>(scaleTransform, ScaleTransform.ScaleYProperty);
171172
scaleYPropertyChangeEventSource.ValueChanged += OnTransformPropertyChanged;
172173
propertyChangeEventSources.Add(scaleYPropertyChangeEventSource);
173174
return;
@@ -177,11 +178,11 @@ private void SubscribeToTransformPropertyChanges(Transform transform)
177178

178179
if (skewTransform != null)
179180
{
180-
var angleXPropertyChangeEventSource = new PropertyChangeEventSource<double>(skewTransform, "AngleX");
181+
var angleXPropertyChangeEventSource = new PropertyChangeEventSource<double>(skewTransform, SkewTransform.AngleXProperty);
181182
angleXPropertyChangeEventSource.ValueChanged += OnTransformPropertyChanged;
182183
propertyChangeEventSources.Add(angleXPropertyChangeEventSource);
183184

184-
var angleYPropertyChangeEventSource = new PropertyChangeEventSource<double>(skewTransform, "AngleY");
185+
var angleYPropertyChangeEventSource = new PropertyChangeEventSource<double>(skewTransform, SkewTransform.AngleYProperty);
185186
angleYPropertyChangeEventSource.ValueChanged += OnTransformPropertyChanged;
186187
propertyChangeEventSources.Add(angleYPropertyChangeEventSource);
187188
return;
@@ -194,7 +195,7 @@ private void SubscribeToTransformPropertyChanges(Transform transform)
194195
var matrixPropertyChangeEventSource =
195196
new PropertyChangeEventSource<double>(
196197
matrixTransform,
197-
"Matrix");
198+
MatrixTransform.MatrixProperty);
198199
matrixPropertyChangeEventSource.ValueChanged += OnTransformPropertyChanged;
199200
propertyChangeEventSources.Add(matrixPropertyChangeEventSource);
200201
}

0 commit comments

Comments
 (0)