-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: complete avalonia button style.
- Loading branch information
Showing
17 changed files
with
1,989 additions
and
176 deletions.
There are no files selected for viewing
464 changes: 440 additions & 24 deletions
464
src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/ButtonDemoCtl.axaml
Large diffs are not rendered by default.
Oops, something went wrong.
508 changes: 462 additions & 46 deletions
508
src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/RepeatButtonDemoCtl.axaml
Large diffs are not rendered by default.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
src/Avalonia/HandyControl_Avalonia/Controls/Attach/BackgroundSwitchElement.cs
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,27 @@ | ||
using Avalonia; | ||
using Avalonia.Media; | ||
|
||
namespace HandyControl.Controls; | ||
|
||
public class BackgroundSwitchElement | ||
{ | ||
public static readonly AttachedProperty<IBrush> MouseHoverBackgroundProperty = | ||
AvaloniaProperty.RegisterAttached<BackgroundSwitchElement, AvaloniaObject, IBrush>("MouseHoverBackground", | ||
defaultValue: Brushes.Transparent, inherits: true); | ||
|
||
public static void SetMouseHoverBackground(AvaloniaObject element, IBrush value) => | ||
element.SetValue(MouseHoverBackgroundProperty, value); | ||
|
||
public static IBrush GetMouseHoverBackground(AvaloniaObject element) => | ||
element.GetValue(MouseHoverBackgroundProperty); | ||
|
||
public static readonly AttachedProperty<IBrush> MouseDownBackgroundProperty = | ||
AvaloniaProperty.RegisterAttached<BackgroundSwitchElement, AvaloniaObject, IBrush>("MouseDownBackground", | ||
defaultValue: Brushes.Transparent, inherits: true); | ||
|
||
public static void SetMouseDownBackground(AvaloniaObject element, IBrush value) => | ||
element.SetValue(MouseDownBackgroundProperty, value); | ||
|
||
public static IBrush GetMouseDownBackground(AvaloniaObject element) => | ||
element.GetValue(MouseDownBackgroundProperty); | ||
} |
51 changes: 51 additions & 0 deletions
51
src/Avalonia/HandyControl_Avalonia/Controls/Attach/BorderElement.cs
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,51 @@ | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Data; | ||
using HandyControl.Tools.Converter; | ||
|
||
namespace HandyControl.Controls; | ||
|
||
public class BorderElement | ||
{ | ||
public static readonly AttachedProperty<CornerRadius> CornerRadiusProperty = | ||
AvaloniaProperty.RegisterAttached<BorderElement, AvaloniaObject, CornerRadius>("CornerRadius", inherits: true); | ||
|
||
public static void SetCornerRadius(AvaloniaObject element, CornerRadius value) => | ||
element.SetValue(CornerRadiusProperty, value); | ||
|
||
public static CornerRadius GetCornerRadius(AvaloniaObject element) => element.GetValue(CornerRadiusProperty); | ||
|
||
public static readonly AttachedProperty<bool> CircularProperty = | ||
AvaloniaProperty.RegisterAttached<BorderElement, AvaloniaObject, bool>("Circular"); | ||
|
||
public static void SetCircular(AvaloniaObject element, bool value) => element.SetValue(CircularProperty, value); | ||
|
||
public static bool GetCircular(AvaloniaObject element) => element.GetValue(CircularProperty); | ||
|
||
static BorderElement() | ||
{ | ||
CircularProperty.Changed.AddClassHandler<AvaloniaObject>(OnCircularChanged); | ||
} | ||
|
||
private static void OnCircularChanged(AvaloniaObject d, AvaloniaPropertyChangedEventArgs e) | ||
{ | ||
if (d is not Border border) | ||
{ | ||
return; | ||
} | ||
|
||
if (e.GetNewValue<bool>()) | ||
{ | ||
var binding = new Binding(Visual.BoundsProperty.Name) | ||
{ | ||
Converter = new BorderCircularConverter(), | ||
Source = border, | ||
}; | ||
border.Bind(Border.CornerRadiusProperty, binding); | ||
} | ||
else | ||
{ | ||
border.ClearValue(Border.CornerRadiusProperty); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/Avalonia/HandyControl_Avalonia/Controls/Attach/IconElement.cs
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,27 @@ | ||
using Avalonia; | ||
using Avalonia.Media; | ||
|
||
namespace HandyControl.Controls; | ||
|
||
public class IconElement | ||
{ | ||
public static readonly AttachedProperty<Geometry> GeometryProperty = | ||
AvaloniaProperty.RegisterAttached<IconElement, AvaloniaObject, Geometry>("Geometry"); | ||
|
||
public static void SetGeometry(AvaloniaObject element, Geometry value) => element.SetValue(GeometryProperty, value); | ||
|
||
public static Geometry GetGeometry(AvaloniaObject element) => element.GetValue(GeometryProperty); | ||
|
||
public static readonly AttachedProperty<double> WidthProperty = | ||
AvaloniaProperty.RegisterAttached<IconElement, AvaloniaObject, double>("Width", defaultValue: double.NaN); | ||
|
||
public static void SetWidth(AvaloniaObject element, double value) => element.SetValue(WidthProperty, value); | ||
|
||
public static double GetWidth(AvaloniaObject element) => element.GetValue(WidthProperty); | ||
|
||
public static readonly AttachedProperty<double> HeightProperty = | ||
AvaloniaProperty.RegisterAttached<IconElement, AvaloniaObject, double>("Height", defaultValue: double.NaN); | ||
|
||
public static void SetHeight(AvaloniaObject element, double value) => element.SetValue(HeightProperty, value); | ||
public static double GetHeight(AvaloniaObject element) => element.GetValue(HeightProperty); | ||
} |
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.