-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement MacOSProperties.IsTemplateIcon attached property on TrayIcon (
#14348) * Implement MacOS.IsTemplateIcon attached property on TrayIcon * Use MacOS.IsTemplateIcon in the ControlCatalog * Rename MacOS to MacOSProperties * Extract IsTemplateIcon to ITrayIconWithIsTemplateImpl
- Loading branch information
Showing
9 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
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
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,35 @@ | ||
using Avalonia.Platform; | ||
|
||
namespace Avalonia.Controls; | ||
|
||
/// <summary> | ||
/// Set of MacOS specific attached properties that allow deeper customization of the application per platform. | ||
/// </summary> | ||
public class MacOSProperties | ||
{ | ||
static MacOSProperties() | ||
{ | ||
IsTemplateIconProperty.Changed.AddClassHandler<TrayIcon>(TrayIconIsTemplateIconChanged); | ||
} | ||
|
||
/// <summary> | ||
/// Defines the IsTemplateIcon attached property. | ||
/// </summary> | ||
public static readonly AttachedProperty<bool> IsTemplateIconProperty = | ||
AvaloniaProperty.RegisterAttached<MacOSProperties, TrayIcon, bool>("IsTemplateIcon"); | ||
|
||
/// <summary> | ||
/// A Boolean value that determines whether the TrayIcon image represents a template image. | ||
/// </summary> | ||
public static void SetIsTemplateIcon(TrayIcon obj, bool value) => obj.SetValue(IsTemplateIconProperty, value); | ||
|
||
/// <summary> | ||
/// Returns a Boolean value that indicates whether the TrayIcon image is a template image. | ||
/// </summary> | ||
public static bool GetIsTemplateIcon(TrayIcon obj) => obj.GetValue(IsTemplateIconProperty); | ||
|
||
private static void TrayIconIsTemplateIconChanged(TrayIcon trayIcon, AvaloniaPropertyChangedEventArgs args) | ||
{ | ||
(trayIcon.Impl as ITrayIconWithIsTemplateImpl)?.SetIsTemplateIcon(args.GetNewValue<bool>()); | ||
} | ||
} |
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
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
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
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