From f39df90b93e1543d531058b058be292c85942ebc Mon Sep 17 00:00:00 2001 From: JamRemco <58340108+JamRemco@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:41:28 +0200 Subject: [PATCH 01/23] Init Wip for ToggleSwitch --- src/Avalonia.Controls/ToggleSwitch.cs | 11 + .../Avalonia.Themes.Default.csproj | 8 + src/Avalonia.Themes.Default/DefaultTheme.xaml | 1 + src/Avalonia.Themes.Default/ToggleSwitch.xaml | 188 +++++++++++++++++ .../Accents/FluentControlResourcesLight.xaml | 3 + .../Avalonia.Themes.Fluent.csproj | 8 + src/Avalonia.Themes.Fluent/FluentTheme.xaml | 1 + src/Avalonia.Themes.Fluent/ToggleSwitch.xaml | 194 ++++++++++++++++++ 8 files changed, 414 insertions(+) create mode 100644 src/Avalonia.Controls/ToggleSwitch.cs create mode 100644 src/Avalonia.Themes.Default/ToggleSwitch.xaml create mode 100644 src/Avalonia.Themes.Fluent/ToggleSwitch.xaml diff --git a/src/Avalonia.Controls/ToggleSwitch.cs b/src/Avalonia.Controls/ToggleSwitch.cs new file mode 100644 index 0000000000..bc9c6f1ff4 --- /dev/null +++ b/src/Avalonia.Controls/ToggleSwitch.cs @@ -0,0 +1,11 @@ +using Avalonia.Controls.Primitives; + +namespace Avalonia.Controls +{ + /// + /// A check box control. + /// + public class ToggleSwitch : ToggleButton + { + } +} diff --git a/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj b/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj index c44cc358e8..d2c6d69bfe 100644 --- a/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj +++ b/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj @@ -17,6 +17,14 @@ + + + + + + MSBuild:Compile + + diff --git a/src/Avalonia.Themes.Default/DefaultTheme.xaml b/src/Avalonia.Themes.Default/DefaultTheme.xaml index 67279fca99..3ed0115fff 100644 --- a/src/Avalonia.Themes.Default/DefaultTheme.xaml +++ b/src/Avalonia.Themes.Default/DefaultTheme.xaml @@ -52,4 +52,5 @@ + diff --git a/src/Avalonia.Themes.Default/ToggleSwitch.xaml b/src/Avalonia.Themes.Default/ToggleSwitch.xaml new file mode 100644 index 0000000000..e929810376 --- /dev/null +++ b/src/Avalonia.Themes.Default/ToggleSwitch.xaml @@ -0,0 +1,188 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml index 15e157f573..15e0925f85 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml @@ -343,5 +343,8 @@ + + + diff --git a/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj b/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj index 3c3e14010d..00846f33fd 100644 --- a/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj +++ b/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj @@ -17,6 +17,14 @@ + + + + + + MSBuild:Compile + + diff --git a/src/Avalonia.Themes.Fluent/FluentTheme.xaml b/src/Avalonia.Themes.Fluent/FluentTheme.xaml index 266acce971..dbbe3d6e69 100644 --- a/src/Avalonia.Themes.Fluent/FluentTheme.xaml +++ b/src/Avalonia.Themes.Fluent/FluentTheme.xaml @@ -52,4 +52,5 @@ + diff --git a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml new file mode 100644 index 0000000000..1fe9788839 --- /dev/null +++ b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 97bbb3ba92bf35ea80aaa0bf0868117147070466 Mon Sep 17 00:00:00 2001 From: JamRemco <58340108+JamRemco@users.noreply.github.com> Date: Wed, 3 Jun 2020 14:10:54 +0200 Subject: [PATCH 02/23] added light fluent resources --- src/Avalonia.Themes.Default/ToggleSwitch.xaml | 335 +++++++++--------- .../Accents/FluentControlResourcesDark.xaml | 62 ++++ src/Avalonia.Themes.Fluent/ToggleSwitch.xaml | 39 +- 3 files changed, 254 insertions(+), 182 deletions(-) diff --git a/src/Avalonia.Themes.Default/ToggleSwitch.xaml b/src/Avalonia.Themes.Default/ToggleSwitch.xaml index e929810376..3cdcb3f6c5 100644 --- a/src/Avalonia.Themes.Default/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Default/ToggleSwitch.xaml @@ -1,170 +1,177 @@ - + - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - + - + + + + + + + - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml index 7364c339f1..8265c22a88 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml @@ -343,5 +343,67 @@ + + + + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml index 1fe9788839..2b665753b1 100644 --- a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml @@ -2,20 +2,21 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> - - + + + - + @@ -31,17 +32,18 @@ - - - - - + + --> + + From 23fc2c945ee542a7a12d3185f03683274e7b65a9 Mon Sep 17 00:00:00 2001 From: JamRemco <58340108+JamRemco@users.noreply.github.com> Date: Thu, 4 Jun 2020 20:33:32 +0200 Subject: [PATCH 03/23] Dark resources and some minors --- src/Avalonia.Controls/ToggleSwitch.cs | 7 +- src/Avalonia.Themes.Default/ToggleSwitch.xaml | 11 +- .../Accents/FluentControlResourcesDark.xaml | 114 +++++++++--------- .../Accents/FluentControlResourcesLight.xaml | 60 ++++++++- src/Avalonia.Themes.Fluent/ToggleSwitch.xaml | 12 +- 5 files changed, 134 insertions(+), 70 deletions(-) diff --git a/src/Avalonia.Controls/ToggleSwitch.cs b/src/Avalonia.Controls/ToggleSwitch.cs index bc9c6f1ff4..19f282d2d1 100644 --- a/src/Avalonia.Controls/ToggleSwitch.cs +++ b/src/Avalonia.Controls/ToggleSwitch.cs @@ -3,9 +3,14 @@ namespace Avalonia.Controls { /// - /// A check box control. + /// A WinUi like ToggleSwitch control. /// public class ToggleSwitch : ToggleButton { } } +/********** Todo *********** + * + * Implement ContenOff property + * Implement ContentOn property. +*/ diff --git a/src/Avalonia.Themes.Default/ToggleSwitch.xaml b/src/Avalonia.Themes.Default/ToggleSwitch.xaml index 3cdcb3f6c5..69ac64bb28 100644 --- a/src/Avalonia.Themes.Default/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Default/ToggleSwitch.xaml @@ -93,7 +93,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -126,7 +126,7 @@ - + --> + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml index 8265c22a88..da3c20e844 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml @@ -345,65 +345,65 @@ - + 0 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml index 15e0925f85..00e2e38ade 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml @@ -345,6 +345,64 @@ - + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml index 2b665753b1..061551f9e7 100644 --- a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml @@ -93,7 +93,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -119,14 +119,14 @@ - + - + - + --> diff --git a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml index 061551f9e7..b423416d7c 100644 --- a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml @@ -143,9 +143,9 @@ - + --> - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - diff --git a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml index b423416d7c..2c9309fe93 100644 --- a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml @@ -62,7 +62,7 @@ Name="PART_CircleThumb" Height="10" Width="10" Canvas.Top="7" - Canvas.Left="5"/> + /> @@ -126,7 +126,7 @@ - + diff --git a/samples/ControlCatalog/MainView.xaml.cs b/samples/ControlCatalog/MainView.xaml.cs index 2d01d37dbe..3fd94bd60a 100644 --- a/samples/ControlCatalog/MainView.xaml.cs +++ b/samples/ControlCatalog/MainView.xaml.cs @@ -32,30 +32,30 @@ namespace ControlCatalog } - var light = new StyleInclude(new Uri("resm:Styles?assembly=ControlCatalog")) - { - Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default") - }; - var dark = new StyleInclude(new Uri("resm:Styles?assembly=ControlCatalog")) - { - Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseDark.xaml?assembly=Avalonia.Themes.Default") - }; + //var light = new StyleInclude(new Uri("resm:Styles?assembly=ControlCatalog")) + //{ + // Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default") + //}; + //var dark = new StyleInclude(new Uri("resm:Styles?assembly=ControlCatalog")) + //{ + // Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseDark.xaml?assembly=Avalonia.Themes.Default") + //}; - var themes = this.Find("Themes"); - themes.SelectionChanged += (sender, e) => - { - switch (themes.SelectedIndex) - { - case 0: - Styles[0] = light; - break; - case 1: - Styles[0] = dark; - break; - } - }; - Styles.Add(light); + //var themes = this.Find("Themes"); + //themes.SelectionChanged += (sender, e) => + //{ + // switch (themes.SelectedIndex) + // { + // case 0: + // Styles[0] = light; + // break; + // case 1: + // Styles[0] = dark; + // break; + // } + //}; + //Styles.Add(light); var decorations = this.Find("Decorations"); decorations.SelectionChanged += (sender, e) => diff --git a/samples/ControlCatalog/MainWindow.xaml b/samples/ControlCatalog/MainWindow.xaml index a0bb956425..670e30725b 100644 --- a/samples/ControlCatalog/MainWindow.xaml +++ b/samples/ControlCatalog/MainWindow.xaml @@ -7,7 +7,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="clr-namespace:ControlCatalog.ViewModels" xmlns:v="clr-namespace:ControlCatalog.Views" - x:Class="ControlCatalog.MainWindow" WindowState="{Binding WindowState, Mode=TwoWay}" Background="Transparent"> + x:Class="ControlCatalog.MainWindow" WindowState="{Binding WindowState, Mode=TwoWay}"> diff --git a/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml b/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml index f90a0c4658..8888cf921a 100644 --- a/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml +++ b/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml @@ -32,6 +32,7 @@ + Light diff --git a/src/Avalonia.Themes.Default/ToggleSwitch.xaml b/src/Avalonia.Themes.Default/ToggleSwitch.xaml index 556e32faab..f7e2c209a2 100644 --- a/src/Avalonia.Themes.Default/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Default/ToggleSwitch.xaml @@ -1,7 +1,9 @@ - + + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:sys="clr-namespace:System;assembly=netstandard"> + @@ -12,7 +14,7 @@ - @@ -44,9 +46,10 @@ - + + - - - + Canvas.Top="7"/> + - - + + + + - + + + - - + + + + + @@ -157,22 +182,45 @@ + - + + + + + - - - - - + + + + + + + + + + + + + + + + - - + + + + 5 + 28 + RoyalBlue + White - + diff --git a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml index 2c9309fe93..bae8151563 100644 --- a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml @@ -1,177 +1,236 @@ + - + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:sys="clr-namespace:System;assembly=netstandard"> + - + - - - + - + - - - + + /> - + + + + - - - - - - + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + 5 + 26 + RoyalBlue + + White + + + From f7d0088d553593ab3079c7f0060a9664717e219b Mon Sep 17 00:00:00 2001 From: JamRemco <58340108+JamRemco@users.noreply.github.com> Date: Wed, 10 Jun 2020 18:46:54 +0200 Subject: [PATCH 07/23] Fix some colors --- samples/ControlCatalog/App.xaml | 11 +- src/Avalonia.Themes.Default/ToggleSwitch.xaml | 388 +++++++++-------- src/Avalonia.Themes.Fluent/ToggleSwitch.xaml | 404 +++++++++--------- 3 files changed, 421 insertions(+), 382 deletions(-) diff --git a/samples/ControlCatalog/App.xaml b/samples/ControlCatalog/App.xaml index de0c273dfb..d289767100 100644 --- a/samples/ControlCatalog/App.xaml +++ b/samples/ControlCatalog/App.xaml @@ -2,14 +2,15 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="ControlCatalog.App"> - + - - + + + + + - - - - - - + - - + + - - - - - - - + + + + + + + + - - - - - - - - - - - + + + + + + + + + - - - - + + + + + + + - - - - - - + + + + + + - - - - - - - - + + + + + + + + - - - + + + + - - - - 5 - 28 - RoyalBlue - White - + + + 5 + 28 + RoyalBlue + + White + + + diff --git a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml index bae8151563..2f311043fd 100644 --- a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml @@ -1,8 +1,8 @@ - + - + @@ -14,8 +14,8 @@ Text="Updates will be automaticly Downloaded and installed shile the computer is shutting down or restarting" TextWrapping="Wrap"/> + FontWeight="Medium" + VerticalAlignment="Bottom" /> @@ -25,154 +25,147 @@ - + FontWeight="Medium"/> + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - + - - + + - - - - - - - + + + + + + + + - - - - - - - - - - - + + + + + + + + + - - - - + + + + + + + - - - - - - + + + + + + - - - - - - - - + + + + + + + + - - - + + + + + + + + 5 + 28 + RoyalBlue + White - - - 5 - 26 - RoyalBlue - - White - - + From 78993eb33cb062c0bba8cc352c17fae1ecd31484 Mon Sep 17 00:00:00 2001 From: JamRemco <58340108+JamRemco@users.noreply.github.com> Date: Fri, 12 Jun 2020 19:48:52 +0200 Subject: [PATCH 08/23] Add contentoff and contentOn to toggleswitch Add more resource suport --- src/Avalonia.Controls/ToggleSwitch.cs | 115 ++++- .../Accents/FluentControlResourcesDark.xaml | 7 +- .../Accents/FluentControlResourcesLight.xaml | 10 +- src/Avalonia.Themes.Fluent/ToggleSwitch.xaml | 465 ++++++++++-------- 4 files changed, 375 insertions(+), 222 deletions(-) diff --git a/src/Avalonia.Controls/ToggleSwitch.cs b/src/Avalonia.Controls/ToggleSwitch.cs index 19f282d2d1..16caf8dbfb 100644 --- a/src/Avalonia.Controls/ToggleSwitch.cs +++ b/src/Avalonia.Controls/ToggleSwitch.cs @@ -1,16 +1,119 @@ using Avalonia.Controls.Primitives; +using Avalonia.Controls.Mixins; +using Avalonia.Controls.Presenters; +using Avalonia.Controls.Templates; +using Avalonia.LogicalTree; + namespace Avalonia.Controls { /// /// A WinUi like ToggleSwitch control. /// + /// + public class ToggleSwitch : ToggleButton { - } + public static readonly StyledProperty OffContentProperty = + AvaloniaProperty.Register(nameof(OffContent)); + + public static readonly StyledProperty OffContentTemplateProperty = + AvaloniaProperty.Register(nameof(OffContentTemplate)); + + + public static readonly StyledProperty OnContentProperty = + AvaloniaProperty.Register(nameof(OnContent)); + + public static readonly StyledProperty OnContentTemplateProperty = + AvaloniaProperty.Register(nameof(OnContentTemplate)); + + public object OnContent + { + get { return GetValue(OnContentProperty); } + set { SetValue(OnContentProperty, value); } + } + + public object OffContent + { + get { return GetValue(OffContentProperty); } + set { SetValue(OffContentProperty, value); } + } + + public IContentPresenter OffContentPresenter + { + get; + private set; + } + + public IContentPresenter OnContentPresenter + { + get; + private set; + } + + + public IDataTemplate OffContentTemplate + { + get { return GetValue(OffContentTemplateProperty); } + set { SetValue(OffContentTemplateProperty, value); } + } + + public IDataTemplate OnContentTemplate + { + get { return GetValue(OnContentTemplateProperty); } + set { SetValue(OnContentTemplateProperty, value); } + } + + private void OffContentChanged(AvaloniaPropertyChangedEventArgs e) + { + if (e.OldValue is ILogical oldChild) + { + LogicalChildren.Remove(oldChild); + } + + if (e.NewValue is ILogical newChild) + { + LogicalChildren.Add(newChild); + } + } + + private void OnContentChanged(AvaloniaPropertyChangedEventArgs e) + { + if (e.OldValue is ILogical oldChild) + { + LogicalChildren.Remove(oldChild); + } + + if (e.NewValue is ILogical newChild) + { + LogicalChildren.Add(newChild); + } + } + + static ToggleSwitch() + { + OffContentProperty.Changed.AddClassHandler((x, e) => x.OffContentChanged(e)); + OnContentProperty.Changed.AddClassHandler((x, e) => x.OnContentChanged(e)); + } + + + protected override bool RegisterContentPresenter(IContentPresenter presenter) + { + var result = base.RegisterContentPresenter(presenter); + + if (presenter.Name == "Part_OnContentPresenter") + { + OnContentPresenter = presenter; + result = true; + } + if (presenter.Name == "PART_OffContentPresenter") + { + OffContentPresenter = presenter; + result = true; + } + + return result; + } + } } -/********** Todo *********** - * - * Implement ContenOff property - * Implement ContentOn property. -*/ + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml index da3c20e844..9fa0458db3 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml @@ -346,8 +346,10 @@ - 0 - 1 + + 0 + + 1 @@ -380,7 +382,6 @@ - diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml index 2426c1034c..5c23bc96ee 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml @@ -345,8 +345,12 @@ - 0 - 1 + + + + 0 + + 1 @@ -379,7 +383,6 @@ - @@ -404,6 +407,5 @@ - diff --git a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml index 2f311043fd..df9be1284a 100644 --- a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml @@ -4,7 +4,7 @@ xmlns:sys="clr-namespace:System;assembly=netstandard"> - + - @@ -26,244 +28,289 @@ Text="The previewer Shows a preview off your code, this could slow down your system" TextWrapping="Wrap"/> + /> - - + + + + + + + + - - + + + - - + + + + + + + + + + + + + - - + + + + + + + - - + - - - - - + - + + + + + + - - - - - - - + - - - - - - - + + + - - - - - - - - - - - - - - + - - - - - - - - + + + + + - + + + + + + + + 0,0,0,6 + 6 + 6 + 154 + 5 + 28 + + + From 19eac7224a22c14195600e9ca11da75ffa687ad1 Mon Sep 17 00:00:00 2001 From: JamRemco <58340108+JamRemco@users.noreply.github.com> Date: Mon, 15 Jun 2020 02:39:56 +0200 Subject: [PATCH 09/23] Fix border --- src/Avalonia.Controls/ToggleSwitch.cs | 2 +- .../Accents/FluentControlResourcesDark.xaml | 2 +- .../Accents/FluentControlResourcesLight.xaml | 2 +- src/Avalonia.Themes.Fluent/ToggleSwitch.xaml | 266 +++++++++--------- 4 files changed, 139 insertions(+), 133 deletions(-) diff --git a/src/Avalonia.Controls/ToggleSwitch.cs b/src/Avalonia.Controls/ToggleSwitch.cs index 16caf8dbfb..9af3ded18d 100644 --- a/src/Avalonia.Controls/ToggleSwitch.cs +++ b/src/Avalonia.Controls/ToggleSwitch.cs @@ -106,7 +106,7 @@ namespace Avalonia.Controls OnContentPresenter = presenter; result = true; } - if (presenter.Name == "PART_OffContentPresenter") + else if (presenter.Name == "PART_OffContentPresenter") { OffContentPresenter = presenter; result = true; diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml index 9fa0458db3..923180f96d 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml @@ -349,7 +349,7 @@ 0 - 1 + 1.5 diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml index 5c23bc96ee..fd7a17d2e3 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml @@ -350,7 +350,7 @@ 0 - 1 + 1.5 diff --git a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml index df9be1284a..6f74c0b715 100644 --- a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml @@ -1,12 +1,12 @@ - + xmlns:sys="clr-namespace:System;assembly=netstandard" + > - + @@ -44,148 +44,157 @@ - - - + + - + - + - - - - - + + + + + - - - - - + + + + + - + Grid.RowSpan="3" + Grid.ColumnSpan="3" + Margin="0,5" /> - + - + - + - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + - - + + - + + + + + + + + + + + + - - - - @@ -211,7 +220,7 @@ - + @@ -274,31 +283,29 @@ - - - - - - + + - @@ -309,7 +316,6 @@ 154 5 28 - From 551ea7711bfa4367da398ca33f37b0ab174e0d12 Mon Sep 17 00:00:00 2001 From: JamRemco <58340108+JamRemco@users.noreply.github.com> Date: Mon, 15 Jun 2020 18:44:52 +0200 Subject: [PATCH 10/23] Fix animation --- src/Avalonia.Themes.Fluent/ToggleSwitch.xaml | 151 +++++++++++-------- 1 file changed, 86 insertions(+), 65 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml index 6f74c0b715..ca951edc9e 100644 --- a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml @@ -111,23 +111,30 @@ CornerRadius="10" BorderThickness="{DynamicResource ToggleSwitchOnStrokeThickness}"/> - + + + + + - - - - - - - + + + + + + @@ -170,32 +178,39 @@ + + - + - + - + - + - + @@ -243,49 +258,51 @@ + - + - - + + + + + - + - + - + + + - - - + + - + + - + + + 0,0,0,6 6 6 154 - 5 - 28 + 20 + 0 From 0f8f459b3244bdbae3cd1f6a058c94422cb68bc4 Mon Sep 17 00:00:00 2001 From: JamRemco <58340108+JamRemco@users.noreply.github.com> Date: Mon, 15 Jun 2020 23:53:46 +0200 Subject: [PATCH 11/23] Little Fix --- src/Avalonia.Themes.Fluent/ToggleSwitch.xaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml index ca951edc9e..2ae3b50b62 100644 --- a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml @@ -100,14 +100,14 @@ @@ -335,7 +335,7 @@ 6 6 154 - 20 + 22 0 From b18b70b82e8dd5509a1212e59b8455cf82462c39 Mon Sep 17 00:00:00 2001 From: JamRemco <58340108+JamRemco@users.noreply.github.com> Date: Tue, 16 Jun 2020 08:11:49 +0200 Subject: [PATCH 12/23] Adding Defauld values and change OuterBorderWidth --- src/Avalonia.Controls/ToggleSwitch.cs | 4 ++-- .../Accents/FluentControlResourcesDark.xaml | 2 +- .../Accents/FluentControlResourcesLight.xaml | 2 +- src/Avalonia.Themes.Fluent/ToggleSwitch.xaml | 17 +++++++++-------- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Avalonia.Controls/ToggleSwitch.cs b/src/Avalonia.Controls/ToggleSwitch.cs index 9af3ded18d..79638dce74 100644 --- a/src/Avalonia.Controls/ToggleSwitch.cs +++ b/src/Avalonia.Controls/ToggleSwitch.cs @@ -15,14 +15,14 @@ namespace Avalonia.Controls public class ToggleSwitch : ToggleButton { public static readonly StyledProperty OffContentProperty = - AvaloniaProperty.Register(nameof(OffContent)); + AvaloniaProperty.Register(nameof(OffContent), defaultValue:"Off"); public static readonly StyledProperty OffContentTemplateProperty = AvaloniaProperty.Register(nameof(OffContentTemplate)); public static readonly StyledProperty OnContentProperty = - AvaloniaProperty.Register(nameof(OnContent)); + AvaloniaProperty.Register(nameof(OnContent), defaultValue: "On"); public static readonly StyledProperty OnContentTemplateProperty = AvaloniaProperty.Register(nameof(OnContentTemplate)); diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml index 923180f96d..9fa0458db3 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml @@ -349,7 +349,7 @@ 0 - 1.5 + 1 diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml index fd7a17d2e3..5c23bc96ee 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml @@ -350,7 +350,7 @@ 0 - 1.5 + 1 diff --git a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml index 2ae3b50b62..d1892d8685 100644 --- a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml @@ -13,11 +13,12 @@ - + VerticalAlignment="Bottom" + /> @@ -28,7 +29,7 @@ Text="The previewer Shows a preview off your code, this could slow down your system" TextWrapping="Wrap"/> @@ -100,15 +101,15 @@ 6 6 154 - 22 + 20 0 From b39bec2425c0c1767d903b453458c1aa1313cb66 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 16 Jun 2020 14:05:41 -0300 Subject: [PATCH 13/23] code tidy. --- src/Avalonia.Themes.Fluent/ToggleSwitch.xaml | 546 +++++++++---------- 1 file changed, 262 insertions(+), 284 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml index d1892d8685..aba5e125ac 100644 --- a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml @@ -1,11 +1,16 @@ - + xmlns:sys="clr-namespace:System;assembly=netstandard"> + + 0,0,0,6 + 6 + 6 + 154 + 20 + 0 + - + VerticalAlignment="Bottom"/> @@ -28,116 +32,110 @@ - + - - - - - - - - - + + + + + + + + + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - 0,0,0,6 - 6 - 6 - 154 - 20 - 0 - - - From bfdb55f819c75dd498d98a8c9789e0b6cd293ca6 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 16 Jun 2020 14:24:31 -0300 Subject: [PATCH 14/23] tidy template. --- src/Avalonia.Themes.Fluent/ToggleSwitch.xaml | 43 ++++---------------- 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml index aba5e125ac..b4c4e7b429 100644 --- a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml @@ -100,50 +100,30 @@ Grid.Row="1" Height="20" Width="40" - CornerRadius="100" + CornerRadius="10" BorderThickness="{DynamicResource ToggleSwitchOuterBorderStrokeThickness}" /> - + Width="20" Height="20"> + Width="20" Height="20"> - + Width="10" Height="10" /> - - + Width="10" Height="10" /> - - @@ -253,10 +233,6 @@ - - - - - From 960780e670b758ebfd5ddace911ba80b2925627e Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 16 Jun 2020 14:31:30 -0300 Subject: [PATCH 15/23] make fluent and default templates match. --- src/Avalonia.Themes.Default/ToggleSwitch.xaml | 404 +++++++++--------- 1 file changed, 212 insertions(+), 192 deletions(-) diff --git a/src/Avalonia.Themes.Default/ToggleSwitch.xaml b/src/Avalonia.Themes.Default/ToggleSwitch.xaml index 7e1be173d9..b4c4e7b429 100644 --- a/src/Avalonia.Themes.Default/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Default/ToggleSwitch.xaml @@ -1,21 +1,28 @@ - - + + 0,0,0,6 + 6 + 6 + 154 + 20 + 0 + - - - + + - + @@ -27,247 +34,260 @@ TextWrapping="Wrap"/> + IsChecked="True" /> - - - + + - - + + + + + + + + - - - - - - - - - - - + - + - - - - - - - + - - - - + - - - - + - - - + + - + - - + - + - + - - - + - + + + - + - 5 - 28 - RoyalBlue - - White - + - + + + + From be33b3692d402e4175cfefc4c64a8331a5a44a67 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 16 Jun 2020 14:31:46 -0300 Subject: [PATCH 16/23] remove stuff vs added to project file. --- .../Avalonia.Themes.Default.csproj | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj b/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj index d2c6d69bfe..cb3a185a2e 100644 --- a/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj +++ b/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj @@ -16,15 +16,7 @@ - - - - - - - MSBuild:Compile - - + From 29c575e6d9abdb1558308707844654bb2eda30a4 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 16 Jun 2020 14:39:03 -0300 Subject: [PATCH 17/23] add missing documentation. --- src/Avalonia.Controls/ToggleSwitch.cs | 49 +++++++++++++++++++-------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/src/Avalonia.Controls/ToggleSwitch.cs b/src/Avalonia.Controls/ToggleSwitch.cs index 79638dce74..ad35c43d87 100644 --- a/src/Avalonia.Controls/ToggleSwitch.cs +++ b/src/Avalonia.Controls/ToggleSwitch.cs @@ -8,31 +8,52 @@ using Avalonia.LogicalTree; namespace Avalonia.Controls { /// - /// A WinUi like ToggleSwitch control. + /// A Toggle Switch control. /// - /// - public class ToggleSwitch : ToggleButton { + static ToggleSwitch() + { + OffContentProperty.Changed.AddClassHandler((x, e) => x.OffContentChanged(e)); + OnContentProperty.Changed.AddClassHandler((x, e) => x.OnContentChanged(e)); + } + + /// + /// Defines the property. + /// public static readonly StyledProperty OffContentProperty = - AvaloniaProperty.Register(nameof(OffContent), defaultValue:"Off"); + AvaloniaProperty.Register(nameof(OffContent), defaultValue: "Off"); + /// + /// Defines the property. + /// public static readonly StyledProperty OffContentTemplateProperty = AvaloniaProperty.Register(nameof(OffContentTemplate)); - + /// + /// Defines the property. + /// public static readonly StyledProperty OnContentProperty = - AvaloniaProperty.Register(nameof(OnContent), defaultValue: "On"); + AvaloniaProperty.Register(nameof(OnContent), defaultValue: "On"); + /// + /// Defines the property. + /// public static readonly StyledProperty OnContentTemplateProperty = AvaloniaProperty.Register(nameof(OnContentTemplate)); + /// + /// Gets or Sets the Content that is displayed when in the On State. + /// public object OnContent { get { return GetValue(OnContentProperty); } set { SetValue(OnContentProperty, value); } } + /// + /// Gets or Sets the Content that is displayed when in the Off State. + /// public object OffContent { get { return GetValue(OffContentProperty); } @@ -51,13 +72,18 @@ namespace Avalonia.Controls private set; } - + /// + /// Gets or Sets the used to display the . + /// public IDataTemplate OffContentTemplate { get { return GetValue(OffContentTemplateProperty); } set { SetValue(OffContentTemplateProperty, value); } } + /// + /// Gets or Sets the used to display the . + /// public IDataTemplate OnContentTemplate { get { return GetValue(OnContentTemplateProperty); } @@ -90,13 +116,6 @@ namespace Avalonia.Controls } } - static ToggleSwitch() - { - OffContentProperty.Changed.AddClassHandler((x, e) => x.OffContentChanged(e)); - OnContentProperty.Changed.AddClassHandler((x, e) => x.OnContentChanged(e)); - } - - protected override bool RegisterContentPresenter(IContentPresenter presenter) { var result = base.RegisterContentPresenter(presenter); @@ -114,6 +133,6 @@ namespace Avalonia.Controls return result; } - } + } } From 62a88c8a5c937bab0b3ddcbe33a7776ac463a8eb Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 16 Jun 2020 14:45:33 -0300 Subject: [PATCH 18/23] remove un-needed code. --- src/Avalonia.Controls/ToggleSwitch.cs | 33 --------------------------- 1 file changed, 33 deletions(-) diff --git a/src/Avalonia.Controls/ToggleSwitch.cs b/src/Avalonia.Controls/ToggleSwitch.cs index ad35c43d87..6c6426a31d 100644 --- a/src/Avalonia.Controls/ToggleSwitch.cs +++ b/src/Avalonia.Controls/ToggleSwitch.cs @@ -1,10 +1,7 @@ using Avalonia.Controls.Primitives; -using Avalonia.Controls.Mixins; -using Avalonia.Controls.Presenters; using Avalonia.Controls.Templates; using Avalonia.LogicalTree; - namespace Avalonia.Controls { /// @@ -60,18 +57,6 @@ namespace Avalonia.Controls set { SetValue(OffContentProperty, value); } } - public IContentPresenter OffContentPresenter - { - get; - private set; - } - - public IContentPresenter OnContentPresenter - { - get; - private set; - } - /// /// Gets or Sets the used to display the . /// @@ -115,24 +100,6 @@ namespace Avalonia.Controls LogicalChildren.Add(newChild); } } - - protected override bool RegisterContentPresenter(IContentPresenter presenter) - { - var result = base.RegisterContentPresenter(presenter); - - if (presenter.Name == "Part_OnContentPresenter") - { - OnContentPresenter = presenter; - result = true; - } - else if (presenter.Name == "PART_OffContentPresenter") - { - OffContentPresenter = presenter; - result = true; - } - - return result; - } } } From e3b9b762f3d5828f84cc82b05903a8a3fdb42155 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 16 Jun 2020 14:49:17 -0300 Subject: [PATCH 19/23] restore template focus target. --- src/Avalonia.Themes.Default/ToggleSwitch.xaml | 1 + src/Avalonia.Themes.Fluent/ToggleSwitch.xaml | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Avalonia.Themes.Default/ToggleSwitch.xaml b/src/Avalonia.Themes.Default/ToggleSwitch.xaml index b4c4e7b429..ed172b52ab 100644 --- a/src/Avalonia.Themes.Default/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Default/ToggleSwitch.xaml @@ -78,6 +78,7 @@ Date: Tue, 16 Jun 2020 14:52:19 -0300 Subject: [PATCH 20/23] remove whitespace. --- src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj b/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj index cb3a185a2e..c44cc358e8 100644 --- a/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj +++ b/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj @@ -16,7 +16,7 @@ - + From e61a2512015c1c90e3d8c9144ac427d960930919 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 16 Jun 2020 14:53:30 -0300 Subject: [PATCH 21/23] remove vs added csproj junk. --- src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj b/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj index 00846f33fd..3c3e14010d 100644 --- a/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj +++ b/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj @@ -17,14 +17,6 @@ - - - - - - MSBuild:Compile - - From 7d24103bda785a4ff5d38b1c000300c8968e1f87 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 16 Jun 2020 14:57:29 -0300 Subject: [PATCH 22/23] tidy resources. --- .../Accents/FluentControlResourcesDark.xaml | 45 ++++++++++--------- .../Accents/FluentControlResourcesLight.xaml | 40 ++++++++--------- 2 files changed, 43 insertions(+), 42 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml index 340a39ea7f..eb6cc610cc 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml @@ -1,5 +1,5 @@ - diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml index 56d6f48341..cba20faf7c 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml @@ -1,5 +1,5 @@ - From dd492e1a2ce53aa2546f5810b44e5021a04f3fec Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 16 Jun 2020 14:58:37 -0300 Subject: [PATCH 23/23] remove from autocompletebox page. --- samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml b/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml index 8888cf921a..f90a0c4658 100644 --- a/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml +++ b/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml @@ -32,7 +32,6 @@ - Light