From a99963e3a0e4172d257ec63c3be765ac3086f389 Mon Sep 17 00:00:00 2001 From: amwx Date: Fri, 29 May 2020 04:08:07 -0500 Subject: [PATCH 01/11] Fluent Calendar style --- .../Accents/FluentControlResourcesDark.xaml | 28 ++ .../Accents/FluentControlResourcesLight.xaml | 28 ++ src/Avalonia.Themes.Fluent/Calendar.xaml | 13 +- .../CalendarButton.xaml | 124 ++++---- .../CalendarDayButton.xaml | 156 +++++----- src/Avalonia.Themes.Fluent/CalendarItem.xaml | 272 +++++++----------- 6 files changed, 321 insertions(+), 300 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml index a0f3ef0d62..fd6203d82d 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml @@ -153,5 +153,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml index ec4f35664c..436b8af3d6 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml @@ -153,5 +153,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Calendar.xaml b/src/Avalonia.Themes.Fluent/Calendar.xaml index 6bbee4ef17..2fbc705d83 100644 --- a/src/Avalonia.Themes.Fluent/Calendar.xaml +++ b/src/Avalonia.Themes.Fluent/Calendar.xaml @@ -7,11 +7,12 @@ - \ No newline at end of file + diff --git a/src/Avalonia.Themes.Fluent/CalendarButton.xaml b/src/Avalonia.Themes.Fluent/CalendarButton.xaml index 3314534b3b..2ba4489204 100644 --- a/src/Avalonia.Themes.Fluent/CalendarButton.xaml +++ b/src/Avalonia.Themes.Fluent/CalendarButton.xaml @@ -7,75 +7,99 @@ - - --> + + - - - - - - - + + + - - + + + + diff --git a/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml b/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml index 2d79e62a75..1e5953ab2d 100644 --- a/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml +++ b/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml @@ -7,110 +7,102 @@ - - - - + --> - - - - - - - - - - - - - - - - + diff --git a/src/Avalonia.Themes.Fluent/CalendarItem.xaml b/src/Avalonia.Themes.Fluent/CalendarItem.xaml index dfd89ed82f..41f3fcbc1f 100644 --- a/src/Avalonia.Themes.Fluent/CalendarItem.xaml +++ b/src/Avalonia.Themes.Fluent/CalendarItem.xaml @@ -8,176 +8,124 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - From 3b48112e1d3f44beaf0df52eb738554e3bd81e57 Mon Sep 17 00:00:00 2001 From: amwx Date: Fri, 29 May 2020 04:24:07 -0500 Subject: [PATCH 02/11] Fluent Calendar Style --- src/Avalonia.Themes.Fluent/Calendar.xaml | 2 +- src/Avalonia.Themes.Fluent/CalendarButton.xaml | 9 ++++++--- src/Avalonia.Themes.Fluent/CalendarDayButton.xaml | 14 ++++++-------- src/Avalonia.Themes.Fluent/CalendarItem.xaml | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/Calendar.xaml b/src/Avalonia.Themes.Fluent/Calendar.xaml index 2fbc705d83..6ae334dbae 100644 --- a/src/Avalonia.Themes.Fluent/Calendar.xaml +++ b/src/Avalonia.Themes.Fluent/Calendar.xaml @@ -5,7 +5,7 @@ // All other rights reserved. --> - + - \ No newline at end of file + diff --git a/src/Avalonia.Themes.Fluent/CalendarButton.xaml b/src/Avalonia.Themes.Fluent/CalendarButton.xaml index 3314534b3b..2ba4489204 100644 --- a/src/Avalonia.Themes.Fluent/CalendarButton.xaml +++ b/src/Avalonia.Themes.Fluent/CalendarButton.xaml @@ -7,75 +7,99 @@ - - --> + + - - - - - - - + + + - - + + + + diff --git a/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml b/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml index 2d79e62a75..1e5953ab2d 100644 --- a/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml +++ b/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml @@ -7,110 +7,102 @@ - - - - + --> - - - - - - - - - - - - - - - - + diff --git a/src/Avalonia.Themes.Fluent/CalendarItem.xaml b/src/Avalonia.Themes.Fluent/CalendarItem.xaml index dfd89ed82f..41f3fcbc1f 100644 --- a/src/Avalonia.Themes.Fluent/CalendarItem.xaml +++ b/src/Avalonia.Themes.Fluent/CalendarItem.xaml @@ -8,176 +8,124 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - From 5065e6c072020860312c01053365105759c5e7eb Mon Sep 17 00:00:00 2001 From: amwx Date: Fri, 29 May 2020 04:24:07 -0500 Subject: [PATCH 04/11] Fluent Calendar Style --- src/Avalonia.Themes.Fluent/Calendar.xaml | 2 +- src/Avalonia.Themes.Fluent/CalendarButton.xaml | 9 ++++++--- src/Avalonia.Themes.Fluent/CalendarDayButton.xaml | 14 ++++++-------- src/Avalonia.Themes.Fluent/CalendarItem.xaml | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/Calendar.xaml b/src/Avalonia.Themes.Fluent/Calendar.xaml index 2fbc705d83..6ae334dbae 100644 --- a/src/Avalonia.Themes.Fluent/Calendar.xaml +++ b/src/Avalonia.Themes.Fluent/Calendar.xaml @@ -5,7 +5,7 @@ // All other rights reserved. --> - + --> + + diff --git a/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml b/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml index 4f6f5951d2..ff72044c93 100644 --- a/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml +++ b/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml @@ -19,12 +19,14 @@ + + + BorderThickness="0" ClipToBounds="True"> + BorderBrush="{TemplateBinding BorderBrush}"/> - + + + --> + diff --git a/src/Avalonia.Themes.Fluent/CalendarItem.xaml b/src/Avalonia.Themes.Fluent/CalendarItem.xaml index 7e17ee7075..df17da84dc 100644 --- a/src/Avalonia.Themes.Fluent/CalendarItem.xaml +++ b/src/Avalonia.Themes.Fluent/CalendarItem.xaml @@ -61,6 +61,9 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml index 5c6286a0bc..f3c19a3ba9 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml @@ -1,4 +1,6 @@ - diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml index 7364c339f1..599177526d 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml @@ -1,6 +1,6 @@ - diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml index 15e157f573..ff43508f8c 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml @@ -1,6 +1,6 @@ - diff --git a/src/Avalonia.Themes.Fluent/Slider.xaml b/src/Avalonia.Themes.Fluent/Slider.xaml index b21cbf3650..a57ea6cedd 100644 --- a/src/Avalonia.Themes.Fluent/Slider.xaml +++ b/src/Avalonia.Themes.Fluent/Slider.xaml @@ -1,93 +1,264 @@ - + + + + + + + + + + + + + + + + + 0,0,0,4 + 15 + 15 + 32 + 32 + 10 + 20 + 20 + 20 + 20 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - From 66c677eab8a536f41aba379ba0d154686ca38329 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Mon, 1 Jun 2020 14:01:23 +0800 Subject: [PATCH 08/11] avoid divide by zero --- src/Avalonia.Controls/Slider.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Avalonia.Controls/Slider.cs b/src/Avalonia.Controls/Slider.cs index de15685e4d..a0d6cb96fc 100644 --- a/src/Avalonia.Controls/Slider.cs +++ b/src/Avalonia.Controls/Slider.cs @@ -189,7 +189,10 @@ namespace Avalonia.Controls private void MoveToPoint(PointerPoint x) { var orient = Orientation == Orientation.Horizontal; + var pointDen = orient ? _track.Bounds.Width : _track.Bounds.Height; + pointDen += double.Epsilon; // Just add epsilon to avoid divide by zero exceptions. + var pointNum = orient ? x.Position.X : x.Position.Y; var logicalPos = MathUtilities.Clamp(pointNum / pointDen, 0.0d, 1.0d); var invert = orient ? 0 : 1; From 7abe7cc926b60302ac0fe7d2db1b0a972b5ca6d7 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Mon, 1 Jun 2020 14:02:29 +0800 Subject: [PATCH 09/11] add base apply template method --- src/Avalonia.Controls/Slider.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Slider.cs b/src/Avalonia.Controls/Slider.cs index a0d6cb96fc..ec23bfa396 100644 --- a/src/Avalonia.Controls/Slider.cs +++ b/src/Avalonia.Controls/Slider.cs @@ -134,6 +134,8 @@ namespace Avalonia.Controls /// protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { + base.OnApplyTemplate(e); + _decreaseButtonPressDispose?.Dispose(); _decreaseButtonReleaseDispose?.Dispose(); _increaseButtonSubscription?.Dispose(); @@ -189,7 +191,7 @@ namespace Avalonia.Controls private void MoveToPoint(PointerPoint x) { var orient = Orientation == Orientation.Horizontal; - + var pointDen = orient ? _track.Bounds.Width : _track.Bounds.Height; pointDen += double.Epsilon; // Just add epsilon to avoid divide by zero exceptions. From 27914d9c64982648fe6d935c352b514cafcf8168 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Fri, 5 Jun 2020 18:12:51 -0400 Subject: [PATCH 10/11] RepeatButton should use same style as Button --- src/Avalonia.Themes.Fluent/Button.xaml | 67 ++++++++++---------- src/Avalonia.Themes.Fluent/FluentTheme.xaml | 1 - src/Avalonia.Themes.Fluent/RepeatButton.xaml | 40 ------------ 3 files changed, 34 insertions(+), 74 deletions(-) delete mode 100644 src/Avalonia.Themes.Fluent/RepeatButton.xaml diff --git a/src/Avalonia.Themes.Fluent/Button.xaml b/src/Avalonia.Themes.Fluent/Button.xaml index 42fcee6cd5..ba5c59b6d3 100644 --- a/src/Avalonia.Themes.Fluent/Button.xaml +++ b/src/Avalonia.Themes.Fluent/Button.xaml @@ -2,15 +2,18 @@ - - + + + + diff --git a/samples/ControlCatalog/Pages/ButtonPage.xaml.cs b/samples/ControlCatalog/Pages/ButtonPage.xaml.cs index 1d0c228a0e..5e555c8c91 100644 --- a/samples/ControlCatalog/Pages/ButtonPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ButtonPage.xaml.cs @@ -5,5 +5,25 @@ namespace ControlCatalog.Pages { public class ButtonPage : UserControl { + private int repeatButtonClickCount = 0; + + public ButtonPage() + { + InitializeComponent(); + + this.FindControl("RepeatButton").Click += OnRepeatButtonClick; + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + + public void OnRepeatButtonClick(object sender, object args) + { + repeatButtonClickCount++; + var textBlock = this.FindControl("RepeatButtonTextBlock"); + textBlock.Text = $"Repeat Button: {repeatButtonClickCount}"; + } } } diff --git a/src/Avalonia.Themes.Fluent/Button.xaml b/src/Avalonia.Themes.Fluent/Button.xaml index ba5c59b6d3..3336e611c1 100644 --- a/src/Avalonia.Themes.Fluent/Button.xaml +++ b/src/Avalonia.Themes.Fluent/Button.xaml @@ -2,10 +2,8 @@ -